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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Surrogate Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!