How to generate the objconstr for multivariate surrogate optimization with nonlinear constraints?

7 views (last 30 days)
I am trying to use the surrogate optimization function in matlab to obtain the global minima of a problem with an objective function and several nonlinear constraints. My problem has been computed using symbolic variables, but I am not able to find the correct syntax of putting these symbolic cost functinos and nonlinear constraints into "matlabFunction" to obtain the function handle to use with surrogateopt.
***** Code example ********
symbolic_objective_function %computed from several operations
symbolic_nonlinear_constraints %computed after several operations
%% Is the below line of code the correct way to compute the objconstr for use in surrogateopt?
objconstr=matlabFunction([symbolic_objective_function], [symbolic_nonlinear_constraints],'vars',{x})

Accepted Answer

Alan Weiss
Alan Weiss on 15 Feb 2022
Try this:
obj = matlabFunction(symbolic_objective_function,'vars',{x});
constr = matlabFunction(symbolic_nonlinear_constraints,'vars',{x});
objconstr = @(x)struct('Fval',obj(x),'Ineq',constr(x));
Alan Weiss
MATLAB mathematical toolbox documentation
Alan Weiss
Alan Weiss on 15 Feb 2022
The problem as I understand it is that you have nonlinear equality constraints as well as nonlinear inequality constraints. Your constraint function should be for nonlinear inequality constraints only. It should not have a deal statement. It should accept the in1 argument and return a scalar or vector. Check that your nonlinear inequality constraint accepts one argument and returns one argument.
Alan Weiss
MATLAB mathematical toolbox documentation

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!