summaryrefslogtreecommitdiffstats
path: root/scilab_doc/neldermead/overview.tex
blob: 7aba21073fdbb7be92d2e894e6b31fd118faa351 (plain)
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
\chapter{Overview}

In this section, we present the main commands of the Nelder-Mead
toolbox as well as an example of use.


\section{How to use the Toolbox}

The design of the toolbox is based on the creation of 
a new token by the \scimacro{neldermead\_new} command.
The Nelder-Mead object associated with this token can then 
be configured with \scimacro{neldermead\_configure} and queried 
with \scimacro{neldermead\_cget}. To be more specific, the
\scimacro{neldermead\_configure} command allows to configure the 
number of variables, the objective function and the initial guess.

The main command of the toolbox is the \scimacro{neldermead\_search} command, which
solves the optimization problem. After an optimization has been performed,
the \scimacro{neldermead\_get} command allows to retrieve the optimum $x^\star$,
as well as other parameters, such as the number of iterations performed, the number 
of evaluations of the function, etc...

\section{An example}

In the following example, one searches the minimum of the 2D Rosenbrock function \cite{citeulike:1903787}, 
defined by
\begin{eqnarray}
f(x_1,x_2) = 100(x_2 - x_1)^2 + (1-x_1)^2
\end{eqnarray}

One begins by defining the function "rosenbrock" which computes the Rosenbrock function. 
The traditionnal initial guess $(-1.2 , 1.0)$ is used. The initial simplex is computed along 
the axes with a length equal to 0.1. The Nelder-Mead algorithm with variable simplex size 
is used. The verbose mode is enabled so that messages are generated during the algorithm. 
After the optimization is performed, the optimum is retrieved with quiery features.

\lstset{language=Scilab}
\lstset{numbers=left}
\lstset{basicstyle=\footnotesize}
\lstset{keywordstyle=\bfseries}
\begin{lstlisting}

function y = rosenbrock (x)
  y = 100*(x(2)-x(1)^2)^2 + (1-x(1))^2;
endfunction

nm = neldermead_new ();
nm = neldermead_configure(nm,"-x0",[-1.2 1.0]');
nm = neldermead_configure(nm,"-simplex0method","axes");
nm = neldermead_configure(nm,"-simplex0length",0.1);
nm = neldermead_configure(nm,"-method","variable");
nm = neldermead_configure(nm,"-verbose",1);
nm = neldermead_configure(nm,"-function",rosenbrock);
nm = neldermead_search(nm);
xopt = neldermead_get(nm,"-xopt");
fopt = neldermead_get(nm,"-fopt");
historyfopt = neldermead_get(nm,"-historyfopt");
iterations = neldermead_get(nm,"-iterations");
historyxopt = neldermead_get(nm,"-historyxopt");
historysimplex = neldermead_get(nm,"-historysimplex");
fx0 = neldermead_get(nm,"-fx0");
status = neldermead_get(nm,"-status");
nm = neldermead_destroy(nm);
\end{lstlisting}

The script makes the hypothesis that an environment variable 
named TOOLBOX\_HOME contains the path to directory 
which contains the toolbox, which is stored in the "neldermead" directory.

For a deeper presentation of the commands and options, the reader 
should consult the help which is provided with the package.