Optimization with MultiStart with nonlinear constraint on some of the parameters

5 views (last 30 days)
M. Reza Andalibi
M. Reza Andalibi on 15 Aug 2018
Commented: M. Reza Andalibi on 15 Aug 2018
Hi
I have an optimization problem where I use MultiStart to regress three unknown model parameters to some experimental data. All the parameters are bounded but only two out of three of these parameters follow a nonlinear constraint which I provide using the following code:
c = @(x) 2 - x(2) * (x(3)/r_nm(1))^3;
ceq = @(x) [];
nonlcon_EMT = @(x) deal(c(x),ceq(x));
where r_nm(1) is a known number (fixed). Note that in the function nonlcon_EMT x(1) is not used in the calculation of c or ceq but it is passed to the function. Then I used the following code to perform the regression:
objFcn = @(x) extinction(lambda,Abs(:,2),T,r_nm(1),0,rho(1),rho_CV(1),eta(1),4/3,x(1),x(2),x(3),[ones(1,5),scaleFact],0,400,1000,0);
ms = MultiStart('FunctionTolerance',1e-3,'XTolerance',1e-2,'StartPointsToRun','bounds-ineqs',...
'MaxTime',600,'UseParallel',true);
problem = createOptimProblem('fmincon','x0',[1e-4,0.3,500].*scaleFact,'objective',objFcn,...
'lb',[1e-6,1e-3,25].*scaleFact,...
'ub',[1,0.5,1000].*scaleFact,...
'nonlcon',nonlcon_EMT);
[x,fval(2),exitflag(2)] = run(ms,problem,10);
When I run the code above with 'StartPointsToRun','bounds' there is no problem. Yet, using 'StartPointsToRun','bounds-ineqs' it gives the following error:
Unable to perform assignment because the left and right sides have a different
number of elements.
I was wondering if someone could help me with this problem. Thank you.

Answers (1)

Alan Weiss
Alan Weiss on 15 Aug 2018
Edited: Alan Weiss on 15 Aug 2018
Try writing a function file to represent your nonlinear constraints:
function [c,ceq] = nonlcon_EMT(x,r_nm)
ceq = [];
c = 2 - x(2) * (x(3)/r_nm(1))^3;
In your script, after defining r_nm in the workspace, set
nlcon = @(x)nonlcon_EMT(x,r_nm);
and, of course, set nlcon as the nonlinear constraint in your problem structure.
Why might this work? The deal function insists on having two outputs, but when you set inequalities as the start points, MultiStart calls the nonlinear constraint for only the inequality, ignoring the equality constraint (it doesn't matter that your equality constraint is null). By ignoring the equality constraint, I believe that deal throws an error.
Alan Weiss
MATLAB mathematical toolbox documentation
  1 Comment
M. Reza Andalibi
M. Reza Andalibi on 15 Aug 2018
Dear Alan
Thanks for the answer. I implemented what you suggested but it still gives the following error as before:
Unable to perform assignment because the left and right sides have a different number of elements.
Is it possible that it's because of not having all elements of x, i.e., all but x(1), in the constraints?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by