File: Quadratic-Programming.html

package info (click to toggle)
octave 10.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 145,388 kB
  • sloc: cpp: 335,976; ansic: 82,241; fortran: 20,963; objc: 9,402; sh: 8,756; yacc: 4,392; lex: 4,333; perl: 1,544; java: 1,366; awk: 1,259; makefile: 660; xml: 192
file content (229 lines) | stat: -rw-r--r-- 13,941 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Quadratic Programming (GNU Octave (version 10.3.0))</title>

<meta name="description" content="Quadratic Programming (GNU Octave (version 10.3.0))">
<meta name="keywords" content="Quadratic Programming (GNU Octave (version 10.3.0))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Concept-Index.html" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Optimization.html" rel="up" title="Optimization">
<link href="Nonlinear-Programming.html" rel="next" title="Nonlinear Programming">
<link href="Linear-Programming.html" rel="prev" title="Linear Programming">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
span:hover a.copiable-link {visibility: visible}
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
ul.mark-bullet {list-style-type: disc}
-->
</style>
<link rel="stylesheet" type="text/css" href="octave.css">


</head>

<body lang="en">
<div class="section-level-extent" id="Quadratic-Programming">
<div class="nav-panel">
<p>
Next: <a href="Nonlinear-Programming.html" accesskey="n" rel="next">Nonlinear Programming</a>, Previous: <a href="Linear-Programming.html" accesskey="p" rel="prev">Linear Programming</a>, Up: <a href="Optimization.html" accesskey="u" rel="up">Optimization</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="Quadratic-Programming-1"><span>25.2 Quadratic Programming<a class="copiable-link" href="#Quadratic-Programming-1"> &para;</a></span></h3>

<p>Octave can also solve Quadratic Programming problems, this is
</p>
<div class="example">
<pre class="example-preformatted">min 0.5 x'*H*x + x'*q
</pre></div>

<p>subject to
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">     A*x = b
     lb &lt;= x &lt;= ub
     A_lb &lt;= A_in*x &lt;= A_ub
</pre></div></div>


<a class="anchor" id="XREFqp"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-qp"><span><code class="def-type">[<var class="var">x</var>, <var class="var">obj</var>, <var class="var">info</var>, <var class="var">lambda</var>] =</code> <strong class="def-name">qp</strong> <code class="def-code-arguments">(<var class="var">x0</var>, <var class="var">H</var>)</code><a class="copiable-link" href="#index-qp"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-qp-1"><span><code class="def-type">[<var class="var">x</var>, <var class="var">obj</var>, <var class="var">info</var>, <var class="var">lambda</var>] =</code> <strong class="def-name">qp</strong> <code class="def-code-arguments">(<var class="var">x0</var>, <var class="var">H</var>, <var class="var">q</var>)</code><a class="copiable-link" href="#index-qp-1"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-qp-2"><span><code class="def-type">[<var class="var">x</var>, <var class="var">obj</var>, <var class="var">info</var>, <var class="var">lambda</var>] =</code> <strong class="def-name">qp</strong> <code class="def-code-arguments">(<var class="var">x0</var>, <var class="var">H</var>, <var class="var">q</var>, <var class="var">A</var>, <var class="var">b</var>)</code><a class="copiable-link" href="#index-qp-2"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-qp-3"><span><code class="def-type">[<var class="var">x</var>, <var class="var">obj</var>, <var class="var">info</var>, <var class="var">lambda</var>] =</code> <strong class="def-name">qp</strong> <code class="def-code-arguments">(<var class="var">x0</var>, <var class="var">H</var>, <var class="var">q</var>, <var class="var">A</var>, <var class="var">b</var>, <var class="var">lb</var>, <var class="var">ub</var>)</code><a class="copiable-link" href="#index-qp-3"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-qp-4"><span><code class="def-type">[<var class="var">x</var>, <var class="var">obj</var>, <var class="var">info</var>, <var class="var">lambda</var>] =</code> <strong class="def-name">qp</strong> <code class="def-code-arguments">(<var class="var">x0</var>, <var class="var">H</var>, <var class="var">q</var>, <var class="var">A</var>, <var class="var">b</var>, <var class="var">lb</var>, <var class="var">ub</var>, <var class="var">A_lb</var>, <var class="var">A_in</var>, <var class="var">A_ub</var>)</code><a class="copiable-link" href="#index-qp-4"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-qp-5"><span><code class="def-type">[<var class="var">x</var>, <var class="var">obj</var>, <var class="var">info</var>, <var class="var">lambda</var>] =</code> <strong class="def-name">qp</strong> <code class="def-code-arguments">(&hellip;, <var class="var">options</var>)</code><a class="copiable-link" href="#index-qp-5"> &para;</a></span></dt>
<dd><p>Solve a quadratic program (QP).
</p>
<p>Solve the quadratic program defined by
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">min 0.5 x'*H*x + x'*q
 x
</pre></div></div>

<p>subject to
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">A*x = b
lb &lt;= x &lt;= ub
A_lb &lt;= A_in*x &lt;= A_ub
</pre></div></div>

<p>using a null-space active-set method.
</p>
<p>Any bound (<var class="var">A</var>, <var class="var">b</var>, <var class="var">lb</var>, <var class="var">ub</var>, <var class="var">A_in</var>, <var class="var">A_lb</var>,
<var class="var">A_ub</var>) may be set to the empty matrix (<code class="code">[]</code>) if not present.  The
constraints <var class="var">A</var> and <var class="var">A_in</var> are matrices with each row representing
a single constraint.  The other bounds are scalars or vectors depending on
the number of constraints.  The algorithm is faster if the initial guess is
feasible.
</p>
<p><var class="var">options</var> is a structure specifying additional parameters which
control the algorithm.  Currently, <code class="code">qp</code> recognizes these options:
<code class="code">&quot;MaxIter&quot;</code>, <code class="code">&quot;TolX&quot;</code>.
</p>
<p><code class="code">&quot;MaxIter&quot;</code> proscribes the maximum number of algorithm iterations
before optimization is halted.  The default value is 200.
The value must be a positive integer.
</p>
<p><code class="code">&quot;TolX&quot;</code> specifies the termination tolerance for the unknown variables
<var class="var">x</var>.  The default is <code class="code">sqrt (eps)</code> or approximately 1e-8.
</p>
<p>On return, <var class="var">x</var> is the location of the minimum and <var class="var">fval</var> contains
the value of the objective function at <var class="var">x</var>.
</p>
<dl class="table">
<dt><var class="var">info</var></dt>
<dd><p>Structure containing run-time information about the algorithm.  The
following fields are defined:
</p>
<dl class="table">
<dt><code class="code">solveiter</code></dt>
<dd><p>The number of iterations required to find the solution.
</p>
</dd>
<dt><code class="code">info</code></dt>
<dd><p>An integer indicating the status of the solution.
</p>
<dl class="table">
<dt>0</dt>
<dd><p>The problem is feasible and convex.  Global solution found.
</p>
</dd>
<dt>1</dt>
<dd><p>The problem is not convex.  Local solution found.
</p>
</dd>
<dt>2</dt>
<dd><p>The problem is not convex and unbounded.
</p>
</dd>
<dt>3</dt>
<dd><p>Maximum number of iterations reached.
</p>
</dd>
<dt>6</dt>
<dd><p>The problem is infeasible.
</p></dd>
</dl>
</dd>
</dl>
</dd>
</dl>

<p><strong class="strong">See also:</strong> <a class="ref" href="Nonlinear-Programming.html#XREFsqp">sqp</a>.
</p></dd></dl>


<a class="anchor" id="XREFpqpnonneg"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-pqpnonneg"><span><code class="def-type"><var class="var">x</var> =</code> <strong class="def-name">pqpnonneg</strong> <code class="def-code-arguments">(<var class="var">c</var>, <var class="var">d</var>)</code><a class="copiable-link" href="#index-pqpnonneg"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-pqpnonneg-1"><span><code class="def-type"><var class="var">x</var> =</code> <strong class="def-name">pqpnonneg</strong> <code class="def-code-arguments">(<var class="var">c</var>, <var class="var">d</var>, <var class="var">x0</var>)</code><a class="copiable-link" href="#index-pqpnonneg-1"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-pqpnonneg-2"><span><code class="def-type"><var class="var">x</var> =</code> <strong class="def-name">pqpnonneg</strong> <code class="def-code-arguments">(<var class="var">c</var>, <var class="var">d</var>, <var class="var">x0</var>, <var class="var">options</var>)</code><a class="copiable-link" href="#index-pqpnonneg-2"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-pqpnonneg-3"><span><code class="def-type">[<var class="var">x</var>, <var class="var">minval</var>] =</code> <strong class="def-name">pqpnonneg</strong> <code class="def-code-arguments">(&hellip;)</code><a class="copiable-link" href="#index-pqpnonneg-3"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-pqpnonneg-4"><span><code class="def-type">[<var class="var">x</var>, <var class="var">minval</var>, <var class="var">exitflag</var>] =</code> <strong class="def-name">pqpnonneg</strong> <code class="def-code-arguments">(&hellip;)</code><a class="copiable-link" href="#index-pqpnonneg-4"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-pqpnonneg-5"><span><code class="def-type">[<var class="var">x</var>, <var class="var">minval</var>, <var class="var">exitflag</var>, <var class="var">output</var>] =</code> <strong class="def-name">pqpnonneg</strong> <code class="def-code-arguments">(&hellip;)</code><a class="copiable-link" href="#index-pqpnonneg-5"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-pqpnonneg-6"><span><code class="def-type">[<var class="var">x</var>, <var class="var">minval</var>, <var class="var">exitflag</var>, <var class="var">output</var>, <var class="var">lambda</var>] =</code> <strong class="def-name">pqpnonneg</strong> <code class="def-code-arguments">(&hellip;)</code><a class="copiable-link" href="#index-pqpnonneg-6"> &para;</a></span></dt>
<dd>
<p>Minimize <code class="code"> (1/2 * <var class="var">x</var>' * <var class="var">c</var> * <var class="var">x</var> + <var class="var">d</var>' * <var class="var">x</var>) </code>
subject to <code class="code"><var class="var">x</var> &gt;= 0</code>.
</p>
<p><var class="var">c</var> and <var class="var">d</var> must be real matrices, and <var class="var">c</var> must be symmetric and
positive definite.
</p>
<p><var class="var">x0</var> is an optional initial guess for the solution <var class="var">x</var>.
</p>
<p><var class="var">options</var> is an options structure to change the behavior of the
algorithm (see <a class="pxref" href="Linear-Least-Squares.html#XREFoptimset"><code class="code">optimset</code></a>).  <code class="code">pqpnonneg</code>
recognizes one option: <code class="code">&quot;MaxIter&quot;</code>.
</p>
<p>Outputs:
</p>
<dl class="table">
<dt><var class="var">x</var></dt>
<dd><p>The solution matrix
</p>
</dd>
<dt><var class="var">minval</var></dt>
<dd><p>The minimum attained model value,
<code class="code">1/2*<var class="var">xmin</var>'*<var class="var">c</var>*<var class="var">xmin</var> + <var class="var">d</var>'*<var class="var">xmin</var></code>
</p>
</dd>
<dt><var class="var">exitflag</var></dt>
<dd><p>An indicator of convergence.  0 indicates that the iteration count was
exceeded, and therefore convergence was not reached; &gt;0 indicates that the
algorithm converged.  (The algorithm is stable and will converge given
enough iterations.)
</p>
</dd>
<dt><var class="var">output</var></dt>
<dd><p>A structure with two fields:
</p>
<ul class="itemize mark-bullet">
<li><code class="code">&quot;algorithm&quot;</code>: The algorithm used (<code class="code">&quot;nnls&quot;</code>)

</li><li><code class="code">&quot;iterations&quot;</code>: The number of iterations taken.
</li></ul>

</dd>
<dt><var class="var">lambda</var></dt>
<dd><p>Lagrange multipliers.  If these are nonzero, the corresponding <var class="var">x</var>
values should be zero, indicating the solution is pressed up against a
coordinate plane.  The magnitude indicates how much the residual would
improve if the <code class="code"><var class="var">x</var> &gt;= 0</code> constraints were relaxed in that
direction.
</p>
</dd>
</dl>

<p><strong class="strong">See also:</strong> <a class="ref" href="Linear-Least-Squares.html#XREFlsqnonneg">lsqnonneg</a>, <a class="ref" href="#XREFqp">qp</a>, <a class="ref" href="Linear-Least-Squares.html#XREFoptimset">optimset</a>.
</p></dd></dl>


</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Nonlinear-Programming.html">Nonlinear Programming</a>, Previous: <a href="Linear-Programming.html">Linear Programming</a>, Up: <a href="Optimization.html">Optimization</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>