Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > b38d2da330d1936e5ab1307c039c4941 > files > 367

octave-doc-3.6.4-3.mga4.noarch.rpm

<html lang="en">
<head>
<title>Nonlinear Programming - GNU Octave</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="GNU Octave">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Optimization.html#Optimization" title="Optimization">
<link rel="prev" href="Quadratic-Programming.html#Quadratic-Programming" title="Quadratic Programming">
<link rel="next" href="Linear-Least-Squares.html#Linear-Least-Squares" title="Linear Least Squares">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="Nonlinear-Programming"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Linear-Least-Squares.html#Linear-Least-Squares">Linear Least Squares</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Quadratic-Programming.html#Quadratic-Programming">Quadratic Programming</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Optimization.html#Optimization">Optimization</a>
<hr>
</div>

<h3 class="section">25.3 Nonlinear Programming</h3>

<p>Octave can also perform general nonlinear minimization using a
successive quadratic programming solver.

<!-- sqp scripts/optimization/sqp.m -->
   <p><a name="doc_002dsqp"></a>

<div class="defun">
&mdash; Function File: [<var>x</var>, <var>obj</var>, <var>info</var>, <var>iter</var>, <var>nf</var>, <var>lambda</var>] = <b>sqp</b> (<var>x0, phi</var>)<var><a name="index-sqp-2386"></a></var><br>
&mdash; Function File: [<small class="dots">...</small>] = <b>sqp</b> (<var>x0, phi, g</var>)<var><a name="index-sqp-2387"></a></var><br>
&mdash; Function File: [<small class="dots">...</small>] = <b>sqp</b> (<var>x0, phi, g, h</var>)<var><a name="index-sqp-2388"></a></var><br>
&mdash; Function File: [<small class="dots">...</small>] = <b>sqp</b> (<var>x0, phi, g, h, lb, ub</var>)<var><a name="index-sqp-2389"></a></var><br>
&mdash; Function File: [<small class="dots">...</small>] = <b>sqp</b> (<var>x0, phi, g, h, lb, ub, maxiter</var>)<var><a name="index-sqp-2390"></a></var><br>
&mdash; Function File: [<small class="dots">...</small>] = <b>sqp</b> (<var>x0, phi, g, h, lb, ub, maxiter, tol</var>)<var><a name="index-sqp-2391"></a></var><br>
<blockquote><p>Solve the nonlinear program

     <pre class="example">          min phi (x)
           x
</pre>
        <p>subject to

     <pre class="example">          g(x)  = 0
          h(x) &gt;= 0
          lb &lt;= x &lt;= ub
</pre>
        <p class="noindent">using a sequential quadratic programming method.

        <p>The first argument is the initial guess for the vector <var>x0</var>.

        <p>The second argument is a function handle pointing to the objective
function <var>phi</var>.  The objective function must accept one vector
argument and return a scalar.

        <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>When supplied, the gradient function <var>phi</var><code>{2}</code> must accept
one vector argument and return a vector.  When supplied, the Hessian
function <var>phi</var><code>{3}</code> must accept one vector argument and
return a matrix.

        <p>The third and fourth arguments <var>g</var> and <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>g</var> (or <var>h</var>).  When supplied, these equality
and inequality constraint functions must accept one vector argument
and return a vector.

        <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:

     <pre class="example">                      [ d f(x)   d f(x)        d f(x) ]
          transpose ( [ ------   -----   ...   ------ ] )
                      [  dx_1     dx_2          dx_N  ]
</pre>
        <p>The fifth and sixth arguments, <var>lb</var> and <var>ub</var>, contain lower
and upper bounds on <var>x</var>.  These must be consistent with the
equality and inequality constraints <var>g</var> and <var>h</var>.  If the
arguments are vectors then <var>x</var>(i) is bound by <var>lb</var>(i) and
<var>ub</var>(i).  A bound can also be a scalar in which case all elements
of <var>x</var> will share the same bound.  If only one bound (lb, ub) is
specified then the other will default to (-<var>realmax</var>,
+<var>realmax</var>).

        <p>The seventh argument <var>maxiter</var> specifies the maximum number of
iterations.  The default value is 100.

        <p>The eighth argument <var>tol</var> specifies the tolerance for the
stopping criteria.  The default value is <code>sqrt(eps)</code>.

        <p>The value returned in <var>info</var> may be one of the following:

          <dl>
<dt>101<dd>The algorithm terminated normally. 
Either all constraints meet the requested tolerance, or the stepsize,
delta <var>x</var>,
is less than <var>tol</var><code> * norm (x)</code>.

          <br><dt>102<dd>The BFGS update failed.

          <br><dt>103<dd>The maximum number of iterations was reached. 
</dl>

        <p>An example of calling <code>sqp</code>:

     <pre class="example">          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>
        <!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
     <!-- A simple blank line produces the correct behavior. -->
     <!-- @sp 1 -->
     <p class="noindent"><strong>See also:</strong> <a href="doc_002dqp.html#doc_002dqp">qp</a>. 
</p></blockquote></div>

   </body></html>