0% found this document useful (0 votes)
97 views3 pages

Fmincon

description description description description descriptiondescription description description description descriptiondescription description description description description
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views3 pages

Fmincon

description description description description descriptiondescription description description description descriptiondescription description description description description
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

1

fmincon
Find minimum of constrained nonlinear multivariable function

Nonlinear programming solver.

Finds the minimum of a problem specified by

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.

Syntax
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(___)

Description

x = fmincon(fun,x0,A,b) starts at x0 and attempts to find a minimizer x of the function


described in fun subject to the linear inequalitiesA*x ≤ b. x0 can be a scalar, vector, or
matrix.

x = fmincon(fun,x0,A,b,Aeq,beq) minimizes fun subject to the linear


equalities Aeq*x = beq and A*x ≤ b. If no inequalities exist, set A = [] and b = [].

x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub) defines a set of lower and upper bounds on


the design variables in 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 ifx(i) is unbounded above, set ub(i) = Inf.
2

x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon) subjects the minimization to the


nonlinear inequalities c(x) or equalities ceq(x)defined in nonlcon. fmincon optimizes
such that c(x) ≤ 0 and ceq(x) = 0. If no bounds exist, set lb = [] and/or ub = [].
x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options) minimizes with the
optimization options specified in options. Useoptimoptions to set these options. If there
are no nonlinear inequality or equality constraints, set nonlcon = [].
x = fmincon(problem) finds the minimum for problem, where problem is a structure.
[x,fval] = fmincon(___), for any syntax, returns the value of the objective
function fun at the solution x.
[x,fval,exitflag,output] = fmincon(___) additionally returns a
value exitflag that describes the exit condition of fmincon, and a structure output with
information about the optimization process.
[x,fval,exitflag,output,lambda,grad,hessian] = fmincon(___) additionally
returns:
 lambda — Structure with fields containing the Lagrange multipliers at the solution x.
 grad — Gradient of fun at the solution x.
 hessian — Hessian of fun at the solution x.

Example. Bound Constraints


Find the minimum of an objective function in the presence of bound constraints.

The objective function is a simple algebraic function of two variables.


fun = @(x)1+x(1)/(1+x(2)) - 3*x(1)*x(2) + x(2)*(1+x(1));

Look in the region where x has positive values, x(1) ≤ 1, and x(2) ≤ 2.
lb = [0,0];
ub = [1,2];

There are no linear constraints, so set those arguments to [].


A = [];
b = [];
Aeq = [];
beq = [];

Try an initial point in the middle of the region. Find the minimum of fun, subject to the bound constraints.
x0 = [0.5,1];
x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub)
Local minimum found that satisfies the constraints.

Optimization completed because the objective function is non-decreasing in


feasible directions, to within the default value of the function tolerance,
and constraints are satisfied to within the default value of the constraint tolerance.

<stopping criteria details>


x =

1.0000 2.0000

Example. Nonlinear Constraints

Find the minimum of a function subject to nonlinear constraints

Find the point where Rosenbrock's function is minimized within a circle, also subject to bound constraints.
3

fun = @(x)100*(x(2)-x(1)^2)^2 + (1-x(1))^2;


Look within the region , .
lb = [0,0.2];
ub = [0.5,0.8];
Also look within the circle centered at [1/3,1/3] with radius 1/3. Copy the following code to a file on your
MATLAB® path named circlecon.m.

% Copyright 2015 The MathWorks, Inc.

function [c,ceq] = circlecon(x)


c = (x(1)-1/3)^2 + (x(2)-1/3)^2 - (1/3)^2;
ceq = [];

There are no linear constraints, so set those arguments to [].


A = [];
b = [];
Aeq = [];
beq = [];
Choose an initial point satisfying all the constraints.
x0 = [1/4,1/4];
Solve the problem.
nonlcon = @circlecon;
x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon)
Local minimum found that satisfies the constraints.

Optimization completed because the objective function is non-decreasing in


feasible directions, to within the default value of the optimality tolerance,
and constraints are satisfied to within the default value of the constraint tolerance.

x =
0.5000 0.2500

Exercises.
1. Open script scr1_circecon.m. Carefully analyze the program code
and comments.
This script demonstrates the use of fmincon solver to solve the
problem of minimizing of Rosenbrock's function subject to bound
constraints (EXAMPLE 1, EXAMPLE 3) and additional nonlinear
constraint (EXAMPLE 2). Rosenbrock's function is minimized within
a circle. EXAMPLE 3 demonstrates the transfer of additional
parameters through the fmincon function header.
2. Run script scr1_circecon.m. Thoroughly analyze the printed in
command window results.
3. Open and run script scr1_circecon.m. This script demonstrates the
transfer of additional parameter through the global variable.
4. Analyze:
 the location of the optimal points relative to the boundaries
of admissible sets;
 the optimal values of objective function at these points;
 the values of the components of the gradient;
 the matrix of the second derivatives (hessian).

You might also like