summaryrefslogtreecommitdiffstats
path: root/scilab_doc
diff options
context:
space:
mode:
authorMichaŽl Baudin <michael.baudin@scilab.org>2009-10-07 16:22:04 +0200
committerMichaŽl Baudin <michael.baudin@scilab.org>2009-10-07 16:22:04 +0200
commitd2e2206254e4ae89d80eb07940bc941c599c7ed3 (patch)
tree253c4848c4430864be1dd354689e1e61090d4394 /scilab_doc
parent71a8166ade18526760b3677be70b846a13f54391 (diff)
downloadscilab-d2e2206254e4ae89d80eb07940bc941c599c7ed3.zip
scilab-d2e2206254e4ae89d80eb07940bc941c599c7ed3.tar.gz
Added validation for fminsearch
Diffstat (limited to 'scilab_doc')
-rw-r--r--scilab_doc/neldermead/fminsearch-so.pdfbin108029 -> 204275 bytes
-rw-r--r--scilab_doc/neldermead/fminsearch.tex444
-rw-r--r--scilab_doc/neldermead/macros.tex73
-rw-r--r--scilab_doc/neldermead/neldermead.bib18
-rw-r--r--scilab_doc/neldermead/scripts/fminsearch_rosenbrock.m26
-rw-r--r--scilab_doc/neldermead/scripts/fminsearch_rosenbrock.sce32
-rw-r--r--scilab_doc/neldermead/testFminsearchOptimplotfvalMatlab.pngbin0 -> 6249 bytes
-rw-r--r--scilab_doc/neldermead/testFminsearchOptimplotfvalScilab.pngbin0 -> 4682 bytes
-rw-r--r--scilab_doc/neldermead/testFminsearchPlotMatlab.pngbin2928 -> 3391 bytes
-rw-r--r--scilab_doc/neldermead/testFminsearchPlotScilab.pngbin3183 -> 3517 bytes
10 files changed, 585 insertions, 8 deletions
diff --git a/scilab_doc/neldermead/fminsearch-so.pdf b/scilab_doc/neldermead/fminsearch-so.pdf
index 6604bc16..5f05ac7 100644
--- a/scilab_doc/neldermead/fminsearch-so.pdf
+++ b/scilab_doc/neldermead/fminsearch-so.pdf
Binary files differ
diff --git a/scilab_doc/neldermead/fminsearch.tex b/scilab_doc/neldermead/fminsearch.tex
index 85dac9f..9209dff 100644
--- a/scilab_doc/neldermead/fminsearch.tex
+++ b/scilab_doc/neldermead/fminsearch.tex
@@ -78,13 +78,64 @@ In this section, we analyse the behaviour of Scilab's \scifunction{fminsearch}
78function, by comparison of Matlab's \scifunction{fminsearch}. We especially analyse 78function, by comparison of Matlab's \scifunction{fminsearch}. We especially analyse
79the results of the optimization, so that we can check that the algorithm 79the results of the optimization, so that we can check that the algorithm
80is indeed behaving the same way, even if the implementation is completely 80is indeed behaving the same way, even if the implementation is completely
81different. Our test case is based on Rosenbrock's function. 81different.
82
83We consider the unconstrained optimization problem \cite{citeulike:1903787}
84\begin{eqnarray}
85\min f(\bx)
86\end{eqnarray}
87where $\bx\in\RR^2$ and the objective function $f$ is defined by
88\begin{eqnarray}
89f(\bx) = 100*(x_2-x_1^2)^2+(1-x_1)^2.
90\end{eqnarray}
91The initial guess is
92\begin{eqnarray}
93\bx^0 = ( -1.2 , 1.)^T,
94\end{eqnarray}
95where the function value is
96\begin{eqnarray}
97f(\bx^0) = 24.2.
98\end{eqnarray}
99The global solution of this problem is
100\begin{eqnarray}
101\bx^\star = ( 1 , 1.)^T
102\end{eqnarray}
103where the function value is
104\begin{eqnarray}
105f(\bx^\star) = 0.
106\end{eqnarray}
107
108\subsection{Algorithm and numerical precision}
109
110In this section, we are concerned by the comparison of the behavior
111of the two algorithms. We are going to check that the algorithms
112produces the same intermediate and final results.
113We also analyze the numerical precision of the results,
114by detailing the number of significant digits.
115
116To make a more living presentation of this topic, we will
117include small scripts which allow to produce the output
118that we are going to analyze. Because of the similarity of the languages,
119in order to avoid confusion, we will specify, for each script, the language
120we use by a small comment. Scripts and outputs written in Matlab's language will begin with
121\lstset{language=matlabscript}
122\begin{lstlisting}
123% Matlab
124% ...
125\end{lstlisting}
126while script written in Scilab's language will begin with
127\lstset{language=scilabscript}
128\begin{lstlisting}
129// Scilab
130// ...
131\end{lstlisting}
82 132
83The following Matlab script allows to see the behaviour of Matlab's \scifunction{fminsearch} 133The following Matlab script allows to see the behaviour of Matlab's \scifunction{fminsearch}
84function on Rosenbrock's test case. 134function on Rosenbrock's test case.
85 135
86\lstset{language=scilabscript} 136\lstset{language=matlabscript}
87\begin{lstlisting} 137\begin{lstlisting}
138% Matlab
88format long 139format long
89banana = @(x)100*(x(2)-x(1)^2)^2+(1-x(1))^2; 140banana = @(x)100*(x(2)-x(1)^2)^2+(1-x(1))^2;
90[x,fval,exitflag,output] = fminsearch(banana,[-1.2, 1]) 141[x,fval,exitflag,output] = fminsearch(banana,[-1.2, 1])
@@ -94,8 +145,9 @@ output.message
94When this script is launched in Matlab, the following output is 145When this script is launched in Matlab, the following output is
95produced. 146produced.
96 147
97\lstset{language=scilabscript} 148\lstset{language=matlabscript}
98\begin{lstlisting} 149\begin{lstlisting}
150>> % Matlab
99>> format long 151>> format long
100>> banana = @(x)100*(x(2)-x(1)^2)^2+(1-x(1))^2; 152>> banana = @(x)100*(x(2)-x(1)^2)^2+(1-x(1))^2;
101>> [x,fval] = fminsearch(banana,[-1.2, 1]) 153>> [x,fval] = fminsearch(banana,[-1.2, 1])
@@ -125,6 +177,7 @@ The following Scilab script allows to solve the problem with Scilab's
125 177
126\lstset{language=scilabscript} 178\lstset{language=scilabscript}
127\begin{lstlisting} 179\begin{lstlisting}
180// Scilab
128format(25) 181format(25)
129function y = banana (x) 182function y = banana (x)
130 y = 100*(x(2)-x(1)^2)^2 + (1-x(1))^2; 183 y = 100*(x(2)-x(1)^2)^2 + (1-x(1))^2;
@@ -137,6 +190,7 @@ The output associated with this Scilab script is the following.
137 190
138\lstset{language=scilabscript} 191\lstset{language=scilabscript}
139\begin{lstlisting} 192\begin{lstlisting}
193-->// Scilab
140-->format(25) 194-->format(25)
141-->function y = banana (x) 195-->function y = banana (x)
142--> y = 100*(x(2)-x(1)^2)^2 + (1-x(1))^2; 196--> y = 100*(x(2)-x(1)^2)^2 + (1-x(1))^2;
@@ -163,11 +217,102 @@ The output associated with this Scilab script is the following.
163!and F(X) satisfies the convergence criteria using OPTIONS.TolFun of 1.000000e-004 ! 217!and F(X) satisfies the convergence criteria using OPTIONS.TolFun of 1.000000e-004 !
164\end{lstlisting} 218\end{lstlisting}
165 219
166The result is as close as possible to the result produced 220Because the two softwares do not use the same formatting rules
221to produce their outputs, we must perform additionnal checking
222in order to check our results.
223
224The following Scilab script displays the results with 16 significant digits.
225
226\lstset{language=scilabscript}
227\begin{lstlisting}
228// Scilab
229// Print the result with 15 significant digits
230mprintf ( "%.15e" , fval );
231mprintf ( "%.15e %.15e" , x(1) , x(2) );
232\end{lstlisting}
233
234The previous script produces the following output.
235
236\lstset{language=scilabscript}
237\begin{lstlisting}
238-->// Scilab
239-->mprintf ( "%.15e" , fval );
2408.177661099387146e-010
241-->mprintf ( "%.15e %.15e" , x(1) , x(2) );
2421.000022021783557e+000 1.000042219751771e+000
243\end{lstlisting}
244
245These results are reproduced verbatim in the table
246\ref{fig-fminsearch-comparison}.
247
248\begin{figure}[htbp]
249\begin{center}
250\begin{tabular}{|l|l|l|}
251\hline
252Matlab Iterations & 85 &\\
253Scilab Iterations & 85 &\\
254\hline
255Matlab Function Evaluations & 159 &\\
256Scilab Function Evaluations & 159 &\\
257\hline
258Matlab $\bx^\star$ & 1.000022021783570 & 1.000042219751772 \\
259Scilab $\bx^\star$ & 1.000022021783557e+000 & 1.000042219751771e+000 \\
260\hline
261Matlab $f(\bx^\star)$ & 8.177661197416674e-10 &\\
262Scilab $f(\bx^\star)$ & 8.177661099387146e-010 &\\
263\hline
264\end{tabular}
265\end{center}
266\caption{Numerical experiment with Rosenbrock's function -- Comparison of
267results produced by Matlab and Scilab.}
268\label{fig-fminsearch-comparison}
269\end{figure}
270
271We must compute the common number of significant digits
272in order to check the consistency of the results.
273The following Scilab script computes the relative error
274between Scilab and Matlab results.
275
276\lstset{language=scilabscript}
277\begin{lstlisting}
278// Scilab
279// Compare the result
280xmb = [1.000022021783570 1.000042219751772 ];
281err = norm(x - xmb) / norm(xmb);
282mprintf ( "Relative Error on x : %e\n", err );
283fmb = 8.177661197416674e-10;
284err = abs(fval - fmb) / abs(fmb);
285mprintf ( "Relative Error on f : %e\n", err );
286\end{lstlisting}
287
288The previous script produces the following output.
289
290\lstset{language=scilabscript}
291\begin{lstlisting}
292// Scilab
293Relative Error on x : 9.441163e-015
294Relative Error on f : 1.198748e-008
295\end{lstlisting}
296
297We must take into account for the floating point implementations
298of both Matlab and Scilab. In both these numerical softwares,
299double precision floating point numbers are used, i.e. the relative
300precision is both these softwares is $\epsilon \approx 10^{-16}$.
301That implies that there are approximately 16 significant digits.
302Therefore, the relative error on $x$, which is equivalent to 15
303significant digits, is acceptable.
304If we now consider the relative error on $f$, which is equivalent
305to only 8 significant digits, that may sound as a problem.
306This corresponds to the square root of the relative precision,
307because $\sqrt{\epsilon} = \approx 10^{-8}$.
308In fact, this is the best that we can expect from an optimization
309algorithm (\cite{Brent73algorithmsfor,Gill81MurrayWright}).
310
311Therefore, the result is as close as possible to the result produced
167by Matlab. More specifically : 312by Matlab. More specifically :
168\begin{itemize} 313\begin{itemize}
169\item the optimum $x$ is the same up to 14 significant digits, 314\item the optimum $x$ is the same up to 15 significant digits,
170\item the function value at optimum is the same up to 9 significant digits, 315\item the function value at optimum is the same up to 8 significant digits,
171\item the number of iterations is the same, 316\item the number of iterations is the same,
172\item the number of function evaluations is the same, 317\item the number of function evaluations is the same,
173\item the exit flag is the same, 318\item the exit flag is the same,
@@ -175,6 +320,291 @@ by Matlab. More specifically :
175display the same way). 320display the same way).
176\end{itemize} 321\end{itemize}
177 322
323The output of the two functions is the same.
324We must now check that the algorithms performs the same way,
325that is, produces the same intermediate steps.
326
327The following Matlab script allows to get deeper information by printing a message at each iteration
328with the "Display" option.
329
330\lstset{language=matlabscript}
331\begin{lstlisting}
332% Matlab
333opt = optimset('Display','iter');
334[x,fval,exitflag,output] = fminsearch(banana,[-1.2, 1] , opt );
335\end{lstlisting}
336
337The previous script produces the following output.
338
339\lstset{language=matlabscript}
340\begin{lstlisting}
341% Matlab
342 Iteration Func-count min f(x) Procedure
343 0 1 24.2
344 1 3 20.05 initial simplex
345 2 5 5.1618 expand
346 3 7 4.4978 reflect
347 4 9 4.4978 contract outside
348 5 11 4.38136 contract inside
349 6 13 4.24527 contract inside
350 7 15 4.21762 reflect
351 8 17 4.21129 contract inside
352 9 19 4.13556 expand
353 10 21 4.13556 contract inside
354 11 23 4.01273 expand
355 12 25 3.93738 expand
356 13 27 3.60261 expand
357 14 28 3.60261 reflect
358 15 30 3.46622 reflect
359 16 32 3.21605 expand
360 17 34 3.16491 reflect
361 18 36 2.70687 expand
362 19 37 2.70687 reflect
363 20 39 2.00218 expand
364 21 41 2.00218 contract inside
365 22 43 2.00218 contract inside
366 23 45 1.81543 expand
367 24 47 1.73481 contract outside
368 25 49 1.31697 expand
369 26 50 1.31697 reflect
370 27 51 1.31697 reflect
371 28 53 1.1595 reflect
372 29 55 1.07674 contract inside
373 30 57 0.883492 reflect
374 31 59 0.883492 contract inside
375 32 61 0.669165 expand
376 33 63 0.669165 contract inside
377 34 64 0.669165 reflect
378 35 66 0.536729 reflect
379 36 68 0.536729 contract inside
380 37 70 0.423294 expand
381 38 72 0.423294 contract outside
382 39 74 0.398527 reflect
383 40 76 0.31447 expand
384 41 77 0.31447 reflect
385 42 79 0.190317 expand
386 43 81 0.190317 contract inside
387 44 82 0.190317 reflect
388 45 84 0.13696 reflect
389 46 86 0.13696 contract outside
390 47 88 0.113128 contract outside
391 48 90 0.11053 contract inside
392 49 92 0.10234 reflect
393 50 94 0.101184 contract inside
394 51 96 0.0794969 expand
395 52 97 0.0794969 reflect
396 53 98 0.0794969 reflect
397 54 100 0.0569294 expand
398 55 102 0.0569294 contract inside
399 56 104 0.0344855 expand
400 57 106 0.0179534 expand
401 58 108 0.0169469 contract outside
402 59 110 0.00401463 reflect
403 60 112 0.00401463 contract inside
404 61 113 0.00401463 reflect
405 62 115 0.000369954 reflect
406 63 117 0.000369954 contract inside
407 64 118 0.000369954 reflect
408 65 120 0.000369954 contract inside
409 66 122 5.90111e-005 contract outside
410 67 124 3.36682e-005 contract inside
411 68 126 3.36682e-005 contract outside
412 69 128 1.89159e-005 contract outside
413 70 130 8.46083e-006 contract inside
414 71 132 2.88255e-006 contract inside
415 72 133 2.88255e-006 reflect
416 73 135 7.48997e-007 contract inside
417 74 137 7.48997e-007 contract inside
418 75 139 6.20365e-007 contract inside
419 76 141 2.16919e-007 contract outside
420 77 143 1.00244e-007 contract inside
421 78 145 5.23487e-008 contract inside
422 79 147 5.03503e-008 contract inside
423 80 149 2.0043e-008 contract inside
424 81 151 1.12293e-009 contract inside
425 82 153 1.12293e-009 contract outside
426 83 155 1.12293e-009 contract inside
427 84 157 1.10755e-009 contract outside
428 85 159 8.17766e-010 contract inside
429
430Optimization terminated:
431 the current x satisfies the termination criteria using OPTIONS.TolX of 1.000000e-004
432 and F(X) satisfies the convergence criteria using OPTIONS.TolFun of 1.000000e-004
433\end{lstlisting}
434
435The following Scilab script set the "Display" option to "iter" and
436run the \scifunction{fminsearch} function.
437
438\lstset{language=scilabscript}
439\begin{lstlisting}
440// Scilab
441opt = optimset ( "Display" , "iter" );
442[x , fval , exitflag , output] = fminsearch ( banana , [-1.2 1] , opt );
443\end{lstlisting}
444
445\lstset{language=scilabscript}
446\begin{lstlisting}
447// Scilab
448 Iteration Func-count min f(x) Procedure
449 0 3 24.2
450 1 3 20.05 initial simplex
451 2 5 5.161796 expand
452 3 7 4.497796 reflect
453 4 9 4.497796 contract outside
454 5 11 4.3813601 contract inside
455 6 13 4.2452728 contract inside
456 7 15 4.2176247 reflect
457 8 17 4.2112906 contract inside
458 9 19 4.1355598 expand
459 10 21 4.1355598 contract inside
460 11 23 4.0127268 expand
461 12 25 3.9373812 expand
462 13 27 3.602606 expand
463 14 28 3.602606 reflect
464 15 30 3.4662211 reflect
465 16 32 3.2160547 expand
466 17 34 3.1649126 reflect
467 18 36 2.7068692 expand
468 19 37 2.7068692 reflect
469 20 39 2.0021824 expand
470 21 41 2.0021824 contract inside
471 22 43 2.0021824 contract inside
472 23 45 1.8154337 expand
473 24 47 1.7348144 contract outside
474 25 49 1.3169723 expand
475 26 50 1.3169723 reflect
476 27 51 1.3169723 reflect
477 28 53 1.1595038 reflect
478 29 55 1.0767387 contract inside
479 30 57 0.8834921 reflect
480 31 59 0.8834921 contract inside
481 32 61 0.6691654 expand
482 33 63 0.6691654 contract inside
483 34 64 0.6691654 reflect
484 35 66 0.5367289 reflect
485 36 68 0.5367289 contract inside
486 37 70 0.4232940 expand
487 38 72 0.4232940 contract outside
488 39 74 0.3985272 reflect
489 40 76 0.3144704 expand
490 41 77 0.3144704 reflect
491 42 79 0.1903167 expand
492 43 81 0.1903167 contract inside
493 44 82 0.1903167 reflect
494 45 84 0.1369602 reflect
495 46 86 0.1369602 contract outside
496 47 88 0.1131281 contract outside
497 48 90 0.1105304 contract inside
498 49 92 0.1023402 reflect
499 50 94 0.1011837 contract inside
500 51 96 0.0794969 expand
501 52 97 0.0794969 reflect
502 53 98 0.0794969 reflect
503 54 100 0.0569294 expand
504 55 102 0.0569294 contract inside
505 56 104 0.0344855 expand
506 57 106 0.0179534 expand
507 58 108 0.0169469 contract outside
508 59 110 0.0040146 reflect
509 60 112 0.0040146 contract inside
510 61 113 0.0040146 reflect
511 62 115 0.0003700 reflect
512 63 117 0.0003700 contract inside
513 64 118 0.0003700 reflect
514 65 120 0.0003700 contract inside
515 66 122 0.0000590 contract outside
516 67 124 0.0000337 contract inside
517 68 126 0.0000337 contract outside
518 69 128 0.0000189 contract outside
519 70 130 0.0000085 contract inside
520 71 132 0.0000029 contract inside
521 72 133 0.0000029 reflect
522 73 135 0.0000007 contract inside
523 74 137 0.0000007 contract inside
524 75 139 0.0000006 contract inside
525 76 141 0.0000002 contract outside
526 77 143 0.0000001 contract inside
527 78 145 5.235D-08 contract inside
528 79 147 5.035D-08 contract inside
529 80 149 2.004D-08 contract inside
530 81 151 1.123D-09 contract inside
531 82 153 1.123D-09 contract outside
532 83 155 1.123D-09 contract inside
533 84 157 1.108D-09 contract outside
534 85 159 8.178D-10 contract inside
535
536Optimization terminated:
537 the current x satisfies the termination criteria using OPTIONS.TolX of 1.000000e-004
538 and F(X) satisfies the convergence criteria using OPTIONS.TolFun of 1.000000e-004
539\end{lstlisting}
540
541A close inspection at the data reveals that the two softwares produces
542indeed the same intermediate results.
543
544\subsection{Plot features}
545
546In this section, we check that the plotting features of the
547\scifunction{fminsearch} function are the same.
548
549The following output function plots in the current graphic
550window the value of the current parameter $\bx$.
551To let Matlab load that script, save the content in a
552.m file, in a directory known by Matlab.
553
554\lstset{language=matlabscript}
555\begin{lstlisting}
556% Matlab
557function stop = outfun(x, optimValues, state)
558stop = false;
559hold on;
560plot(x(1),x(2),'.');
561drawnow
562\end{lstlisting}
563
564The following Matlab script allows to perform the optimization
565so that the output function is called back at each iteration.
566
567\lstset{language=matlabscript}
568\begin{lstlisting}
569% Matlab
570options = optimset('OutputFcn', @outfun);
571[x fval] = fminsearch(banana, [-1.2, 1], options)
572\end{lstlisting}
573
574This produces the plot which is presented in figure \ref{fig-fminsearch-matlab-outputfun}.
575
576\begin{figure}
577\begin{center}
578\includegraphics[width=10cm]{testFminsearchPlotMatlab.png}
579\end{center}
580\caption{Plot produced by Matlab's fminsearch, with customized output function.}
581\label{fig-fminsearch-matlab-outputfun}
582\end{figure}
583
584The following Scilab script sets the "OutputFcn" option and then calls
585the \scifunction{fminsearch} in order to perform the optimization.
586
587\lstset{language=scilabscript}
588\begin{lstlisting}
589// Scilab
590function outfun ( x , optimValues , state )
591 plot( x(1),x(2),'.');
592endfunction
593opt = optimset ( "OutputFcn" , outfun);
594[x fval] = fminsearch ( banana , [-1.2 1] , opt );
595\end{lstlisting}
596
597The previous script produces the plot which is presented
598in figure \ref{fig-fminsearch-scilab-outputfun}.
599
600\begin{figure}
601\begin{center}
602\includegraphics[width=10cm]{testFminsearchPlotScilab.png}
603\end{center}
604\caption{Plot produced by Scilab's fminsearch, with customized output function.}
605\label{fig-fminsearch-scilab-outputfun}
606\end{figure}
178 607
179%TODO : check that the iterations are the same 608Except for the size of the dots (which can be configured in
609both softwares), the graphics are exactly the same.
180 610
diff --git a/scilab_doc/neldermead/macros.tex b/scilab_doc/neldermead/macros.tex
index 9464b36..572dd39 100644
--- a/scilab_doc/neldermead/macros.tex
+++ b/scilab_doc/neldermead/macros.tex
@@ -227,6 +227,79 @@
227 stringstyle=\bfseries 227 stringstyle=\bfseries
228 }[keywords,comments,strings]% 228 }[keywords,comments,strings]%
229 229
230\lstdefinelanguage{matlabscript}%
231 {morekeywords={gt,lt,gt,lt,amp,abs,acos,acosh,acot,acoth,acsc,acsch,%
232 all,angle,ans,any,asec,asech,asin,asinh,atan,atan2,atanh,auread,%
233 auwrite,axes,axis,balance,bar,bessel,besselk,bessely,beta,%
234 betainc,betaln,blanks,bone,break,brighten,capture,cart2pol,%
235 cart2sph,caxis,cd,cdf2rdf,cedit,ceil,chol,cla,clabel,clc,clear,%
236 clf,clock,close,colmmd,Colon,colorbar,colormap,ColorSpec,colperm,%
237 comet,comet3,compan,compass,computer,cond,condest,conj,contour,%
238 contour3,contourc,contrast,conv,conv2,cool,copper,corrcoef,cos,%
239 cosh,cot,coth,cov,cplxpair,cputime,cross,csc,csch,csvread,%
240 csvwrite,cumprod,cumsum,cylinder,date,dbclear,dbcont,dbdown,%
241 dbquit,dbstack,dbstatus,dbstep,dbstop,dbtype,dbup,ddeadv,ddeexec,%
242 ddeinit,ddepoke,ddereq,ddeterm,ddeunadv,deblank,dec2hex,deconv,%
243 del2,delete,demo,det,diag,diary,diff,diffuse,dir,disp,dlmread,%
244 dlmwrite,dmperm,dot,drawnow,echo,eig,ellipj,ellipke,else,elseif,%
245 end,engClose,engEvalString,engGetFull,engGetMatrix,engOpen,%
246 engOutputBuffer,engPutFull,engPutMatrix,engSetEvalCallback,%
247 engSetEvalTimeout,engWinInit,eps,erf,erfc,erfcx,erfinv,error,%
248 errorbar,etime,etree,eval,exist,exp,expint,expm,expo,eye,fclose,%
249 feather,feof,ferror,feval,fft,fft2,fftshift,fgetl,fgets,figure,%
250 fill,fill3,filter,filter2,find,findstr,finite,fix,flag,fliplr,%
251 flipud,floor,flops,fmin,fmins,fopen,for,format,fplot,fprintf,%
252 fread,frewind,fscanf,fseek,ftell,full,function,funm,fwrite,fzero,%
253 gallery,gamma,gammainc,gammaln,gca,gcd,gcf,gco,get,getenv,%
254 getframe,ginput,global,gplot,gradient,gray,graymon,grid,griddata,%
255 gtext,hadamard,hankel,help,hess,hex2dec,hex2num,hidden,hilb,hist,%
256 hold,home,hostid,hot,hsv,hsv2rgb,if,ifft,ifft2,imag,image,%
257 imagesc,Inf,info,input,int2str,interp1,interp2,interpft,inv,%
258 invhilb,isempty,isglobal,ishold,isieee,isinf,isletter,isnan,%
259 isreal,isspace,issparse,isstr,jet,keyboard,kron,lasterr,lcm,%
260 legend,legendre,length,lin2mu,line,linspace,load,log,log10,log2,%
261 loglog,logm,logspace,lookfor,lower,ls,lscov,lu,magic,matClose,%
262 matDeleteMatrix,matGetDir,matGetFp,matGetFull,matGetMatrix,%
263 matGetNextMatrix,matGetString,matlabrc,matlabroot,matOpen,%
264 matPutFull,matPutMatrix,matPutString,max,mean,median,menu,mesh,%
265 meshc,meshgrid,meshz,mexAtExit,mexCallMATLAB,mexdebug,%
266 mexErrMsgTxt,mexEvalString,mexFunction,mexGetFull,mexGetMatrix,%
267 mexGetMatrixPtr,mexPrintf,mexPutFull,mexPutMatrix,mexSetTrapFlag,%
268 min,more,movie,moviein,mu2lin,mxCalloc,mxCopyCharacterToPtr,%
269 mxCopyComplex16ToPtr,mxCopyInteger4ToPtr,mxCopyPtrToCharacter,%
270 mxCopyPtrToComplex16,mxCopyPtrToInteger4,mxCopyPtrToReal8,%
271 mxCopyReal8ToPtr,mxCreateFull,mxCreateSparse,mxCreateString,%
272 mxFree,mxFreeMatrix,mxGetIr,mxGetJc,mxGetM,mxGetN,mxGetName,%
273 mxGetNzmax,mxGetPi,mxGetPr,mxGetScalar,mxGetString,mxIsComplex,%
274 mxIsFull,mxIsNumeric,mxIsSparse,mxIsString,mxIsTypeDouble,%
275 mxSetIr,mxSetJc,mxSetM,mxSetN,mxSetName,mxSetNzmax,mxSetPi,%
276 mxSetPr,NaN,nargchk,nargin,nargout,newplot,nextpow2,nnls,nnz,%
277 nonzeros,norm,normest,null,num2str,nzmax,ode23,ode45,orient,orth,%
278 pack,pascal,patch,path,pause,pcolor,pi,pink,pinv,plot,plot3,%
279 pol2cart,polar,poly,polyder,polyeig,polyfit,polyval,polyvalm,%
280 pow2,print,printopt,prism,prod,pwd,qr,qrdelete,qrinsert,quad,%
281 quad8,quit,quiver,qz,rand,randn,randperm,rank,rat,rats,rbbox,%
282 rcond,real,realmax,realmin,refresh,rem,reset,reshape,residue,%
283 return,rgb2hsv,rgbplot,rootobject,roots,rose,rosser,rot90,rotate,%
284 round,rref,rrefmovie,rsf2csf,save,saxis,schur,sec,sech,semilogx,%
285 semilogy,set,setstr,shading,sign,sin,sinh,size,slice,sort,sound,%
286 spalloc,sparse,spaugment,spconvert,spdiags,specular,speye,spfun,%
287 sph2cart,sphere,spinmap,spline,spones,spparms,sprandn,sprandsym,%
288 sprank,sprintf,spy,sqrt,sqrtm,sscanf,stairs,startup,std,stem,%
289 str2mat,str2num,strcmp,strings,strrep,strtok,subplot,subscribe,%
290 subspace,sum,surf,surface,surfc,surfl,surfnorm,svd,symbfact,%
291 symmmd,symrcm,tan,tanh,tempdir,tempname,terminal,text,tic,title,%
292 toc,toeplitz,trace,trapz,tril,triu,type,uicontrol,uigetfile,%
293 uimenu,uiputfile,unix,unwrap,upper,vander,ver,version,view,%
294 viewmtx,waitforbuttonpress,waterfall,wavread,wavwrite,what,%
295 whatsnew,which,while,white,whitebg,who,whos,wilkinson,wk1read,%
296 wk1write,xlabel,xor,ylabel,zeros,zlabel,zoom},%
297 sensitive,%
298 morecomment=[l]\%,%
299 basicstyle=\tiny,%
300 morestring=[m]'%
301 }[keywords,comments,strings]%
302
230\usepackage{algorithmic} 303\usepackage{algorithmic}
231 304
232% To allow one bibliograph by chapter 305% To allow one bibliograph by chapter
diff --git a/scilab_doc/neldermead/neldermead.bib b/scilab_doc/neldermead/neldermead.bib
index 3d6f69b..ca7d39a 100644
--- a/scilab_doc/neldermead/neldermead.bib
+++ b/scilab_doc/neldermead/neldermead.bib
@@ -491,3 +491,21 @@ PAGES = {2928}
491 pages = {1422--1428} 491 pages = {1422--1428}
492} 492}
493 493
494@MISC{Brent73algorithmsfor,
495 author = {Richard P. Brent},
496 title = {Algorithms for Minimization without Derivatives},
497 year = {1973}
498}
499
500@book{Gill81MurrayWright,
501 address = {London},
502 author = {Gill, P. E. and Murray, W. and Wright, M. H. },
503 citeulike-article-id = {1055426},
504 keywords = {bibtex-import},
505 posted-at = {2007-01-20 09:02:15},
506 priority = {2},
507 publisher = {Academic Press},
508 title = {Practical optimization},
509 year = {1981}
510}
511
diff --git a/scilab_doc/neldermead/scripts/fminsearch_rosenbrock.m b/scilab_doc/neldermead/scripts/fminsearch_rosenbrock.m
new file mode 100644
index 0000000..e1a3cc4
--- /dev/null
+++ b/scilab_doc/neldermead/scripts/fminsearch_rosenbrock.m
@@ -0,0 +1,26 @@
1% Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2% Copyright (C) 2008-2009 - Digiteo - Michael Baudin
3%
4% This file must be used under the terms of the CeCILL.
5% This source file is licensed as described in the file COPYING, which
6% you should have received as part of this distribution. The terms
7% are also available at
8% http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
9
10% Basic use
11format long
12banana = @(x)100*(x(2)-x(1)^2)^2+(1-x(1))^2;
13[x,fval,exitflag,output] = fminsearch(banana,[-1.2, 1])
14output.message
15
16% Now check each iteration
17opt = optimset('Display','iter');
18[x,fval,exitflag,output] = fminsearch(banana,[-1.2, 1] , opt );
19
20
21% Check that the output functions are OK
22options = optimset('OutputFcn', @outfun);
23[x fval] = fminsearch(banana, [-1.2, 1], options)
24
25
26
diff --git a/scilab_doc/neldermead/scripts/fminsearch_rosenbrock.sce b/scilab_doc/neldermead/scripts/fminsearch_rosenbrock.sce
index ae80978..1029015 100644
--- a/scilab_doc/neldermead/scripts/fminsearch_rosenbrock.sce
+++ b/scilab_doc/neldermead/scripts/fminsearch_rosenbrock.sce
@@ -1,10 +1,40 @@
1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) 2008-2009 - Digiteo - Michael Baudin
3//
4// This file must be used under the terms of the CeCILL.
5// This source file is licensed as described in the file COPYING, which
6// you should have received as part of this distribution. The terms
7// are also available at
8// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
9
10// Basic use
1format(25) 11format(25)
2function y = banana (x) 12function y = banana (x)
3 y = 100*(x(2)-x(1)^2)^2 + (1-x(1))^2; 13 y = 100*(x(2)-x(1)^2)^2 + (1-x(1))^2;
4endfunction 14endfunction
5[x , fval , exitflag , output] = fminsearch ( banana , [-1.2 1] ) 15[x , fval , exitflag , output] = fminsearch ( banana , [-1.2 1] )
6output.message 16output.message
17// Print the result with 15 significant digits
18mprintf ( "%.15e" , fval );
19mprintf ( "%.15e %.15e" , x(1) , x(2) );
20// Compare the result
21xmb = [1.000022021783570 1.000042219751772 ];
22err = norm(x - xmb) / norm(xmb);
23mprintf ( "Relative Error on x : %e\n", err );
24fmb = 8.177661197416674e-10;
25err = abs(fval - fmb) / abs(fmb);
26mprintf ( "Relative Error on f : %e\n", err );
27
28// Now check each iteration
29opt = optimset ( "Display" , "iter" );
30[x , fval , exitflag , output] = fminsearch ( banana , [-1.2 1] , opt );
31
32// Check that the output functions are OK
33function outfun ( x , optimValues , state )
34 plot( x(1),x(2),'.');
35endfunction
36opt = optimset ( "OutputFcn" , outfun);
37[x fval] = fminsearch ( banana , [-1.2 1] , opt );
7 38
8// Now check the iterations
9 39
10 40
diff --git a/scilab_doc/neldermead/testFminsearchOptimplotfvalMatlab.png b/scilab_doc/neldermead/testFminsearchOptimplotfvalMatlab.png
new file mode 100644
index 0000000..32f528a
--- /dev/null
+++ b/scilab_doc/neldermead/testFminsearchOptimplotfvalMatlab.png
Binary files differ
diff --git a/scilab_doc/neldermead/testFminsearchOptimplotfvalScilab.png b/scilab_doc/neldermead/testFminsearchOptimplotfvalScilab.png
new file mode 100644
index 0000000..ca1600a
--- /dev/null
+++ b/scilab_doc/neldermead/testFminsearchOptimplotfvalScilab.png
Binary files differ
diff --git a/scilab_doc/neldermead/testFminsearchPlotMatlab.png b/scilab_doc/neldermead/testFminsearchPlotMatlab.png
index e78702c..09e3476 100644
--- a/scilab_doc/neldermead/testFminsearchPlotMatlab.png
+++ b/scilab_doc/neldermead/testFminsearchPlotMatlab.png
Binary files differ
diff --git a/scilab_doc/neldermead/testFminsearchPlotScilab.png b/scilab_doc/neldermead/testFminsearchPlotScilab.png
index 164d426..5408533 100644
--- a/scilab_doc/neldermead/testFminsearchPlotScilab.png
+++ b/scilab_doc/neldermead/testFminsearchPlotScilab.png
Binary files differ