Filter löschen
Filter löschen

Few questions regarding optimization using fmincon (EXITFLAG = 5 or 0)

2 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 7 Apr. 2016
I recommend you pass an options structure that changes the tolerances that you feel are better suited.
  3 Kommentare
Alan Weiss
Alan Weiss am 7 Apr. 2016
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by