What does this Fmincon error mean?
2 ビュー (過去 30 日間)
古いコメントを表示
Hi Everyone
I'm doing a constrained optimization where I first generate a few random intial points, I then only keep the feasible ones. I do this by running the objective function to see if it returns a NaN.
Then I use the feasible set of initial values and I call fmincon in a FOR loop. I did this because I was worried about local minima. I have turned on the option to use parallel workers.
However, I'm now receiving a weird error after a certain amount of fmincon executions.
Here is the output:
User objective function returned NaN; trying a new point...
22 590 9.074473e-01 1.382e+01 2.173e+03 1.337e-01
Error using parallel_function (line 589)
Matrix dimensions must agree.
Error stack:
parfinitedifferences>(parfor body) at 158
Error in C:\MATLAB\R2012a
Student\toolbox\shared\optimlib\parfinitedifferences.p>parfinitedifferences (line 118)
Error in C:\MATLAB\R2012a
Student\toolbox\optim\optim\private\computeFinDiffGradAndJac.p>computeFinDiffGradAndJac (line
45)
Error in C:\MATLAB\R2012a Student\toolbox\optim\optim\barrier.p>barrier (line 564)
Error in fmincon (line 841)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, ...
Error in FreeTailObjConstr (line 70)
[x,fval,exitflag] = fmincon(fun,x0,Aineq,Bineq,Aeq,Beq,LB,UB,cfun,options,param);
Error in multiStartFreeTail (line 113)
[x,fval,exitflag] = FreeTailObjConstr(x0, UB, LB, muVal);
% code
end
What does this mean???
0 件のコメント
回答 (2 件)
Steve Grikschat
2013 年 6 月 14 日
This is a bug with the parallel finite differences approximation code. In particular, how this feature works with "invalid" values (i.e. Inf, NaN, and complex) is broken when it cannot get a real/defined function value. I'll make a bug report for this.
In your problem, does your objective function naturally evaluate to NaN when the input parameters are outside of a constrained region? Or do you do this manually:
if isFeasible(x)
f = ...
else
f = NaN
end
If you force the function value to NaN, I suggest trying without that, which will avoid this error. Otherwise, you can use the serial mode (set UseParallel to 'never').
5 件のコメント
Steve Grikschat
2013 年 6 月 24 日
What you are doing is reasonable. See my original answer for a workaround. See comment below about MultiStart.
Amir Patel
2013 年 6 月 17 日
1 件のコメント
Steve Grikschat
2013 年 6 月 24 日
It depends where you use the parallel resources.
MultiStart in parallel means that fmincon is run with a different start point on each worker. This disables the parallelism inside fmincon (finite differences). So the bug does not happen here.
If, however, you run MultiStart in serial, but enable parallelism in fmincon, then the bug can happen.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!