Few questions regarding optimization using fmincon (EXITFLAG = 5 or 0)
1 回表示 (過去 30 日間)
古いコメントを表示
Hi MATLAB Experts,
I have some issues with my optimization code. The objective function that I've made is to minimize the trades that can satisfy assigned turnover limits (i.e. 2%).
The objective function that will need to run with fmincon is below.
function [c,ceq] = conTO(x,D,C,sglTotTurn)
c = (sum(abs(D+x-C))/2 - sglTotTurn);
ceq = [];
end
%%Optimization
diff = currentportfolio_A - modelportfolio_A; % difference in weights between modelportfolio_A and currentportfolio_A
TotTurn = 0.02; % set Turnover limit to 2%
fullexec = [20;30;40]; % fund funds that have to be fully executed
% 1st constraint: Full implementation on desired portfolio
lb = zeros(size(diff,1),1); ub = zeros(size(diff,1),1);
lb(diff<0,1) = diff(diff<0,1);
ub(diff>0,1) = diff(diff>0,1);
lb(fullexec,1) = 0; ub(fullexec,1) = 0;
% linear inequality
A=[]; b=[];
% linear equality
Aeq = ones(size(diff,1),1)';
beq = 0;
% find trades
desired_w = modelportfolio_A;
current_w = currentportfolio_A;
[trades,FVAL,EXITFLAG] = fmincon(@(x)std(x), diff, A, b, Aeq, beq, lb, ub, @(x) conTO(x,desired_w,current_w,TotTurn));
fval_1 = FVAL;
flag_1 = EXITFLAG;
actual_w = desired_w + trades; % actual weight
However, after running this script, I found that "fmincon stopped because the predicted change in the objective function is less than the default value of the function tolerance and constraints are satisfied to within the default value of the constraint tolerance."
Every time I run the script, flag_1 is '5' or '0'. I think the default value is already very tiny.. So, I don't think the predicted change in the objective function is less than the default value as mentioned..
Could you please give me some advise to improve the model? Please let me know if I miss anything important.
Thanks for any help you could provide in advance!!
Best Regards,
Jake
0 件のコメント
採用された回答
Walter Roberson
2016 年 4 月 7 日
I recommend you pass an options structure that changes the tolerances that you feel are better suited.
3 件のコメント
Alan Weiss
2016 年 4 月 7 日
Take a look at the documentation. It won't take more than 20 minutes or so to read through the first five topics. Then you'll be well-versed in setting options.
Alan Weiss
MATLAB mathematical toolbox documentation
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!