FUNCTION REFERENCE
fmincon
Find a local constrained minimum of a scalar objective.
Find a local constrained minimum of a scalar objective.
Syntax
[x, fval, exitflag, output, lambda, grad, hessian] = fmincon(fun, x0, A, b, Aeq, beq, lb, ub, nonlcon, options)Syntax
x = fmincon(problem)Arguments after b can be omitted. nonlcon returns [c,ceq] with c <= 0,
ceq = 0; [] omits the callback. x retains x0's shape. Problem fields:
objective (or fun),x0,Aineq,bineq,Aeq,beq,lb,ub,nonlcon,options.
Uses SQP with Powell-damped BFGS, an l1 merit line search, elastic l1 QPs for
inconsistent linearizations and a second-order correction for curved constraints.
QP steps use the shared primal-dual interior-point kernel. All accepted algorithm
names map to SQP. The Hessian output is the final BFGS approximation.
Forward finite differences are default; FiniteDifferenceType 'central' uses
central differences where bounds permit. SpecifyObjectiveGradient true requests
[f,g] from fun. SpecifyConstraintGradient true requests [c,ceq,GC,GCeq], with
GC and GCeq n-by-m, one gradient column per constraint. x0 is projected onto
bounds, and all evaluated points, including finite differences, stay inside bounds.
Defaults: MaxIterations 400, MaxFunctionEvaluations 3000, OptimalityTolerance
1e-6, ConstraintTolerance 1e-6, StepTolerance 1e-10. funcCount counts objective
calls only; constraint calls do not consume the objective budget. Output fields
and lambda signs follow linprog and its SciPy sign table. Exitflag 1 means
first-order convergence; 2 a feasible step below StepTolerance; 0 a budget;
-1 a failed merit search; -2 unsuccessful elastic feasibility restoration.
An elastic stop checks the current iterate: feasible first-order convergence
returns 1, a feasible tiny step returns 2, and -2 requires infeasibility.
For -2, or a failed solve without an evaluated finite feasible point, x, fval,
grad and hessian are []; all lambda fields are []. Feasible evaluated points
are retained at a budget or search stop.
SciPy signs: negate linprog ineqlin/eqlin/upper marginals; keep lower.
For SLSQP constraints -g >= 0 keep inequality multipliers; negate equality
multipliers for h = 0. All MatRust inequality multipliers are nonnegative.
Differences from MATLAB: one dense SQP method, no sparse derivatives, Hessian
callback or global guarantee. There is no simplex; algorithm names are aliases.
Example
[x,f]=fmincon(@(x) (x(1)-2)^2+(x(2)-3)^2,[0;0],[],[],[1 1],1)Example
x=fmincon(@(x) (x-2)^2,0,[],[],[],[],-3,3,@(x) deal(x^2-1,[]))These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.