Error in parfinitedifferences using fmincon and parallel

10 ビュー (過去 30 日間)
Carsten Asmanoglo
Carsten Asmanoglo 2018 年 8 月 8 日
コメント済み: Steve Grikschat 2018 年 8 月 10 日
Hi everyone,
I have a question using fmincon with the useparallel option set to 'always' to optimize a process model (linear ineq constraints, non-linear ineq constraints, all decision variables subject to upper and lower bounds) in R2013b, where the process model can return NaN values as outputs due to convergence problems.
Now I have the problem that the optimization runs for a while (>150 evaluations of the process model) without problems (even when the process model sometimes returns NaN) and then suddenly breaks, displaying the following error code:
Error using parfinitedifferences>(parfor body) (line 158)
Matrix dimensions must agree.
Error in parfinitedifferences (line 118)
Error in computeFinDiffGradAndJac (line 45)
Error in barrier (line 573)
Error in fmincon (line 905)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] =
barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, ...
Error in solve_optimization_problem (line 90)
[dec_var,obj,eflag,output]=fmincon(fun,dec_var_0,A,b,A_eq,b_eq,lb_dec_var,ub_dec_var,cfun,opts);
Caused by:
Error using -
Matrix dimensions must agree.
This only happens when using the parallel mode in fmincon
opts=optimset('Display','iter','UseParallel','always','Algorithm','interior-point','PlotFcn',@optimplotfval,'TolFun',10^-4,'MaxFunEvals',1000','FinDiffRelStep',1e-5);
[dec_var,obj,eflag,output]=fmincon(fun,dec_var_0,A,b,A_eq,b_eq,lb_dec_var,ub_dec_var,cfun,opts);
Additionally, I initialize a parallel pool with 3 workers
parpool(3)
and disable multi threads computation, befor running the program
LASTN = maxNumCompThreads(1);
Does anyone know how to fix the described problem? Thank you for your kind support!
Best regards
Carsten Asmanoglo

採用された回答

Steve Grikschat
Steve Grikschat 2018 年 8 月 9 日
This is a bug in the R2013b Optimization Toolbox. See the report here: Bug Report Link
It was fixed in R2014a and later releases.
  2 件のコメント
Carsten Asmanoglo
Carsten Asmanoglo 2018 年 8 月 10 日
Ok. Thank you for your fast response.
Now, starting with an additional nl-const, to avoid this error, I now get the following error message:
In an assignment A(:) = B, the number of elements in A and B must be the same.
Error in barrier (line 402)
Error in fmincon (line 905)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] =
barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, ...
Error in solve_optimization_problem (line 90)
[dec_var,obj,eflag,output]=fmincon(fun,dec_var_0,A,b,A_eq,b_eq,lb_dec_var,ub_dec_var,cfun,opts);
Again, the optimization runs without problems before for more than 500 evaluations. Do you also have an idea where this problem is might come from?
Steve Grikschat
Steve Grikschat 2018 年 8 月 10 日
The line where it errors assigns the output of a nonlinear constraint function into an existing array.
The error indicates that the sizes are not equal. I suspect that your constraint function is returning a different number of either inequality or equality constraints during the optimization.
This is not allowed. The number of constraint values returned must be constant. Using the debugger, or with debugging code, you may be able to detect how the function returns different number of constraints for different inputs.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSystems of Nonlinear Equations についてさらに検索

製品


リリース

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by