sos.htm
来自「国外专家做的求解LMI鲁棒控制的工具箱,可以相对高效的解决LMI问题」· HTM 代码 · 共 459 行 · 第 1/2 页
HTM
459 行
double(lower)
<font color="#000000">
ans =</font></pre>
<pre><font color="#000000"> 0.75</font></pre>
</td>
</tr>
</table>
<p>Multiple SOS constraints can also be used. Consider the following problem of
finding the smallest possible <b>t</b> such that the polynomials <b>t(1+xy)<sup>2</sup>-xy+(1-y)<sup>2</sup></b>
and <b>(1-xy)<sup>2</sup>+xy+t(1+y)<sup>2</sup> </b>are both
sum of squares.</p>
<table cellPadding="10" width="100%">
<tr>
<td class="xmpcode">
<pre>sdpvar x y t
p1 = t*(1+x*y)^2-x*y+(1-y)^2;
p2 = (1-x*y)^2+x*y+t*(1+y)^2;
F = set(sos(p1))+set(sos(p2));
solvesos(F,t);</pre>
<pre>double(t)
<font color="#000000">
ans =
0.2500</font></pre>
<pre>sdisplay(sosd(F(1)))</pre>
<pre><font color="#000000">ans = </font></pre>
<pre><font color="#000000"> '-1.102+0.95709y+0.14489xy'
'-0.18876-0.28978y+0.47855xy'</font></pre>
<pre>sdisplay(sosd(F(2)))</pre>
<pre><font color="#000000">ans = </font></pre>
<pre><font color="#000000"> '-1.024-0.18051y+0.76622xy'
'-0.43143-0.26178y-0.63824xy'
'0.12382-0.38586y+0.074568xy'</font></pre>
<pre> </pre>
</td>
</tr>
</table>
<p>
<img border="0" src="demoicon.gif" width="16" height="16">If you have
parametric variables, bounding the feasible region typically
improves numerical behavior. Having lower bounds will
additionally decrease the size of the optimization problem
(variables bounded from below can be treated as translated cone
variables in <a href="dual.htm#dualization">dualization</a>, which
is used by <a href="reference.htm#solvesos">
solvesos</a>).</p>
<p>
<img border="0" src="demoicon.gif" width="16" height="16"> One of the
most common mistake people make when using the sum of squares module
is to forget to declare some parametric variables. This will
typically lead to a (of-course erroneous) huge sum of squares
problem which easily freezes MATLAB and/or give strange error
messages (trivially infeasible, nonlinear parameterization, etc).
Make sure to initially run the module in verbose mode to see how
YALMIP characterizes the problem (most importantly to check the
number of parametric variables and independent variables).</p>
<p>
<img border="0" src="demoicon.gif" width="16" height="16">When you use
a kernel representation (<code>sos.model=1</code> and typically the case also
for <code>sos.model=0</code>), YALMIP will derive and solve a
problem which is related to the dual of your original problem. This
means that warnings about infeasibility after solving the SDP actually means
unbounded objective, and vice versa. If you use <code>sos.model=2</code>,
a primal problem is solved, and YALMIP error messages are directly related to
your problem.</p>
<p>
<img border="0" src="demoicon.gif" width="16" height="16">The quality
of the SOS approximation is typically improved substantially if the
tolerance and precision options of the semidefinite solver is
decreased. As an example, having <code>sedumi.eps</code>
less than 10<sup>-10 </sup> when solving sum of squares problems is
typically recommended for anything but trivial problems. There is a
higher likelihood that the semidefinite solver will complain about
numerical problems in the end-phase, but the resulting solutions are
typically much better. This seem to be even more important in
parameterized problems.</p>
<p>
<img border="0" src="demoicon.gif" width="16" height="16">To evaluate
the quality and success of the sum of squares decomposition, do not
forget to study the discrepancy between the decomposition and the
original polynomial.<checksetche The quality
of the SOS approximation is typically improved substantially if the
tolerance and precision options of the semidefinite solver is
decreased. As an example, having <code> No problems in the
semidefinite solver is no guarantee for a successful decomposition
(due to numerical reasons, tolerances in the solvers etc.)</p>
<checksetche The quality
of the SOS approximation is typically improved substantially if the
tolerance and precision options of the semidefinite solver is
decreased. As an example, having <code>
<h3>Polynomial parameterizations</h3>
<p>A special feature of the sum of squares package in YALMIP is the
possibility to work with nonlinear SOS parameterizations, i.e. SOS problems
resulting in PMIs (polynomial matrix inequalities) instead of LMIs. The following piece of code solves a
nonlinear control <i>synthesis</i> problem using sum of squares. Note
that this requires the solver <a href="solvers.htm#penbmi">PENBMI</a>.</p>
<table cellPadding="10" width="100%">
<tr>
<td class="xmpcode">
<pre>clear all
yalmip('clear');
% States...
sdpvar x1 x2
x = [x1;x2];
% Non-quadratic Lyapunov z'Pz
z = [x1;x2;x1^2];
P = sdpvar(3,3);
V = z'*P*z;
% Non-linear state feedback
v = [x1;x2;x1^2];
K = sdpvar(1,3);
u = K*v;
% System x' = f(x)+Bu
f = [1.5*x1^2-0.5*x1^3-x2; 3*x1-x2];
B = [0;1];
% Closed loop system, u = Kv
fc = f+B*K*v;
% Stability and performance constraint dVdt < -x'x-u'u
% NOTE : This polynomial is bilinear in P and K
F = set(sos(-jacobian(V,x)*fc-x'*x-u'*u));
% P is positive definite, bound P and K for numerical reasons
F = F + set(P>0)+set(25>P(:)>-25)+set(25>K>-25);
% Minimize trace(P)
% Parametric variables P and K automatically detected
% by YALMIP since they are both constrained
solvesos(F,trace(P));</pre>
</td>
</tr>
</table>
<h3><a name="lowrank"></a>Low-rank sum-of-squares (<font color="#FF0000">experimental!</font>)</h3>
<p>By using the capabilities of the solver <a href="solvers.htm#LMIRANK">LMIRANK</a>,
we can pose sum-of-squares problems where we search for decompositions
with few terms (low-rank Gramian). Consider the following problem where
a trace heuristic leads to an effective rank of 5, perhaps 6. </p>
<table cellPadding="10" width="100%" id="table2">
<tr>
<td class="xmpcode">
<pre>x = sdpvar(1,1);
y = sdpvar(1,1);
f = 200*(x^3 - 4*x)^2+200 * (y^3 - 4*y)^2+(y - x)*(y + x)*x*(x + 2)*(x*(x - 2)+2*(y^2 - 4));
g = 1 + x^2 + y^2;
p = f * g;
F = set(sos(h));
[sol,v,Q] = solvesos(F,[],sdpsettings('sos.traceobj',1));
eig(Q{1})
<font color="#000000">ans =</font></pre>
<pre><font color="#000000"> 1.0e+003 *</font></pre>
<pre><font color="#000000"> 0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0001
0.0124
0.3977
3.3972
3.4000
6.7972</font></pre>
</td>
</tr>
</table>
<p>We solve the problem using <a href="solvers.htm#LMIRANK">LMIRANK</a>
instead, and aim for a rank less than or equal to 4. The desired rank is
specified easily in the <a href="reference.htm#sos">sos</a> construct.</p>
<table cellPadding="10" width="100%" id="table3">
<tr>
<td class="xmpcode">
<pre>x = sdpvar(1,1);
y = sdpvar(1,1);
f = 200*(x^3 - 4*x)^2+200 * (y^3 - 4*y)^2+(y - x)*(y + x)*x*(x + 2)*(x*(x - 2)+2*(y^2 - 4));
g = 1 + x^2 + y^2;
p = f * g;
F = set(sos(h,<font color="#FF0000">4</font>));
[sol,v,Q] = solvesos(F,[],sdpsettings('lmirank.eps',0));
eig(Q{1})
<font color="#000000">ans =</font></pre>
<pre><font color="#000000"> 1.0e+003 *</font></pre>
<pre><font color="#000000"> -0.0000
-0.0000
-0.0000
-0.0000
-0.0000
-0.0000
-0.0000
-0.0000
0.0000
0.0000
0.4634
4.2674
4.6584
7.1705</font></pre>
</td>
</tr>
</table>
<p>The resulting rank is indeed effectively 4. Note though that <a href="solvers.htm#LMIRANK">LMIRANK</a>
works on the dual problem side, and can return slightly infeasible
solutions (in terms of positive definiteness.) Keep in mind though that
sum-of-squares decompositions <i>almost always</i> be slightly wrong, in
one way or the other. If a dual (also called image) approach is used
(corresponding to <font color="#0000FF">sos.model=2</font>), positive
definiteness may be violated, and if a primal approach (also called
kernel) approach is used (corresponding to <font color="#0000FF">
sos.model=1</font>), there is typically a difference between the
polynomial and its decomposition. This simply due to the way SDP solvers
work. See more in the example <font color="#0000FF">sosex.m</font></p>
<p>Remember that <a href="solvers.htm#LMIRANK">LMIRANK</a> is a local
solver, hence there are no guarantees that it will find a low rank
solution even though one is known to exist. Moreover, note that <a href="solvers.htm#LMIRANK">LMIRANK</a>
does not support objective functions.</td>
</tr>
</table>
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?