Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Find minimum of constrained nonlinear multivariable function

Nonlinear programming solver.

Finds the minimum of a problem specified by

$$\underset{x}{\mathrm{min}}f(x)\text{suchthat}\{\begin{array}{c}c(x)\le 0\\ ceq(x)=0\\ A\cdot x\le b\\ Aeq\cdot x=beq\\ lb\le x\le ub,\end{array}$$

*b* and *beq* are vectors, *A* and *Aeq* are
matrices, *c*(*x*) and *ceq*(*x*)
are functions that return vectors, and *f*(*x*)
is a function that returns a scalar. *f*(*x*), *c*(*x*),
and *ceq*(*x*) can be nonlinear
functions.

*x*, *lb*, and *ub* can
be passed as vectors or matrices; see Matrix Arguments.

`x = fmincon(fun,x0,A,b)`

`x = fmincon(fun,x0,A,b,Aeq,beq)`

`x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub)`

`x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon)`

`x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options)`

`x = fmincon(problem)`

```
[x,fval]
= fmincon(___)
```

```
[x,fval,exitflag,output]
= fmincon(___)
```

```
[x,fval,exitflag,output,lambda,grad,hessian]
= fmincon(___)
```

starts
at `x`

= fmincon(`fun`

,`x0`

,`A`

,`b`

)`x0`

and attempts to find a minimizer `x`

of
the function described in `fun`

subject to the linear
inequalities `A*x ≤ b`

. `x0`

can
be a scalar, vector, or matrix.

Passing Extra Parameters explains how to pass extra parameters to the objective function and nonlinear constraint functions, if necessary.

defines
a set of lower and upper bounds on the design variables in `x`

= fmincon(`fun`

,`x0`

,`A`

,`b`

,`Aeq`

,`beq`

,`lb`

,`ub`

)`x`

,
so that the solution is always in the range `lb `

≤` x `

≤` ub`

.
If no equalities exist, set `Aeq = []`

and ```
beq
= []
```

. If `x(i)`

is unbounded below, set ```
lb(i)
= -Inf
```

, and if `x(i)`

is unbounded above,
set `ub(i) = Inf`

.

If the specified input bounds for a problem are inconsistent, `fmincon`

throws
an error. In this case, output `x`

is `x0`

and `fval`

is `[]`

.

For the default `'interior-point'`

algorithm, `fmincon`

sets
components of `x0`

that violate the bounds `lb ≤ x ≤ ub`

, or are equal to a bound, to the interior
of the bound region. For the `'trust-region-reflective'`

algorithm, `fmincon`

sets
violating components to the interior of the bound region. For other
algorithms, `fmincon`

sets violating components
to the closest bound. Components that respect the bounds are not changed.
See Iterations Can Violate Constraints.

finds
the minimum for `x`

= fmincon(`problem`

)`problem`

, where `problem`

is
a structure described in Input Arguments.
Create the `problem`

structure by exporting a problem
from Optimization app, as described in Exporting Your Work.

`fmincon`

is a gradient-based method that is designed to work on problems where the objective and constraint functions are both continuous and have continuous first derivatives.For the

`'trust-region-reflective'`

algorithm, you must provide the gradient in`fun`

and set the`'SpecifyObjectiveGradient'`

option to`true`

.The

`'trust-region-reflective'`

algorithm does not allow equal upper and lower bounds. For example, if`lb(2)==ub(2)`

,`fmincon`

gives this error:Equal upper and lower bounds not permitted in trust-region-reflective algorithm. Use either interior-point or SQP algorithms instead.

There are two different syntaxes for passing a Hessian, and there are two different syntaxes for passing a

`HessianMultiplyFcn`

function; one for`trust-region-reflective`

, and another for`interior-point`

. See Including Hessians.For

`trust-region-reflective`

, the Hessian of the Lagrangian is the same as the Hessian of the objective function. You pass that Hessian as the third output of the objective function.For

`interior-point`

, the Hessian of the Lagrangian involves the Lagrange multipliers and the Hessians of the nonlinear constraint functions. You pass the Hessian as a separate function that takes into account both the current point`x`

and the Lagrange multiplier structure`lambda`

.

When the problem is infeasible,

`fmincon`

attempts to minimize the maximum constraint value.

[1] Byrd, R. H., J. C. Gilbert, and J. Nocedal.
“A Trust Region Method Based on Interior Point Techniques for
Nonlinear Programming.” *Mathematical Programming*,
Vol 89, No. 1, 2000, pp. 149–185.

[2] Byrd, R. H., Mary E. Hribar, and Jorge Nocedal.
“An Interior Point Algorithm for Large-Scale Nonlinear Programming.” *SIAM
Journal on Optimization*, Vol 9, No. 4, 1999, pp. 877–900.

[3] Coleman, T. F. and Y. Li. “An Interior,
Trust Region Approach for Nonlinear Minimization Subject to Bounds.” *SIAM
Journal on Optimization*, Vol. 6, 1996, pp. 418–445.

[4] Coleman, T. F. and Y. Li. “On the
Convergence of Reflective Newton Methods for Large-Scale Nonlinear
Minimization Subject to Bounds.” *Mathematical Programming*,
Vol. 67, Number 2, 1994, pp. 189–224.

[5] Gill, P. E., W. Murray, and M. H. Wright. *Practical
Optimization*, London, Academic Press, 1981.

[6] Han, S. P. “A Globally Convergent
Method for Nonlinear Programming.” *Journal of Optimization
Theory and Applications*, Vol. 22, 1977, pp. 297.

[7] Powell, M. J. D. “A Fast Algorithm
for Nonlinearly Constrained Optimization Calculations.” *Numerical
Analysis*, ed. G. A. Watson, *Lecture Notes
in Mathematics*, Springer-Verlag, Vol. 630, 1978.

[8] Powell, M. J. D. “The Convergence
of Variable Metric Methods For Nonlinearly Constrained Optimization
Calculations.” *Nonlinear Programming 3* (O.
L. Mangasarian, R. R. Meyer, and S. M. Robinson, eds.), Academic Press,
1978.

[9] Waltz, R. A., J. L. Morales, J. Nocedal,
and D. Orban. “An interior algorithm for nonlinear optimization
that combines line search and trust region steps.” *Mathematical
Programming*, Vol 107, No. 3, 2006, pp. 391–408.

`fminbnd`

| `fminsearch`

| `fminunc`

| `optimoptions`

| `optimtool`

Was this topic helpful?