Tarbiat Modares University AEM Seminar
_______________________
How to solve LMIs in MATLAB
____________________
January 2012
How to solve LMIs in MATLAB
Saeed Varzandian
YALMIP
YALMIP is a modelling language for advanced modeling and solution of convex and nonconvex optimization problems. It is implemented as a free (as in no charge) toolbox for MATLAB. Created by: Johan Lfberg Linkping Universitet (Sweden)
Download from: http://users.isy.liu.se/johanl/yalmip/
How to solve LMIs in MATLAB
How to install YALMIP ...
4 easy steps: 1. Extract the zipped file (yalmip.zip) 2. Open MATLAB and type the following command in the command window: >>addpath(genpath('the yalmip path')); e.g. >>addpath(genpath('E:\yalmip')); 3. Add the YALMIP path to MATLAB from: File / Set path... / Add with subfolders 4. To test whether it is working properly or not, type: >>yalmiptest
How to solve LMIs in MATLAB
How to solve LMIs with YALMIP?
LMI canonical form:
F ( x )= F 0 + x i F i > 0
i =1
LMI is can be considered as an optimization problem of the following kind: min h subject to F >(=) 0 that can be solved with YALMIP's semidefinite programming (sdp) tool.
How to solve LMIs in MATLAB
Solve LMIs with just five simple commands!
SDPVAR SET SEE SOLVESDP DOUBLE
How to solve LMIs in MATLAB
SDPVAR
Create symbolic decision variable You can create a sdpvar variable by: X = SDPVAR(n) Symmetric nxn matrix X = SDPVAR(n,n) Symmetric nxn matrix X = SDPVAR(n,m) Full nxm matrix (n~=m) Definition of multiple scalars can be simplified SDPVAR x y z w The parametrizations supported are X = SDPVAR(n,n,'full') Full nxn matrix X = SDPVAR(n,n,'symmetric') Symmetric nxn matrix Other available forms: Diagonal, Symmetric Toeplitz, Unsymmetric Hankel, Symmetric Hankel, Skew-symmetric, ... A scalar is defined as a 1x1 matrix
How to solve LMIs in MATLAB
SET
Define the constraints The second most important concept in YALMIP is the set object. A set object is basically a collection of sdpvar objects constrained to have some property. F = set ( X > 0 ) or F = set ( X^2+eye(2)==Y ) For adding multiple constraints, simply use '+' : F = set(P>eye(2)) + set(A'*P+P*A<0)
How to solve LMIs in MATLAB
SEE
See the base matrices With see, it is possible to see what the base matrices look like. see(F) see( eye(e)+F' )
How to solve LMIs in MATLAB
SOLVESDP
Computes solution to optimization problem DIAGNOSTIC = SOLVESDP(F,h,options) SOLVESDP is the common command to solve optimization problems of the following kind min h
subject to F >(=) 0 OUTPUT diagnostic : Diagnostic information INPUT F : Object describing the constraints. Can be []. h : SDPVAR object describing the objective h(x). Can be []. options : Options structure. See SDPSETTINGS. Can be [].
How to solve LMIs in MATLAB
DOUBLE
Obtain solution for a variable double(P) X_feasible=double(X)
How to solve LMIs in MATLAB
10
EXAMPLES 1) sdpvar x1 x2 x3 x4 L=set([4+x1+2*x2 x2+x3+2; x2+x3+2 3*x2+x4] > 0); see(L) Constant matrix 4 2 2 0 Base matrices 1 0 0 0 2 1 0 1 1 3 1 0
4+ x 1+ 2x 2 x 2+ x 3 + 2 >0 x 2 + x 3+ 2 3x 2+ x 4
[ ] [ ] [ ] [ ] [ ]
3 4
4 2 1 0 2 1 0 1 0 0 + x1 + x2 +x3 +x4 >0 2 0 0 0 1 3 1 0 0 1
0 0 0 1 Used variables 1 2
How to solve LMIs in MATLAB
11
2) x1=sdpvar(1,1); x2=sdpvar(1,1); L=set([1-x1 x1+x2 x1+x2 2-x2 x1 0 +set(x1+x2<1); Z=solvesdp(L,[]); x1_feasible=double(x1) x2_feasible=double(x2) x1_feasible = -0.3562 x2_feasible = 0.2921 x1 ; 0 ; 1+x2] > 0)...
How to solve LMIs in MATLAB
12
3)Lyapunov analysis using semidefinite programming % Create a stable matrix A = [-1 2;0 -2]; % Create symmetric matrix (full syntax) P = sdpvar(2,2,'symmetric'); % Add SETs for stability F = set(P>eye(2)) + set(A'*P+P*A<0) % Find feasible solution, minimize trace(P) solution = solvesdp(F,trace(P)); % Extract numerical solution P_feasible = double(P) P_feasible = 1.0000 0.0000 0.0000 1.0000 % Check solution eig(P_feasible) ans = 1.0000 1.0000 eig(A'*P_feasible+P_feasible'*A) ans = -5.2361 -0.7639
How to solve LMIs in MATLAB
13
Further reading
1. Type: >> yalmipdemo for various examples and more useful commands.
2. More information on the main website: http://users.isy.liu.se/johanl/yalmip/
How to solve LMIs in MATLAB
14
Thanks for your attention!
How to solve LMIs in MATLAB
15