Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Optimization with MATLAB (3)

The document provides an overview of optimization using MATLAB, specifically focusing on the linprog function for solving linear programming problems in minimization form. It details the input and output arguments of the function, as well as the structure of Lagrange multipliers and optimization output. Additionally, it includes an example of Giapettos's Woodcarving Problem and mentions other functions like fzero and fminsearch for finding zeros and local minima, respectively.

Uploaded by

kkirbiyik7
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Optimization with MATLAB (3)

The document provides an overview of optimization using MATLAB, specifically focusing on the linprog function for solving linear programming problems in minimization form. It details the input and output arguments of the function, as well as the structure of Lagrange multipliers and optimization output. Additionally, it includes an example of Giapettos's Woodcarving Problem and mentions other functions like fzero and fminsearch for finding zeros and local minima, respectively.

Uploaded by

kkirbiyik7
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

• Optimization using MATLAB

▪ MATLAB function linprog solves linear programming problems in the minimization form.

Minimize 𝑧 = 𝑓𝑇𝑥
s.t. 𝐴. 𝑥 ≤ 𝑏
𝐴𝑒𝑞. 𝑥 = 𝑏𝑒𝑞
𝑙𝑏 ≤ 𝑥 ≤ 𝑢𝑏
[x,fval,exitflag,output,lambda]=linprog(f,A,b,Aeq,beq,lb,ub,x0,options)

Input arguments Output arguments

f: objective function lb, []: lower bounds on x, x: optimal solution output: number of iterations
coefficients no lower bounds algorithm used
A: matrix of inequality ub, []: upper bounds on x, fval: optimal objective
constraints no upper bounds function value
b: RHS of inequality x0: start vector for the exitflag: tells whether the lambda: contains Lagrange
constraints algorithm if known, else [] algorithm converged or not, multipliers corresponding
>0 means convergence to constraints
Aeq: matrix of equality options: options set to
constraints determine what algorithms
to use
beq: RHS of equality
constraints 2
▪ lambda Structure containing the Lagrange multipliers at the solution x (separated by constraint type). The
fields of the structure are:
lower Lower bounds lb
upper Upper bounds ub
ineqlin Linear inequalities
eqlin Linear equalities
▪ output Structure containing information about the optimization. The fields of the structure are:
algorithm Algorithm used
cgiterations The number of conjugate gradient iterations (large-scale algorithm only).
iterations Number of iterations
message Exit message
▪ exitflag Integer identifying the reason the algorithm terminated. The following lists the values of exitflag
and the corresponding reasons the algorithm terminated.
1 Function converged to a solution x.
0 Number of iterations exceeded options.MaxIter.
-2 No feasible point was found.
-3 Problem is unbounded.
-4 NaN value was encountered during execution of the algorithm.
-5 Both primal and dual problems are infeasible.
-7 Search direction became too small. No further progress could be made.

3
% Giapettos's Woodcarving Problem
% Define the problem coefficients:
%Since the original problem is maximization, the objective function coefficients are negated
for minimization:
f = [-3; -2];
%Inequality constraint coefficients are defined for <= constraints:
A = [1 1
2 1
1 0];
%RHS values for inequality constraints:
b = [80
100
40];
% Variables are non-negative:
lb = zeros(2,1);

[x,fval,exitflag,output,lambda] = linprog(f,A,b,[],[],lb);

4
Optimization terminated. >> output
>> x
output =
x=

20.0000 struct with fields:


60.0000
iterations: 5
>> fval
algorithm: 'interior-point-legacy'
fval = cgiterations: 0
message: 'Optimization terminated.'
-180.0000 constrviolation: 1.1369e-13
firstorderopt: 3.1264e-13
>> lambda

lambda = >> exitflag

struct with fields: exitflag =

ineqlin: [3×1 double]


1
eqlin: [0×1 double]
upper: [2×1 double]
lower: [2×1 double] >>

5
▪ fzero
x = fzero(fun,x0) tries to find a zero of fun near x0
x0 is a scalar, fun is a function handle.

▪ fminsearch
x = fminsearch(fun,x0) starts at the point x0 and finds a local
minimum x of the function described in fun.
x0 can be a scalar, vector, or matrix;fun is a function handle.

You might also like