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
|
<!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>Nonlinear Programming (GNU Octave (version 10.3.0))</title>
<meta name="description" content="Nonlinear Programming (GNU Octave (version 10.3.0))">
<meta name="keywords" content="Nonlinear 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="Linear-Least-Squares.html" rel="next" title="Linear Least Squares">
<link href="Quadratic-Programming.html" rel="prev" title="Quadratic 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}
-->
</style>
<link rel="stylesheet" type="text/css" href="octave.css">
</head>
<body lang="en">
<div class="section-level-extent" id="Nonlinear-Programming">
<div class="nav-panel">
<p>
Next: <a href="Linear-Least-Squares.html" accesskey="n" rel="next">Linear Least Squares</a>, Previous: <a href="Quadratic-Programming.html" accesskey="p" rel="prev">Quadratic Programming</a>, Up: <a href="Optimization.html" accesskey="u" rel="up">Optimization</a> [<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="Nonlinear-Programming-1"><span>25.3 Nonlinear Programming<a class="copiable-link" href="#Nonlinear-Programming-1"> ¶</a></span></h3>
<p>Octave can also perform general nonlinear minimization using a
successive quadratic programming solver.
</p>
<a class="anchor" id="XREFsqp"></a><span style="display:block; margin-top:-4.5ex;"> </span>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-sqp"><span><code class="def-type">[<var class="var">x</var>, <var class="var">obj</var>, <var class="var">info</var>, <var class="var">iter</var>, <var class="var">nf</var>, <var class="var">lambda</var>] =</code> <strong class="def-name">sqp</strong> <code class="def-code-arguments">(<var class="var">x0</var>, <var class="var">phi</var>)</code><a class="copiable-link" href="#index-sqp"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-sqp-1"><span><code class="def-type">[…] =</code> <strong class="def-name">sqp</strong> <code class="def-code-arguments">(<var class="var">x0</var>, <var class="var">phi</var>, <var class="var">g</var>)</code><a class="copiable-link" href="#index-sqp-1"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-sqp-2"><span><code class="def-type">[…] =</code> <strong class="def-name">sqp</strong> <code class="def-code-arguments">(<var class="var">x0</var>, <var class="var">phi</var>, <var class="var">g</var>, <var class="var">h</var>)</code><a class="copiable-link" href="#index-sqp-2"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-sqp-3"><span><code class="def-type">[…] =</code> <strong class="def-name">sqp</strong> <code class="def-code-arguments">(<var class="var">x0</var>, <var class="var">phi</var>, <var class="var">g</var>, <var class="var">h</var>, <var class="var">lb</var>, <var class="var">ub</var>)</code><a class="copiable-link" href="#index-sqp-3"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-sqp-4"><span><code class="def-type">[…] =</code> <strong class="def-name">sqp</strong> <code class="def-code-arguments">(<var class="var">x0</var>, <var class="var">phi</var>, <var class="var">g</var>, <var class="var">h</var>, <var class="var">lb</var>, <var class="var">ub</var>, <var class="var">maxiter</var>)</code><a class="copiable-link" href="#index-sqp-4"> ¶</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-sqp-5"><span><code class="def-type">[…] =</code> <strong class="def-name">sqp</strong> <code class="def-code-arguments">(<var class="var">x0</var>, <var class="var">phi</var>, <var class="var">g</var>, <var class="var">h</var>, <var class="var">lb</var>, <var class="var">ub</var>, <var class="var">maxiter</var>, <var class="var">tolerance</var>)</code><a class="copiable-link" href="#index-sqp-5"> ¶</a></span></dt>
<dd><p>Minimize an objective function using sequential quadratic programming (SQP).
</p>
<p>Solve the nonlinear program
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">min phi (x)
x
</pre></div></div>
<p>subject to
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">g(x) = 0
h(x) >= 0
lb <= x <= ub
</pre></div></div>
<p>using a sequential quadratic programming method.
</p>
<p>The first argument is the initial guess for the vector <var class="var">x0</var>.
</p>
<p>The second argument is a function handle pointing to the objective function
<var class="var">phi</var>. The objective function must accept one vector argument and
return a scalar.
</p>
<p>The second argument may also be a 2- or 3-element cell array of function
handles. The first element should point to the objective function, the
second should point to a function that computes the gradient of the
objective function, and the third should point to a function that computes
the Hessian of the objective function. If the gradient function is not
supplied, the gradient is computed by finite differences. If the Hessian
function is not supplied, a BFGS update formula is used to approximate the
Hessian.
</p>
<p>When supplied, the gradient function <code class="code"><var class="var">phi</var>{2}</code> must accept one
vector argument and return a vector. When supplied, the Hessian function
<code class="code"><var class="var">phi</var>{3}</code> must accept one vector argument and return a matrix.
</p>
<p>The third and fourth arguments <var class="var">g</var> and <var class="var">h</var> are function handles
pointing to functions that compute the equality constraints and the
inequality constraints, respectively. If the problem does not have
equality (or inequality) constraints, then use an empty matrix ([]) for
<var class="var">g</var> (or <var class="var">h</var>). When supplied, these equality and inequality
constraint functions must accept one vector argument and return a vector.
</p>
<p>The third and fourth arguments may also be 2-element cell arrays of
function handles. The first element should point to the constraint
function and the second should point to a function that computes the
gradient of the constraint function:
</p>
<div class="example">
<div class="group"><pre class="example-preformatted"> [ d f(x) d f(x) d f(x) ]
transpose ( [ ------ ----- ... ------ ] )
[ dx_1 dx_2 dx_N ]
</pre></div></div>
<p>The fifth and sixth arguments, <var class="var">lb</var> and <var class="var">ub</var>, contain lower and
upper bounds on <var class="var">x</var> and when provided must be vectors of the same size
as the vector <var class="var">x0</var>. The bounds must be consistent with the
equality and inequality constraints <var class="var">g</var> and <var class="var">h</var>.
</p>
<p>The seventh argument <var class="var">maxiter</var> specifies the maximum number of
iterations. The default value is 100.
</p>
<p>The eighth argument <var class="var">tolerance</var> specifies the tolerance for the stopping
criteria. The default value is <code class="code">sqrt (eps)</code>.
</p>
<p>The value returned in <var class="var">info</var> may be one of the following:
</p>
<dl class="table">
<dt>101</dt>
<dd><p>The algorithm terminated normally.
All constraints meet the specified tolerance.
</p>
</dd>
<dt>102</dt>
<dd><p>The BFGS update failed.
</p>
</dd>
<dt>103</dt>
<dd><p>The maximum number of iterations was reached.
</p>
</dd>
<dt>104</dt>
<dd><p>The stepsize has become too small, i.e.,
delta <var class="var">x</var>,
is less than <code class="code"><var class="var">tol</var> * norm (x)</code>.
</p></dd>
</dl>
<p>An example of calling <code class="code">sqp</code>:
</p>
<div class="example">
<pre class="example-preformatted">function r = g (x)
r = [ sumsq(x)-10;
x(2)*x(3)-5*x(4)*x(5);
x(1)^3+x(2)^3+1 ];
endfunction
function obj = phi (x)
obj = exp (prod (x)) - 0.5*(x(1)^3+x(2)^3+1)^2;
endfunction
x0 = [-1.8; 1.7; 1.9; -0.8; -0.8];
[x, obj, info, iter, nf, lambda] = sqp (x0, @phi, @g, [])
x =
-1.71714
1.59571
1.82725
-0.76364
-0.76364
obj = 0.053950
info = 101
iter = 8
nf = 10
lambda =
-0.0401627
0.0379578
-0.0052227
</pre></div>
<p><strong class="strong">See also:</strong> <a class="ref" href="Quadratic-Programming.html#XREFqp">qp</a>.
</p></dd></dl>
</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Linear-Least-Squares.html">Linear Least Squares</a>, Previous: <a href="Quadratic-Programming.html">Quadratic Programming</a>, Up: <a href="Optimization.html">Optimization</a> [<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>
|