exit flag -2

4 views (last 30 days)
DrLoz
DrLoz on 14 Oct 2018
Commented: Walter Roberson on 16 Oct 2018
Hi, I have the following code which returns exit flag -2. I've tried using different algorithms and different initial starting values. But I'm not sure what to do next. Thanks!
for iPt = 1:nFrontierPts %This is only looping over the FX overlay - I'm adding the exogenous portfolio at the final step
%Max iter and funevals small while debugging - need to increase to deal with exit flag 0
%Currency Specific Frontier
options = optimoptions(@fmincon,'Algorithm','interior-point','MaxIter',1000,'MaxFunEvals',10000);
targetVar_cs = minVar_cs + (iPt-1)*VarIncr_cs;
[tempWts_cs,FVAL_cs,EXITFLAG_cs,OUTPUT_cs] =fmincon(@(w) ERObjective(w,ExpFXret_cs_t),w0_cs,[],[],[],[],LB_cs,UB_cs, @(w) nonlcon2(w,targetVar_cs,teCap,AssetReturns(t-59:t,1),csAssetReturns(t-59:t,2:7),equRet(t-59:t),covCap),options);
% [tempWts_cs,FVAL_cs,EXITFLAG_cs,OUTPUT_cs] =fmincon(@(w) ERObjective(w,ExpFXret_cs_t),w0_cs,[],[],[],[],LB_cs,UB_cs, @(w) nonlcon2(w,targetVar_cs,100,AssetReturns(t-59:t,1),csAssetReturns(t-59:t,2:7),equRet(t-59:t),100),options);
if EXITFLAG_cs ==-2
w0_cs = UB_cs';
options = optimoptions(@fmincon,'Algorithm','sqp','MaxIter',1000,'MaxFunEvals',10000);
[tempWts_cs,FVAL_cs,EXITFLAG_cs,OUTPUT_cs] =fmincon(@(w) ERObjective(w,ExpFXret_cs_t),w0_cs,[],[],[],[],LB_cs,UB_cs, @(w) nonlcon2(w,targetVar_cs,teCap,AssetReturns(t-59:t,1),csAssetReturns(t-59:t,2:7),equRet(t-59:t),covCap),options);
if EXITFLAG_cs==-2
options = optimoptions(@fmincon,'Algorithm','active-set','MaxIter',1000,'MaxFunEvals',10000);
[tempWts_cs,FVAL_cs,EXITFLAG_cs,OUTPUT_cs] =fmincon(@(w) ERObjective(w,ExpFXret_cs_t),w0_cs,[],[],[],[],LB_cs,UB_cs, @(w) nonlcon2(w,targetVar_cs,teCap,AssetReturns(t-59:t,1),csAssetReturns(t-59:t,2:7),equRet(t-59:t),covCap),options);
end
if EXITFLAG_cs==-2
for ct = 1:10
w0_cs = UB_cs'*rand(1);
options = optimoptions(@fmincon,'Algorithm','active-set','MaxIter',1000,'MaxFunEvals',10000);
[tempWts_cs,FVAL_cs,EXITFLAG_cs,OUTPUT_cs] =fmincon(@(w) ERObjective(w,ExpFXret_cs_t),w0_cs,[],[],[],[],LB_cs,UB_cs, @(w) nonlcon2(w,targetVar_cs,teCap,AssetReturns(t-59:t,1),csAssetReturns(t-59:t,2:7),equRet(t-59:t),covCap),options);
if EXITFLAG_cs ~= -2
break;
end
end
end
end
end
I'm not sure what else to do next. Thanks!
  21 Comments
DrLoz
DrLoz on 15 Oct 2018
oh... I guess this is not looking promising at all... thanks Walter.
Walter Roberson
Walter Roberson on 16 Oct 2018
Okay, I will look at it when I am able. I have some dental work when in the morning, so I am not sure whether I will feel up to doing anything for a couple of days.

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2015a

Community Treasure Hunt

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

Start Hunting!