File: Nonlinear-Programming.html

package info (click to toggle)
octave3.2 3.2.4-8
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 62,936 kB
  • ctags: 37,353
  • sloc: cpp: 219,497; fortran: 116,336; ansic: 10,264; sh: 5,508; makefile: 4,245; lex: 3,573; yacc: 3,062; objc: 2,042; lisp: 1,692; awk: 860; perl: 844
file content (174 lines) | stat: -rw-r--r-- 7,113 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
<html lang="en">
<head>
<title>Nonlinear Programming - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.11">
<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">
<p>
<a name="Nonlinear-Programming"></a>
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">24.3 Nonlinear Programming</h3>

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

<!-- ./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>x, phi, g, h, lb, ub, maxiter, tolerance</var>)<var><a name="index-sqp-1803"></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 successive quadratic programming method.

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

        <p>The second argument is a function handle pointing to the objective
function.  The objective function must be of the form

     <pre class="example">               y = phi (x)
</pre>
        <p class="noindent">in which <var>x</var> is a vector and <var>y</var> is 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 to compute 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>If supplied, the gradient function must be of the form

     <pre class="example">          g = gradient (x)
</pre>
        <p class="noindent">in which <var>x</var> is a vector and <var>g</var> is a vector.

        <p>If supplied, the hessian function must be of the form

     <pre class="example">          h = hessian (x)
</pre>
        <p class="noindent">in which <var>x</var> is a vector and <var>h</var> is a matrix.

        <p>The third and fourth arguments are function handles pointing to
functions that compute the equality constraints and the inequality
constraints, respectively.

        <p>If your problem does not have equality (or inequality) constraints,
you may pass an empty matrix for <var>cef</var> (or <var>cif</var>).

        <p>If supplied, the equality and inequality constraint functions must be
of the form

     <pre class="example">          r = f (x)
</pre>
        <p class="noindent">in which <var>x</var> is a vector and <var>r</var> is 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 are vectors containing lower and upper bounds
on <var>x</var>.  These must be consistent with equality and inequality
constraints <var>g</var> and <var>h</var>.  If the bounds are not specified, or are
empty, they are set to -<var>realmax</var> and <var>realmax</var> by default.

        <p>The seventh argument is max. number of iterations.  If not specified,
the default value is 100.

        <p>The eighth argument is tolerance for stopping criteria.  If not specified,
the default value is <var>eps</var>.

        <p>Here is 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>
        <p>The value returned in <var>info</var> may be one of the following:
          <dl>
<dt>101<dd>The algorithm terminated because the norm of the last step was less
than <code>tol * norm (x))</code> (the value of tol is currently fixed at
<code>sqrt (eps)</code>&mdash;edit <samp><span class="file">sqp.m</span></samp> to modify this value. 
<br><dt>102<dd>The BFGS update failed. 
<br><dt>103<dd>The maximum number of iterations was reached (the maximum number of
allowed iterations is currently fixed at 100&mdash;edit <samp><span class="file">sqp.m</span></samp> to
increase this value). 
</dl>
        <!-- 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>