What does this Fmincon error mean?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (2)
Steve Grikschat
il 14 Giu 2013
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 Commenti
Steve Grikschat
il 24 Giu 2013
What you are doing is reasonable. See my original answer for a workaround. See comment below about MultiStart.
Amir Patel
il 17 Giu 2013
1 Commento
Steve Grikschat
il 24 Giu 2013
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.
Vedere anche
Categorie
Scopri di più su Surrogate Optimization in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!