Download presentation
Published byNicholas Watkins Modified over 9 years ago
1
Ali Molavi Iran University Of Science and Technology April 28
Sostool Toolbox Ali Molavi Iran University Of Science and Technology April 28
2
Intruduction Sum of Squares Polynomials
provide tractable relaxations for many hard optimization problems SOS can be solved using the powerful tools of convex optimization
3
Solving sum of squares problem
SOSTOOLS can solve two kinds of sum of squares programs Feasibility Optimization To define and solve a SOSP Initialize the SOSP Declare the SOSP variables. Define the SOSP constraints. Set objective function (for optimization problems) Call solver. Get solutions 1
4
Initializing a Sum of Squares Program
symbolic objects >> syms x y; Polynomial variables >> pvar x y; polynomial objects >> p = (x^4)+(5*x*y)+(x*y^2) 2
5
Initializing a Sum of Squares Program
>> Program1 = sosprogram([x;y]); [x,y] vector containing Independent variable p=(x^2)+(x*y)+(x*z)+(m*h) [x;y;z;m;h] decision variables Scalar decision variables Polynomial variables Sum of squares variables Matrix of polynomial variables Matrix of sum of squares variables 3
6
Declare the SOSP variables
Scalar decision variables or constant variable >>Program1 = sosdecvar(Program1,[a;b]); >>Program1 = sosprogram([x;y],[a;b]); Example P=ax+by >> syms x y a b; >> Program = sosprogram([x;y],[a,b]); >> Program1 = sosdecvar(Program1,[a;b]); 4
7
Declare the SOSP variables
Scalar Polynomial Variables polynomials with unknown coefficients >> Program1 = sosdecvar(Program1,[a;b;c]); >> v = a*x^2 + b*x*y + c*y^2; [Program1,v] = sospolyvar(Program1,[x^2; x*y; y^2]; ’ wscoeff’); V=coeff_1*x^2+coeff_2*x*y+coeff_3*y^2 5
8
Declare the SOSP variables
Constructing Vectors of Monomials VEC = monomials([x; y],[1 2 3]) VEC = mpmonomials({[x1; x2],[y1; y2],[z1]},{1:2,1,3}) 6
9
Declare the SOSP variables
Sum of Squares Variables [Program1,p] = sossosvar(Program1,[x; y]); P=coeff_4*y^2+(coeff_2+coeff_3)*x*y+coeff_1*x^2 [Q,Z,f] = findsos(P); 7
10
Declare the SOSP variables
Matrix Variables [prog,P] = sospolymatrixvar(prog,monomials(x,0),[2 2]); [prog,Q]=sospolymatrixvar(prog,monomials([x1],[1]),[2 2], ’symmetric’); Matrix dimention 8
11
Define the SOSP constraints
Adding Constraints Equality constraints Program1 = soseq(Program1,diff(p,x)-x^2); Inequality Constraints Program1 = sosineq(Program1,diff(p,x)-x^2); Inequlity constraints with an interval Program2 = sosineq(Program2,diff(p,x)-x^2,[-1 2]); 9
12
Define the SOSP constraints
Matrix Inequality Constraints syms theta1 theta2; or >>pvar theta1 theta2 theta = [theta1; theta2]; prog = sosprogram(theta); [prog,M]=sospolymatrixvar(prog,monomials(theta,0:2),[3,3] ,’symmetric’); There are 2 case prog = sosmatrixineq(prog,M,’quadraticMineq’); prog = sosmatrixineq(prog,M,’Mineq’); 10
13
Define the SOSP constraints
Example Lyapunove Function V(X)=X’PX For Stability We can define “eps” then eps<<1 A’P+PA<0 P>0 A’P+PA<-eps*I P>eps*I 11
14
Define the SOSP constraints
syms x; G = rss(4,2,2); A = G.a; eps = 1e-6; I = eye(4); prog = sosprogram(x); [prog,P]=sospolymatrixvar(prog,monomials(x,0),[4,4],’symm etric’); prog = sosmatrixineq(prog,P-eps*I,’quadraticMineq’); d= A’*P+P*A; prog = sosmatrixineq(prog,-d-eps*I,’quadraticMineq’); 12
15
Setting an Objective Function and calling solver
Setting objective function Program1 = sossetobj(Program1,a-b); (a ,b )are decision variable Calling solver Program1 = sossolve(Program1,options); Getting Solutions SOLp1 = sosgetsol(Program6,p1,5); P1 is in fact SOSP variable For example a polynomial variable 13
16
Application of sum of Squares programming
Sum of Square Test Given a polynomial p(x), determine if p(x)>0 is feasible syms x1 x2; vartable = [x1, x2]; prog = sosprogram(vartable) % define the inequality p = 2*x1^4 + 2*x1^3*x2 - x1^2*x2^2 + 5*x2^4; prog = sosineq(prog,p); prog = sossolve(prog); % call solver [Q,Z]=findsos(p,’rational’); % P=Z’QZ 14
17
Application of sum of Squares programming
Lyapunov Function Search Finding a V(X)>0 Derivative of V(X) 15
18
Application of sum of Squares programming
syms x1 x2 x3; prog = sosprogram([x1;x2;x3]) f=[-x1^3-x1*x3^2;-x2-x1^2*x2;x3+3*x1^2*x33*x3/(x3^2+1)] [prog,V] = sospolyvar(prog,[x1^2; x2^2; x3^2],’wscoeff’); V=coeff_4*x1^2 + coeff_5*x2^2 + coeff_6*x3^2 %For example “eps=1” prog = sosineq(prog,V-(x1^2+x2^2+x3^2)); dd=-(diff(V,x1)*f(1)+diff(V,x2)*f(2)+diff(V,x3)*f(3))*(x3^2+1); prog = sosineq(prog,dd); prog = sossolve(prog); SOLV = sosgetsol(prog,V) 16
19
Application of sum of Squares programming
Another Way to Find Lyapunov Function syms x1 x2; V = findlyap([-x1^3+x2; -x1-x2],[x1; x2],2) The function ‘’findlyap’’ has three argument The first one Vector Field The second one Ordering of the independent variable The third one Degree of lyapunov function 17
20
Application of sum of Squares programming
Global and Constrained Optimization Minimum ( -Gama ) such that syms x1 x2 gam; prog = sosprogram([x1,x2]); prog = sosdecvar(prog,[gam]); f = x1+x2-3*x1^2+6*x2*x1 prog = sosineq(prog,(f-gam)) prog = sossetobj(prog,-gam); prog = sossolve(prog); SOLgamma = sosgetsol(prog,gam) 18
21
Application of sum of Squares programming
Another way to find minimum of an objective function syms a b c d; F=(a^4+1)*(b^4+1)*(c^4+1)*(d^4+1)+2*a + 3*b + 4*c + 5*d; [bnd,vars,xopt] = findbound(F) bnd=lower bound for polynomial Vars=A vector of variable of the polynomial Xopt=A Point Where The Result is achieved 19
22
Application of sum of Square programming
Minimization of polynomial with constraint Example: Minimizing (X1^2)+(X2^2) subject to syms x1 x2; degree = 4; [gam,vars,opt] = findbound(x1+x2,[x1, x2-0.5],... [x1^2+x2^2-1, x2-x1^2-0.5],degree); 20
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.