Opt

Purpose

Interface for solving optimization problems

Syntax

problem = Opt('H',H,'f',f,'pF',F,'A',A,'b',b,'Ae',Ae,...)
problem = Opt('M',M,'q',q,'Q',Q,'Ath',Ath,'bth',bth)
problem = Opt(Matrices)
problem = Opt(constraints, objective, theta, x)

Description

Encapsulates data and solutions for LP/QP/MPLP/MPQP/LCP/PLCP problems. The data can be provided directly, or using YALMIP format or MPT2 format. The following general MPQP format that is considered by Opt class:

../../../../../fig/mpt/modules/solvers/@Opt/opt29.png

which contains ../../../../../fig/mpt/modules/solvers/@Opt/opt1.png optimization variables ../../../../../fig/mpt/modules/solvers/@Opt/opt2.png, ../../../../../fig/mpt/modules/solvers/@Opt/opt3.png number of parameters ../../../../../fig/mpt/modules/solvers/@Opt/opt4.png, ../../../../../fig/mpt/modules/solvers/@Opt/opt5.pnginequality constrains, ../../../../../fig/mpt/modules/solvers/@Opt/opt6.png equality constraints and constraints on the parameter ../../../../../fig/mpt/modules/solvers/@Opt/opt7.png. Opt class accepts also PLCP formulation of the form

../../../../../fig/mpt/modules/solvers/@Opt/opt30.png

where ../../../../../fig/mpt/modules/solvers/@Opt/opt8.png and ../../../../../fig/mpt/modules/solvers/@Opt/opt9.png are the optimization variables and ../../../../../fig/mpt/modules/solvers/@Opt/opt10.png is the parameter. The output format of the optimization problem depends on the input data. For instance, non-parametric LCP can be created by providing ../../../../../fig/mpt/modules/solvers/@Opt/opt11.png, ../../../../../fig/mpt/modules/solvers/@Opt/opt12.png data and the parametric LPC by supplying ../../../../../fig/mpt/modules/solvers/@Opt/opt13.png, ../../../../../fig/mpt/modules/solvers/@Opt/opt14.png, and ../../../../../fig/mpt/modules/solvers/@Opt/opt15.png. At the time of construction, the problem data are validated and checked for proper dimensions. For all the methods involved in Opt class see methods('Opt').

Input Arguments

H

Quadratic part of the objective function.

Class: double

Default: []

f

Linear part of the objective function.

Class: double

pF

Linear part of the objective function for parameters.

Class: double

Default: []

Y

Quadratic part of the objective function for parameters.

Class: double

Default: 0

C

Linear part of the objective function for parameters.

Class: double

Default: 0

c

Constant term in the objective function

Class: double

Default: 0

A

Linear part of the inequality constraints ../../../../../fig/mpt/modules/solvers/@Opt/opt16.png.

Class: double

b

Right hand side of the inequality constraints ../../../../../fig/mpt/modules/solvers/@Opt/opt17.png.

Class: double

pB

Right hand side of the inequality constraints for parameters ../../../../../fig/mpt/modules/solvers/@Opt/opt18.png.

Class: double

Ae

Linear part of the equality constraints ../../../../../fig/mpt/modules/solvers/@Opt/opt19.png.

Class: double

Default: []

be

Right hand side of the equality constraints ../../../../../fig/mpt/modules/solvers/@Opt/opt20.png.

Class: double

Default: []

pE

Right hand side of the equality constraints for parameters ../../../../../fig/mpt/modules/solvers/@Opt/opt21.png.

Class: double

Default: []

lb

Lower bound for the decision variables ../../../../../fig/mpt/modules/solvers/@Opt/opt22.png.

Class: double

Default: []

ub

Upper bound for the decision variables ../../../../../fig/mpt/modules/solvers/@Opt/opt23.png.

Class: double

Default: []

Ath

Linear part of the inequality constraints ../../../../../fig/mpt/modules/solvers/@Opt/opt24.png.

Class: double

Default: []

bth

Right hand side of the inequality constraints ../../../../../fig/mpt/modules/solvers/@Opt/opt25.png.

Class: double

Default: []

vartype

A vector of strings determining the type of the variable. Supported characters are C (continuous), I (integer), B (binary), N (semi-integer), S (semi-continuous). Example: First variable from three is binary, the rest is continuous: vartype='BCC';

Class: char

Default: ''

solver

S string specifying which solver should be called.

Class: char

Default: []

M

Linear matrix involved in LCP.

Class: double

Default: []

q

Right hand side vector involved in LCP.

Class: double

Default: []

Q

Linear matrix involved in parametric formulation of LCP.

Class: double

Default: []

Matrices

Structure with the matrices defining MPLP/MPQP problem as returned by mpt_constructMatrices function. For detailed description, see help mpt_constructMatrices.

Class: struct

constraints

Yalmip set of constraints that formulate the given problem.

Class: lmi

objective

Yalmip variable that represents objective value of the given problem.

Class: sdpvar

theta

Specification of parametric variables involved in problem formulated in Yalmip.

Class: sdpvar

x

Specification of decision variables involved in problem formulated in Yalmip.

Class: sdpvar

Output Arguments

problem

Object of the Opt class that defines the optimization problem.

Class: Opt

Example(s)

Example 1

Formulate LP problem ../../../../../fig/mpt/modules/solvers/@Opt/opt26.png.
 f = [1 2 3]; A = randn(8,3); b = ones(8,1); 
 Consruct the object
 problem = Opt('f',f,'A',A,'b',b) 
-------------------------------------------------
Linear program
	Num variables:                3
	Num inequality constraints:   8
	Num equality constraints:     0
	Solver:                     LCP
-------------------------------------------------
Solve the problem
 problem.solve 
ans = 

        xopt: [3x1 double]
      lambda: [1x1 struct]
         obj: -2.25934252307113
         how: 'ok'
    exitflag: 1

Example 2

Formulate MPQP ../../../../../fig/mpt/modules/solvers/@Opt/opt27.png.
 f = [-1 2 -3 4]; A = randn(12,4); b = ones(12,1); B = randn(12,2);  
 Restrict the parameters to a unitbox of the size 5. 
 Ath = [eye(2); -eye(2)]; bth = 5*ones(4,1); 
 Construct the object 
 problem = Opt('H',eye(4),'f',f,'A',A,'b',b,'pB',B,'Ath',Ath,'bth',bth) 
-------------------------------------------------
Parametric quadratic program
	Num variables:                4
	Num inequality constraints:  12
	Num equality constraints:     0
	Num parameters:               2
	Solver:                     PLCP
-------------------------------------------------
Solve the problem
 solution = problem.solve 
regions:   27, unexplored: 9 
mpt_plcp: 43 regions
Fixing the adjacency list...
...done.

solution = 

        xopt: [1x1 PolyUnion]
    exitflag: 1
         how: 'ok'
       stats: [1x1 struct]

Since we have an explicit solution, we can plot the partition
 solution.xopt.plot 

../../../../../fig/mpt/modules/solvers/@Opt/opt_img_1.png

Example 3

Formulate LCP problem
 H = randn(5); M = sqrt(2)*H'*H; q = randn(5,1); 
 Construct the object 
 problem = Opt('M',M,'q',q); 
 Solve the problem 
 problem.solve 
ans = 

        xopt: [5x1 double]
      lambda: [5x1 double]
         obj: []
         how: 'ok'
    exitflag: 1

Example 4

Formulate MPC parametric problem using YALMIP Define the model ../../../../../fig/mpt/modules/solvers/@Opt/opt28.png.
 A = 0.7*randn(2); B = randn(2,1); 
 Define the optimization variables 
 u = sdpvar(repmat(1,1,5),repmat(1,1,5)); 

 x = sdpvar(repmat(2,1,6),repmat(1,1,6)); 
 Define the constraints and the cost function. 
 objective = []; constraints = []; 

 for k = 1:5,
                objective = objective + norm(eye(2)*x{k},2) + norm(u{k},2);
                constraints = [constraints, x{k+1} == A*x{k} + B*u{k}];                
                constraints = [constraints, -5 <= u{k} <= 5, -10 <= x{k} <= 10];
              end            
        
 Create the object 
 problem = Opt(constraints, objective, x{1}, u{1}) 
-------------------------------------------------
Parametric linear program
	Num variables:               15
	Num inequality constraints:  30
	Num equality constraints:    10
	Num lower bounds             15
	Num upper bounds             15
	Num parameters:               2
	Solver:                     PLCP
-------------------------------------------------
Solve the problem explicitly
 solution = problem.solve 
mpt_plcp: 4 regions

solution = 

        xopt: [1x1 PolyUnion]
    exitflag: 1
         how: 'ok'
       stats: [1x1 struct]

Plot the explicit solution
 solution.xopt.plot 

../../../../../fig/mpt/modules/solvers/@Opt/opt_img_2.png

Example 5

Formulate MPC problem using MPT2
 sysStruct.A = 0.7*randn(2); 

 sysStruct.B = randn(2,1); 

 sysStruct.C = [1, -1]; 

 sysStruct.D = 0; 

 sysStruct.xmin = [-10;-10]; 

 sysStruct.xmax = [10;10]; 

 sysStruct.umin = -5; 

 sysStruct.umax = 5; 

 probStruct.Q = 2*eye(2); 

 probStruct.R = 1; 

 probStruct.subopt_lev = 0; 

 probStruct.norm = 2; 

 probStruct.N = 5; 
 Create problem data to MPQP 
 Matrices = mpt_constructMatrices(sysStruct,probStruct) 
Function mpt_constructMatrices is obsolete and will be removed in a future MPT version.
Iteration 1...
Iteration 2...
Iteration 3...

Matrices = 

           PbndIncluded: 1
                      G: [36x5 double]
                      W: [36x1 double]
                      E: [36x2 double]
                      H: [5x5 double]
                      F: [2x5 double]
                      Y: [2x2 double]
                     Cf: [0 0 0 0 0]
                     Cx: [0 0]
                     Cc: 0
              symmetric: 0
                   bndA: [4x2 double]
                   bndb: [4x1 double]
                Pinvset: [1x1 polytope]
    constraints_reduced: 1

Construct object of the Opt class.
 problem = Opt(Matrices) 
-------------------------------------------------
Parametric quadratic program
	Num variables:                5
	Num inequality constraints:  36
	Num equality constraints:     0
	Num parameters:               2
	Solver:                     PLCP
-------------------------------------------------
Solve the problem
 solution = problem.solve 
mpt_plcp: 7 regions

solution = 

        xopt: [1x1 PolyUnion]
    exitflag: 1
         how: 'ok'
       stats: [1x1 struct]

Plot the control law over the explicit solution
 solution.xopt.fplot('primal') 

../../../../../fig/mpt/modules/solvers/@Opt/opt_img_3.png


© 2010-2013 Colin Neil Jones: EPF Lausanne, colin.jones@epfl.ch

© 2010-2013 Martin Herceg: ETH Zurich, herceg@control.ee.ethz.ch