source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/htmldata/basics.htm @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 5.9 KB
Line 
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 : Basics</title>
7<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
8<link href="yalmip.css" type="text/css" rel="stylesheet">
9<base target="_self">
10</head>
11
12<body leftmargin="0" topmargin="0">
13
14<div align="left">
15  <table border="0" cellpadding="4" cellspacing="3" style="border-collapse: collapse" bordercolor="#000000" width="100%" align="left" height="100%">
16    <tr>
17      <td width="100%" align="left" height="100%" valign="top">
18      <h2>Basics: The sdpvar and set object</h2>
19      <hr size="1" color="#000000">
20      <p>The most important command in YALMIP is <a href="reference.htm#sdpvar">
21      sdpvar</a>. This command is used to the define decision variables. To define
22      a matrix (or scalar) <b>P</b> with height <b>n</b> and width <b>m</b>, we
23      write</p>
24      <table cellpadding="10" width="100%">
25        <tr>
26          <td class="xmpcode">
27          <pre>P = sdpvar(n,m)</pre>
28          </td>
29        </tr>
30      </table>
31      <p><font color="#FF0000">A square matrix is symmetric by default!</font>. To obtain a fully parameterized
32      square matrix, a third argument is needed.</p>
33      <table cellpadding="10" width="100%">
34        <tr>
35          <td class="xmpcode">
36          <pre>P = sdpvar(3,3,&#39;full&#39;)</pre>
37          </td>
38        </tr>
39      </table>
40      <p>The third argument can be used to obtain a number of pre-defined types
41      of variables, such as Toeplitz, Hankel, symmetric and skew-symmetric matrices.
42      See the help text on <a href="reference.htm#sdpvar">sdpvar</a> for details.&nbsp; 
43                Alternatively, the associated standard commands can be applied to a
44                suitable vector</p>
45      <table cellpadding="10" width="100%" id="table2">
46        <tr>
47          <td class="xmpcode">
48          <pre>x = sdpvar(n,1);
49D = diag(x) ;    % Diagonal matrix
50H = hankel(x);   % Hankel matrix
51T = toeplitz(x); % Hankel matrix</pre>
52          </td>
53        </tr>
54      </table>
55                <p>Scalars can be defined in three different ways.</p>
56      <table cellpadding="10" width="100%" id="table1">
57        <tr>
58          <td class="xmpcode">
59          <pre>x = sdpvar(1,1); y = sdpvar(1,1);
60x = sdpvar(1);   y = sdpvar(1);
61sdpvar x y</pre>
62          </td>
63        </tr>
64      </table>
65      <p>The <a href="reference.htm#sdpvar">sdpvar</a> objects are manipulated in
66      MATLAB as any other variable and (almost)<font color="#FF0000"> all standard
67      functions are overloaded</font>. Hence, the following commands are valid</p>
68      <table cellpadding="10" width="100%">
69        <tr>
70          <td class="xmpcode">
71          <pre>P = sdpvar(3,3) + diag(sdpvar(3,1));
72X = [P P;P eye(length(P))] + 2*trace(P);
73Y = X + sum(sum(P*rand(length(P)))) + P(end,end)+hankel(X(:,1));</pre>
74          </td>
75        </tr>
76      </table>
77      <p>To define constraints, the command <a href="reference.htm#set">set</a> 
78      is used (with set meaning set as in convex set, non-convex set, set of integers
79      etc, not as in set/get). The meaning of a constraint is context-dependent.
80      If left-hand side and right-hand side are Hermitian, the constraint is interpreted
81      in terms of positive definiteness, otherwise element-wise. Hence, declaring
82      a symmetric matrix and a positive definiteness constraint is done with</p>
83      <table cellpadding="10" width="100%">
84        <tr>
85          <td class="xmpcode">
86          <pre>n = 3;
87P = sdpvar(n,n);
88F = set(P&gt;0);</pre>
89          </td>
90        </tr>
91      </table>
92      <p>while a symmetric matrix with positive elements is defined with, e.g.,</p>
93      <table cellpadding="10" width="100%">
94        <tr>
95          <td class="xmpcode" >
96          <pre>P = sdpvar(n,n);
97F = set(P(:)&gt;0);</pre>
98          </td>
99        </tr>
100      </table>
101      <p>According to the rules above, a non-square matrix with positive elements
102      can be defined using the &gt; operator immediately</p>
103      <table cellpadding="10" width="100%">
104        <tr>
105          <td class="xmpcode">
106          <pre>P = sdpvar(n,2*n);
107F = set(P&gt;0);</pre>
108          </td>
109        </tr>
110      </table>
111      <p>A list of several constraints is defined by just adding
112      <a href="reference.htm#set">set</a> objects.</p>
113      <table cellpadding="10" width="100%">
114        <tr>
115          <td class="xmpcode">
116          <pre>P = sdpvar(n,n);
117F = set(P&gt;0) + set(P(1,1)&gt;2);</pre>
118          </td>
119        </tr>
120      </table>
121      <p>Of course, the involved expressions can be arbitrary
122      <a href="reference.htm#sdpvar">sdpvar</a> objects, and equality constraints
123      (==) can be defined, as well as constraints using &lt;.</p>
124      <table cellpadding="10" width="100%">
125        <tr>
126          <td class="xmpcode">
127          <pre>F = set(P&gt;0) + set(P(1,1)&lt;2) + set(sum(sum(P))==10);</pre>
128          </td>
129        </tr>
130      </table>
131      <p>In fact, non-strict operators =&lt; and &gt;= may also be used (by default, there
132      is no difference, but by using the option <code>shift</code> in
133      <a href="reference.htm#sdpsettings">sdpsetttings</a>, it is possible to
134                aim for
135      strict feasibility). Note though that no solver can distinguish between
136                strict and non-strict constraints. In fact, most solvers will not even
137                respect a non-strict constraint but often return slightly infeasible
138                solutions.</p>
139      <table cellpadding="10" width="100%">
140        <tr>
141          <td class="xmpcode">
142          <pre>F = set(P&gt;=0) + set(P(1,1)&lt;=2) + set(sum(sum(P))==10);</pre>
143          </td>
144        </tr>
145      </table>
146      <p>Finally, a convenient way to define several constraint is to use double-sided
147      constraints.</p>
148      <table cellpadding="10" width="100%">
149        <tr>
150          <td class="xmpcode">
151          <pre>F = set(0 &lt; P(1,1) &lt; 2);</pre>
152          </td>
153        </tr>
154      </table>
155      </td>
156    </tr>
157  </table>
158</div>
159
160</body>
161
162</html>
Note: See TracBrowser for help on using the repository browser.