forked from johannesgerer/jburkardt-m
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nelder_mead.html
449 lines (401 loc) · 12.8 KB
/
nelder_mead.html
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
<html>
<head>
<title>
NELDER_MEAD - The Nelder-Mead Optimization Algorithm
</title>
</head>
<body bgcolor="#EEEEEE" link="#CC0000" alink="#FF3300" vlink="#000055">
<h1 align = "center">
NELDER_MEAD <br> The Nelder-Mead Optimization Algorithm
</h1>
<hr>
<p>
<b>NELDER_MEAD</b>
is a MATLAB program which
seeks the minimizer of a scalar function of several variables,
by Jeff Borggaard.
</p>
<p>
The algorithm is easy to visualize. The user supplies an initial set
of points that represent solution estimates. The number of points supplied
is one greater than the spatial dimension, so they form a "simplex" -
in 2D, this is simply a triangle. The algorithm then evaluates the function
at each point on the simplex, and then considers various ways of seeking
a better estimate, including replacing one vertex of the simplex by its
reflected image, or by shrinking or expanding the simplex. An animation
of the procedure looks almost like a little triangular creature trying
to blindly feel its way downhill.
</p>
<p>
Although the user specifies an initial simplex of starting values,
the algorithm is not constrained to search only within that simplex.
This means that the user cannot force the algorithm to search
only within a restricted region.
</p>
<h3 align = "center">
Usage:
</h3>
<p>
<blockquote>
<i>x_opt</i> = nelder_mead ( <i>simplex</i>, <i>f</i>, <i>flag</i> )
</blockquote>
where
<ul>
<li>
<i>simplex</i> is a matrix which contains a list of distinct points that serve as initial
guesses for the solution. If the dimension of the space is <b>M</b>,
then the matrix must contain exactly <b>M+1</b> points. For instance,
for a 2D space, you supply 3 points. Each row of the matrix contains
one point; for a 2D space, this means that <i>simplex</i> would be a
3x2 matrix.
</li>
<li>
<i>f</i> is the "function handle"; that is, either a quoted expression for the function,
or the name of an M-file that defines the function, preceded by an "@" sign;
</li>
<li>
<i>flag</i> is an optional argument; if present, and set to 1, it will cause the program
to display a graphical image of the contours and solution procedure.
Note that this option only makes sense for problems in 2D, that is,
with N=2.
</li>
<li>
<i>x_opt</i> is the program's estimate for the minimizer of the
function;
</li>
</ul>
</p>
<p>
Very simple functions can be input as a quoted string. Thus, one could
specify the <i>f</i> argument as '(x(1)-2*x(2)+7)^2'; However, for more
complicated functions it makes sense to prepare an M-file that defines the
function. For this same example, a suitable M-file would be:
<pre><code>
function f = example ( x )
f = ( x(1) - 2 * x(2) + 7 )^2;
</code></pre>
</p>
<p>
If this information was stored in an M-file called <i>example.m</i>, then
one might invoke the optimization program with a command like
<pre><code>
x_opt = nelder_mead ( x_init, @example, 0 )
</code></pre>
</p>
<p>
MATLAB's built in command
<a href = "http://www.mathworks.com/help/techdoc/ref/fminsearch.html">
fminsearch</a>
minimizes a scalar function of several variables using the
Nelder-Mead algorithm.
</p>
<h3 align = "center">
Licensing:
</h3>
<p>
The computer code and data files described and made available on this web page
are distributed under
<a href = "../../txt/gnu_lgpl.txt">the GNU LGPL license.</a>
</p>
<h3 align = "center">
Languages:
</h3>
<p>
<b>NELDER_MEAD</b> is available in
<a href = "../../m_src/nelder_mead/nelder_mead.html">a MATLAB version</a>.
</p>
<h3 align = "center">
Related Data and Programs:
</h3>
<p>
<a href = "../../m_src/asa047/asa047.html">
ASA047</a>,
a MATLAB library which
minimizes a scalar function of several variables using the Nelder-Mead algorithm.
</p>
<p>
<a href = "../../m_src/compass_search/compass_search.html">
COMPASS_SEARCH</a>,
a MATLAB library which
seeks the minimizer of a scalar function of several variables
using compass search, a direct search algorithm that does not use derivatives.
</p>
<p>
<a href = "../../m_src/entrust/entrust.html">
ENTRUST</a>,
a MATLAB program which
minimizes a scalar function of several variables using trust-region methods.
</p>
<p>
<a href = "../../f_src/praxis/praxis.html">
PRAXIS</a>,
a FORTRAN90 library which
implements the principal axis method of Richard Brent for minimization of
a function without the use of derivatives.
</p>
<p>
<a href = "../../m_src/test_opt/test_opt.html">
TEST_OPT</a>,
a MATLAB library which
defines test problems
requiring the minimization of a scalar function of several variables.
</p>
<p>
<a href = "../../m_src/toms178/toms178.html">
TOMS178</a>,
a MATLAB library which
optimizes a scalar functional of multiple variables using the Hooke-Jeeves method.
</p>
<h3 align = "center">
Author:
</h3>
<p>
Jeff Borggaard, Mathematics Department, Virginia Tech.
</p>
<h3 align = "center">
Reference:
</h3>
<p>
<ol>
<li>
Evelyn Beale,<br>
On an Iterative Method for Finding a Local Minimum of a Function
of More than One Variable,<br>
Technical Report 25, <br>
Statistical Techniques Research Group,<br>
Princeton University, 1958.
</li>
<li>
Richard Brent,<br>
Algorithms for Minimization without Derivatives,<br>
Dover, 2002,<br>
ISBN: 0-486-41998-3,<br>
LC: QA402.5.B74.
</li>
<li>
David Himmelblau,<br>
Applied Nonlinear Programming,<br>
McGraw Hill, 1972,<br>
ISBN13: 978-0070289215,<br>
LC: T57.8.H55.
</li>
<li>
Jeffrey Lagarias, James Reeds, Margaret Wright, Paul Wright,<br>
Convergence properties of the Nelder-Mead simplex method in low dimensions,</br>
SIAM Journal on Optimization,<br>
Volume 9, Number 1, 1998, pages 112-147.
</li>
<li>
Ken McKinnon,<br>
Convergence of the Nelder-Mead simplex method to a nonstationary point,<br>
SIAM Journal on Optimization,<br>
Volume 9, Number 1, 1998, pages 148-158.
</li>
<li>
Zbigniew Michalewicz,<br>
Genetic Algorithms + Data Structures = Evolution Programs,<br>
Third Edition,<br>
Springer, 1996,<br>
ISBN: 3-540-60676-9,<br>
LC: QA76.618.M53.
</li>
<li>
John Nelder, Roger Mead,<br>
A simplex method for function minimization,<br>
Computer Journal,<br>
Volume 7, Number 4, January 1965, pages 308-313.
</li>
<li>
Michael Powell,<br>
An Iterative Method for Finding Stationary Values of a Function
of Several Variables,<br>
Computer Journal,<br>
Volume 5, 1962, pages 147-151.
</li>
<li>
William Press, Brian Flannery, Saul Teukolsky, William Vetterling,<br>
Numerical Recipes in FORTRAN: The Art of Scientific Computing,<br>
Second Edition,<br>
Cambridge University Press, 1992,<br>
ISBN: 0-521-43064-X,<br>
LC: QA297.N866.
</li>
<li>
Howard Rosenbrock,<br>
An Automatic Method for Finding the Greatest or Least Value of a Function,<br>
Computer Journal,<br>
Volume 3, 1960, pages 175-184.
</li>
</ol>
</p>
<h3 align = "center">
Source Code:
</h3>
<p>
<ul>
<li>
<a href = "nelder_mead.m">nelder_mead.m</a>,
the Nelder-Mead optimization algorithm.
</li>
</ul>
</p>
<h3 align = "center">
Examples and Tests:
</h3>
<p>
<ul>
<li>
<a href = "nelder_mead_test.m">nelder_mead_test.m</a>,
calls all the tests.
</li>
<li>
<a href = "nelder_mead_test_output.txt">nelder_mead_test_output.txt</a>,
the output file.
</li>
<li>
<a href = "nelder_mead_test01.m">nelder_mead_test01.m</a>,
uses the Himmelblau function.
</li>
<li>
<a href = "nelder_mead_test02.m">nelder_mead_test02.m</a>,
uses the Himmelblau function.
</li>
<li>
<a href = "nelder_mead_test03.m">nelder_mead_test03.m</a>,
uses the extended Rosenbrock function.
</li>
<li>
<a href = "nelder_mead_test04.m">nelder_mead_test04.m</a>,
uses the Goldstein-Price function.
</li>
<li>
<a href = "nelder_mead_test05.m">nelder_mead_test05.m</a>,
uses the Beale function.
</li>
<li>
<a href = "nelder_mead_test06.m">nelder_mead_test06.m</a>,
uses the Powell function.
</li>
<li>
<a href = "nelder_mead_test07.m">nelder_mead_test07.m</a>,
uses the Local function.
</li>
<li>
<a href = "nelder_mead_test08.m">nelder_mead_test08.m</a>,
uses the McKinnon function.
</li>
</ul>
</p>
<p>
<b>BEALE</b> is the Beale function, for which N = 2.
<ul>
<li>
<a href = "beale.m">beale.m</a>,
defines the Beale function.
</li>
</ul>
</p>
<p>
<b>BOHACH1</b> is the Bohachevsky function #1, for which N=2.
<ul>
<li>
<a href = "bohach1.m">bohach1.m</a>,
defines the Bohachevsky function #1.
</li>
</ul>
</p>
<p>
<b>BOHACH2</b> is the Bohachevsky function #2, for which N=2.
<ul>
<li>
<a href = "bohach2.m">bohach2.m</a>,
defines the Bohachevsky function #2.
</li>
</ul>
</p>
<p>
<b>EXTENDED_ROSENBROCK</b> is the "extended" Rosenbrock function. This version
of the Rosenbrock function allows the spatial dimension to be arbitrary, except
that it must be even.
<ul>
<li>
<a href = "extended_rosenbrock.m">extended_rosenbrock.m</a>,
defines the extended Rosenbrock function.
</li>
</ul>
</p>
<p>
<b>GOLDSTEIN_PRICE</b> is the Goldstein-Price polynomial, for which N=2.
<ul>
<li>
<a href = "goldstein_price.m">goldstein_price.m</a>,
defines the Goldstein-Price polynomial.
</li>
</ul>
</p>
<p>
<b>HIMMELBLAU</b> is the Himmelblau function:
<blockquote><code>
f(x) = (x(1)^2 + x(2) - 11)^2 + (x(1) + x(2)^2 - 7)^2
</code></blockquote>
which has four global minima.
<ul>
<li>
<a href = "himmelblau.m">himmelblau.m</a>,
defines the Himmelblau function.
</li>
</ul>
</p>
<p>
<b>LOCAL</b> is a badly scaled function with a local minimum, for which N=2.
<ul>
<li>
<a href = "local.m">local.m</a>,
defines the "local" function.
</li>
</ul>
</p>
<p>
<b>MCKINNON</b> is the McKinnon function, for which N=2.
This function can cause problems for the Nelder-Mead optimization algorithm.
<ul>
<li>
<a href = "mckinnon.m">mckinnon.m</a>,
defines the McKinnon function.
</li>
</ul>
</p>
<p>
<b>POWELL</b> is the Powell singular quartic function, for which N = 4.
<ul>
<li>
<a href = "powell.m">powell.m</a>,
defines the Powell function.
</li>
</ul>
</p>
<p>
<b>ROSENBROCK</b> is the Rosenbrock "banana" function. The contour lines
form a nested set of "banana", which can make convergence very slow:
<blockquote><code>
f(x) = ( 1 - x(1) )^2 + 100 * ( x(2) - x(1) * x(1) )^2
</code></blockquote>
<ul>
<li>
<a href = "rosenbrock.m">rosenbrock.m</a>,
defines the Rosenbrock function.
</li>
</ul>
</p>
<p>
You can go up one level to <a href = "../m_src.html">
the MATLAB source codes</a>.
</p>
<hr>
<i>
Last revised on 06 September 2010.
</i>
<!-- John Burkardt -->
</body>
<!-- Initial HTML skeleton created by HTMLINDEX. -->
</html>