How can I set up nonlcon in fmincon using a surface?

4 次查看(过去 30 天)
Hi everyone,
I'm working on a design optimisation project with 2 input design parameters and 2 design parameters that i would like to minimise. So I have created 2 sfit, 1 for each design parameters as shown
I'm trying to use fmincon to find the combination of inputs that minimises pressure at temperature below zero, so I've set nonlcon up as below (p_surf is the surface show in first image and t_surf is the surface shown in the second image), when the error message "Error using fittype/horzcat (line 6) Concatenation of sfit objects not permitted." shows up.
opt = fmincon(p_surf,x0,[],[],[],[],lb,ub,[[t_surf], []],[])
fmincon worked perfectly well when I didn't apply nonlcon, and the error only shows up when I add in the second surface as nonlcon
Therefore, I am wondering if there's any way I can set up the nonlcon to get around this problem?
Many thanks

回答(1 个)

Alan Weiss
Alan Weiss 2020-7-20
I do not understand your syntax
opt = fmincon(p_surf,x0,[],[],[],[],lb,ub,[[t_surf], []],[])
and I suspect that fmincon does not, either. The problematic part is [[t_surf], []]. Read in the fmincon function reference page what the correct syntax is for nonlinear constraints. For an example of a nonlinear constraint function, see Solve a Constrained Nonlinear Problem, Solver-Based.
In brief, your t_surf function must return two outputs, c and ceq. It appears that you are trying to override the ceq output with []. You cannot do it this way; t_surf must return both outputs. For details, see Nonlinear Constraints.
Alan Weiss
MATLAB mathematical toolbox documentation

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by