File: cg_005fmin.html

package info (click to toggle)
octave-optim 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,064 kB
  • ctags: 374
  • sloc: cpp: 1,126; perl: 158; makefile: 79
file content (124 lines) | stat: -rw-r--r-- 5,363 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
<html lang="en">
<head>
<title>cg_min - optim_doc</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="optim_doc">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Scalar-optimization.html#Scalar-optimization" title="Scalar optimization">
<link rel="prev" href="nrm.html#nrm" title="nrm">
<link rel="next" href="brent_005fline_005fmin.html#brent_005fline_005fmin" title="brent_line_min">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Additional documentation for the optim package for Octave.

Copyright (C) <Olaf Till <i7tiol@t-online.de>>

You can redistribute this documentation and/or modify it under the terms
of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any
later version.

This documentation is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.

You should have received a copy of the GNU General Public License along
with this documentation; if not, see <http://www.gnu.org/licenses/>.-->
<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="cg_min"></a>
<a name="cg_005fmin"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="brent_005fline_005fmin.html#brent_005fline_005fmin">brent_line_min</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="nrm.html#nrm">nrm</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Scalar-optimization.html#Scalar-optimization">Scalar optimization</a>
<hr>
</div>

<h3 class="section">1.15 A conjugate gradient method</h3>

<p><a name="index-cg_005fmin-21"></a>
<!-- cg_min ../inst/cg_min.m -->
<a name="XREFcg_005fmin"></a>

<div class="defun">
&mdash; Function File: [<var>x0</var>,<var>v</var>,<var>nev</var>] <b>cg_min</b> (<var> f,df,args,ctl </var>)<var><a name="index-cg_005fmin-22"></a></var><br>
<blockquote><p>NonLinear Conjugate Gradient method to minimize function <var>f</var>.

<h4 class="subheading">Arguments</h4>

          <ul>
<li><var>f</var>   : string   : Name of function. Return a real value
<li><var>df</var>  : string   : Name of f's derivative. Returns a (R*C) x 1 vector
<li><var>args</var>: cell     : Arguments passed to f.<br>
<li><var>ctl</var>   : 5-vec    : (Optional) Control variables, described below
</ul>

<h4 class="subheading">Returned values</h4>

          <ul>
<li><var>x0</var>    : matrix   : Local minimum of f
<li><var>v</var>     : real     : Value of f in x0
<li><var>nev</var>   : 1 x 2    : Number of evaluations of f and of df
</ul>

<h4 class="subheading">Control Variables</h4>

          <ul>
<li><var>ctl</var>(1)       : 1 or 2 : Select stopping criterion amongst :
<li><var>ctl</var>(1)==0    : Default value
<li><var>ctl</var>(1)==1    : Stopping criterion : Stop search when value doesn't
improve, as tested by  ctl(2) &gt; Deltaf/max(|f(x)|,1) 
where Deltaf is the decrease in f observed in the last iteration
(each iteration consists R*C line searches). 
<li><var>ctl</var>(1)==2    : Stopping criterion : Stop search when updates are small,
as tested by  ctl(2) &gt; max { dx(i)/max(|x(i)|,1) | i in 1..N }
where  dx is the change in the x that occured in the last iteration. 
<li><var>ctl</var>(2)       : Threshold used in stopping tests.           Default=10*eps
<li><var>ctl</var>(2)==0    : Default value
<li><var>ctl</var>(3)       : Position of the minimized argument in args  Default=1
<li><var>ctl</var>(3)==0    : Default value
<li><var>ctl</var>(4)       : Maximum number of function evaluations      Default=inf
<li><var>ctl</var>(4)==0    : Default value
<li><var>ctl</var>(5)       : Type of optimization:
<li><var>ctl</var>(5)==1    : "Fletcher-Reves" method
<li><var>ctl</var>(5)==2    : "Polak-Ribiere" (Default)
<li><var>ctl</var>(5)==3    : "Hestenes-Stiefel" method
</ul>

        <p><var>ctl</var> may have length smaller than 4. Default values will be used if ctl is
not passed or if nan values are given.

<h4 class="subheading">Example:</h4>

     <p>function r=df( l )  b=[1;0;-1]; r = -( 2*l{1} - 2*b + rand(size(l{1}))); endfunction <br>
function r=ff( l )  b=[1;0;-1]; r = (l{1}-b)' * (l{1}-b); endfunction <br>
ll = { [10; 2; 3] }; <br>
ctl(5) = 3; <br>
[x0,v,nev]=cg_min( "ff", "df", ll, ctl ) <br>

        <p>Comment:  In general, BFGS method seems to be better performin in many cases but requires more computation per iteration
See also http://en.wikipedia.org/wiki/Nonlinear_conjugate_gradient.

     <p class="noindent"><strong>See also:</strong> <a href="XREFbfgsmin.html#XREFbfgsmin">bfgsmin</a>.

        </blockquote></div>

<!--  -->
   </body></html>