f = @(x)sin(x)
sdpvar x
f(x)
Nonlinear scalar (real, models 'sin', 1 variable)parsetree = mtree('array2table.m', '-file')
parsetree =
mtree (complete: 180 nodes)>> >> help mtree mtree Create and manipulate M parse trees This is an experimental program whose behavior and interface is likely to change in the future.
help baron
baron Solve a NLP/MINLP using the global MINLP solver baron
Calling Form:
[x,fval,exitflag,info,allsol] = baron(fun,A,rl,ru,lb,ub,nlcon,cl,cu,xtype,x0,opts)...x = baron(fun,...,ub,nlcon,cl,cu) solves subject to the nonlinear
constraints specified by nlcon, cl and cu of the form
cl <= nlcon(x) <= cu. nlcon is a column-wise vector function and must
be a function specified using baron rules. To specify a one
sided constraint use infinity on the empty side, and cl = cu for an
equality constraint....Matlab functions supplied to this method are processed and passed to
baron as a text model and therefore must meet certain requirements. An
example function is shown below:
obj = @(x) 3*x(1)^2 - 2*x(2)^3 + 3*x(1)*x(2);
OR
function fx = objective(x)
fx = 3*x(1)^2 - 2*x(2)^3 + 3*x(1)*x(2);
end
The function must be:
- A function of one input argument (the decision variable vector)
- Contain scalar, vector, or matrix operations only (max 2D supported)
- Limited to a subset of functions (exp, log, log10, dot, sqrt, norm, sum, prod)
- Contain no conditional statements or relational operators with respect to the decision variables
For nonlinear constraints the function must be a column-wise vector:
con = @(x) [-(x(1)*x(2));
3*x(1) + 2*x(2)];
OR
function cx = nlconstraints(x)
cx(1) = -(x(1)*x(2));
cx(2) = 3*x(1) + 2*x(2);
end
Constraints = [Constraints,c <= 0,ceq == 0];if model.linearconstraints
callback_con = [];
else
callback_con = @(x)fmincon_con_liftlayer(x,model);
end
solvertime = tic;
f = @(x)fmincon_fun_liftlayer(x,model);
[xout,fmin,flag,output,lambda] = fmincon(f,model.x0,model.A,model.b,model.Aeq,model.beq,model.lb,model.ub,g,model.options.fmincon);error: cat: dimension mismatcherror: called from __constraints_interface__>@<anonymous> at line 107 column 2 __lm_feasible__ at line 156 column 13 fmincon at line 417 column 24 callfmincon at line 95 column 29 solvesdp at line 368 column 5 optimize at line 31 column 24debug> backend (f.objf, pin, hook)debug> dct = df_cstr (p, ac_idx, setfield (dfdp_hook, "f", v_cstr))error: cat: dimension mismatcherror: called from __constraints_interface__>@<anonymous> at line 107 column 2 __lm_feasible__ at line 156 column 13 fmincon at line 417 column 24 callfmincon at line 95 column 29 solvesdp at line 368 column 5 optimize at line 31 column 24debug>tic;ops = sdpsettings('usex0', 1, 'debug', 1, 'solver', 'fmincon');toc
Elapsed time is 31.6697 seconds.
>>