📄 reference.htm
字号:
<tr>
<td class="tabxpl">blkvar is used to handle block matrices in a
more symbolic fashion.</td>
</tr>
<tr>
<th class="doc" valign="top" nowrap align="left" bgcolor="#eeeeee" rowspan="2">
Examples</th>
</tr>
<tr>
<td class="tabxpl">Consider the 3x3 block matrix <code>[A B 0;B' C
D;0 D' E]</code>. Using standard YALMIP and MATLAB code, we would define this using
concatenations. <table cellpadding="10" width="100%" id="table56">
<tr>
<td class="xmpcode">
<pre>n = 5;
m = 3;
A = sdpvar(n,n);
B = randn(n,2);
E = sdpvar(m,m);
C = randn(2,2);
D = randn(2,m);</pre>
<pre>X = [A B zeros(n,m);B' C D;zeros(m,n) D' E];</pre>
</td>
</tr>
</table>
<p>By using a block variable, we can define blocks instead. </p>
<table cellpadding="10" width="100%" id="table57">
<tr>
<td class="xmpcode">
<pre>X = blkvar;
X(1,1) = A;
X(1,2) = B;
X(1,3) = 0;
X(2,2) = C;
X(2,3) = D;
X(3,3) = E;
X = sdpvar(X);</pre>
</td>
</tr>
</table>
<p>Dimension of 0 blocks do not have to be specified, they will be
automatically be derived, if possible, from the dimension of
other elements. Note that we only have to define one element of
symmetric pairs, YALMIP will automatically fill in the symmetric
counter-part. If no symmetric counter-part is found, the
corresponding block is filled with zeroes. Hence, the following
code is equivalent.</p>
<table cellpadding="10" width="100%" id="table58">
<tr>
<td class="xmpcode">
<pre>X = blkvar;
X(1,1) = A;
X(1,2) = B;
X(2,2) = C;
X(2,3) = D;
X(3,3) = E;
X = sdpvar(X);</pre>
</td>
</tr>
</table>
<p>Standard operators can typically be applied directly to the
block variable (but it is currently recommended to convert the
variable to an sdpvar object)</p>
<table cellpadding="10" width="100%" id="table59">
<tr>
<td class="xmpcode">
<pre>X = blkvar;
X(1,1) = A;
X(1,2) = B;
X(2,2) = C;
X(2,3) = D;
X(3,3) = E;
F = set(X > 0 ) + set(trace(X)==1);
% Recommended
X = sdpvar(X);
F = set(X > 0 ) + set(trace(X)==1);</pre>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<th class="doc" valign="top" nowrap align="left" bgcolor="#eeeeee" rowspan="2">
Related commands</th>
</tr>
<tr>
<td class="tabxpl"><a href="reference.htm#sdpvar">sdpvar</a></td>
</tr>
</table>
</td>
</tr>
</table>
<p> </p>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" bordercolor="#FF9933" id="table44">
<tr>
<td class="tableheader">
<p class="tableheader"><a name="bounds">BOUNDS</font></a></p>
</td>
</tr>
<tr>
<td>
<table cellspacing="0" cellpadding="4" width="100%" border="0" id="table45">
<tr>
<th class="doc" valign="top" nowrap align="left" bgcolor="#eeeeee" rowspan="2">
Syntax</th>
<td class="code" valign="top" nowrap width="100%"><code>bounds(X,lower,upper)</code></td>
</tr>
<tr>
<td class="tabxpl">
<table border="0" id="table51">
<tr>
<td>
<p align="right"><font face="Courier New" size="2">X:</font></p>
</td>
<td>sdpvar</td>
</tr>
<tr>
<td>
<p align="right"><font face="Courier New" size="2">lower:</font></p>
</td>
<td>double</td>
</tr>
<tr>
<td>
<p align="right"><font face="Courier New" size="2">upper:</font></p>
</td>
<td>double</td>
</tr>
</table>
</td>
</tr>
<tr>
<th class="doc" valign="top" nowrap align="left" bgcolor="#eeeeee" rowspan="2">
Description</th>
</tr>
<tr>
<td class="tabxpl" height="26">bounds is used to add implicit
domain bounds on variables to improve big-M relaxations.</td>
</tr>
<tr>
<th class="doc" valign="top" nowrap align="left" bgcolor="#eeeeee" rowspan="2">
Examples</th>
</tr>
<tr>
<td class="tabxpl">Variable bounds defined with the command bounds
are used to compute suitable constants when performing big-M
relaxations in
<a href="logic.htm">logic programming</a> and while creating MILP
models for <a href="extoperators.htm#milp">non-convex operators</a>. As an example, the following simple mixed
integer logic
program requires a big-M relaxation in YALMIP. To improve the
relaxation, we supply bounds on the variable <b>x</b>.<table cellpadding="10" width="100%" id="table47">
<tr>
<td class="xmpcode">
<pre>A1 = randn(10,3);
b1 = rand(10,1)*10;
A2 = randn(10,3);
b2 = rand(10,1)*10;
x = sdpvar(3,1);bounds(x,[-25;-25;-25],[25;25;25]);
F = set((A1*x<=b1) | (A1*x <=b2));
solvesdp(F,sum(x))</pre>
</td>
</tr>
</table>
<p>Of course, standard MATLAB notation applies so if you have the
same bound on all variables, you only need to supply one scalar
bound.</p><table cellpadding="10" width="100%" id="table52">
<tr>
<td class="xmpcode">
<pre>A1 = randn(10,3);
b1 = rand(10,1)*10;
A2 = randn(10,3);
b2 = rand(10,1)*10;
x = sdpvar(3,1);bounds(x,-25,25);
F = set((A1*x<=b1) | (A1*x <=b2));
solvesdp(F,sum(x))</pre>
</td>
</tr>
</table>
<p>Note that the big-M computation only take advantage of
bounds explicitly defined using the bounds command. Bounds defined using a
<a href="reference.htm#set">set</a> construction will not be detected or exploited. Hence, the
following problem will give rise to a MILP with weaker relaxations (big-M will be set to e 10<sup>4</sup>).</p>
<table cellpadding="10" width="100%" id="table49">
<tr>
<td class="xmpcode">
<pre>x = sdpvar(3,1);
F = set(-25 <= x<= 25) + set((A1*x<=b1) | (A1*x <=b2));
solvesdp(F,sum(x))</pre>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<th class="doc" valign="top" nowrap align="left" bgcolor="#eeeeee" rowspan="2">
Related commands</th>
</tr>
<tr>
<td class="tabxpl"><a href="reference.htm#set">set</a></td>
</tr>
</table>
</td>
</tr>
</table>
<p> </p>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" bordercolor="#FF9933">
<tr>
<td class="tableheader">
<p class="tableheader"><a name="checkset">CHECKSET</a></p>
</td>
</tr>
<tr>
<td>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
<th class="doc" valign="top" nowrap align="left" bgcolor="#eeeeee" rowspan="2">
Syntax</th>
<td class="code" valign="top" nowrap width="100%"><code>[p,d] = checkset(F)</code></td>
</tr>
<tr>
<td class="tabxpl">
<table border="0">
<tr>
<td>
<p align="right"><font face="Courier New" size="2">F:</font></p>
</td>
<td>set object</td>
</tr>
<tr>
<td>
<p align="right"><font face="Courier New">p</font><font face="Courier New" size="2">:</font></p>
</td>
<td>Primal constraint residuals</td>
</tr>
<tr>
<td>
<p align="right"><font face="Courier New">d</font><font face="Courier New" size="2">:</font></p>
</td>
<td>Dual constraint residuals</td>
</tr>
</table>
</td>
</tr>
<tr>
<th class="doc" valign="top" nowrap align="left" bgcolor="#eeeeee" rowspan="2">
Description</th>
</tr>
<tr>
<td class="tabxpl">checkset is used to examine satisfaction of constraints
in a <a href="#set">set</a> object.</td>
</tr>
<tr>
<th class="doc" valign="top" nowrap align="left" bgcolor="#eeeeee" rowspan="2">
Examples</th>
</tr>
<tr>
<td class="tabxpl"><p>After solving a problem, we can easily check how
well the constraints are satisfied.</p><table cellpadding="10" width="100%">
<tr>
<td class="xmpcode">
<pre>solvesdp(F,objective);
checkset(F)</pre>
</td>
</tr>
</table>
<p>The constraint residuals are defined as smallest eigenvalue, smallest
element, negated largest absolute-value element and largest distance
to an integer for semidefinite, element-wise, second order cone and
integrality constraints respectively. Hence, a solution is feasible
if all residuals related to inequalities are non-negative and residuals
related to equalities are sufficiently close to zero.</p>
<p>Sometimes it might be convenient to have the numerical values of
the constraint violations</p>
<table cellpadding="10" width="100%">
<tr>
<td class="xmpcode">
<pre>[p,d] = checkset(F);</pre>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<th class="doc" valign="top" nowrap align="left" bgcolor="#eeeeee" rowspan="2">
Related commands</th>
</tr>
<tr>
<td class="tabxpl"><a href="reference.htm#set">set</a>,
<a href="reference.htm#solvesdp">solvesdp</a></td>
</tr>
</table>
</td>
</tr>
</table>
<p class="Sh2"> </p>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" bordercolor="#FF9933">
<tr>
<td class="tableheader">
<p class="tableheader"><a name="clean">CLEAN</a></p>
</td>
</tr>
<tr>
<td>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
<th class="doc" valign="top" nowrap align="left" bgcolor="#eeeeee" rowspan="2">
Syntax</th>
<td class="code" valign="top" nowrap width="100%"><code>y = clean(x,tol)</code></td>
</tr>
<tr>
<td class="tabxpl">
<table border="0">
<tr>
<td>
<p align="right"><font face="Courier New" size="2">y:</font></p>
</td>
<td>sdpvar object</td>
</tr>
<tr>
<td>
<p align="right"><font face="Courier New" size="2">x:</font></p>
</td>
<td>sdpvar object</td>
</tr>
<tr>
<td>
<p align="right"><font face="Courier New" size="2">tol:</font></p>
</td>
<td>double (tolerance)</td>
</tr>
</table>
</td>
</tr>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -