1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
---|
2 | <html> |
---|
3 | |
---|
4 | <head> |
---|
5 | <meta http-equiv="Content-Language" content="en-us"> |
---|
6 | <title>YALMIP Example : Polynomial expressions</title> |
---|
7 | <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> |
---|
8 | <meta content="Microsoft FrontPage 6.0" name="GENERATOR"> |
---|
9 | <meta name="ProgId" content="FrontPage.Editor.Document"> |
---|
10 | <link href="yalmip.css" type="text/css" rel="stylesheet"> |
---|
11 | <base target="_self"> |
---|
12 | </head> |
---|
13 | |
---|
14 | <body leftMargin="0" topMargin="0"> |
---|
15 | |
---|
16 | <div align="left"> |
---|
17 | |
---|
18 | <table border="0" cellpadding="4" cellspacing="3" style="border-collapse: collapse" bordercolor="#000000" width="100%" align="left" height="100%"> |
---|
19 | <tr> |
---|
20 | <td width="100%" align="left" height="100%" valign="top"> |
---|
21 | <h2>Polynomial expressions</h2> |
---|
22 | <hr noShade SIZE="1"> |
---|
23 | <p>Starting from YALMIP 3, polynomial expressions are supported. These |
---|
24 | nonlinear expressions can be used for, e.g., SDPs with BMI constraints, |
---|
25 | quadratic programming, or |
---|
26 | to solve sum-of-squares problems.</p> |
---|
27 | <p>Nonlinear expressions are built using |
---|
28 | <a href="reference.htm#sdpvar"> |
---|
29 | sdpvar</a> objects, and are manipulated in same way</p> |
---|
30 | <table cellPadding="10" width="100%"> |
---|
31 | <tr> |
---|
32 | <td class="xmpcode"> |
---|
33 | <pre>x = sdpvar(1,1); |
---|
34 | y = sdpvar(1,1); |
---|
35 | p = 1+x*y+x^2+y^3; |
---|
36 | Y = sdpvar(3,3); |
---|
37 | Z = Y*Y+Y.*Y;</pre> |
---|
38 | </td> |
---|
39 | </tr> |
---|
40 | </table> |
---|
41 | <p>A convenient command is |
---|
42 | <a href="reference.htm#sdisplay"> |
---|
43 | sdisplay</a> (symbolic display)</p> |
---|
44 | <table cellPadding="10" width="100%"> |
---|
45 | <tr> |
---|
46 | <td class="xmpcode"> |
---|
47 | <pre>sdisplay(p) |
---|
48 | <font color="#000000"> ans = |
---|
49 | '1+xy+x^2+y^3'</font></pre> |
---|
50 | </td> |
---|
51 | </tr> |
---|
52 | </table> |
---|
53 | <p>Some simple operators for polynomials have been implemented, such as |
---|
54 | differentiation.</p> |
---|
55 | <table cellPadding="10" width="100%"> |
---|
56 | <tr> |
---|
57 | <td class="xmpcode"> |
---|
58 | <pre>dp = jacobian(p); |
---|
59 | d2p = jacobian(jacobian(p)');</pre> |
---|
60 | </td> |
---|
61 | </tr> |
---|
62 | </table> |
---|
63 | <p>Checking the degree is easily done</p> |
---|
64 | <table cellPadding="10" width="100%"> |
---|
65 | <tr> |
---|
66 | <td class="xmpcode"> |
---|
67 | <pre>degree(p) |
---|
68 | <font color="#000000"> ans = |
---|
69 | 3 |
---|
70 | </font> |
---|
71 | degree(p,x) |
---|
72 | <font color="#000000"> ans = |
---|
73 | 2</font></pre> |
---|
74 | </td> |
---|
75 | </tr> |
---|
76 | </table> |
---|
77 | <p>Of course, all standard operators applies to the nonlinear objects.</p> |
---|
78 | <table cellPadding="10" width="100%"> |
---|
79 | <tr> |
---|
80 | <td class="xmpcode"> |
---|
81 | <pre>x = sdpvar(3,1); |
---|
82 | p = 5*trace(x*x') + jacobian(sum(x.^4))</pre> |
---|
83 | </td> |
---|
84 | </tr> |
---|
85 | </table> |
---|
86 | <p><img border="0" src="demoicon.gif" width="16" height="16"> Clear the internals of YALMIP on a regular basis with |
---|
87 | the command <code>yalmip('clear')</code> when working with polynomial |
---|
88 | expressions. The reason is that every time a nonlinear variable is defined, |
---|
89 | a description on how it is created is saved inside YALMIP (all monomials |
---|
90 | generate new variables). With many |
---|
91 | nonlinear terms this list grows fast, making YALMIP slower and slower since |
---|
92 | the list has to be searched in when polynomial expressions are manipulated.<br> |
---|
93 | <br> |
---|
94 | <img border="0" src="demoicon.gif" width="16" height="16"> The current implementation of the |
---|
95 | polynomial objects is inefficient for large problems. Multiplying two |
---|
96 | matrices of dimension, say 20, takes several seconds. But if you have a |
---|
97 | problem with this type of non-linearity, the solver will probably be the |
---|
98 | bottle-neck anyway... |
---|
99 | </td> |
---|
100 | </tr> |
---|
101 | </table> |
---|
102 | |
---|
103 | </div> |
---|
104 | |
---|
105 | </body> |
---|
106 | |
---|
107 | </html> |
---|