Added submodules for fminsearch
Michaël Baudin [Thu, 27 Aug 2009 12:26:49 +0000 (14:26 +0200)]
194 files changed:
scilab/modules/optimization/help/en_US/neldermead/neldermead.xml [new file with mode: 0644]
scilab/modules/optimization/help/en_US/neldermead/overview.xml [new file with mode: 0644]
scilab/modules/optimization/help/en_US/optimbase/optimbase.xml [new file with mode: 0644]
scilab/modules/optimization/help/en_US/optimsimplex/optimsimplex.xml [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/mtlb_fminsearch.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/mtlb_optimset.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/neldermead_cget.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/neldermead_configure.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/neldermead_contour.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/neldermead_costf.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/neldermead_destroy.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/neldermead_display.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/neldermead_function.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/neldermead_get.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/neldermead_log.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/neldermead_new.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/neldermead_restart.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/neldermead_search.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/neldermead_updatesimp.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/nmplot_cget.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/nmplot_configure.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/nmplot_contour.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/nmplot_destroy.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/nmplot_display.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/nmplot_get.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/nmplot_historyplot.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/nmplot_log.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/nmplot_new.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/nmplot_outputcmd.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/nmplot_search.sci [new file with mode: 0644]
scilab/modules/optimization/macros/neldermead/nmplot_simplexhistory.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimbase/optimbase_cget.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimbase/optimbase_checkbounds.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimbase/optimbase_checkx0.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimbase/optimbase_configure.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimbase/optimbase_destroy.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimbase/optimbase_display.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimbase/optimbase_function.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimbase/optimbase_get.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimbase/optimbase_hasbounds.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimbase/optimbase_histget.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimbase/optimbase_histset.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimbase/optimbase_incriter.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimbase/optimbase_isfeasible.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimbase/optimbase_log.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimbase/optimbase_new.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimbase/optimbase_outputcmd.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimbase/optimbase_outstruct.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimbase/optimbase_proj2bnds.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimbase/optimbase_set.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimbase/optimbase_stoplog.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimbase/optimbase_terminate.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_axes.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_center.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_check.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_computefv.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_deltafv.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_deltafvmax.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_destroy.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_dirmat.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_fvmean.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_fvstdev.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_getall.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_getallfv.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_getallx.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_getfv.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_getn.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_getnbve.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_getve.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_getx.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_gradientfv.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_log.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_new.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_oriented.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_pfeffer.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_print.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_randbounds.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_reflect.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_setall.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_setallfv.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_setallx.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_setfv.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_setn.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_setnbve.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_setve.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_setx.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_shrink.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_size.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_sort.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_spendley.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_tostring.sci [new file with mode: 0644]
scilab/modules/optimization/macros/optimsimplex/optimsimplex_xbar.sci [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/mtlb_fminsearch.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/mtlb_fminsearch.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/mtlb_optimset.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/mtlb_optimset.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_compute.tst.backup [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_configure.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_configure.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_display.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_display.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_kelley.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_mckinnon.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_mckinnon.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_outputcmd.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_outputcmd.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_outputcmd2.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_outputcmd2.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_rosensuzuki.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_rosensuzuki.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_searchaddarg.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_searchaddarg.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_searchaddarg2.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_searchaddarg2.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_searchaddarg3.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_searchaddarg3.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_searchdefault.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_searchdefault.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_searchfixed.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_searchfixed.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_searchfixed2.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_searchfixed2.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_searchvariable.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_searchvariable.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_simplex0.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_simplex0.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_simplexaxes.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_simplexaxes.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_simplexregular.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_simplexregular.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_tolerance.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/neldermead_tolerance.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/nmplot_contour.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/nmplot_contour.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/nmplot_rosenbrock.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/neldermead/nmplot_rosenbrock.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimbase/optimbase_checkbounds.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimbase/optimbase_checkbounds.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimbase/optimbase_checkx0.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimbase/optimbase_checkx0.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimbase/optimbase_hasbounds.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimbase/optimbase_hasbounds.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimbase/optimbase_isfeasible.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimbase/optimbase_isfeasible.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimbase/optimbase_newdestroy.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimbase/optimbase_newdestroy.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimbase/optimbase_proj2bnds.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimbase/optimbase_proj2bnds.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_axes.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_axes.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_center.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_center.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_check.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_check.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_computefv.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_computefv.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_deltafv.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_deltafv.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_deltafvmax.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_deltafvmax.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_dirmat.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_dirmat.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_fvmean.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_fvmean.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_fvstdev.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_fvstdev.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_getset.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_getset.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_gradientfv.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_gradientfv.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_new.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_new.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_oriented.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_oriented.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_pfeffer.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_pfeffer.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_print.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_print.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_randbounds.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_randbounds.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_reflect.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_reflect.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_shrink.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_shrink.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_size.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_size.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_sort.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_sort.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_spendley.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_spendley.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_tostring.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_tostring.tst [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_xbar.dia.ref [new file with mode: 0644]
scilab/modules/optimization/tests/unit_tests/optimsimplex/optimsimplex_xbar.tst [new file with mode: 0644]

diff --git a/scilab/modules/optimization/help/en_US/neldermead/neldermead.xml b/scilab/modules/optimization/help/en_US/neldermead/neldermead.xml
new file mode 100644 (file)
index 0000000..f7e1c10
--- /dev/null
@@ -0,0 +1,1685 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ * Ajouter ici d'éventuels commentaires sur le fichier XML
+-->
+<refentry version="5.0-subset Scilab" xml:id="montecarlo_run" xml:lang="fr"
+          xmlns="http://docbook.org/ns/docbook"
+          xmlns:xlink="http://www.w3.org/1999/xlink"
+          xmlns:svg="http://www.w3.org/2000/svg"
+          xmlns:ns4="http://www.w3.org/1999/xhtml"
+          xmlns:mml="http://www.w3.org/1998/Math/MathML"
+          xmlns:db="http://docbook.org/ns/docbook">
+  <info>
+    <pubdate>$LastChangedDate: 16-12-2008 $</pubdate>
+  </info>
+
+  <refnamediv>
+    <refname>neldermead</refname>
+
+    <refpurpose>Provides several direct search optimization algorithms based
+    on the simplex method.</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <title>SYNOPSIS</title>
+
+    <synopsis>
+newobj = neldermead_new ()
+this = neldermead_destroy (this)
+this = neldermead_configure (this,key,value)
+value = neldermead_cget (this,key)
+this = neldermead_display ( this )
+value = neldermead_get ( this , key )
+this = neldermead_restart ( this )
+this = neldermead_search ( this )
+[ this , xdata , ydata , zdata ] = neldermead_contour ( this , xmin , xmax , ymin , ymax , nx , ny )
+</synopsis>
+  </refsynopsisdiv>
+
+  <refsection>
+    <title>Description</title>
+
+    <para>This class provides several direct search optimization algorithms
+    based on the simplex method.</para>
+
+    <para>The optimization problem to solve is the minimization of a cost
+    function, with bounds and nonlinear constraints</para>
+
+    <programlisting role="example">min f(x)
+l_i &lt;= x_i &lt;= h_i, i = 1,n
+g_i(x) &lt;= 0, i = 1,nbineq</programlisting>
+
+    <para>where</para>
+
+    <variablelist>
+      <varlistentry>
+        <term>n</term>
+
+        <listitem>
+          <para>number of variables</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>nbineq</term>
+
+        <listitem>
+          <para>number of inequality constraints</para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+
+    <para>The provided algorithms are direct search algorithms, i.e.
+    algorithms which do not use the derivative of the cost function. They are
+    based on the update of a simplex, which is a set of k&gt;=n+1 vertices,
+    where each vertex is associated with one point and one function
+    value.</para>
+
+    <para>The following algorithms are available :</para>
+
+    <variablelist>
+      <varlistentry>
+        <term>Spendley, Hext and Himsworth fixed size simplex method</term>
+
+        <listitem>
+          <para>This algorithm solves an unconstrained optimization problem
+          with a fixed sized simplex made of k=n+1 vertices.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>Nelder and Mead variable size simplex method</term>
+
+        <listitem>
+          <para>This algorithm solves an unconstrained optimization problem
+          with a variable sized simplex made of k=n+1 vertices.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>Box complex method</term>
+
+        <listitem>
+          <para>This algorithm solves an constrained optimization problem with
+          a variable sized simplex made of an arbitrary k number of vertices
+          (k=2n is recommended by Box).</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>Box-Guin complex method</term>
+
+        <listitem>
+          <para>This algorithm solves an constrained optimization problem with
+          a variable sized simplex made of an arbitrary k number of vertices.
+          This is an update of Box's algorithm.</para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsection>
+
+  <refsection>
+    <title>Functions</title>
+
+    <para>The following functions are available.</para>
+
+    <variablelist>
+      <varlistentry>
+        <term>newobj = neldermead_new ()</term>
+
+        <listitem>
+          <para>Creates a new neldermead object.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>newobj</term>
+
+              <listitem>
+                <para>The new object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = neldermead_destroy (this)</term>
+
+        <listitem>
+          <para>Destroy the given object.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = neldermead_configure (this,key,value)</term>
+
+        <listitem>
+          <para>Configure the current object with the given value for the
+          given key.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>key</term>
+
+              <listitem>
+                <para>the key to configure. The following keys are
+                available.</para>
+
+                <variablelist>
+                  <varlistentry>
+                    <term>-verbose</term>
+
+                    <listitem>
+                      <para>set to 1 to enable verbose logging. (default is
+                      0)</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-verbosetermination</term>
+
+                    <listitem>
+                      <para>set to 1 to enable verbose termination logging.
+                      (default is 0)</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-x0</term>
+
+                    <listitem>
+                      <para>the initial guess.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-maxfunevals</term>
+
+                    <listitem>
+                      <para>the maximum number of function evalutations
+                      (default is 100). If this criteria is triggered, the
+                      status of the optimization is set to
+                      "maxfuneval".</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-maxiter</term>
+
+                    <listitem>
+                      <para>the maximum number of iterations (default is 100).
+                      If this criteria is triggered, the status of the
+                      optimization is set to "maxiter".</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-tolfunabsolute</term>
+
+                    <listitem>
+                      <para>the absolute tolerance for the function value
+                      (default is 0.0).</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-tolfunrelative</term>
+
+                    <listitem>
+                      <para>the relative tolerance for the function value
+                      (default is %eps).</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-tolfunmethod</term>
+
+                    <listitem>
+                      <para>the method used for the tolerance on function
+                      value in the termination criteria.</para>
+
+                      <para>The following values are available :
+                      "absolute+relative", "relative", "absolute", "disabled"
+                      (default is "disabled"). If this criteria is triggered,
+                      the status of the optimization is set to "tolf".</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-tolxabsolute</term>
+
+                    <listitem>
+                      <para>the absolute tolerance on x (default is
+                      0.0).</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-tolxrelative</term>
+
+                    <listitem>
+                      <para>the relative tolerance on x (default is
+                      %eps).</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-tolxmethod</term>
+
+                    <listitem>
+                      <para>the method used for the tolerance on x in the
+                      termination criteria.</para>
+
+                      <para>The following values are available : "relative",
+                      "absolute", "disabled" (default is "relative"). If this
+                      criteria is triggered, the status of the optimization is
+                      set to "tolx".</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-function</term>
+
+                    <listitem>
+                      <para>the objective function, which computes the value
+                      of the cost and the non linear constraints, if
+                      any.</para>
+
+                      <para>See below for the details of the communication
+                      between the optimization system and the cost
+                      function.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-costfargument</term>
+
+                    <listitem>
+                      <para>an additionnal argument, passed to the cost
+                      function.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-outputcommand</term>
+
+                    <listitem>
+                      <para>a command which is called back for output.</para>
+
+                      <para>See below for the details of the communication
+                      between the optimization system and the output command
+                      function.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-outputcommandarg</term>
+
+                    <listitem>
+                      <para>an additionnal argument, passed to the output
+                      command.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-numberofvariables</term>
+
+                    <listitem>
+                      <para>the number of variables to optimize (default is
+                      0).</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-storehistory</term>
+
+                    <listitem>
+                      <para>set to 1 to enable the history storing (default is
+                      0).</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-boundsmin</term>
+
+                    <listitem>
+                      <para>the minimum bounds for the parameters, as an array
+                      of values (default is empty, i.e. there are no
+                      bounds).</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-boundsmax</term>
+
+                    <listitem>
+                      <para>the maximum bounds for the parameters, as an array
+                      of values (default is empty, i.e. there are no
+                      bounds).</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-nbineqconst</term>
+
+                    <listitem>
+                      <para>the number of inequality constraints (default is
+                      0)</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-method</term>
+
+                    <listitem>
+                      <para>the name of the algorithm to use. The following
+                      methods are available :</para>
+
+                      <variablelist>
+                        <varlistentry>
+                          <term>"fixed"</term>
+
+                          <listitem>
+                            <para>the Spendley et al. fixed simplex shape
+                            algorithm. This algorithm is for unconstrained
+                            problems (i.e. bounds and non linear constraints are
+                            not taken into account)</para>
+                          </listitem>
+                        </varlistentry>
+
+                        <varlistentry>
+                          <term>"variable"</term>
+
+                          <listitem>
+                            <para>the Nelder-Mead variable simplex shape
+                            algorithm. This algorithm is for unconstrained
+                            problems (i.e. bounds and non linear constraints are
+                            not taken into account)</para>
+                          </listitem>
+                        </varlistentry>
+
+                        <varlistentry>
+                          <term>"box"</term>
+
+                          <listitem>
+                            <para>the Box complex algorithm. This algorithm
+                            takes into account bounds and nonlinear inequality
+                            constraints.</para>
+                          </listitem>
+                        </varlistentry>
+                      </variablelist>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-simplex0method</term>
+
+                    <listitem>
+                      <para>the method to use to compute the initial simplex.
+                      The first vertex in the simplex is always the initial
+                      guess associated with the -x0 option. The following
+                      methods are available :</para>
+
+                      <variablelist>
+                        <varlistentry>
+                          <term>"given"</term>
+
+                          <listitem>
+                            <para>the coordinates associated with the -coords0
+                            option are used to compute the initial simplex, with
+                            arbitrary number of vertices.</para>
+
+                            <para>This allow the user to setup the initial
+                            simplex by a specific method which is not provided
+                            by the current component (for example with a simplex
+                            computed from a design of experiments). This allows
+                            also to configure the initial simplex so that a
+                            specific behaviour of the algorithm an be reproduced
+                            (for example the Mac Kinnon test case).</para>
+
+                            <para>The given matrix is expected to have n rows
+                            and k columns, where n is the dimension of the
+                            problem and k is the number of vertices.</para>
+                          </listitem>
+                        </varlistentry>
+
+                        <varlistentry>
+                          <term>"axes"</term>
+
+                          <listitem>
+                            <para>the simplex is computed from the coordinate
+                            axes and the length associated with the
+                            -simplex0length option.</para>
+                          </listitem>
+                        </varlistentry>
+
+                        <varlistentry>
+                          <term>"spendley"</term>
+
+                          <listitem>
+                            <para>the simplex is computed so that it is regular
+                            with the length associated with the -simplex0length
+                            option (i.e. all the edges have the same
+                            length).</para>
+                          </listitem>
+                        </varlistentry>
+
+                        <varlistentry>
+                          <term>"pfeffer"</term>
+
+                          <listitem>
+                            <para>the simplex is computed from an heuristic, in
+                            the neighborhood of the initial guess. This initial
+                            simplex depends on the -simplex0deltausual and
+                            -simplex0deltazero.</para>
+                          </listitem>
+                        </varlistentry>
+
+                        <varlistentry>
+                          <term>"randbounds"</term>
+
+                          <listitem>
+                            <para>the simplex is computed from the bounds and a
+                            random number. This option is available only if
+                            bounds are available : if bounds are not available,
+                            an error is generated. This method is usually
+                            associated with Box's algorithm. The number of
+                            vertices in the simplex is taken from the
+                            -boxnbpoints option.</para>
+                          </listitem>
+                        </varlistentry>
+                      </variablelist>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-coords0</term>
+
+                    <listitem>
+                      <para>the coordinates of the vertices of the initial
+                      simplex. If the -simplex0method option is set to
+                      "given", these coordinates are used to compute the
+                      initial simplex.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-simplex0length</term>
+
+                    <listitem>
+                      <para>the length to use when the initial simplex is
+                      computed with the "axes" or "spendley" methods. If the
+                      initial simplex is computed from "spendley" method, the
+                      length is expected to be a scalar value. If the initial
+                      simplex is computed from "axes" method, it may be either
+                      a scalar value or a vector of values, with rank n, where
+                      n is the number of variables.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-simplex0deltausual</term>
+
+                    <listitem>
+                      <para>the relative delta for non-zero parameters in
+                      "pfeffer" method. The default value is 0.05.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-simplex0deltazero</term>
+
+                    <listitem>
+                      <para>the absolute delta for non-zero parameters in
+                      "pfeffer" method. The default value is 0.0075.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-rho</term>
+
+                    <listitem>
+                      <para>the reflection coefficient. This parameter is used
+                      when the -method option is set to "fixed" or "variable".
+                      The default value is 1.0.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-chi</term>
+
+                    <listitem>
+                      <para>the expansion coefficient. This parameter is used
+                      when the -method option is set to "variable". The
+                      default value is 2.0.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-gamma</term>
+
+                    <listitem>
+                      <para>the contraction coefficient. This parameter is
+                      used when the -method option is set to "variable". The
+                      default value is 0.5.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-sigma</term>
+
+                    <listitem>
+                      <para>the shrinkage coefficient. This parameter is used
+                      when the -method option is set to "fixed" or "variable".
+                      The default value is 0.5.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-tolfstdeviationmethod</term>
+
+                    <listitem>
+                      <para>set to "enabled" to enable the termination
+                      criteria based on the standard deviation of the function
+                      values in the simplex. The default value is "disabled".
+                      If this criteria is triggered, the status of the
+                      optimization is set to "tolfstdev".</para>
+
+                      <para>This criteria is suggested by Nelder and
+                      Mead.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-tolfstdeviation</term>
+
+                    <listitem>
+                      <para>the absolute tolerance on standard deviation. The
+                      default value is 0.0.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-tolsimplexizemethod</term>
+
+                    <listitem>
+                      <para>set to "disabled" to disable the tolerance on the
+                      simplex size. The default value is "enabled". If this
+                      criteria is triggered, the status of the optimization is
+                      set to "tolsize".</para>
+
+                      <para>When this criteria is enabled, the values of the
+                      options -tolsimplexizeabsolute and
+                      -tolsimplexizerelative are used in the termination
+                      criteria. The method to compute the size is the
+                      "sigmaplus" method.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-tolsimplexizeabsolute</term>
+
+                    <listitem>
+                      <para>the absolute tolerance on the simplex size. The
+                      default value is 0.0.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-tolsimplexizerelative</term>
+
+                    <listitem>
+                      <para>the relative tolerance on the simplex size. The
+                      default value is %eps.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-tolssizedeltafvmethod</term>
+
+                    <listitem>
+                      <para>set to "enabled" to enable the termination
+                      criteria based on the size of the simplex and the
+                      difference of function value in the simplex. The default
+                      value is "disabled". If this criteria is triggered, the
+                      status of the optimization is set to
+                      "tolsizedeltafv".</para>
+
+                      <para>This termination criteria uses the values of the
+                      options -tolsimplexizeabsolute and -toldeltafv. This
+                      criteria is identical to Matlab's fminsearch.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-toldeltafv</term>
+
+                    <listitem>
+                      <para>the absolute tolerance on the difference between
+                      the highest and the lowest function values.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-kelleystagnationflag</term>
+
+                    <listitem>
+                      <para>set to 1 to enable the termination criteria using
+                      Kelley's stagnation detection, based on sufficient
+                      decrease condition. The default value is 0. If this
+                      criteria is triggered, the status of the optimization is
+                      set to "kelleystagnation".</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-kelleynormalizationflag</term>
+
+                    <listitem>
+                      <para>set to 0 to disable the normalization of the alpha
+                      coefficient in Kelley's stagnation detection, i.e. use
+                      the value of the option -kelleystagnationalpha0 as is.
+                      Default value is 1, i.e. the simplex gradient of the
+                      initial simplex is taken into account in the stagnation
+                      detection.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-kelleystagnationalpha0</term>
+
+                    <listitem>
+                      <para>the parameter used in Kelley's stagnation
+                      detection. The default value is 1.e-4.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-restartflag</term>
+
+                    <listitem>
+                      <para>set to 1 to enable the automatic restart of the
+                      algorithm. Default value is 0.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-restartdetection</term>
+
+                    <listitem>
+                      <para>the method to detect if the automatic restart must
+                      be performed. The following methods are available
+                      :</para>
+
+                      <variablelist>
+                        <varlistentry>
+                          <term>"oneill"</term>
+
+                          <listitem>
+                            <para>the factorial local optimality test by O'Neill
+                            is used. If the test finds a local point which is
+                            better than the computed optimum, a restart is
+                            performed.</para>
+                          </listitem>
+                        </varlistentry>
+
+                        <varlistentry>
+                          <term>"kelley"</term>
+
+                          <listitem>
+                            <para>the sufficient decrease condition by O'Neill
+                            is used. If the test finds that the status of the
+                            optimization is "kelleystagnation", a restart is
+                            performed. This status may be generated if the
+                            -kelleystagnationflag option is set to 1.</para>
+                          </listitem>
+                        </varlistentry>
+                      </variablelist>
+
+                      <para>The default method is "oneill".</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-restartmax</term>
+
+                    <listitem>
+                      <para>the maximum number of restarts, when automatic
+                      restart is enabled via the -restartflag option. Default
+                      value is 3.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-restarteps</term>
+
+                    <listitem>
+                      <para>the absolute epsilon value used to check for
+                      optimality in the factorial O'Neill restart detection.
+                      The default value is %eps.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-restartstep</term>
+
+                    <listitem>
+                      <para>the absolute step length used to check for
+                      optimality in the factorial O'Neill restart detection.
+                      The default value is 1.0.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-restartsimplexmethod</term>
+
+                    <listitem>
+                      <para>the method to compute the initial simplex after a
+                      restart. The following methods are available.</para>
+
+                      <variablelist>
+                        <varlistentry>
+                          <term>"given"</term>
+
+                          <listitem>
+                            <para>the coordinates associated with the -coords0
+                            option are used to compute the initial simplex, with
+                            arbitrary number of vertices.</para>
+
+                            <para>This allow the user to setup the initial
+                            simplex by a specific method which is not provided
+                            by the current component (for example with a simplex
+                            computed from a design of experiments). This allows
+                            also to configure the initial simplex so that a
+                            specific behaviour of the algorithm an be reproduced
+                            (for example the Mac Kinnon test case).</para>
+
+                            <para>The given matrix is expected to have n rows
+                            and k columns, where n is the dimension of the
+                            problem and k is the number of vertices.</para>
+                          </listitem>
+                        </varlistentry>
+
+                        <varlistentry>
+                          <term>"axes"</term>
+
+                          <listitem>
+                            <para>the simplex is computed from the coordinate
+                            axes and the length associated with the
+                            -simplex0length option.</para>
+                          </listitem>
+                        </varlistentry>
+
+                        <varlistentry>
+                          <term>"spendley"</term>
+
+                          <listitem>
+                            <para>the simplex is computed so that it is regular
+                            with the length associated with the -simplex0length
+                            option (i.e. all the edges have the same
+                            length).</para>
+                          </listitem>
+                        </varlistentry>
+
+                        <varlistentry>
+                          <term>"pfeffer"</term>
+
+                          <listitem>
+                            <para>the simplex is computed from an heuristic, in
+                            the neighborhood of the initial guess. This initial
+                            simplex depends on the -simplex0deltausual and
+                            -simplex0deltazero.</para>
+                          </listitem>
+                        </varlistentry>
+
+                        <varlistentry>
+                          <term>"randbounds"</term>
+
+                          <listitem>
+                            <para>the simplex is computed from the bounds and a
+                            random number. This option is available only if
+                            bounds are available : if bounds are not available,
+                            an error is generated. This method is usually
+                            associated with Box's algorithm. The number of
+                            vertices in the simplex is taken from the
+                            -boxnbpoints option.</para>
+                          </listitem>
+                        </varlistentry>
+
+                        <varlistentry>
+                          <term>"oriented"</term>
+
+                          <listitem>
+                            <para>the simplex is computed so that it is
+                            oriented, as suggested by C.T. Kelley.</para>
+                          </listitem>
+                        </varlistentry>
+                      </variablelist>
+
+                      <para>The default method is "oriented".</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-boxnbpoints</term>
+
+                    <listitem>
+                      <para>the number of points in the initial simplex, when
+                      the -restartsimplexmethod option is set to "randbounds".
+                      The default value is so that the number of points is
+                      twice the number of variables of the problem.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-nbineqloops</term>
+
+                    <listitem>
+                      <para>the number of loops to perform in Box and Box-Guin
+                      algorithms to scale the trial point for function
+                      improvement or into the constraints. Default value is
+                      10.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-ineqscaling</term>
+
+                    <listitem>
+                      <para>the scaling coefficient used to scale the trial
+                      point for function improvement or into the constraints.
+                      Default value is 0.5</para>
+                    </listitem>
+                  </varlistentry>
+                </variablelist>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>value</term>
+
+              <listitem>
+                <para>the value.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>value = neldermead_cget (this,key)</term>
+
+        <listitem>
+          <para>Get the value for the given key. If the key is unknown,
+          generates an error.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>key</term>
+
+              <listitem>
+                <para>the name of the key to quiery. The list of available
+                keys is the same as for the neldermead_configure
+                function.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>value = neldermead_get ( this , key )</term>
+
+        <listitem>
+          <para>Get the value for the given key. If the key is unknown,
+          generates an error.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>key</term>
+
+              <listitem>
+                <para>the key to get.</para>
+
+                <para>The following keys are available :</para>
+
+                <variablelist>
+                  <varlistentry>
+                    <term>-funevals</term>
+
+                    <listitem>
+                      <para>the number of function evaluations</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-iterations</term>
+
+                    <listitem>
+                      <para>the number of iterations</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-xopt</term>
+
+                    <listitem>
+                      <para>the x optimum</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-fopt</term>
+
+                    <listitem>
+                      <para>the optimum cost function value</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-historyxopt</term>
+
+                    <listitem>
+                      <para>an array, with nbiter values, containing the
+                      history of x during the iterations.</para>
+
+                      <para>This array is available after optimization if the
+                      history storing was enabled with the -storehistory
+                      option.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-historyfopt</term>
+
+                    <listitem>
+                      <para>an array, with nbiter values, containing the
+                      history of the function value during the
+                      iterations.</para>
+
+                      <para>This array is available after optimization if the
+                      history storing was enabled with the -storehistory
+                      option.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-fx0</term>
+
+                    <listitem>
+                      <para>the function value for the initial guess</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-status</term>
+
+                    <listitem>
+                      <para>a string containing the status of the
+                      optimization. See below for details about the
+                      optimization status.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-historysimplex</term>
+
+                    <listitem>
+                      <para>a matrix containing the history of the simplex
+                      during the iterations. This matrix has rank nbiter x k x
+                      n, where nbiter is the number of iterations, k is the
+                      number of vertices in the simplex and n is the number of
+                      variables.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-simplexopt</term>
+
+                    <listitem>
+                      <para>the optimum simplex. This is a simplex object,
+                      which is suitable for processing with the simplex
+                      interface.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-restartnb</term>
+
+                    <listitem>
+                      <para>the number of actual restarts performed.</para>
+                    </listitem>
+                  </varlistentry>
+                </variablelist>
+
+                <para>Most fields are available only after an optimization has
+                been performed with one call to the neldermead_search
+                method.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = neldermead_display ( this )</term>
+
+        <listitem>
+          <para>Display the current settings in the console.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = neldermead_search ( this )</term>
+
+        <listitem>
+          <para>Performs the optimization associated with the method
+          associated with the -method option and find the optimum.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+
+          <para>If the -restartflag option is enabled, automatic restarts are
+          performed, based on the -restartdetection option.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = neldermead_restart ( this )</term>
+
+        <listitem>
+          <para>Restarts the optimization by updating the simplex and
+          performing a new search.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsection>
+
+  <refsection>
+    <title>The cost function</title>
+
+    <para>The option -function allows to configure the cost function. The cost
+    function is used to compute the cost and the value of the nonlinear
+    inequality constraints.</para>
+
+    <para>In the more general case, the cost function is expected to have the
+    following header</para>
+
+    <programlisting role="example">function y = myfunction ( x , index , data )</programlisting>
+
+    <para>where</para>
+
+    <variablelist>
+      <varlistentry>
+        <term>x</term>
+
+        <listitem>
+          <para>the current point</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>index</term>
+
+        <listitem>
+          <para>optional, an integer representing the value to compute</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>data</term>
+
+        <listitem>
+          <para>optional, a user-defined data.</para>
+
+          <para>This argument is configured with the -costfargument
+          option.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>y</term>
+
+        <listitem>
+          <para>the result</para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+
+    <para>The index input parameter has the following meaning</para>
+
+    <variablelist>
+      <varlistentry>
+        <term>index = 1 (or no index)</term>
+
+        <listitem>
+          <para>the result is the value of the cost function</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>index = 2</term>
+
+        <listitem>
+          <para>the result is the value of the non-linear inequality
+          constraints, as an array of values</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>index = 3</term>
+
+        <listitem>
+          <para>the result is an array, which content is the following. At
+          index #1, the value of the cost function. At index #2 to the end,
+          the list of values of the nonlinear inequality constraints.</para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+
+    <para>In the most simple case, the cost function is expected to have the
+    following header</para>
+
+    <programlisting role="example">function y = myfunction (x)</programlisting>
+
+    <para>where x is the current point and y is the value of the cost. This
+    case is associated with an unconstrained problem without any additionnal
+    parameter.</para>
+  </refsection>
+
+  <refsection>
+    <title>The output function</title>
+
+    <para>The option -outputcommand allows to configure a command which is
+    called back at the start of the optimization, at each iteration and at the
+    end of the optimization.</para>
+
+    <para>The output function must have the following header</para>
+
+    <programlisting role="example">function outputcmd ( state , data , myobj )</programlisting>
+
+    <para>where</para>
+
+    <variablelist>
+      <varlistentry>
+        <term>state</term>
+
+        <listitem>
+          <para>a string representing the current state of the algorithm.
+          Available values are "init", "iter", "done".</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>data</term>
+
+        <listitem>
+          <para>a tlist containing at least the following entries</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>x</term>
+
+              <listitem>
+                <para>the current optimum</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>fval</term>
+
+              <listitem>
+                <para>the current function value</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>iteration</term>
+
+              <listitem>
+                <para>the current iteration index</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>funccount</term>
+
+              <listitem>
+                <para>the number of function evaluations</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>myobj</term>
+
+        <listitem>
+          <para>a user-defined parameter.</para>
+
+          <para>This input parameter is defined with the -outputcommandarg
+          option.</para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+
+    <para>The output function may be used when debugging the specialized
+    optimization algorithm, so that a verbose logging is produced. It may also
+    be used to write one or several report files in a specialized format
+    (ASCII, LaTeX, Excel, Hdf5, etc...). The user-defined parameter may be
+    used in that case to store file names or logging options.</para>
+
+    <para>The data tlist argument may contain more fields than the current
+    presented ones. These additionnal fields may contain values which are
+    specific to the specialized algorithm, such as the simplex in a
+    Nelder-Mead method, the gradient of the cost function in a BFGS method,
+    etc...</para>
+  </refsection>
+
+  <refsection>
+    <title>Termination</title>
+
+    <para>The current component takes into account for several generic
+    termination criterias. Specialized termination criterias should be
+    implemented in specialized optimization algorithms, by calling the
+    optimization_termination function and adding external criterias, rather
+    than by modification of this function.</para>
+
+    <para>The optimization_terminate function uses a set of rules to compute
+    if the termination occurs, which leads to an optimization status which is
+    equal to one of the following : "continue", "maxiter", "maxfunevals",
+    "tolf", "tolx", "tolfstdev", "tolsize", "tolsizedeltafv",
+    "kelleystagnation". The set of rules is the following.</para>
+
+    <itemizedlist>
+      <listitem>
+        <para>By default, the status is "continue" and the terminate flag is
+        0.</para>
+      </listitem>
+
+      <listitem>
+        <para>The number of iterations is examined and compared to the
+        -maxiter option : if the following condition</para>
+
+        <programlisting role="example">iterations &gt;= maxiter</programlisting>
+
+        <para>is true, then the status is set to "maxiter" and terminate is
+        set to 1.</para>
+      </listitem>
+
+      <listitem>
+        <para>The number of function evaluations and compared to the
+        -maxfunevals option is examined : if the following condition</para>
+
+        <programlisting role="example">funevals &gt;= maxfunevals</programlisting>
+
+        <para>is true, then the status is set to "maxfuneval" and terminate is
+        set to 1.</para>
+      </listitem>
+
+      <listitem>
+        <para>The tolerance on function value is examined depending on the
+        value of the -tolfunmethod.</para>
+
+        <variablelist>
+          <varlistentry>
+            <term>"disabled"</term>
+
+            <listitem>
+              <para>then the criteria is just ignored.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>"enabled"</term>
+
+            <listitem>
+              <para>if the following condition</para>
+
+              <programlisting role="example">abs(currentfopt) &lt; tolfunrelative * abs(previousfopt) + tolfunabsolute</programlisting>
+
+              <para>is true, then the status is set to "tolf" and terminate is
+              set to 1.</para>
+            </listitem>
+          </varlistentry>
+        </variablelist>
+
+        <para>The relative termination criteria on the function value works
+        well if the function value at optimum is near zero. In that case, the
+        function value at initial guess fx0 may be used as
+        previousfopt.</para>
+
+        <para>The absolute termination criteria on the function value works if
+        the user has an accurate idea of the optimum function value.</para>
+      </listitem>
+
+      <listitem>
+        <para>The tolerance on x is examined depending on the value of the
+        -tolxmethod.</para>
+
+        <variablelist>
+          <varlistentry>
+            <term>"disabled"</term>
+
+            <listitem>
+              <para>then the criteria is just ignored.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>"enabled"</term>
+
+            <listitem>
+              <para>if the following condition</para>
+
+              <programlisting role="example">norm(currentxopt - previousxopt) &lt; tolxrelative * norm(currentxopt) + tolxabsolute</programlisting>
+
+              <para>is true, then the status is set to "tolx" and terminate is
+              set to 1.</para>
+            </listitem>
+          </varlistentry>
+        </variablelist>
+
+        <para>The relative termination criteria on the function value works
+        well if x at optimum is different from zero. In that case, the
+        condition measures the distance between two iterates.</para>
+
+        <para>The absolute termination criteria on the function value works if
+        the user has an accurate idea of the scale of the optimum x. If the
+        optimum x is near 0, the relative tolerance will not work and the
+        absolute tolerance is more appropriate.</para>
+      </listitem>
+
+      <listitem>
+        <para>The absolute tolerance on standard deviation of the function
+        value is examined depending on the value of the -tolfstdeviationmethod
+        option.</para>
+
+        <variablelist>
+          <varlistentry>
+            <term>"disabled"</term>
+
+            <listitem>
+              <para>then the criteria is just ignored.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>"enabled"</term>
+
+            <listitem>
+              <para>if the following condition</para>
+
+              <programlisting role="example">st_deviation(fv) &lt; tolfstdeviation</programlisting>
+
+              <para>is true where fv is an array containing the function
+              values in the simplex, then the status is set to "tolfstdev" and
+              terminate is set to 1.</para>
+            </listitem>
+          </varlistentry>
+        </variablelist>
+      </listitem>
+
+      <listitem>
+        <para>The absolute tolerance on simplex size is examined depending on
+        the value of the -tolsimplexizemethod option.</para>
+
+        <variablelist>
+          <varlistentry>
+            <term>"disabled"</term>
+
+            <listitem>
+              <para>then the criteria is just ignored.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>"enabled"</term>
+
+            <listitem>
+              <para>if the following condition</para>
+
+              <programlisting role="example">ssize &lt; tolsimplexizerelative * simplexsize0 + tolsimplexizeabsolute</programlisting>
+
+              <para>is true where simplexsize0 is the size of the simplex at
+              iteration 0, then the status is set to "tolsize" and terminate
+              is set to 1.</para>
+            </listitem>
+          </varlistentry>
+        </variablelist>
+      </listitem>
+
+      <listitem>
+        <para>The absolute tolerance on simplex size and absolute difference
+        of function value is examined depending on the value of the
+        -tolssizedeltafvmethod option.</para>
+
+        <variablelist>
+          <varlistentry>
+            <term>"disabled"</term>
+
+            <listitem>
+              <para>then the criteria is just ignored.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>"enabled"</term>
+
+            <listitem>
+              <para>if both the following conditions</para>
+
+              <programlisting role="example">ssize &lt; tolsimplexizeabsolute</programlisting>
+
+              <programlisting role="example">shiftfv &lt; toldeltafv</programlisting>
+
+              <para>is true where ssize is the current simplex size and
+              shiftfv is the absolute value of the difference of function
+              value between the highest and lowest vertices, then the status
+              is set to "tolsizedeltafv" and terminate is set to 1.</para>
+            </listitem>
+          </varlistentry>
+        </variablelist>
+      </listitem>
+
+      <listitem>
+        <para>The stagnation condition based on Kelley sufficient decrease
+        condition is examined depending on the value of the
+        -kelleystagnationflag option.</para>
+
+        <variablelist>
+          <varlistentry>
+            <term>"disabled"</term>
+
+            <listitem>
+              <para>then the criteria is just ignored.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>"enabled"</term>
+
+            <listitem>
+              <para>if the following condition</para>
+
+              <programlisting role="example">newfvmean &gt;= oldfvmean - alpha * sg' * sg</programlisting>
+
+              <para>is true where newfvmean (resp. oldfvmean) is the function
+              value average in the current iteration (resp. in the previous
+              iteration), then the status is set to "kelleystagnation" and
+              terminate is set to 1. Here, alpha is a non-dimensional
+              coefficient and sg is the simplex gradient.</para>
+            </listitem>
+          </varlistentry>
+        </variablelist>
+      </listitem>
+    </itemizedlist>
+  </refsection>
+
+  <refsection>
+    <title>Kelley's stagnation detection</title>
+
+    <para>The stagnation detection criteria suggested by Kelley is based on a
+    sufficient decrease condition, which requires a parameter alpha &gt; 0 to
+    be defined. The -kelleynormalizationflag option allows to configure the
+    method to use to compute this alpha parameter : two methods are available,
+    where each method corresponds to a different paper by Kelley :</para>
+
+    <variablelist>
+      <varlistentry>
+        <term>constant</term>
+
+        <listitem>
+          <para>In "Detection and Remediation of Stagnation in the
+          Nelder--Mead Algorithm Using a Sufficient Decrease Condition",
+          Kelley uses a constant alpha, with the suggested value 1.e-4, which
+          is is typical choice for line search method.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>normalized</term>
+
+        <listitem>
+          <para>in "Iterative Methods for Optimization", Kelley uses a
+          normalized alpha, computed from the following formula</para>
+
+          <programlisting role="example">alpha = alpha0 * sigma0 / nsg</programlisting>
+
+          <para>where sigma0 is the size of the initial simplex and nsg is the
+          norm of the simplex gradient for the initial guess point.</para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsection>
+
+  <refsection>
+    <title>O'Neil factorial optimality test</title>
+
+    <para>In "Algorithm AS47 - Function minimization using a simplex
+    procedure", R. O'Neil presents a fortran 77 implementation of the simplex
+    method. A factorial test is used to check if the computed optimum point is
+    a local minimum. If the -restartdetection option is set to "oneill", that
+    factorial test is used to see if a restart should be performed.</para>
+  </refsection>
+
+  <refsection>
+    <title>TODO</title>
+
+    <variablelist>
+      <varlistentry>
+        <term>Box-Guin algorithm</term>
+
+        <listitem>
+          <para>add the Box-Guin algoritm as a 4th method</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>add examples</term>
+
+        <listitem>
+          <para>add the optimization of the Rosenbrock test case</para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsection>
+
+  <refsection>
+    <title>Bibliography</title>
+
+    <para>"Sequential Application of Simplex Designs in Optimisation and
+    Evolutionary Operation", Spendley, W. and Hext, G. R. and Himsworth, F.
+    R., American Statistical Association and American Society for Quality,
+    1962</para>
+
+    <para>"A Simplex Method for Function Minimization", Nelder, J. A. and
+    Mead, R., The Computer Journal, 1965</para>
+
+    <para>"A New Method of Constrained Optimization and a Comparison With
+    Other Methods", M. J. Box, The Computer Journal 1965 8(1):42-52, 1965 by
+    British Computer Society</para>
+
+    <para>"Discussion and correspondence: modification of the complex method
+    of constrained optimization", J. A. Guin, The Computer Journal,
+    1968</para>
+
+    <para>"Detection and Remediation of Stagnation in the Nelder--Mead
+    Algorithm Using a Sufficient Decrease Condition", Kelley C. T., SIAM J. on
+    Optimization, 1999</para>
+
+    <para>"Iterative Methods for Optimization", C. T. Kelley, SIAM Frontiers
+    in Applied Mathematics, 1999</para>
+
+    <para>"Algorithm AS47 - Function minimization using a simplex procedure",
+    O'Neill, R., Applied Statistics, 1971</para>
+  </refsection>
+
+  <refsection>
+    <title>Authors</title>
+
+    <para>Michael Baudin, 2008-2009</para>
+  </refsection>
+</refentry>
diff --git a/scilab/modules/optimization/help/en_US/neldermead/overview.xml b/scilab/modules/optimization/help/en_US/neldermead/overview.xml
new file mode 100644 (file)
index 0000000..02b54b9
--- /dev/null
@@ -0,0 +1,340 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ * Ajouter ici d'éventuels commentaires sur le fichier XML
+-->
+<refentry version="5.0-subset Scilab" xml:id="mce_display" xml:lang="fr"
+          xmlns="http://docbook.org/ns/docbook"
+          xmlns:xlink="http://www.w3.org/1999/xlink"
+          xmlns:svg="http://www.w3.org/2000/svg"
+          xmlns:ns4="http://www.w3.org/1999/xhtml"
+          xmlns:mml="http://www.w3.org/1998/Math/MathML"
+          xmlns:db="http://docbook.org/ns/docbook">
+  <info>
+    <pubdate>$LastChangedDate: 16-12-2008 $</pubdate>
+  </info>
+
+  <refnamediv>
+    <refname>overview</refname>
+
+    <refpurpose>An overview of the Nelder-Mead toolbox.</refpurpose>
+  </refnamediv>
+
+  <refsection>
+    <title>Purpose</title>
+
+    <para>The goal of this toolbox is to provide a Nelder-Mead direct search
+    optimization method. That Nelder-Mead algorithm may be used in the
+    following optimization context :<itemizedlist>
+        <listitem>
+          <para>there is no need to provide the derivatives of the objective
+          function,</para>
+        </listitem>
+
+        <listitem>
+          <para>the number of parameters is small (up to 10-20),</para>
+        </listitem>
+
+        <listitem>
+          <para>there are bounds and/or non linear constraints.</para>
+        </listitem>
+      </itemizedlist></para>
+  </refsection>
+
+  <refsection>
+    <title>Design</title>
+
+    <para>The internal design of the system is based on the following
+    components :</para>
+
+    <itemizedlist>
+      <listitem>
+        <para>&#8220;neldermead&#8221; provides various Nelder-Mead variants
+        and manages for Nelder-Mead specific settings, such as the method to
+        compute the initial simplex, the specific termination criteria,</para>
+      </listitem>
+
+      <listitem>
+        <para>&#8220;fminsearch&#8221; provides a Scilab commands which aims
+        at behaving as Matlab's fminsearch. Specific terminations criteria,
+        initial simplex and auxiliary settings are automatically configured so
+        that the behaviour of Matlab's fminsearch is exactly
+        reproduced.</para>
+      </listitem>
+
+      <listitem>
+        <para>&#8220;optimset&#8221;, &#8220;optimget&#8221; provides Scilab
+        commands to emulate their Matlab counterparts.</para>
+      </listitem>
+
+      <listitem>
+        <para>&#8220;nmplot&#8221; provides a high-level component which
+        provides directly output pictures for Nelder-Mead algorithm.</para>
+      </listitem>
+    </itemizedlist>
+
+    <para>The current toolbox is based on (and therefore requires) the
+    following toolboxes </para>
+
+    <itemizedlist>
+      <listitem>
+        <para>&#8220;optimbase&#8221; provides an abstract class for a general
+        optimization component, including the number of variables, the minimum
+        and maximum bounds, the number of non linear inequality constraints,
+        the loggin system, various termination criteria, the cost function,
+        etc...</para>
+      </listitem>
+
+      <listitem>
+        <para>&#8220;optimsimplex&#8221; provides a class to manage a simplex
+        made of an arbitrary number of vertices, including the computation of
+        a simplex by various methods (axes, regular, Pfeffer's, randomized
+        bounds), the computation of the size by various methods (diameter,
+        sigma +, sigma-, etc...),</para>
+      </listitem>
+    </itemizedlist>
+  </refsection>
+
+  <refsection>
+    <title>Features</title>
+
+    <para>The following is a list of features the Nelder-Mead prototype
+    algorithm currently provides :</para>
+
+    <itemizedlist>
+      <listitem>
+        <para>Manage various simplex initializations</para>
+
+        <itemizedlist>
+          <listitem>
+            <para>initial simplex given by user,</para>
+          </listitem>
+
+          <listitem>
+            <para>initial simplex computed with a length and along the
+            coordinate axes,</para>
+          </listitem>
+
+          <listitem>
+            <para>initial regular simplex computed with Spendley et al.
+            formula</para>
+          </listitem>
+
+          <listitem>
+            <para>initial simplex computed by a small perturbation around the
+            initial guess point</para>
+          </listitem>
+        </itemizedlist>
+      </listitem>
+
+      <listitem>
+        <para>Manage cost function</para>
+
+        <itemizedlist>
+          <listitem>
+            <para>optionnal additionnal argument</para>
+          </listitem>
+
+          <listitem>
+            <para>direct communication of the task to perform : cost function
+            or inequality constraints</para>
+          </listitem>
+        </itemizedlist>
+      </listitem>
+
+      <listitem>
+        <para>Manage various termination criteria, including maximum number of
+        iterations, tolerance on function value (relative or absolute),
+        <itemizedlist>
+            <listitem>
+              <para>tolerance on x (relative or absolute),</para>
+            </listitem>
+
+            <listitem>
+              <para>tolerance on standard deviation of function value
+              (original termination criteria in [3]),</para>
+            </listitem>
+
+            <listitem>
+              <para>maximum number of evaluations of cost function,</para>
+            </listitem>
+
+            <listitem>
+              <para>absolute or relative simplex size,</para>
+            </listitem>
+          </itemizedlist></para>
+      </listitem>
+
+      <listitem>
+        <para>Manage the history of the convergence, including</para>
+
+        <itemizedlist>
+          <listitem>
+            <para>history of function values,</para>
+          </listitem>
+
+          <listitem>
+            <para>history of optimum point,</para>
+          </listitem>
+
+          <listitem>
+            <para>history of simplices,</para>
+          </listitem>
+
+          <listitem>
+            <para>history of termination criterias,</para>
+          </listitem>
+        </itemizedlist>
+      </listitem>
+
+      <listitem>
+        <para>Provide a plot command which allows to graphically see the
+        history of the simplices toward the optimum,</para>
+      </listitem>
+
+      <listitem>
+        <para>Provide query features for the status of the optimization
+        process number of iterations, number of function evaluations, status
+        of execution, function value at initial point, function value at
+        optimal point, etc...</para>
+      </listitem>
+
+      <listitem>
+        <para>Spendley et al. fixed shaped algorithm,</para>
+      </listitem>
+
+      <listitem>
+        <para>Kelley restart based on simplex gradient,</para>
+      </listitem>
+
+      <listitem>
+        <para>O'Neill restart based on factorial search around optimum,</para>
+      </listitem>
+
+      <listitem>
+        <para>Box-like method managing bounds and nonlinear inequality
+        constraints based on arbitrary number of vertices in the
+        simplex.</para>
+      </listitem>
+    </itemizedlist>
+  </refsection>
+
+  <refsection>
+    <title>TODO</title>
+
+    <para><itemizedlist>
+        <listitem>
+          <para>implement "optimget"</para>
+        </listitem>
+
+        <listitem>
+          <para>provide the original Box method</para>
+        </listitem>
+
+        <listitem>
+          <para>implement parabolic line search</para>
+        </listitem>
+      </itemizedlist></para>
+  </refsection>
+
+  <refsection>
+    <title>Example : Optimizing the Rosenbrock function</title>
+
+    <para>In the following example, one searches the minimum of the 2D
+    Rosenbrock function. 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.</para>
+
+    <programlisting role="example">
+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);
+    </programlisting>
+  </refsection>
+
+  <refsection>
+    <title>Authors</title>
+
+    <para>Michael Baudin, 2008-2009</para>
+  </refsection>
+
+  <refsection>
+    <title>Bibliography</title>
+
+    <para>&#8220;Sequential Application of Simplex Designs in Optimisation and
+    Evolutionary Operation&#8221;, Spendley, W. and Hext, G. R. and Himsworth,
+    F. R., American Statistical Association and American Society for Quality,
+    1962</para>
+
+    <para>&#8220;A Simplex Method for Function Minimization&#8221;, Nelder, J.
+    A. and Mead, R., The Computer Journal, 1965</para>
+
+    <para>"A New Method of Constrained Optimization and a Comparison With
+    Other Methods", M. J. Box, The Computer Journal 1965 8(1):42-52, 1965 by
+    British Computer Society</para>
+
+    <para>&#8220;Convergence Properties of the Nelder--Mead Simplex Method in
+    Low Dimensions&#8221;, Jeffrey C. Lagarias and James A. Reeds and Margaret
+    H. Wright and Paul E. Wright, SIAM Journal on Optimization, 1998</para>
+
+    <para>&#8220;Compact numerical methods for computers : linear algebra and
+    function minimisation&#8221;, Nash, J. C., Hilger, Bristol, 1979</para>
+
+    <para>&#8220;Iterative Methods for Optimization&#8221;, C. T. Kelley,
+    1999</para>
+
+    <para>&#8220;Iterative Methods for Optimization: Matlab Codes&#8221;,
+    http://www4.ncsu.edu/~ctk/matlab_darts.html</para>
+
+    <para>&#8220;Sequential Simplex Optimization: A Technique for Improving
+    Quality and Productivity in Research, Development, and
+    Manufacturing&#8221;, Walters, Fred H. and Jr, Lloyd R. and Morgan,
+    Stephen L. and Deming, Stanley N., 1991</para>
+
+    <para>&#8220;Numerical Recipes in C, Second Edition&#8221;, W. H. Press
+    and Saul A. Teukolsky and William T. Vetterling and Brian P. Flannery,
+    1992</para>
+
+    <para>&#8220;Detection and Remediation of Stagnation in the Nelder--Mead
+    Algorithm Using a Sufficient Decrease Condition&#8221;, SIAM J. on
+    Optimization, Kelley,, C. T., 1999</para>
+
+    <para>Matlab &#8211; fminsearch ,
+    http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/fminsearch.html</para>
+
+    <para>GAMS, A19A20 - description,
+    http://gams.nist.gov/serve.cgi/Module/NASHLIB/A19A20/11238/</para>
+
+    <para>asa047.f,
+    http://people.sc.fsu.edu/~burkardt/f77_src/asa047/asa047.f</para>
+
+    <para>optim1.f,
+    http://www.stat.uconn.edu/~mhchen/survbook/example51/optim1.f</para>
+
+    <para>as47,f, http://lib.stat.cmu.edu/apstat/47</para>
+
+    <para>&#8220;Algorithm AS47 - Function minimization using a simplex
+    procedure, O'Neill, R., 1971, Applied Statistics</para>
+  </refsection>
+</refentry>
diff --git a/scilab/modules/optimization/help/en_US/optimbase/optimbase.xml b/scilab/modules/optimization/help/en_US/optimbase/optimbase.xml
new file mode 100644 (file)
index 0000000..fd72514
--- /dev/null
@@ -0,0 +1,1527 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ * Ajouter ici d'éventuels commentaires sur le fichier XML
+-->
+<refentry version="5.0-subset Scilab" xml:id="montecarlo_run" xml:lang="fr"
+          xmlns="http://docbook.org/ns/docbook"
+          xmlns:xlink="http://www.w3.org/1999/xlink"
+          xmlns:svg="http://www.w3.org/2000/svg"
+          xmlns:ns4="http://www.w3.org/1999/xhtml"
+          xmlns:mml="http://www.w3.org/1998/Math/MathML"
+          xmlns:db="http://docbook.org/ns/docbook">
+  <info>
+    <pubdate>$LastChangedDate: 16-12-2008 $</pubdate>
+  </info>
+
+  <refnamediv>
+    <refname>optimbase</refname>
+
+    <refpurpose>Provides an abstract class for a general optimization
+    component.</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <title>SYNOPSIS</title>
+
+    <synopsis>
+newobj = optimbase_new ()
+this = optimbase_destroy (this)
+this = optimbase_configure (this,key,value)
+value = optimbase_cget (this,key)
+value = optimbase_get (this,key)
+this = optimbase_set ( this , key , value )
+[ this , isok ] = optimbase_checkbounds ( this )
+[ opt , isok ] = optimbase_checkx0 ( this )
+this = optimbase_display ( this )
+[ this , result ] = optimbase_function ( this , x , index )
+[ this , hasbounds ] = optimbase_hasbounds ( this )
+value = optimbase_histget ( this , iter , key )
+this = optimbase_histset ( this , iter , key , value )
+this = optimbase_incriter ( this )
+[ this , isfeasible ] = optimbase_isfeasible ( this , x )
+this = optimbase_log (this,msg)
+optimbase_outputcmd ( this , state , data )
+data = optimbase_outstruct ( this )
+[ this , p ] = optimbase_proj2bnds ( this ,  x )
+this = optimbase_stoplog ( this , msg )
+[this , terminate , status] = optimbase_terminate (this , previousfopt , currentfopt , previousxopt , currentxopt )
+</synopsis>
+  </refsynopsisdiv>
+
+  <refsection>
+    <title>Purpose</title>
+
+    <para>The goal of this toolbox is to provide a building block for
+    optimization methods. The goal is to provide a building block for a large
+    class of specialized optimization methods. This component manages
+    <itemizedlist>
+        <listitem>
+          <para>the number of variables,</para>
+        </listitem>
+
+        <listitem>
+          <para>the minimum and maximum bounds,</para>
+        </listitem>
+
+        <listitem>
+          <para>the number of non linear inequality constraints,</para>
+        </listitem>
+
+        <listitem>
+          <para>the cost function,</para>
+        </listitem>
+
+        <listitem>
+          <para>the logging system,</para>
+        </listitem>
+
+        <listitem>
+          <para>various termination criteria,</para>
+        </listitem>
+
+        <listitem>
+          <para>etc...</para>
+        </listitem>
+      </itemizedlist></para>
+  </refsection>
+
+  <refsection>
+    <title>Design</title>
+
+    <para>This toolbox is designed with Oriented Object ideas in mind.</para>
+  </refsection>
+
+  <refsection>
+    <title>Features</title>
+
+    <para>The following is a list of features the Optimbase toolbox currently
+    provides :</para>
+
+    <itemizedlist>
+      <listitem>
+        <para>Manage cost function</para>
+
+        <itemizedlist>
+          <listitem>
+            <para>optionnal additionnal argument</para>
+          </listitem>
+
+          <listitem>
+            <para>direct communication of the task to perform : cost function
+            or inequality constraints</para>
+          </listitem>
+        </itemizedlist>
+      </listitem>
+
+      <listitem>
+        <para>Manage various termination criteria, including <itemizedlist>
+            <listitem>
+              <para>maximum number of iterations,</para>
+            </listitem>
+
+            <listitem>
+              <para>tolerance on function value (relative or absolute),</para>
+            </listitem>
+
+            <listitem>
+              <para>tolerance on x (relative or absolute),</para>
+            </listitem>
+
+            <listitem>
+              <para>maximum number of evaluations of cost function,</para>
+            </listitem>
+          </itemizedlist></para>
+      </listitem>
+
+      <listitem>
+        <para>Manage the history of the convergence, including</para>
+
+        <itemizedlist>
+          <listitem>
+            <para>history of function values,</para>
+          </listitem>
+
+          <listitem>
+            <para>history of optimum point.</para>
+          </listitem>
+        </itemizedlist>
+      </listitem>
+
+      <listitem>
+        <para>Provide query features for</para>
+
+        <itemizedlist>
+          <listitem>
+            <para>the status of the optimization process,</para>
+          </listitem>
+
+          <listitem>
+            <para>the number of iterations,</para>
+          </listitem>
+
+          <listitem>
+            <para>the number of function evaluations,</para>
+          </listitem>
+
+          <listitem>
+            <para>function value at initial point,</para>
+          </listitem>
+
+          <listitem>
+            <para>function value at optimal point,</para>
+          </listitem>
+
+          <listitem>
+            <para>the optimum parameters,</para>
+          </listitem>
+
+          <listitem>
+            <para>etc...</para>
+          </listitem>
+        </itemizedlist>
+      </listitem>
+    </itemizedlist>
+  </refsection>
+
+  <refsection>
+    <title>Description</title>
+
+    <para>This set of commands allows to manage an abstract optimization
+    method. The goal is to provide a building block for a large class of
+    specialized optimization methods. This component manages the number of
+    variables, the minimum and maximum bounds, the number of non linear
+    inequality constraints, the logging system, various termination criteria,
+    the cost function, etc...</para>
+
+    <para>The optimization problem to solve is the following</para>
+
+    <programlisting role="example">min f(x)
+l_i &lt;= x_i &lt;= h_i, i = 1,n
+g_i(x) &lt;= 0, i = 1,nbineq</programlisting>
+
+    <para>where</para>
+
+    <variablelist>
+      <varlistentry>
+        <term>n</term>
+
+        <listitem>
+          <para>number of variables</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>nbineq</term>
+
+        <listitem>
+          <para>number of inequality constraints</para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsection>
+
+  <refsection>
+    <title>Functions</title>
+
+    <para>The following functions are available.</para>
+
+    <variablelist>
+      <varlistentry>
+        <term>newobj = optimbase_new ()</term>
+
+        <listitem>
+          <para>Creates a new optimization object.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>newobj</term>
+
+              <listitem>
+                <para>The new object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = optimbase_destroy (this)</term>
+
+        <listitem>
+          <para>Destroy the given object.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = optimbase_configure (this,key,value)</term>
+
+        <listitem>
+          <para>Configure the current object with the given value for the
+          given key.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>key</term>
+
+              <listitem>
+                <para>the key to configure. The following keys are
+                available.</para>
+
+                <variablelist>
+                  <varlistentry>
+                    <term>-verbose</term>
+
+                    <listitem>
+                      <para>set to 1 to enable verbose logging. (default is
+                      0)</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-verbosetermination</term>
+
+                    <listitem>
+                      <para>set to 1 to enable verbose termination logging.
+                      (default is 0)</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-x0</term>
+
+                    <listitem>
+                      <para>the initial guess.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-maxfunevals</term>
+
+                    <listitem>
+                      <para>the maximum number of function evalutations
+                      (default is 100). If this criteria is triggered, the
+                      status of the optimization is set to
+                      "maxfuneval".</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-maxiter</term>
+
+                    <listitem>
+                      <para>the maximum number of iterations (default is 100).
+                      If this criteria is triggered, the status of the
+                      optimization is set to "maxiter".</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-tolfunabsolute</term>
+
+                    <listitem>
+                      <para>the absolute tolerance for the function value
+                      (default is 0.0).</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-tolfunrelative</term>
+
+                    <listitem>
+                      <para>the relative tolerance for the function value
+                      (default is %eps).</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-tolfunmethod</term>
+
+                    <listitem>
+                      <para>the method used for the tolerance on function
+                      value in the termination criteria.</para>
+
+                      <para>The following values are available : "enabled",
+                      "disabled" (default is "disabled"). If this criteria is
+                      triggered, the status of the optimization is set to
+                      "tolf".</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-tolxabsolute</term>
+
+                    <listitem>
+                      <para>the absolute tolerance on x (default is
+                      0.0).</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-tolxrelative</term>
+
+                    <listitem>
+                      <para>the relative tolerance on x (default is
+                      %eps).</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-tolxmethod</term>
+
+                    <listitem>
+                      <para>the method used for the tolerance on x in the
+                      termination criteria.</para>
+
+                      <para>The following values are available : "enabled",
+                      "disabled" (default is "enabled"). If this criteria is
+                      triggered, the status of the optimization is set to
+                      "tolx".</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-function</term>
+
+                    <listitem>
+                      <para>the objective function, which computes the value
+                      of the cost and the non linear constraints, if
+                      any.</para>
+
+                      <para>See below for the details of the communication
+                      between the optimization system and the cost
+                      function.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-costfargument</term>
+
+                    <listitem>
+                      <para>an additionnal argument, passed to the cost
+                      function.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-outputcommand</term>
+
+                    <listitem>
+                      <para>a command which is called back for output.</para>
+
+                      <para>See below for the details of the communication
+                      between the optimization system and the output command
+                      function.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-outputcommandarg</term>
+
+                    <listitem>
+                      <para>an additionnal argument, passed to the output
+                      command.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-numberofvariables</term>
+
+                    <listitem>
+                      <para>the number of variables to optimize (default is
+                      0).</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-storehistory</term>
+
+                    <listitem>
+                      <para>set to 1 to enable the history storing (default is
+                      0).</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-boundsmin</term>
+
+                    <listitem>
+                      <para>the minimum bounds for the parameters, as an array
+                      of values (default is empty, i.e. there are no
+                      bounds).</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-boundsmax</term>
+
+                    <listitem>
+                      <para>the maximum bounds for the parameters, as an array
+                      of values (default is empty, i.e. there are no
+                      bounds).</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-nbineqconst</term>
+
+                    <listitem>
+                      <para>the number of inequality constraints (default is
+                      0)</para>
+                    </listitem>
+                  </varlistentry>
+                </variablelist>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>value</term>
+
+              <listitem>
+                <para>the value.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>value = optimbase_cget (this,key)</term>
+
+        <listitem>
+          <para>Get the value for the given key. If the key is unknown,
+          generates an error.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>key</term>
+
+              <listitem>
+                <para>the name of the key to quiery. The list of available
+                keys is the same as for the optimbase_configure
+                function.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>[ this , isok ] = optimbase_checkbounds ( this )</term>
+
+        <listitem>
+          <para>Check if the bounds are consistent and puts an error message
+          if not. One could generate an error, but errors are not testable
+          with the current system.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>[ opt , isok ] = optimbase_checkx0 ( this )</term>
+
+        <listitem>
+          <para>Returns %T if the initial guess is consistent with the bounds
+          and the non linear inequality constraints, if any.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = optimbase_display ( this )</term>
+
+        <listitem>
+          <para>Display the current settings in the console.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>[ this , result ] = optimbase_function ( this , x , index
+        )</term>
+
+        <listitem>
+          <para>Call the cost function and return the value.</para>
+
+          <para>If a cost function additionnal argument is defined in current
+          object, pass it to the function. If an index is defined as input
+          argument, pass it to the function, always as second argument.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>x</term>
+
+              <listitem>
+                <para>the current point</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>index</term>
+
+              <listitem>
+                <para>optional, the value to compute.</para>
+
+                <para>See below in the section "Cost function" for details on
+                this index.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = optimbase_set ( this , key , value )</term>
+
+        <listitem>
+          <para>Set the value for the given key. If the key is unknown,
+          generates an error.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>key</term>
+
+              <listitem>
+                <para>the key to set</para>
+
+                <para>The following keys are available :</para>
+
+                <variablelist>
+                  <varlistentry>
+                    <term>-funevals</term>
+
+                    <listitem>
+                      <para>the number of function evaluations</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-iterations</term>
+
+                    <listitem>
+                      <para>the number of iterations</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-xopt</term>
+
+                    <listitem>
+                      <para>the x optimum</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-fopt</term>
+
+                    <listitem>
+                      <para>the optimum cost function value</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-historyxopt</term>
+
+                    <listitem>
+                      <para>an array, with nbiter values, containing the
+                      history of x during the iterations.</para>
+
+                      <para>This array is available after optimization if the
+                      history storing was enabled with the -storehistory
+                      option.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-historyfopt</term>
+
+                    <listitem>
+                      <para>an array, with nbiter values, containing the
+                      history of the function value during the
+                      iterations.</para>
+
+                      <para>This array is available after optimization if the
+                      history storing was enabled with the -storehistory
+                      option.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-fx0</term>
+
+                    <listitem>
+                      <para>the function value for the initial guess</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>-status</term>
+
+                    <listitem>
+                      <para>a string containing the status of the
+                      optimization</para>
+                    </listitem>
+                  </varlistentry>
+                </variablelist>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>value</term>
+
+              <listitem>
+                <para>the value to set</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>value = optimbase_get (this,key)</term>
+
+        <listitem>
+          <para>Get the value for the given key. If the key is unknown,
+          generates an error. This command corresponds with options which are
+          not available directly to the optimbase_configure function, but are
+          computed internally.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>key</term>
+
+              <listitem>
+                <para>the name of the key to quiery.</para>
+
+                <para>The list of available keys is the same as the
+                optimbase_set function.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>[ this , hasbounds ] = optimbase_hasbounds ( this )</term>
+
+        <listitem>
+          <para>Returns %T if current problem has bounds.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = optimbase_histset ( this , iter , key , value )</term>
+
+        <listitem>
+          <para>Set the history value at given iteration for the given key. If
+          the key is unknown, generates an error.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>iter</term>
+
+              <listitem>
+                <para>the iteration number to get</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>key</term>
+
+              <listitem>
+                <para>the name of the key to quiery.</para>
+
+                <para>The list of available keys is the following : "-xopt",
+                "-fopt".</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>value</term>
+
+              <listitem>
+                <para>the value to set</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>value = optimbase_histget ( this , iter , key )</term>
+
+        <listitem>
+          <para>Returns the history value at the given iteration number for
+          the given key. If the key is unknown, generates an error.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>iter</term>
+
+              <listitem>
+                <para>the iteration number to get</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>key</term>
+
+              <listitem>
+                <para>the name of the key to quiery.</para>
+
+                <para>The list of available keys is the same as the
+                optimbase_histset function.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = optimbase_incriter ( this )</term>
+
+        <listitem>
+          <para>Increments the number of iterations.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>[ this , isfeasible ] = optimbase_isfeasible ( this , x )</term>
+
+        <listitem>
+          <para>Returns 1 if the given point satisfies bounds constraints and
+          inequality constraints. Returns 0 if the given point is not in the
+          bounds. Returns -1 if the given point does not satisfies inequality
+          constraints.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>x</term>
+
+              <listitem>
+                <para>the current point</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = optimbase_log (this,msg)</term>
+
+        <listitem>
+          <para>If verbose logging is enabled, prints the given message in the
+          console. If verbose logging is disabled, does nothing.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>msg</term>
+
+              <listitem>
+                <para>the message to print</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>optimbase_outputcmd ( this , state , data )</term>
+
+        <listitem>
+          <para>Calls back user's output command.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>data = optimbase_outstruct ( this )</term>
+
+        <listitem>
+          <para>Returns a tlist with basic optimization fields. This tlist is
+          suitable for use as an input argument of the output function. This
+          tlist may be enriched by children (specialize) optimization
+          methods.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>[ this , p ] = optimbase_proj2bnds ( this , x )</term>
+
+        <listitem>
+          <para>Returns a point, which is the projection of the given point
+          into the bounds.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>x</term>
+
+              <listitem>
+                <para>the current point</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = optimbase_stoplog ( this , msg )</term>
+
+        <listitem>
+          <para>Prints the given stopping rule message if verbose termination
+          is enabled. If verbose termination is disabled, does nothing.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>msg</term>
+
+              <listitem>
+                <para>the message to print</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>[this , terminate , status] = optimbase_terminate (this ,
+        previousfopt , currentfopt , previousxopt , currentxopt )</term>
+
+        <listitem>
+          <para>Returns 1 if the algorithm terminates. Returns 0 if the
+          algorithm must continue. If the -verbosetermination option is
+          enabled, messages are printed detailing the termination intermediate
+          steps. The optimbase_terminate function takes into account the
+          number of iterations, the number of evaluations of the cost
+          function, the tolerance on x and the tolerance on f. See below in
+          the section "Termination" for more details.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>previousfopt</term>
+
+              <listitem>
+                <para>the previous value of the cost function</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>currentfopt</term>
+
+              <listitem>
+                <para>the current value of the cost function</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>previousxopt</term>
+
+              <listitem>
+                <para>the previous x optimum</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>currentxopt</term>
+
+              <listitem>
+                <para>the current x optimum</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>terminate</term>
+
+              <listitem>
+                <para>1 if the algorithm must terminate, 0 if the algorithm
+                must continue</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>status</term>
+
+              <listitem>
+                <para>if terminate = 1, the detailed status of the
+                termination, as a string. If terminate = 0, the status is
+                "continue".</para>
+
+                <para>The following status are available :</para>
+
+                <variablelist>
+                  <varlistentry>
+                    <term>"maxiter"</term>
+
+                    <listitem>
+                      <para>the maximum number of iterations, provided by the
+                      -maxiter option, is reached.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>"maxfuneval"</term>
+
+                    <listitem>
+                      <para>the maximum number of function evaluations,
+                      provided by the -maxfunevals option, is reached</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>"tolf"</term>
+
+                    <listitem>
+                      <para>the tolerance on the function value is reached.
+                      This status is associated with the -tolfunmethod,
+                      -tolfunabsolute and -tolfunrelative options.</para>
+                    </listitem>
+                  </varlistentry>
+
+                  <varlistentry>
+                    <term>"tolx"</term>
+
+                    <listitem>
+                      <para>the tolerance on x is reached. This status is
+                      associated with the -tolxmethod, -tolxabsolute and
+                      -tolxrelative options.</para>
+                    </listitem>
+                  </varlistentry>
+                </variablelist>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsection>
+
+  <refsection>
+    <title>The cost function</title>
+
+    <para>The option -function allows to configure the cost function. The cost
+    function is used to compute the cost and the value of the nonlinear
+    inequality constraints.</para>
+
+    <para>In the more general case, the cost function is expected to have the
+    following header</para>
+
+    <programlisting role="example">function y = myfunction ( x , index , data )</programlisting>
+
+    <para>where</para>
+
+    <variablelist>
+      <varlistentry>
+        <term>x</term>
+
+        <listitem>
+          <para>the current point</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>index</term>
+
+        <listitem>
+          <para>optional, an integer representing the value to compute</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>data</term>
+
+        <listitem>
+          <para>optional, a user-defined data.</para>
+
+          <para>This argument is configured with the -costfargument
+          option.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>y</term>
+
+        <listitem>
+          <para>the result</para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+
+    <para>The index input parameter has the following meaning</para>
+
+    <variablelist>
+      <varlistentry>
+        <term>index = 1 (or no index)</term>
+
+        <listitem>
+          <para>the result is the value of the cost function</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>index = 2</term>
+
+        <listitem>
+          <para>the result is the value of the non-linear inequality
+          constraints, as an array of values</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>index = 3</term>
+
+        <listitem>
+          <para>the result is an array, which content is the following. At
+          index #1, the value of the cost function. At index #2 to the end,
+          the list of values of the nonlinear inequality constraints.</para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+
+    <para>In the most simple case, the cost function is expected to have the
+    following header</para>
+
+    <programlisting role="example">function y = myfunction (x)</programlisting>
+
+    <para>where x is the current point and y is the value of the cost. This
+    case is associated with an unconstrained problem without any additionnal
+    parameter.</para>
+  </refsection>
+
+  <refsection>
+    <title>The output function</title>
+
+    <para>The option -outputcommand allows to configure a command which is
+    called back at the start of the optimization, at each iteration and at the
+    end of the optimization.</para>
+
+    <para>The output function must have the following header</para>
+
+    <programlisting role="example">function outputcmd ( state , data , myobj )</programlisting>
+
+    <para>where</para>
+
+    <variablelist>
+      <varlistentry>
+        <term>state</term>
+
+        <listitem>
+          <para>a string representing the current state of the algorithm.
+          Available values are "init", "iter", "done".</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>data</term>
+
+        <listitem>
+          <para>a tlist containing at least the following entries</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>x</term>
+
+              <listitem>
+                <para>the current optimum</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>fval</term>
+
+              <listitem>
+                <para>the current function value</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>iteration</term>
+
+              <listitem>
+                <para>the current iteration index</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>funccount</term>
+
+              <listitem>
+                <para>the number of function evaluations</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>myobj</term>
+
+        <listitem>
+          <para>a user-defined parameter.</para>
+
+          <para>This input parameter is defined with the -outputcommandarg
+          option.</para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+
+    <para>The output function may be used when debugging the specialized
+    optimization algorithm, so that a verbose logging is produced. It may also
+    be used to write one or several report files in a specialized format
+    (ASCII, LaTeX, Excel, Hdf5, etc...). The user-defined parameter may be
+    used in that case to store file names or logging options.</para>
+
+    <para>The data tlist argument may contain more fields than the current
+    presented ones. These additionnal fields may contain values which are
+    specific to the specialized algorithm, such as the simplex in a
+    Nelder-Mead method, the gradient of the cost function in a BFGS method,
+    etc...</para>
+  </refsection>
+
+  <refsection>
+    <title>Termination</title>
+
+    <para>The current component takes into account for several generic
+    termination criterias. Specialized termination criterias should be
+    implemented in specialized optimization algorithms, by calling the
+    optimbase_termination function and adding external criterias, rather than
+    by modification of this function.</para>
+
+    <para>The optimbase_terminate function uses a set of rules to compute if
+    the termination occurs, which leads to an optimization status which is
+    equal to one of the following : "continue", "maxiter", "maxfunevals",
+    "tolf", "tolx". The set of rules is the following.</para>
+
+    <itemizedlist>
+      <listitem>
+        <para>By default, the status is "continue" and the terminate flag is
+        0.</para>
+      </listitem>
+
+      <listitem>
+        <para>The number of iterations is examined and compared to the
+        -maxiter option : if the following condition</para>
+
+        <programlisting role="example">iterations &gt;= maxiter</programlisting>
+
+        <para>is true, then the status is set to "maxiter" and terminate is
+        set to 1.</para>
+      </listitem>
+
+      <listitem>
+        <para>The number of function evaluations and compared to the
+        -maxfunevals option is examined : if the following condition</para>
+
+        <programlisting role="example">funevals &gt;= maxfunevals</programlisting>
+
+        <para>is true, then the status is set to "maxfuneval" and terminate is
+        set to 1.</para>
+      </listitem>
+
+      <listitem>
+        <para>The tolerance on function value is examined depending on the
+        value of the -tolfunmethod.</para>
+
+        <variablelist>
+          <varlistentry>
+            <term>"disabled"</term>
+
+            <listitem>
+              <para>then the tolerance on f is just skipped.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>"enabled"</term>
+
+            <listitem>
+              <para>if the following condition</para>
+
+              <programlisting role="example">abs(currentfopt) &lt; tolfunrelative * abs(previousfopt) + tolfunabsolute</programlisting>
+
+              <para>is true, then the status is set to "tolf" and terminate is
+              set to 1.</para>
+            </listitem>
+          </varlistentry>
+        </variablelist>
+
+        <para>The relative termination criteria on the function value works
+        well if the function value at optimum is near zero. In that case, the
+        function value at initial guess fx0 may be used as
+        previousfopt.</para>
+
+        <para>The absolute termination criteria on the function value works if
+        the user has an accurate idea of the optimum function value.</para>
+      </listitem>
+
+      <listitem>
+        <para>The tolerance on x is examined depending on the value of the
+        -tolxmethod.</para>
+
+        <variablelist>
+          <varlistentry>
+            <term>"disabled"</term>
+
+            <listitem>
+              <para>then the tolerance on x is just skipped.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>"enabled"</term>
+
+            <listitem>
+              <para>if the following condition</para>
+
+              <programlisting role="example">norm(currentxopt - previousxopt) &lt; tolxrelative * norm(currentxopt) + tolxabsolute</programlisting>
+
+              <para>is true, then the status is set to "tolx" and terminate is
+              set to 1.</para>
+            </listitem>
+          </varlistentry>
+        </variablelist>
+
+        <para>The relative termination criteria on the function value works
+        well if x at optimum is different from zero. In that case, the
+        condition measures the distance between two iterates.</para>
+
+        <para>The absolute termination criteria on the function value works if
+        the user has an accurate idea of the scale of the optimum x. If the
+        optimum x is near 0, the relative tolerance will not work and the
+        absolute tolerance is more appropriate.</para>
+      </listitem>
+    </itemizedlist>
+  </refsection>
+
+  <refsection>
+    <title>Example : Setting up an optimization</title>
+
+    <para>In the following example, one searches the minimum of the 2D
+    Rosenbrock function. 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.</para>
+
+    <programlisting role="example">
+function y = rosenbrock (x)
+  y = 100*(x(2)-x(1)^2)^2 + (1-x(1))^2;
+endfunction
+
+opt = optimbase_new ();
+// Check number of variables
+opt = optimbase_configure(opt,"-numberofvariables",2);
+nbvar = optimbase_cget(opt,"-numberofvariables");
+// Check cost function without additionnal argument
+opt = optimbase_configure(opt,"-function",rosenbrock);
+[this,f] = optimbase_function ( opt , [0.0 0.0] );
+opt = optimbase_destroy(opt);
+
+    </programlisting>
+  </refsection>
+
+  <refsection>
+    <title>Authors</title>
+
+    <para>Michael Baudin, 2008-2009</para>
+  </refsection>
+
+  <refsection>
+    <title>TODO</title>
+
+    <para><itemizedlist>
+        <listitem>
+          <para>manage equality constraints</para>
+        </listitem>
+
+        <listitem>
+          <para>manage linear constraints</para>
+        </listitem>
+
+        <listitem>
+          <para>manage quadratic objective</para>
+        </listitem>
+
+        <listitem>
+          <para>manage linear objective</para>
+        </listitem>
+
+        <listitem>
+          <para>methods with derivatives : add a flag to manage for the
+          derivatives of the cost function</para>
+        </listitem>
+      </itemizedlist></para>
+  </refsection>
+</refentry>
diff --git a/scilab/modules/optimization/help/en_US/optimsimplex/optimsimplex.xml b/scilab/modules/optimization/help/en_US/optimsimplex/optimsimplex.xml
new file mode 100644 (file)
index 0000000..34ab769
--- /dev/null
@@ -0,0 +1,1752 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ * Ajouter ici d'éventuels commentaires sur le fichier XML
+-->
+<refentry version="5.0-subset Scilab" xml:id="montecarlo_run" xml:lang="fr"
+          xmlns="http://docbook.org/ns/docbook"
+          xmlns:xlink="http://www.w3.org/1999/xlink"
+          xmlns:svg="http://www.w3.org/2000/svg"
+          xmlns:ns4="http://www.w3.org/1999/xhtml"
+          xmlns:mml="http://www.w3.org/1998/Math/MathML"
+          xmlns:db="http://docbook.org/ns/docbook">
+  <info>
+    <pubdate>$LastChangedDate: 16-12-2008 $</pubdate>
+  </info>
+
+  <refnamediv>
+    <refname>simplex</refname>
+
+    <refpurpose>Manage a simplex with arbitrary number of points.</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <title>SYNOPSIS</title>
+
+    <synopsis>[ newobj , data ] = simplex_new ( coords , fun , data )
+this = simplex_destroy (this)
+[ this , data ] = simplex_axes ( this , x0 , fun , len , data )
+[ this , data ] = simplex_pfeffer ( this , x0 , fun , deltausual , deltazero , data )
+[ this , data ] = simplex_randbounds ( this , x0 , fun , boundsmin , boundsmax , nbpoints  , data )
+[ this , data ] = simplex_spendley ( this , x0 , fun , len , data )
+this = simplex_setall ( this , simplex )
+this = simplex_setallfv ( this , fv )
+this = simplex_setallx ( this , x )
+this = simplex_setfv ( this , ive , fv )
+this = simplex_setn ( this , n )
+this = simplex_setnbve ( this , nbve )
+this = simplex_setve ( this , ive , fv , x )
+this = simplex_setx ( this , ive , x )
+simplex = simplex_getall ( this )
+fv = simplex_getallfv ( this )
+x = simplex_getallx ( this )
+fv = simplex_getfv ( this , ive )
+n = simplex_getn ( this )
+n = simplex_getnbve ( this )
+vertex = simplex_getve ( this , ive )
+x = simplex_getx ( this , ive )
+sicenter = simplex_center ( this )
+simplex_check ( this )
+[ this , data ] = simplex_computefv ( this , fun , data )
+df = simplex_deltafv ( this )
+dfm = simplex_deltafvmax ( this )
+m = simplex_dirmat ( this )
+sd = simplex_fvmean ( this )
+sd = simplex_fvstdev ( this )
+[ g , data ] = simplex_gradientfv ( this , fun , method , data )
+g = simplex_gradforward ( this )
+[ g , data ] = simplex_gradcentered ( this , fun , data )
+[ ns , data ] = simplex_oriented ( this , fun , data )
+simplex_print ( this )
+[ r , data ] = simplex_reflect ( this , fun , data )
+[ this , data ] = simplex_shrink ( this , fun , sigma , data )
+ssize = simplex_size ( this , method )
+this = simplex_sort ( this )
+str = simplex_tostring ( this )
+cen = simplex_xbar ( this , iexcl )</synopsis>
+  </refsynopsisdiv>
+
+  <refsection>
+    <title>Purpose</title>
+
+    <para>The goal of this toolbox is to provide a building block for
+    optimization algorithms based on a simplex. That Optimsimplex package may
+    be used in the following optimization methods :<itemizedlist>
+        <listitem>
+          <para>the Spendley et al. simplex method,</para>
+        </listitem>
+
+        <listitem>
+          <para>the Nelder-Mead method,</para>
+        </listitem>
+
+        <listitem>
+          <para>the Box algorithm for constrained optimization,</para>
+        </listitem>
+
+        <listitem>
+          <para>the multi-dimensional search by Virginia Torczon,</para>
+
+          <para>etc ...</para>
+        </listitem>
+      </itemizedlist></para>
+  </refsection>
+
+  <refsection>
+    <title>Design</title>
+
+    <para>This toolbox is designed with Oriented Object ideas in mind.</para>
+  </refsection>
+
+  <refsection>
+    <title>Features</title>
+
+    <para>The following is a list of features the Nelder-Mead prototype
+    algorithm currently provides :</para>
+
+    <itemizedlist>
+      <listitem>
+        <para>Manage various simplex initializations</para>
+
+        <itemizedlist>
+          <listitem>
+            <para>initial simplex given by user,</para>
+          </listitem>
+
+          <listitem>
+            <para>initial simplex computed with a length and along the
+            coordinate axes,</para>
+          </listitem>
+
+          <listitem>
+            <para>initial regular simplex computed with Spendley et al.
+            formula,</para>
+          </listitem>
+
+          <listitem>
+            <para>initial simplex computed by a small perturbation around the
+            initial guess point,</para>
+          </listitem>
+
+          <listitem>
+            <para>initial simplex computed from randomized bounds.</para>
+          </listitem>
+        </itemizedlist>
+      </listitem>
+
+      <listitem>
+        <para>sort the vertices by increasing function values,</para>
+      </listitem>
+
+      <listitem>
+        <para>compute the standard deviation of the function values in the
+        simplex,</para>
+      </listitem>
+
+      <listitem>
+        <para>compute the simplex gradient with forward or centered
+        differences,</para>
+      </listitem>
+
+      <listitem>
+        <para>shrink the simplex toward the best vertex,</para>
+      </listitem>
+
+      <listitem>
+        <para>etc...</para>
+      </listitem>
+    </itemizedlist>
+  </refsection>
+
+  <refsection>
+    <title>Description</title>
+
+    <para>This set of commands allows to manage a simplex made of k&gt;=n+1
+    points in a n-dimensional space. This component is the building block for
+    a class of direct search optimization methods such as the Nelder-Mead
+    algorithm or Torczon's Multi-Dimensionnal Search.</para>
+
+    <para>A simplex is designed as a collection of k&gt;=n+1 vertices. Each
+    vertex is made of a point and a function value at that point.</para>
+
+    <para>The simplex can be created with various shapes. It can be configured
+    and quieried at will. The simplex can also be reflected or shrinked. The
+    simplex gradient can be computed with a order 1 forward formula and with a
+    order 2 centered formula.</para>
+
+    <para>The simplex_new function allows to create a simplex. If vertices
+    coordinates are given, there are registered in the simplex. If a function
+    is provided, it is evaluated at each vertex. The simplex_destroy function
+    destroys the object and frees internal memory. Several functions allow to
+    create a simplex with special shapes, including axes-by-axes
+    (simplex_axes), regular (simplex_spendley), randomized bounds simplex with
+    arbitrary k vertices (simplex_randbounds) and an heuristical small
+    variation around a given point (simplex_pfeffer).</para>
+  </refsection>
+
+  <refsection>
+    <title>Functions</title>
+
+    <para>The following functions are available.</para>
+
+    <variablelist>
+      <varlistentry>
+        <term>[ newobj , data ] = simplex_new ( coords , fun , data )</term>
+
+        <listitem>
+          <para>Creates a new simplex object. All input arguments are
+          optional. If no input argument is provided, returns an empty simplex
+          object.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>newobj</term>
+
+              <listitem>
+                <para>The new object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>coords</term>
+
+              <listitem>
+                <para>optional, matrix of point coordinates in the
+                simplex.</para>
+
+                <para>The coords matrix is expected to be a n x k matrix,
+                where n is the dimension of the space and k is the number of
+                vertices in the simplex, with k&gt;= n+1.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>fun</term>
+
+              <listitem>
+                <para>optional, the function to compute at vertices.</para>
+
+                <para>The function is expected to have the following input and
+                output arguments :</para>
+
+                <programlisting role="example">function y = myfunction (x)</programlisting>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>data</term>
+
+              <listitem>
+                <para>optional, user-defined data passed to the
+                function.</para>
+
+                <para>If data is provided, it is passed to the callback
+                function both as an input and output argument. In that case,
+                the function must have the following header :</para>
+
+                <programlisting role="example">function [ y , data ] = myfunction ( x , data )</programlisting>
+
+                <para>The data input parameter may be used if the function
+                uses some additionnal parameters. It is returned as an output
+                parameter because the function may modify the data while
+                computing the function value. This feature may be used, for
+                example, to count the number of times that the function has
+                been called.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = simplex_destroy (this)</term>
+
+        <listitem>
+          <para>Destroy the given object.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>[ this , data ] = simplex_axes ( this , x0 , fun , len , data
+        )</term>
+
+        <listitem>
+          <para>Configure the current simplex so that it is computed axis by
+          axis, with the given length.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>x0</term>
+
+              <listitem>
+                <para>the initial point, as a row vector.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>fun</term>
+
+              <listitem>
+                <para>optional, the function to compute at vertices.</para>
+
+                <para>The function is expected to have the following input and
+                output arguments :</para>
+
+                <programlisting role="example">function y = myfunction (x)</programlisting>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>len</term>
+
+              <listitem>
+                <para>optional, the length of the simplex. The default length
+                is 1.0. If length is a value, that unique length is used in
+                all directions. If length is a vector with n values, each
+                length is used with the corresponding direction.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>data</term>
+
+              <listitem>
+                <para>optional, user-defined data passed to the
+                function.</para>
+
+                <para>If data is provided, it is passed to the callback
+                function both as an input and output argument. In that case,
+                the function must have the following header :</para>
+
+                <programlisting role="example">function [ y , data ] = myfunction ( x , data )</programlisting>
+
+                <para>The data input parameter may be used if the function
+                uses some additionnal parameters. It is returned as an output
+                parameter because the function may modify the data while
+                computing the function value. This feature may be used, for
+                example, to count the number of times that the function has
+                been called.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>[ this , data ] = simplex_pfeffer ( this , x0 , fun , deltausual
+        , deltazero , data )</term>
+
+        <listitem>
+          <para>Configure the current simplex so that it is computed from
+          Pfeffer's method, i.e. a relative delta for non-zero values and an
+          absolute delta for zero values.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>x0</term>
+
+              <listitem>
+                <para>the initial point, as a row vector.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>fun</term>
+
+              <listitem>
+                <para>optional, the function to compute at vertices.</para>
+
+                <para>The function is expected to have the following input and
+                output arguments :</para>
+
+                <programlisting role="example">function y = myfunction (x)</programlisting>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>deltausual</term>
+
+              <listitem>
+                <para>optional, the absolute delta for non-zero values. The
+                default value is 0.05.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>deltazero</term>
+
+              <listitem>
+                <para>optional, the absolute delta for zero values. The
+                default value is 0.0075.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>data</term>
+
+              <listitem>
+                <para>optional, user-defined data passed to the
+                function.</para>
+
+                <para>If data is provided, it is passed to the callback
+                function both as an input and output argument. In that case,
+                the function must have the following header :</para>
+
+                <programlisting role="example">function [ y , data ] = myfunction ( x , data )</programlisting>
+
+                <para>The data input parameter may be used if the function
+                uses some additionnal parameters. It is returned as an output
+                parameter because the function may modify the data while
+                computing the function value. This feature may be used, for
+                example, to count the number of times that the function has
+                been called.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>[ this , data ] = simplex_randbounds ( this , x0 , fun ,
+        boundsmin , boundsmax , nbpoints , data )</term>
+
+        <listitem>
+          <para>Configure the current simplex so that it is computed by taking
+          the bounds into account with random scaling. The number of vertices
+          in the simplex is arbitrary.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>x0</term>
+
+              <listitem>
+                <para>the initial point, as a row vector. It is the first
+                vertex in the simplex.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>fun</term>
+
+              <listitem>
+                <para>optional, the function to compute at vertices.</para>
+
+                <para>The function is expected to have the following input and
+                output arguments :</para>
+
+                <programlisting role="example">function y = myfunction (x)</programlisting>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>boundsmin</term>
+
+              <listitem>
+                <para>array of minimum bounds</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>boundsmax</term>
+
+              <listitem>
+                <para>array of maximum bounds</para>
+
+                <para>Each component ix =1 , n of the vertex #jve = 2,k is
+                computed from the formula :</para>
+
+                <programlisting role="example">x ( ix , jve ) = boundsmin( ix ) + rand() * (boundsmax( ix ) - boundsmin( ix ))</programlisting>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>nbpoints</term>
+
+              <listitem>
+                <para>total number of points in the simplex</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>data</term>
+
+              <listitem>
+                <para>optional, user-defined data passed to the
+                function.</para>
+
+                <para>If data is provided, it is passed to the callback
+                function both as an input and output argument. In that case,
+                the function must have the following header :</para>
+
+                <programlisting role="example">function [ y , data ] = myfunction ( x , data )</programlisting>
+
+                <para>The data input parameter may be used if the function
+                uses some additionnal parameters. It is returned as an output
+                parameter because the function may modify the data while
+                computing the function value. This feature may be used, for
+                example, to count the number of times that the function has
+                been called.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>[ this , data ] = simplex_spendley ( this , x0 , fun , len ,
+        data )</term>
+
+        <listitem>
+          <para>Configure the current simplex so that it is computed from
+          Spendley's et al. method, i.e. a regular simplex made of k = n+1
+          vertices.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>x0</term>
+
+              <listitem>
+                <para>the initial point, as a row vector.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>fun</term>
+
+              <listitem>
+                <para>optional, the function to compute at vertices.</para>
+
+                <para>The function is expected to have the following input and
+                output arguments :</para>
+
+                <programlisting role="example">function y = myfunction (x)</programlisting>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>len</term>
+
+              <listitem>
+                <para>optional, the length of the simplex. The default length
+                is 1.0.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>data</term>
+
+              <listitem>
+                <para>optional, user-defined data passed to the
+                function.</para>
+
+                <para>If data is provided, it is passed to the callback
+                function both as an input and output argument. In that case,
+                the function must have the following header :</para>
+
+                <programlisting role="example">function [ y , data ] = myfunction ( x , data )</programlisting>
+
+                <para>The data input parameter may be used if the function
+                uses some additionnal parameters. It is returned as an output
+                parameter because the function may modify the data while
+                computing the function value. This feature may be used, for
+                example, to count the number of times that the function has
+                been called.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = simplex_setall ( this , simplex )</term>
+
+        <listitem>
+          <para>Set all the coordinates and and the function values of all the
+          vertices.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>simplex</term>
+
+              <listitem>
+                <para>the simplex to set.</para>
+
+                <para>The given matrix is expected to be a nbve x n+1 matrix
+                where n is the dimension of the space, nbve is the number of
+                vertices and with the following content (where the data is
+                organized by row with function value first, and x
+                coordinates)</para>
+
+                <itemizedlist>
+                  <listitem>
+                    <para>simplex(k,1) is the function value of the vertex #k,
+                    with k = 1 , nbve</para>
+                  </listitem>
+
+                  <listitem>
+                    <para>simplex(k,2:n+1) is the coordinates of the vertex
+                    #k, with k = 1 , nbve</para>
+                  </listitem>
+                </itemizedlist>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = simplex_setallfv ( this , fv )</term>
+
+        <listitem>
+          <para>Set all the function values of all the vertices. The vertex #k
+          is expected to be stored in fv(k) with k = 1 , nbve</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>fv</term>
+
+              <listitem>
+                <para>the array of function values</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = simplex_setallx ( this , x )</term>
+
+        <listitem>
+          <para>Set all the coordinates of all the vertices. The vertex #k is
+          expected to be stored in x(1:n,k) with k = 1 , nbve</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>x</term>
+
+              <listitem>
+                <para>the coordinates of the vertices.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = simplex_setfv ( this , ive , fv )</term>
+
+        <listitem>
+          <para>Set the function value at given index and // returns an
+          updated simplex.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>ive</term>
+
+              <listitem>
+                <para>vertex index</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>fv</term>
+
+              <listitem>
+                <para>the function value</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = simplex_setn ( this , n )</term>
+
+        <listitem>
+          <para>Set the dimension of the space of the simplex.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>n</term>
+
+              <listitem>
+                <para>the dimension</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = simplex_setnbve ( this , nbve )</term>
+
+        <listitem>
+          <para>Set the number of vertices of the simplex.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>nbve</term>
+
+              <listitem>
+                <para>the number of vertices</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = simplex_setve ( this , ive , fv , x )</term>
+
+        <listitem>
+          <para>Sets the coordinates of the vertex and the function value at
+          given index in the current simplex.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>ive</term>
+
+              <listitem>
+                <para>the vertex index</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>fv</term>
+
+              <listitem>
+                <para>the function value</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>x</term>
+
+              <listitem>
+                <para>the coordinates of the point, as a column vector</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = simplex_setx ( this , ive , x )</term>
+
+        <listitem>
+          <para>Set the coordinates of the vertex at given index, as a column
+          vector, into the current simplex.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>ive</term>
+
+              <listitem>
+                <para>the vertex index</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>x</term>
+
+              <listitem>
+                <para>the coordinates of the point, as a column vector</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>simplex = simplex_getall ( this )</term>
+
+        <listitem>
+          <para>Returns all the coordinates of all the vertices and the
+          function values in the same matrix.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>simplex</term>
+
+              <listitem>
+                <para>the simplex data.</para>
+
+                <para>The simplex matrix has size nbve x n+1, and is organized
+                by row by row as follows :</para>
+
+                <itemizedlist>
+                  <listitem>
+                    <para>simplex(k,1) is the function value of the vertex #k,
+                    with k = 1 , nbve</para>
+                  </listitem>
+
+                  <listitem>
+                    <para>simplex(k,2:n+1) is the coordinates of the vertex
+                    #k, with k = 1 , nbve</para>
+                  </listitem>
+                </itemizedlist>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>fv = simplex_getallfv ( this )</term>
+
+        <listitem>
+          <para>Returns all the function values of all the vertices, as a
+          column vector.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>fv</term>
+
+              <listitem>
+                <para>The array of function values. The function value of
+                vertex #k is stored in fv(k) with k = 1 , nbve.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>x = simplex_getallx ( this )</term>
+
+        <listitem>
+          <para>Returns all the coordinates of all the vertices.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>x</term>
+
+              <listitem>
+                <para>the coordinates.</para>
+
+                <para>The vertex #k is stored in x(1:n,k) with k = 1 ,
+                nbve.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>fv = simplex_getfv ( this , ive )</term>
+
+        <listitem>
+          <para>Returns the function value at given index</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>ive</term>
+
+              <listitem>
+                <para>the vertex index</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>n = simplex_getn ( this )</term>
+
+        <listitem>
+          <para>Returns the dimension of the space of the simplex</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>n = simplex_getnbve ( this )</term>
+
+        <listitem>
+          <para>Returns the number of vertices in the simplex.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>vertex = simplex_getve ( this , ive )</term>
+
+        <listitem>
+          <para>Returns the vertex at given index as a tlist, with fields n, x
+          and fv</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>ive</term>
+
+              <listitem>
+                <para>the vertex index</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>x = simplex_getx ( this , ive )</term>
+
+        <listitem>
+          <para>Returns the coordinates of the vertex at given index, as a
+          column vector.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>ive</term>
+
+              <listitem>
+                <para>the vertex index</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>sicenter = simplex_center ( this )</term>
+
+        <listitem>
+          <para>Returns the center of the given simplex</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>simplex_check ( this )</term>
+
+        <listitem>
+          <para>Check the consistency of the internal data. Generates an error
+          if necessary.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>[ this , data ] = simplex_computefv ( this , fun , data )</term>
+
+        <listitem>
+          <para>Set the values of the function at vertices points.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>fun</term>
+
+              <listitem>
+                <para>optional, the function to compute at vertices.</para>
+
+                <para>The function is expected to have the following input and
+                output arguments :</para>
+
+                <programlisting role="example">function y = myfunction (x)</programlisting>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>data</term>
+
+              <listitem>
+                <para>optional, user-defined data passed to the
+                function.</para>
+
+                <para>If data is provided, it is passed to the callback
+                function both as an input and output argument. In that case,
+                the function must have the following header :</para>
+
+                <programlisting role="example">function [ y , data ] = myfunction ( x , data )</programlisting>
+
+                <para>The data input parameter may be used if the function
+                uses some additionnal parameters. It is returned as an output
+                parameter because the function may modify the data while
+                computing the function value. This feature may be used, for
+                example, to count the number of times that the function has
+                been called.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>df = simplex_deltafv ( this )</term>
+
+        <listitem>
+          <para>Returns the vector of difference of function values with
+          respect to the function value at vertex #1.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>dfm = simplex_deltafvmax ( this )</term>
+
+        <listitem>
+          <para>Returns the difference of function value between the high and
+          the low vertices. It is expected that the vertex #1 is associated
+          with the smallest function value and that the vertex #nbve is
+          associated with the highest function value. Since vertices are
+          ordered, the high is greater than the low.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>m = simplex_dirmat ( this )</term>
+
+        <listitem>
+          <para>Returns the n x n matrix of simplex directions i.e. the matrix
+          of differences of vertices coordinates with respect to the vertex
+          #1.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>sd = simplex_fvmean ( this )</term>
+
+        <listitem>
+          <para>Returns the mean of the function value on the simplex.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>sd = simplex_fvstdev ( this )</term>
+
+        <listitem>
+          <para>Returns the standard deviation of the function value on the
+          simplex.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>[ g , data ] = simplex_gradientfv ( this , fun , method , data
+        )</term>
+
+        <listitem>
+          <para>Returns the simplex gradient of the function.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>fun</term>
+
+              <listitem>
+                <para>optional, the function to compute at vertices.</para>
+
+                <para>The function is expected to have the following input and
+                output arguments :</para>
+
+                <programlisting role="example">function y = myfunction (x)</programlisting>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>method</term>
+
+              <listitem>
+                <para>optional, the method to use to compute the simplex
+                gradient. Two methods are available : "forward" or "centered".
+                The forward method uses the current simplex to compute the
+                simplex gradient. The centered method creates an intermediate
+                reflected simplex and computes the average.</para>
+
+                <para>If not provided, the default method is "forward".</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>data</term>
+
+              <listitem>
+                <para>optional, user-defined data passed to the
+                function.</para>
+
+                <para>If data is provided, it is passed to the callback
+                function both as an input and output argument. In that case,
+                the function must have the following header :</para>
+
+                <programlisting role="example">function [ y , data ] = myfunction ( x , data )</programlisting>
+
+                <para>The data input parameter may be used if the function
+                uses some additionnal parameters. It is returned as an output
+                parameter because the function may modify the data while
+                computing the function value. This feature may be used, for
+                example, to count the number of times that the function has
+                been called.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>[ ns , data ] = simplex_oriented ( this , fun , data )</term>
+
+        <listitem>
+          <para>Returns a new oriented simplex, in sorted order. The new
+          simplex has the same sigma- length of the base simplex, but is
+          "oriented" depending on the function value. This simplex may be
+          used, as Kelley suggests, for a restart of Nelder-Mead
+          algorithm.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>fun</term>
+
+              <listitem>
+                <para>optional, the function to compute at vertices.</para>
+
+                <para>The function is expected to have the following input and
+                output arguments :</para>
+
+                <programlisting role="example">function y = myfunction (x)</programlisting>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>data</term>
+
+              <listitem>
+                <para>optional, user-defined data passed to the
+                function.</para>
+
+                <para>If data is provided, it is passed to the callback
+                function both as an input and output argument. In that case,
+                the function must have the following header :</para>
+
+                <programlisting role="example">function [ y , data ] = myfunction ( x , data )</programlisting>
+
+                <para>The data input parameter may be used if the function
+                uses some additionnal parameters. It is returned as an output
+                parameter because the function may modify the data while
+                computing the function value. This feature may be used, for
+                example, to count the number of times that the function has
+                been called.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>simplex_print ( this )</term>
+
+        <listitem>
+          <para>Display the current simplex, with coordinates and function
+          values.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>[ r , data ] = simplex_reflect ( this , fun , data )</term>
+
+        <listitem>
+          <para>Returns a new simplex by reflexion of current simplex, by
+          reflection with respect to the first vertex in the simplex. This
+          move is used in the centered simplex gradient.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>fun</term>
+
+              <listitem>
+                <para>optional, the function to compute at vertices.</para>
+
+                <para>The function is expected to have the following input and
+                output arguments :</para>
+
+                <programlisting role="example">function y = myfunction (x)</programlisting>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>data</term>
+
+              <listitem>
+                <para>optional, user-defined data passed to the
+                function.</para>
+
+                <para>If data is provided, it is passed to the callback
+                function both as an input and output argument. In that case,
+                the function must have the following header :</para>
+
+                <programlisting role="example">function [ y , data ] = myfunction ( x , data )</programlisting>
+
+                <para>The data input parameter may be used if the function
+                uses some additionnal parameters. It is returned as an output
+                parameter because the function may modify the data while
+                computing the function value. This feature may be used, for
+                example, to count the number of times that the function has
+                been called.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>[ this , data ] = simplex_shrink ( this , fun , sigma , data
+        )</term>
+
+        <listitem>
+          <para>Shrink the simplex with given coefficient sigma and returns an
+          updated simplex. The shrink is performed with respect to the first
+          point in the simplex.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>fun</term>
+
+              <listitem>
+                <para>optional, the function to compute at vertices.</para>
+
+                <para>The function is expected to have the following input and
+                output arguments :</para>
+
+                <programlisting role="example">function y = myfunction (x)</programlisting>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>sigma</term>
+
+              <listitem>
+                <para>optional, the shrinkage coefficient. The default value
+                is 0.5.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>data</term>
+
+              <listitem>
+                <para>optional, user-defined data passed to the
+                function.</para>
+
+                <para>If data is provided, it is passed to the callback
+                function both as an input and output argument. In that case,
+                the function must have the following header :</para>
+
+                <programlisting role="example">function [ y , data ] = myfunction ( x , data )</programlisting>
+
+                <para>The data input parameter may be used if the function
+                uses some additionnal parameters. It is returned as an output
+                parameter because the function may modify the data while
+                computing the function value. This feature may be used, for
+                example, to count the number of times that the function has
+                been called.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>ssize = simplex_size ( this , method )</term>
+
+        <listitem>
+          <para>Returns the size of the simplex.</para>
+
+          <para>The diameter is the maximum length of all the vertices. It
+          requires 2 nested loops over the vertices.</para>
+
+          <para>The sigmaminus (resp. sigmamplus) size is the minimum (resp.
+          maximum) length of the vector from the given vertex to the first
+          vertex. It requires one loop over the vertices.</para>
+
+          <para>The "Nash" size is the sum of the norm of the length of the
+          vector from the given vertex to the first vertex. It requires one
+          loop over the vertices.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>method</term>
+
+              <listitem>
+                <para>optional, the method to use to compute the size. The
+                available methods are "Nash", "diameter", "sigmaplus" or
+                "sigmaminus" (default is "sigmaplus").</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>this = simplex_sort ( this )</term>
+
+        <listitem>
+          <para>Sorts the simplex with increasing function value order so that
+          the smallest function value is at vertex #1</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>str = simplex_tostring ( this )</term>
+
+        <listitem>
+          <para>Returns the current simplex as a string.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>cen = simplex_xbar ( this , iexcl )</term>
+
+        <listitem>
+          <para>Returns the center of n vertices, by excluding the vertex with
+          index iexcl.</para>
+
+          <variablelist>
+            <varlistentry>
+              <term>this</term>
+
+              <listitem>
+                <para>The current simplex object.</para>
+              </listitem>
+            </varlistentry>
+
+            <varlistentry>
+              <term>iexcl</term>
+
+              <listitem>
+                <para>the index of the vertex to exclude in center
+                computation. The default value of iexcl is the number of
+                vertices : in that case, if the simplex is sorted in
+                increasing function value order, the worst vertex is
+                excluded.</para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsection>
+
+  <refsection>
+    <title>Example : Creating a simplex with given vertices
+    coordinates</title>
+
+    <para>In the following example, one creates a simplex with known vertices
+    coordinates. The function values at the vertices are unset.</para>
+
+    <programlisting role="example">
+coords = [
+0.0 1.0 0.0
+0.0 0.0 1.0
+];
+s1 = simplex_new ( coords );
+computed = simplex_getallx ( s1 );
+computed = simplex_getn(s1);
+computed = simplex_getnbve (s1);
+s1 = simplex_destroy(s1);
+    </programlisting>
+  </refsection>
+
+  <refsection>
+    <title>Example : Creating a simplex with randomized bounds</title>
+
+    <para>In the following example, one creates a simplex with in the 2D
+    domain [-5 5]^2, with [-1.2 1.0] as the first vertex. One uses the
+    randomized bounds method to generate a simplex with 5 vertices. The
+    function takes an additionnal argument myobj, which is counts the number
+    of times the function is called. After the creation of the simplex, the
+    value of mydude.nb is 5, which is the expected result because there is one
+    function call by vertex.</para>
+
+    <programlisting role="example">
+function [ y , myobj ] = mycostf ( x , myobj )
+  y = rosenbrock(x);
+  myobj.nb = myobj.nb + 1
+endfunction
+
+mydude = tlist(["T_MYSTUFF","nb"]);
+mydude.nb = 0;
+s1 = simplex_new ();
+[ s1 , mydude ] = simplex_randbounds ( s1 , x0 = [-1.2 1.0], fun = mycostf, ...
+  boundsmin = [-5.0 -5.0] , boundsmax = [5.0 5.0], nbve=5 , data = mydude );
+s1 = simplex_destroy ( s1 );
+
+    </programlisting>
+  </refsection>
+
+  <refsection>
+    <title>TODO</title>
+
+    <para><itemizedlist>
+        <listitem>
+          <para>implement reflection and expansion as in multidimensional
+          search by Torczon</para>
+        </listitem>
+      </itemizedlist></para>
+  </refsection>
+
+  <refsection>
+    <title>Authors</title>
+
+    <para>Michael Baudin, 2008-2009</para>
+  </refsection>
+
+  <refsection>
+    <title>Bibliography</title>
+
+    <para>&#8220;Sequential Application of Simplex Designs in Optimisation and
+    Evolutionary Operation&#8221;, Spendley, W. and Hext, G. R. and Himsworth,
+    F. R., American Statistical Association and American Society for Quality,
+    1962</para>
+
+    <para>"A Simplex Method for Function Minimization", Nelder, J. A. and
+    Mead, R. The Computer Journal, January, 1965, 308--313</para>
+
+    <para>"A New Method of Constrained Optimization and a Comparison With
+    Other Methods", M. J. Box, The Computer Journal 1965 8(1):42-52, 1965 by
+    British Computer Society</para>
+
+    <para>"Iterative Methods for Optimization", C.T. Kelley, 1999, Chapter 6.,
+    section 6.2</para>
+
+    <para>"Compact Numerical Methods For Computers - Linear Algebra and
+    Function Minimization", J.C. Nash, 1990, Chapter 14. Direct Search
+    Methods</para>
+
+    <para>"Sequential Application of Simplex Designs in Optimisation and
+    Evolutionary Operation", W. Spendley, G. R. Hext, F. R. Himsworth,
+    Technometrics, Vol. 4, No. 4 (Nov., 1962), pp. 441-461, Section 3.1</para>
+
+    <para>"A New Method of Constrained Optimization and a Comparison With
+    Other Methods", M. J. Box, The Computer Journal 1965 8(1):42-52, 1965 by
+    British Computer Society</para>
+
+    <para>&#8220;Detection and Remediation of Stagnation in the Nelder--Mead
+    Algorithm Using a Sufficient Decrease Condition&#8221;, SIAM J. on
+    Optimization, Kelley,, C. T., 1999</para>
+
+    <para>" Multi-Directional Search: A Direct Search Algorithm for Parallel
+    Machines", by E. Boyd, Kenneth W. Kennedy, Richard A. Tapia, Virginia
+    Joanne Torczon,, Virginia Joanne Torczon, 1989, Phd Thesis, Rice
+    University</para>
+
+    <para>"Grid Restrained Nelder-Mead Algorithm", Árpád B&#361;rmen, Janez
+    Puhan, Tadej Tuma, Computational Optimization and Applications, Volume 34
+    , Issue 3 (July 2006), Pages: 359 - 375</para>
+
+    <para>"A convergent variant of the Nelder-Mead algorithm", C. J. Price, I.
+    D. Coope, D. Byatt, Journal of Optimization Theory and Applications,
+    Volume 113 , Issue 1 (April 2002), Pages: 5 - 19,</para>
+  </refsection>
+</refentry>
diff --git a/scilab/modules/optimization/macros/neldermead/mtlb_fminsearch.sci b/scilab/modules/optimization/macros/neldermead/mtlb_fminsearch.sci
new file mode 100644 (file)
index 0000000..ce085cf
--- /dev/null
@@ -0,0 +1,107 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+//
+// mtlb_fminsearch --
+//   Emulate the fminsearch command of Matlab.
+//   Search the minimum with Nelder-Mead algorithm.
+//   [x,fval,exitflag,output] = fminsearch(fun,x0,options)
+// Arguments, input
+//   fun : the function to minimize
+//   x0 : a row vector with dimension n where n is the number of parameters
+//        to optimize.
+//        Initial guess for optimization algorithm.
+//  options : an optional struct, as provided by mtlb_optimset
+//
+function [x,fval,exitflag,output] = mtlb_fminsearch ( varargin )
+  [lhs,rhs]=argn();
+  if rhs<>2 & rhs<>3 then
+    errmsg = sprintf("Unexpected number of arguments : %d provided while 2 or 3 are expected.",rhs);
+    error(errmsg)
+  end
+  fun = varargin(1);
+  x0 = varargin(2);
+  if rhs==2 then
+    // No options on the command line
+    // Set default values
+    options = mtlb_optimset ("fminsearch");
+  elseif rhs==3 then
+    // One options struc on the command line : use it !
+    options = varargin(3);
+  else
+    errmsg = sprintf("Unexpected error.");
+    error(errmsg)
+  end
+  // Compute options from the options struct
+  numberofvariables = size(x0,2);
+  // If the MaxIter option is a string, this is the default 200 value.
+  // If not, this is the actual value.
+  if type(options.MaxIter)==10 then
+    MaxIter = 200 * numberofvariables;
+  else
+    MaxIter = options.MaxIter;
+  end
+  // If the MaxFunEvals option is a string, this is the default 200 value
+  // If not, this is the actual value.
+  if type(options.MaxFunEvals)==10 then
+    MaxFunEvals = 200 * numberofvariables;
+  else
+    MaxFunEvals = options.MaxFunEvals;
+  end
+  TolFun = options.TolFun;
+  TolX = options.TolX;
+  // Get options from the options struct
+  options.MaxFunEvals
+  // Perform Optimization
+  nm = neldermead_new ();
+  nm = neldermead_configure(nm,"-x0",x0');
+  nm = neldermead_configure(nm,"-numberofvariables",numberofvariables);
+  nm = neldermead_configure(nm,"-simplex0method","pfeffer");
+  nm = neldermead_configure(nm,"-simplex0deltausual",0.05);
+  nm = neldermead_configure(nm,"-simplex0deltazero",0.0075);
+  nm = neldermead_configure(nm,"-method","variable");
+  nm = neldermead_configure(nm,"-function",fun);
+  nm = neldermead_configure(nm,"-maxiter",MaxIter);
+  nm = neldermead_configure(nm,"-maxfunevals",MaxFunEvals);
+  nm = neldermead_configure(nm,"-tolxmethod","disabled");
+  nm = neldermead_configure(nm,"-tolfunmethod","disabled");
+  nm = neldermead_configure(nm,"-tolssizedeltafvmethod","enabled");
+  nm = neldermead_configure(nm,"-tolsimplexizemethod","disabled");
+  nm = neldermead_configure(nm,"-toldeltafv",TolFun);
+  nm = neldermead_configure(nm,"-tolsimplexizeabsolute",TolX);
+  nm = neldermead_search(nm);
+  x = neldermead_get(nm,"-xopt")';
+  fval = neldermead_get(nm,"-fopt");
+  status = neldermead_get(nm,"-status");
+  select status
+  case "maxiter" then
+    exitflag = 0;
+  case "maxfuneval" then
+    exitflag = 0;
+  case "tolsizedeltafv" then
+    exitflag = 1;
+  else
+    errmsg = sprintf("Unknown status %s",status)
+    error(errmsg)
+  end
+  output = struct(...
+      "algorithm" ,[],...
+      "funcCount" ,[],...
+      "iterations" ,[],...
+      "message" , []);
+  output.algorithm = 'Nelder-Mead simplex direct search';
+  output.funcCount = neldermead_get(nm,"-funevals");
+  output.iterations = neldermead_get(nm,"-iterations");
+  output.message = sprintf("%s\n%s\n%s", "Optimization terminated:",...
+    "the current x satisfies the termination criteria using OPTIONS.TolX of 1.000000e-04",...
+    "and F(X) satisfies the convergence criteria using OPTIONS.TolFun of 1.000000e-04");
+  nm = neldermead_destroy(nm);
+  clear nm;
+endfunction
+
diff --git a/scilab/modules/optimization/macros/neldermead/mtlb_optimset.sci b/scilab/modules/optimization/macros/neldermead/mtlb_optimset.sci
new file mode 100644 (file)
index 0000000..718412b
--- /dev/null
@@ -0,0 +1,132 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+//
+// mtlb_optimset --
+//   Emulate the optimset command of Matlab.
+// Usage:
+//   options = mtlb_optimset ()
+//   options = mtlb_optimset ('TolX',1e-4)
+//   options = mtlb_optimset (options,'TolX',1e-4)
+//
+function options = mtlb_optimset (varargin)
+  [lhs,rhs]=argn();
+  //mprintf("lhs\n");
+  //disp(lhs);
+  //mprintf("rhs\n");
+  //disp(rhs);
+  if rhs==1 then
+    //
+    // If there is only one argument, it is expected to be the
+    // name of a method.
+    //
+    method = varargin(1);
+    options = mtlb_optimset_method ( method );
+  elseif modulo(rhs,2)<>0 then
+    //
+    // If the number of arguments is odd,
+    // the first argument is expected to be a optimset struct.
+    //
+    options = varargin(1);
+    t1 = typeof(options);
+    if t1<>"st" then
+      errmsg = sprintf("Odd number of arguments : the first argument is expected to be a struct, but is a %s",t1);
+      error(errmsg)
+    end
+    // ivar is a counter of the input arguments
+    ivar = 1;
+  else
+    options = mtlb_optimset_new ();
+    // ivar is a counter of the input arguments
+    ivar = 0;
+  end
+  //
+  // Process key,values as pairs.
+  //
+  nbkeys = rhs/2;
+  for i=1:nbkeys
+    ivar = ivar + 1;
+    key = varargin(ivar);
+    ivar = ivar + 1;
+    value = varargin(ivar);
+    //mprintf("Argument #%d\n",ivar);
+    //mprintf("key = %s\n",key);
+    //mprintf("value = %s\n",string(value)); // One cannot display a function.
+    options = mtlb_optimset_configure (options,key,value);
+  end
+endfunction
+//
+// mtlb_optimset_configure --
+//   Configure the given key with the given value.
+// Arguments
+//   options : a optimset struct
+//   key : a string, the key to configure
+//   value : the value
+//
+function options = mtlb_optimset_configure ( options , key , value )
+    select key
+    case "Display" then
+      options.Display = value;
+    case "FunValCheck" then
+      options.FunValCheck = value;
+    case "MaxFunEvals" then
+      options.MaxFunEvals = value;
+    case "MaxIter" then
+      options.MaxIter = value;
+    case "OutputFcn" then
+      options.OutputFcn = value;
+    case "PlotFcns" then
+      options.PlotFcns = value;
+    case "TolFun" then
+      options.TolFun = value;
+    case "TolX" then
+      options.TolX = value;
+    else
+      errmsg = sprintf("Unknown key %s",key)
+      error(errmsg)
+    end
+endfunction
+//
+// mtlb_optimset_new --
+//   Returns an empty optimset struct
+//
+function options = mtlb_optimset_new ()
+    options = struct(...
+      "Display" ,[],...
+      "FunValCheck" ,[],...
+      "MaxFunEvals" ,[],...
+      "MaxIter" ,[],...
+      "OutputFcn" ,[],...
+      "PlotFcns" ,[],...
+      "TolFun" ,[],...
+      "TolX" ,[]...
+      );
+endfunction
+//
+// mtlb_optimset_method --
+//   Returns an optimset struct which content is the default 
+//   settings for the given method.
+// Arguments
+//   method : a string, the name of the method
+//
+function options = mtlb_optimset_method ( method )
+    options = mtlb_optimset_new ();
+    select method
+    case "fminsearch" then
+      options = mtlb_optimset_configure ( options , "Display" , "notify" );
+      options = mtlb_optimset_configure ( options , "MaxFunEvals" , "200*numberofvariables" );
+      options = mtlb_optimset_configure ( options , "MaxIter" , "200*numberofvariables" );
+      options = mtlb_optimset_configure ( options , "TolFun" , 1.e-4 );
+      options = mtlb_optimset_configure ( options , "TolX" , 1.e-4 );
+    else
+      errmsg = sprintf("Unknown method %s",method)
+      error(errmsg)
+    end
+endfunction
+
diff --git a/scilab/modules/optimization/macros/neldermead/neldermead_cget.sci b/scilab/modules/optimization/macros/neldermead/neldermead_cget.sci
new file mode 100644 (file)
index 0000000..d745cd1
--- /dev/null
@@ -0,0 +1,82 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+
+//
+// neldermead_cget --
+//   Get the value for the given key.
+//   If the key is unknown, generates an error.
+//
+function value = neldermead_cget (this,key)
+  select key
+  case "-method" then
+    value = this.method;
+  case "-coords0" then
+    value = this.coords0;
+  case "-simplex0" then
+    value = this.simplex0;
+  case "-simplex0method" then
+    value = this.simplex0method;
+  case "-simplex0length" then
+    value = this.simplex0length;
+  case "-simplex0deltausual" then
+    value = this.simplex0deltausual;
+  case "-simplex0deltazero" then
+    value = this.simplex0deltazero;
+  case "-rho" then
+    value= this.rho;
+  case "-chi" then
+    value = this.chi;
+  case "-gamma" then
+    value = this.gamma;
+  case "-sigma" then
+    value = this.sigma;
+  case "-tolfstdeviationmethod" then
+  value = this.tolfstdeviationmethod;
+  case "-tolfstdeviation" then
+    value = this.tolfstdeviation;
+  case "-tolsimplexizemethod" then
+  value = this.tolsimplexizemethod;
+  case "-tolsimplexizeabsolute" then
+    value = this.tolsimplexizeabsolute;
+  case "-tolsimplexizerelative" then
+    value = this.tolsimplexizerelative;
+  case "-toldeltafv" then
+    value = this.toldeltafv;
+  case "-tolssizedeltafvmethod" then
+    value = this.tolssizedeltafvmethod;
+  case "-restartmax" then
+    value = this.restartmax;
+  case "-restarteps" then
+    value = this.restarteps;
+  case "-restartstep" then
+    value = this.restartstep;
+  case "-kelleystagnationflag" then
+    value = this.kelleystagnationflag;
+  case "-kelleynormalizationflag" then
+    value = this.kelleynormalizationflag;
+  case "-kelleystagnationalpha0" then
+    value = this.kelleystagnationalpha0;
+  case "-restartflag" then
+    value = this.restartflag;
+  case "-restartdetection" then
+    value = this.restartdetection;
+  case "-restartsimplexmethod" then
+    value = this.restartsimplexmethod;
+  case "-boxnbpoints" then
+    value = this.boxnbpoints;
+  case "-nbineqloops" then
+    value = this.nbineqloops;
+  case "-ineqscaling" then
+    value = this.ineqscaling;
+  else
+    // Delegate to the optimization object
+    value = optimbase_cget ( this.optbase , key );
+  end
+endfunction
diff --git a/scilab/modules/optimization/macros/neldermead/neldermead_configure.sci b/scilab/modules/optimization/macros/neldermead/neldermead_configure.sci
new file mode 100644 (file)
index 0000000..a001e4c
--- /dev/null
@@ -0,0 +1,126 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+//
+// neldermead_configure --
+//   Configure neldermead and returns the modified object.
+//
+function this = neldermead_configure (this,key,value)
+  select key
+  case "-method" then
+    select value
+    case "fixed" then
+      this.method = "fixed";
+    case "variable" then
+      this.method = "variable";
+    case "box" then
+      this.method = "box";
+    else
+      errmsg = sprintf("Unknown method %s",value);
+      error(errmsg);
+    end
+  case "-coords0" then
+    this.coords0 = value;
+  case "-simplex0method" then
+    select value
+    case "given" then
+      this.simplex0method = "given";
+    case "axes" then
+      this.simplex0method = "axes";
+    case "spendley" then
+      this.simplex0method = "spendley";
+    case "pfeffer" then
+      this.simplex0method = "pfeffer";
+    case "randbounds" then
+      this.simplex0method = "randbounds";
+    else
+      errmsg = sprintf("Unknown -simplex0method %s",value);
+      error(errmsg);
+    end
+  case "-simplex0length" then
+    this.simplex0length = value;
+  case "-simplex0deltausual" then
+    this.simplex0deltausual = value;
+  case "-simplex0deltazero" then
+    this.simplex0deltazero = value;
+  case "-rho" then
+    this.rho = value;
+  case "-chi" then
+    this.chi = value;
+  case "-gamma" then
+    this.gamma = value;
+  case "-sigma" then
+    this.sigma = value;
+  case "-tolfstdeviation" then
+    this.tolfstdeviation = value;
+  case "-tolfstdeviationmethod" then
+    select value
+    case "enabled" then
+      this.tolfstdeviationmethod = value;
+    case "disabled" then
+      this.tolfstdeviationmethod = value;
+    else
+      errmsg = sprintf("Unknown tolerance on function standard deviation method %s",value);
+      error(errmsg);
+    end
+  case "-tolsimplexizeabsolute" then
+    this.tolsimplexizeabsolute = value;
+  case "-tolsimplexizerelative" then
+    this.tolsimplexizerelative = value;
+  case "-tolsimplexizemethod" then
+    select value
+    case "enabled" then
+      this.tolsimplexizemethod = value;
+    case "disabled" then
+      this.tolsimplexizemethod = value;
+    else
+      errmsg = sprintf("Unknown tolerance on simplex size method %s",value);
+      error(errmsg);
+    end
+  case "-toldeltafv" then
+    this.toldeltafv = value;
+  case "-tolssizedeltafvmethod" then
+    select value
+    case "enabled" then
+      this.tolssizedeltafvmethod = value;
+    case "disabled" then
+      this.tolssizedeltafvmethod = value;
+    else
+      errmsg = sprintf("Unknown tolerance on simplex size and delta function value method %s",value);
+      error(errmsg);
+    end
+  case "-restartmax" then
+    this.restartmax = value;
+  case "-restarteps" then
+    this.restarteps = value;
+  case "-restartstep" then
+    this.restartstep = value;
+  case "-kelleystagnationflag" then
+    this.kelleystagnationflag = value;
+  case "-kelleynormalizationflag" then
+    this.kelleynormalizationflag = value;
+  case "-kelleystagnationalpha0" then
+    this.kelleystagnationalpha0 = value;
+  case "-restartflag" then
+    this.restartflag = value;
+  case "-restartdetection" then
+    this.restartdetection = value;
+  case "-restartsimplexmethod" then
+    this.restartsimplexmethod = value;
+  case "-boxnbpoints" then
+    this.boxnbpoints = value;
+  case "-nbineqloops" then
+    this.nbineqloops = value;
+  case "-ineqscaling" then
+    this.ineqscaling = value;
+  else
+    // Delegate to the optimization object
+    this.optbase = optimbase_configure ( this.optbase , key , value );
+  end
+endfunction
diff --git a/scilab/modules/optimization/macros/neldermead/neldermead_contour.sci b/scilab/modules/optimization/macros/neldermead/neldermead_contour.sci
new file mode 100644 (file)
index 0000000..0cf0d23
--- /dev/null
@@ -0,0 +1,33 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+//
+// neldermead_contour --
+//   Computes data necessary to create a contour plot of the cost function.
+//   The cost function must be a function with two parameters.
+// TODO : move to optimbase_compcontour
+// Arguments
+//   xmin , xmax , ymin , ymax : the bounds for the contour plot
+//   nx , ny : the number of points in the directions x, y
+//   xdata , ydata , zdata : vectors of data, as required by the contour command
+//
+function [ this , xdata , ydata , zdata ] = neldermead_contour ( this , xmin , xmax , ymin , ymax , nx , ny )
+  stepx = (xmax - xmin)/nx
+  xdata = xmin:stepx:xmax;
+  stepy = (ymax - ymin)/ny
+  ydata = ymin:stepy:ymax;
+  for ix = 1:length(xdata)
+    for iy = 1:length(ydata)
+      x = [xdata(ix) ydata(iy)]
+      [ this , f ] = neldermead_function ( this , x );
+      zdata ( ix , iy ) = f;
+    end
+  end
+endfunction
+
diff --git a/scilab/modules/optimization/macros/neldermead/neldermead_costf.sci b/scilab/modules/optimization/macros/neldermead/neldermead_costf.sci
new file mode 100644 (file)
index 0000000..db518da
--- /dev/null
@@ -0,0 +1,23 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+//
+// neldermead_costf --
+//   Call the cost function and return the value.
+// Note
+//   This function is given to the simplex class as 
+//   a callback.
+//   Input/Output arguments are swapped w.r.t. 
+//   neldermead_function, so that it matches
+//   the requirements of simplex methods.
+//
+function [ f , this ] = neldermead_costf ( x , this )
+  [this.optbase , f] = optimbase_function ( this.optbase , x );
+endfunction
+
diff --git a/scilab/modules/optimization/macros/neldermead/neldermead_destroy.sci b/scilab/modules/optimization/macros/neldermead/neldermead_destroy.sci
new file mode 100644 (file)
index 0000000..6c84142
--- /dev/null
@@ -0,0 +1,18 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+//
+// neldermead_destroy --
+//   Destroy a Nelder-Mead object.
+//
+function this = neldermead_destroy (this)
+  this.optbase = optimbase_destroy ( this.optbase );
+  this.simplex0 = optimsimplex_destroy ( this.simplex0 );
+endfunction
+
diff --git a/scilab/modules/optimization/macros/neldermead/neldermead_display.sci b/scilab/modules/optimization/macros/neldermead/neldermead_display.sci
new file mode 100644 (file)
index 0000000..66beb65
--- /dev/null
@@ -0,0 +1,42 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+
+//
+// neldermead_display --
+//   Display a Nelder-Mead engine
+//
+function this = neldermead_display ( this )
+  mprintf("Nelder-Mead Object\n");
+  this.optbase = optimbase_display ( this.optbase )
+  mprintf("Simplex0 : \n");
+  str = optimsimplex_tostring ( this.simplex0 );
+  for k =1:size(str,1)
+    mprintf("%s\n",str(k));
+  end
+  mprintf("Simplex0 Method : %s\n", string(this.simplex0method));
+  mprintf("Simplex0 Length : %s\n", string(this.simplex0length));
+  mprintf("Termination Method on simplex size : %s\n", string(this.tolsimplexizemethod));
+  mprintf("Termination Absolute Tolerance on simplex size : %s\n", string(this.tolsimplexizeabsolute));
+  mprintf("Termination Relative Tolerance on simplex size : %s\n", string(this.tolsimplexizerelative));
+  mprintf("Termination Method on standard deviation of function value : %s\n", string(this.tolfstdeviationmethod));
+  mprintf("Termination Tolerance on standard deviation of function value : %s\n", string(this.tolfstdeviation));
+  mprintf("Termination Method on simplex size + shift of function value : %s\n", string(this.tolssizedeltafvmethod));
+  mprintf("Termination Tolerance on shift of function value : %s\n", string(this.toldeltafv));
+  mprintf("Method : %s\n", string(this.method));
+  mprintf("Reflection Factor (rho) : %s\n", string(this.rho));
+  mprintf("Expansion Factor (chi) : %s\n", string(this.chi));
+  mprintf("Contraction Factor (gamma) : %s\n", string(this.gamma));
+  mprintf("Shrinkage Factor (sigma) : %s\n", string(this.sigma));
+  mprintf("Kelley Stagnation : %d\n", this.kelleystagnationflag);
+  mprintf("Restart Epsilon : %e\n", this.restarteps);
+  mprintf("Restart Step : %s\n", strcat(string(this.restartstep)," "));
+  mprintf("Restart Maximum : %d\n", this.restartmax);
+endfunction
+
diff --git a/scilab/modules/optimization/macros/neldermead/neldermead_function.sci b/scilab/modules/optimization/macros/neldermead/neldermead_function.sci
new file mode 100644 (file)
index 0000000..6d57d06
--- /dev/null
@@ -0,0 +1,42 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+//
+// neldermead_function --
+//   Call the cost function and return the value.
+// Arguments
+//   x : the point where the function is to be evaluated.
+//   index : a flag to pass to the cost function (default = 1)
+//   result : the result of the cost function
+//     This result may be the value of the cost function, the 
+//     values are the inequality constraints, the values of the 
+//     gradient of f or of the constraints, etc...
+// Note
+//  The following protocol is used
+//  * if index=1, or no index, returns the value of the cost 
+//    function (default case)
+//  * if index=2, returns the value of the nonlinear inequality 
+//    constraints, as a row array
+//  * if index=3, returns an array which contains
+//    at index #0, the value of the cost function  
+//    at index #1 to the end is the list of the values of the nonlinear 
+//    constraints
+//  The inequality constraints are expected to be positive.
+//
+// Note
+//   This is the function which is used internally
+//   by the neldermead class.
+//
+function [ this , result ] = neldermead_function ( this , x , index )
+  if (~isdef('index','local')) then
+    [ this.optbase , result ] = optimbase_function ( this.optbase , x )
+  else
+    [ this.optbase , result ] = optimbase_function ( this.optbase , x , index )
+  end
+endfunction
diff --git a/scilab/modules/optimization/macros/neldermead/neldermead_get.sci b/scilab/modules/optimization/macros/neldermead/neldermead_get.sci
new file mode 100644 (file)
index 0000000..e7888f9
--- /dev/null
@@ -0,0 +1,35 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+
+//
+// neldermead_get --
+//   Get the value for the given key.
+//   If the key is unknown, generates an error.
+//
+function value = neldermead_get ( this , key )
+  select key
+  case "-historysimplex" then
+    storehistory = optimbase_cget ( this.optbase , "-storehistory" );
+    if storehistory == 0 then
+      errmsg = sprintf("History disabled ; turn on -storehistory option.")
+      error(errmsg)
+    else
+      value = this.historysimplex;
+    end
+  case "-simplexopt" then
+    value = this.simplexopt;
+  case "-restartnb" then
+    value = this.restartnb;
+  else
+    // Delegate to optbase
+    value = optimbase_get ( this.optbase , key );
+  end
+endfunction
+
diff --git a/scilab/modules/optimization/macros/neldermead/neldermead_log.sci b/scilab/modules/optimization/macros/neldermead/neldermead_log.sci
new file mode 100644 (file)
index 0000000..8420bb6
--- /dev/null
@@ -0,0 +1,18 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+//
+// neldermead_log --
+//   Prints the given message.
+//
+function this = neldermead_log ( this , msg )
+  // Delegate to optimbase
+  this.optbase = optimbase_log ( this.optbase , msg )
+endfunction
+
diff --git a/scilab/modules/optimization/macros/neldermead/neldermead_new.sci b/scilab/modules/optimization/macros/neldermead/neldermead_new.sci
new file mode 100644 (file)
index 0000000..023c417
--- /dev/null
@@ -0,0 +1,117 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+//
+// neldermead_new --
+//   Creates a new Nelder-Mead object.
+//
+function newobj = neldermead_new ()
+  newobj = tlist(["T_NELDERMEAD",...
+    "optbase","method",...
+    "simplex0","simplex0method","simplex0length",...
+    "rho","chi","gamma","sigma",...
+    "tolfstdeviation","tolfstdeviationmethod",...
+    "tolsimplexizeabsolute","tolsimplexizerelative","tolsimplexizemethod", "simplexsize0", ...
+    "toldeltafv","tolssizedeltafvmethod",...
+    "historysimplex", ...
+    "coords0",...
+    "simplex0deltausual","simplex0deltazero", ...
+    "restartsimplexmethod",...
+    "simplexopt","restartmax" , "restarteps", ...
+    "restartstep","kelleystagnationflag",...
+    "kelleynormalizationflag","kelleystagnationalpha0", ...
+    "kelleyalpha","restartnb","restartflag","restartdetection" , ...
+    "startupflag" , ...
+    "boxnbpoints" , "boxnbpointseff" , "nbineqloops" , "ineqscaling" ]);
+  newobj.optbase = optimbase_new();
+  // Possible values "variable", "fixed".
+  newobj.method = "variable";
+  newobj.simplex0 = optimsimplex_new ( );
+  // Possible values : "axes", "spendley", "pfeffer" 
+  newobj.simplex0method = "axes";
+  newobj.simplex0length = 1.0;
+  // Reflection factor : rho
+  newobj.rho = 1.0;
+  // Expansion factor : chi
+  newobj.chi = 2.0;
+  // Contraction factor : gamma
+  newobj.gamma = .5;
+  // Shrinkage factor : sigma
+  newobj.sigma = .5;
+  // The tolerance for the standard deviation
+  newobj.tolfstdeviation = 0.0;
+  // Possible values : "disabled", "enabled"
+  newobj.tolfstdeviationmethod = "disabled";
+  // The absolute tolerance for the simplex size
+  newobj.tolsimplexizeabsolute = 0.0;
+  // The relative tolerance for the simplex size
+  newobj.tolsimplexizerelative = %eps;
+  // Possible values : "disabled", "enabled"
+  // TODO : turn this on by default. 
+  // Note :
+  //   If the simplex method converges, the simplex size is near zero.
+  newobj.tolsimplexizemethod = "enabled";
+  // The tolerance for the function value delta
+  newobj.toldeltafv = %eps;
+  // Possible values : "disabled", "enabled"
+  newobj.tolssizedeltafvmethod = "disabled";
+  // The value used in Pfeffer method initial simplex computation for non-zero parameters
+  newobj.simplex0deltausual = 0.05;
+  // The value used in Pfeffer method initial simplex computation for zero parameters
+  newobj.simplex0deltazero = 0.0075;
+  // The coordinates of the initial simplex, given by the user
+  newobj.coords0 = [];
+  // The Kelley stagnation detection in termination criteria :  0/1
+  // (i.e. sufficient decrease of function value)
+  newobj.kelleystagnationflag = 0
+  // The Kelley stagnation detection parameter
+  newobj.kelleystagnationalpha0 = 1.e-4
+  // The Kelley stagnation detection can be normalized or not.
+  // Note: 
+  // * in the 1997 paper "Detection and Remediation of Stagnation in Nelder-Mead
+  //   algorithm", Kelley uses the constant value of 1.e-4.
+  // * in the 1999 book "Iterative Methods for Optimization", Kelley uses normalization.
+  // Results are slightly changed, as indicated in the book/paper (the modification is 
+  // not mentioned, but the iteration number when the restart is performed
+  // is modified).
+  newobj.kelleynormalizationflag = 1
+  // The current value of Kelley's alpha, after normalization, if required
+  newobj.kelleyalpha = 1.e-4;
+  // The optimum simplex, after one optimization process
+  newobj.simplexopt = [];
+  // The maximum number of restarts
+  newobj.restartmax = 3;
+  // The epsilon value for O'Neill restart detection
+  newobj.restarteps = %eps;
+  // The step length for O'Neill restart detection
+  newobj.restartstep = 1.0;
+  // Possible values : "oriented", "axes", "spendley", "pfeffer" 
+  newobj.restartsimplexmethod = "oriented";
+  // Possible values : 0/1
+  newobj.restartflag = 0;
+  // Number of restarts performed
+  newobj.restartnb = 0;
+  // Type of restart detection method : "kelley", "oneill"
+  newobj.restartdetection = "oneill";
+  // Set to 1 when the startup has been performed
+  newobj.startupflag = 0;
+  // Initial size of the simplex, for the tolerance on the simplex size
+  newobj.simplexsize0 = 0.0
+  // Number of points required in the simplex (for Box method)
+  newobj.boxnbpoints = "2n"
+  // Effective number of points required in the simplex (for Box method)
+  newobj.boxnbpointseff = 0
+  // Number of loops performed to satisfy nonlinear
+  // inequality constraints (for Box method)
+  newobj.nbineqloops = 10
+  // The scaling coefficient in nonlinear inequality constraints
+  // in Box method, in (0,1) range
+  newobj.ineqscaling = 0.5
+endfunction
+
diff --git a/scilab/modules/optimization/macros/neldermead/neldermead_restart.sci b/scilab/modules/optimization/macros/neldermead/neldermead_restart.sci
new file mode 100644 (file)
index 0000000..d3f036b
--- /dev/null
@@ -0,0 +1,18 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+//
+// neldermead_restart --
+//   Restarts optimization.
+//
+function this = neldermead_restart ( this )
+  this = neldermead_updatesimp ( this );
+  this = neldermead_search (this);
+endfunction
+
diff --git a/scilab/modules/optimization/macros/neldermead/neldermead_search.sci b/scilab/modules/optimization/macros/neldermead/neldermead_search.sci
new file mode 100644 (file)
index 0000000..fe8f4ca
--- /dev/null
@@ -0,0 +1,985 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+//
+// References
+//   Sequential Application of Simplex Designs in Optimisation and Evolutionary Operation
+//   Spendley, W. and Hext, G. R. and Himsworth, F. R.
+//   1962
+//
+//   Convergence Properties of the Nelder-Mead Simplex Method in Low Dimensions
+//   Jeffrey C. Lagarias and James A. Reeds nd Margaret H. Wright and Paul E. Wright
+//   SIAM Journal of Optimization, 1998, volume 9, pp. 112--147
+//
+//   A Simplex Method for Function Minimization
+//   Nelder, J. A.  and Mead, R.
+//   1965
+//
+//   Iterative Methods for Optimization
+//   C. T. Kelley,
+//   SIAM Frontiers in Applied Mathematics
+//   1999
+//
+//   Detection and Remediation of Stagnation in the Nelder--Mead Algorithm Using a Sufficient Decrease Condition
+//   Kelley C. T.
+//   SIAM J. on Optimization},
+//   1999
+//
+
+//
+// neldermead_search --
+//   Search the minimum with Nelder-Mead algorithm.
+//
+function this = neldermead_search ( this )
+  if ( this.startupflag == 0) then
+    this = neldermead_startup ( this );
+    this.startupflag = 1;
+  end
+  neldermead_outputcmd ( this, "init" , this.simplex0 )
+  if this.restartflag == 1 then
+    this = neldermead_autorestart ( this )
+  else
+    this = neldermead_algo ( this );
+  end
+  neldermead_outputcmd ( this, "done" , this.simplexopt )
+endfunction
+//
+// neldermead_algo --
+//   Performs an optimization without restart
+//
+function this = neldermead_algo ( this )
+    select this.method
+    case "fixed" then
+      this = neldermead_fixed (this);
+    case "variable" then
+      this = neldermead_variable (this);
+    case "box" then
+      this = neldermead_box (this);
+    else
+      errmsg = sprintf("Unknown -method %s",this.method)
+      error(errmsg)
+    end
+endfunction
+//
+// neldermead_autorestart --
+//   Performs an optimization with automatic restart
+//
+function this = neldermead_autorestart ( this )
+  for irestart = 1: this.restartmax
+    this = neldermead_log (this,sprintf("Restart #%d/%d", irestart,this.restartmax));
+    this = neldermead_algo ( this );
+    [ this , istorestart ] = neldermead_istorestart ( this );
+    if istorestart==0 then
+      this = neldermead_log (this,"Must not restart");
+      this.restartnb  = irestart
+      break
+    else
+      this = neldermead_log (this,"Must restart");
+    end
+    if ( irestart == this.restartmax ) then
+      this = neldermead_log (this,"Stopping after all restarts performed");
+      this.restartnb  = irestart
+      this.optbase = optimbase_set ( this.optbase , "-status" , "maxrestart" );
+    else
+      this = neldermead_updatesimp ( this );
+    end
+  end
+endfunction
+
+
+//
+// neldermead_variable --
+//   The original Nelder-Mead algorithm, with variable-size simplex.
+//
+function this = neldermead_variable ( this )
+  //
+  // Order the vertices for the first time
+  //
+  simplex = this.simplex0;
+  n = optimbase_cget ( this.optbase , "-numberofvariables" );
+  if (n==0) then
+    errmsg = sprintf("The number of variable is zero.")
+    error(errmsg)
+  end
+  fvinitial = optimbase_get ( this.optbase , "-fx0" );
+  // Sort function values and x points by increasing function value order
+  this = neldermead_log (this,"Step #1 : order");
+  simplex = optimsimplex_sort ( simplex );
+  currentcenter = optimsimplex_center ( simplex );
+  currentxopt = optimbase_cget ( this.optbase , "-x0" );
+  newfvmean = optimsimplex_fvmean ( simplex );
+  //
+  // Initialize
+  //
+  terminate = 0;
+  iter = 0;
+  //
+  // Nelder-Mead Loop
+  //
+  while ( terminate == 0 )
+    this.optbase = optimbase_incriter ( this.optbase );
+    iter = iter + 1;
+    xlow = optimsimplex_getx ( simplex , 1 )
+    flow = optimsimplex_getfv ( simplex , 1 )
+    xhigh = optimsimplex_getx ( simplex , n+1 )
+    fhigh = optimsimplex_getfv ( simplex , n+1 )
+    xn = optimsimplex_getx ( simplex , n )
+    fn = optimsimplex_getfv ( simplex , n )
+    //
+    // Store history
+    //
+    xcoords = optimsimplex_getallx ( simplex )
+    this = neldermead_storehistory ( this , n , flow , xlow , xcoords );
+    deltafv = abs(optimsimplex_deltafvmax ( simplex ));
+    currentfopt = flow;
+    previousxopt = currentxopt;
+    currentxopt = xlow;
+    previouscenter = currentcenter;
+    currentcenter = optimsimplex_center ( simplex );
+    oldfvmean = newfvmean;
+    newfvmean = optimsimplex_fvmean ( simplex );
+    totaliter = optimbase_get ( this.optbase , "-iterations" );
+    funevals = optimbase_get ( this.optbase , "-funevals" );
+    ssize = optimsimplex_size ( simplex )
+    this = neldermead_log (this,sprintf("================================================================="));
+    this = neldermead_log (this,sprintf("Iteration #%d (total = %d)",iter,totaliter));
+    this = neldermead_log (this,sprintf("Function Eval #%d",funevals));
+    this = neldermead_log (this,sprintf("Xopt : %s",strcat(string(xlow)," ")));
+    this = neldermead_log (this,sprintf("Fopt : %e",flow));
+    this = neldermead_log (this,sprintf("DeltaFv : %e",deltafv));
+    this = neldermead_log (this,sprintf("Center : %s",strcat(string(currentcenter)," ")));
+    this = neldermead_log (this,sprintf("Size : %e",ssize));
+    str = optimsimplex_tostring ( simplex )
+    for i = 1:n+1
+      this = neldermead_log (this,str(i));
+    end
+    this.optbase = optimbase_set ( this.optbase , "-xopt" , xlow );
+    this.optbase = optimbase_set ( this.optbase , "-fopt" , flow );
+    neldermead_outputcmd ( this, "iter" , simplex )
+
+    //
+    // Update termination flag
+    //
+    if ( iter > 1 ) then
+      [this , terminate , status] = neldermead_termination (this , ...
+        fvinitial , oldfvmean , newfvmean , previouscenter , currentcenter , simplex );
+      if (terminate==1) then
+        this = neldermead_log (this,sprintf("Terminate with status : %s",status));
+        break
+      end
+    end
+    //
+    // Compute xbar, center of better vertices
+    //
+    this = neldermead_log (this,sprintf("Reflect"));
+    xbar   = optimsimplex_xbar ( simplex );
+    this = neldermead_log (this,sprintf("xbar="+strcat(string(xbar)," ")+""));
+    //
+    // Reflect the worst point with respect to center
+    //
+    xr = neldermead_interpolate ( xbar , xhigh , this.rho );
+    [ this , fr ] = neldermead_function ( this , xr );
+    this = neldermead_log (this,sprintf("xr=["+strcat(string(xr)," ")+"], f(xr)=%f",fr));
+    if ( fr >= flow & fr < fn ) then
+      this = neldermead_log (this,sprintf("  > Perform reflection"));
+      simplex = optimsimplex_setve ( simplex , n+1 , fr , xr )
+    elseif ( fr < flow ) then
+      // Expand
+      this = neldermead_log (this,sprintf("Expand"));
+      xe = neldermead_interpolate ( xbar , xhigh , this.rho*this.chi );
+      [ this ,fe] = neldermead_function ( this ,xe);
+      this = neldermead_log (this,sprintf("xe="+strcat(string(xe)," ")+", f(xe)=%f",fe));
+      if (fe < fr) then
+        this = neldermead_log (this,sprintf("  > Perform Expansion"));
+        simplex = optimsimplex_setve ( simplex , n+1 , fe , xe )
+      else
+        this = neldermead_log (this,sprintf("  > Perform reflection"));
+        simplex = optimsimplex_setve ( simplex , n+1 , fr , xr )
+      end
+    elseif ( fr >= fn & fr < fhigh ) then
+      // Outside contraction
+      this = neldermead_log (this,sprintf("Contract - outside"));
+      xc = neldermead_interpolate ( xbar , xhigh , this.rho*this.gamma );
+      [ this ,fc] = neldermead_function ( this ,xc);
+      this = neldermead_log (this,sprintf("xc="+strcat(string(xc)," ")+", f(xc)=%f",fc));
+      if ( fc <= fr ) then
+        this = neldermead_log (this,sprintf("  > Perform Outside Contraction"));
+        simplex = optimsimplex_setve ( simplex , n+1 , fc , xc )
+      else
+        //  Shrink
+        this = neldermead_log (this,sprintf("  > Perform Shrink"));
+        [ simplex , this ] = optimsimplex_shrink ( simplex , neldermead_costf , this.sigma , this );
+      end
+    else
+      // ( fr >= fn & fr >= fhigh )  
+      // Inside contraction
+      this = neldermead_log (this,sprintf("Contract - inside"));
+      xc = neldermead_interpolate ( xbar , xhigh , -this.gamma );
+      [ this ,fc] = neldermead_function ( this ,xc);
+      this = neldermead_log (this,sprintf("xc="+strcat(string(xc)," ")+", f(xc)=%f",fc));
+      if ( fc < fhigh ) then
+        this = neldermead_log (this,sprintf("  > Perform Inside Contraction"));
+        simplex = optimsimplex_setve ( simplex , n+1 , fc , xc )
+      else
+        //  Shrink
+        this = neldermead_log (this,sprintf("  > Perform Shrink"));
+        [ simplex , this ] = optimsimplex_shrink ( simplex , neldermead_costf , this.sigma , this )
+      end
+    end
+    //
+    // Sort simplex
+    //
+    this = neldermead_log (this,sprintf("Sort"));
+    simplex  = optimsimplex_sort ( simplex );
+  end
+  this.optbase = optimbase_set ( this.optbase , "-xopt" , xlow );
+  this.optbase = optimbase_set ( this.optbase , "-fopt" , flow );
+  this.optbase = optimbase_set ( this.optbase , "-status" , status );
+  this.simplexopt = simplex;
+endfunction
+
+//
+// neldermead_fixed --
+//   The simplex algorithm with fixed size simplex.
+//
+function this = neldermead_fixed (this)
+  //
+  // Order the vertices for the first time
+  //
+  simplex = this.simplex0;
+  n = optimbase_cget ( this.optbase , "-numberofvariables" );
+  fvinitial = optimbase_get ( this.optbase , "-fx0" );
+  // Sort function values and x points by increasing function value order
+  this = neldermead_log (this,sprintf("Sort"));
+  simplex = optimsimplex_sort ( simplex );
+  neldermead_outputcmd ( this, "init" , simplex )
+  //
+  // Compute center of simplex
+  //
+  currentcenter = optimsimplex_center ( simplex );
+  newfvmean = optimsimplex_fvmean ( simplex );
+  currentxopt = optimbase_cget ( this.optbase , "-x0" );
+  //
+  // Initialize
+  //
+  terminate = 0;
+  iter = 0;
+  //
+  // main N-M loop
+  //
+  while (terminate == 0)
+    this.optbase = optimbase_incriter ( this.optbase );
+    iter = iter + 1;
+    xlow = optimsimplex_getx ( simplex , 1 )
+    flow = optimsimplex_getfv ( simplex , 1 )
+    xhigh = optimsimplex_getx ( simplex , n+1 )
+    fhigh = optimsimplex_getfv ( simplex , n+1 )
+    //
+    // Store history
+    //
+    xcoords = optimsimplex_getallx ( simplex )
+    this = neldermead_storehistory ( this , n , flow , xlow , xcoords );
+    deltafv = abs(optimsimplex_deltafvmax ( simplex ));
+    currentfopt = flow;
+    previousxopt = currentxopt;
+    currentxopt = xlow;
+    previouscenter = currentcenter;
+    currentcenter = optimsimplex_center ( simplex );
+    oldfvmean = newfvmean;
+    newfvmean = optimsimplex_fvmean ( simplex );
+    totaliter = optimbase_get ( this.optbase , "-iterations" );
+    funevals = optimbase_get ( this.optbase , "-funevals" );
+    ssize = optimsimplex_size ( simplex )
+    this = neldermead_log (this,sprintf("================================================================="));
+    this = neldermead_log (this,sprintf("Iteration #%d (total = %d)",iter,totaliter));
+    this = neldermead_log (this,sprintf("Function Eval #%d",funevals));
+    this = neldermead_log (this,sprintf("Xopt : %s",strcat(string(xlow)," ")));
+    this = neldermead_log (this,sprintf("Fopt : %e",flow));
+    this = neldermead_log (this,sprintf("DeltaFv : %e",deltafv));
+    this = neldermead_log (this,sprintf("Center : %s",strcat(string(currentcenter)," ")));
+    this = neldermead_log (this,sprintf("Size : %e",ssize));
+    str = optimsimplex_tostring ( simplex )
+    for i = 1:n+1
+      this = neldermead_log (this,str(i));
+    end
+    this.optbase = optimbase_set ( this.optbase , "-xopt" , xlow );
+    this.optbase = optimbase_set ( this.optbase , "-fopt" , flow );
+    neldermead_outputcmd ( this, "iter" , simplex )
+    //
+    // Update termination flag
+    //
+    if ( iter > 1 ) then
+      [this , terminate , status] = neldermead_termination (this , ...
+        fvinitial , oldfvmean , newfvmean , previouscenter , currentcenter , simplex );
+      if (terminate==1) then
+        this = neldermead_log (this,sprintf("Terminate with status : %s",status));
+        break;
+      end
+    end
+    //
+    // Compute xbar, center of better vertices
+    //
+    this = neldermead_log (this,sprintf("Reflect"));
+    xbar = optimsimplex_xbar ( simplex );
+    this = neldermead_log (this,sprintf("xbar="+strcat(string(xbar)," ")+""));
+    //
+    // Reflect the worst point with respect to center
+    //
+    xr = neldermead_interpolate ( xbar , xhigh , this.rho );
+    [ this ,fr] = neldermead_function ( this ,xr);
+    this = neldermead_log (this,sprintf("xr="+strcat(string(xr)," ")+", f(xr)=%f",fr));
+    //
+    // Replace worst point by xr if it is better
+    //
+    if ( fr < fhigh ) then
+      this = neldermead_log (this,sprintf("  > Perform reflect"));
+      simplex = optimsimplex_setve ( simplex , n+1 , fr , xr )
+    else
+      //  Shrink
+      this = neldermead_log (this,sprintf("  > Perform Shrink"));
+      [ simplex , this ] = optimsimplex_shrink ( simplex , neldermead_costf , this.sigma , this )
+    end
+    //
+    // Sort simplex
+    //
+    simplex = optimsimplex_sort ( simplex );
+  end
+  this.optbase = optimbase_set ( this.optbase , "-xopt" , xlow );
+  this.optbase = optimbase_set ( this.optbase , "-fopt" , flow );
+  this.optbase = optimbase_set ( this.optbase , "-status" , status );
+  this.simplexopt = simplex;
+endfunction
+//
+// neldermead_interpolate --
+//   Computes xi as an interpolation between x1 and x2, with factor as :
+//     xi = (1+fac)x1 - fac x2
+//
+function xi = neldermead_interpolate ( x1 , x2 , fac )
+  xi = (1 + fac)*x1 - fac*x2;
+endfunction
+
+//
+// neldermead_termination --
+//   Returns 1 if the algorithm terminates.
+//   Returns 0 if the algorithm must continue.
+// Arguments
+//   this : the current object
+//   fvinitial : initial function value
+//   newfvmean, oldfvmean : the old and new function value average on the simplex
+//   previousxopt : the previous value of x
+//   currentxopt : the current value of x
+//   simplex : the simplex
+//     The best point in the simplex is expected to be stored at 1
+//     The worst point in the simplex is expected to be stored at n+1
+//   terminate : 1 if the algorithm terminates, 0 if the algorithm must continue.
+//   this.status : termination status
+//     status = "continue"
+//     status = "maxiter"
+//     status = "maxfuneval"
+//     status = "tolf"
+//     status = "tolx"
+//     status = "tolfstdev"
+//     status = "tolsize"
+//     status = "tolsizedeltafv"
+// Notes
+//   Use the function average on the simplex instead of the best function value.
+//   This is because the function average changes at each iteration.
+//   Instead, the best function value as a step-by-step evolution and may not
+//   change in 2 iterations, leading to astop of the algorithm.
+// TODO : set the fvinitial, oldfvmean, newfvmean.
+//
+function [this , terminate , status ] = neldermead_termination (this , ...
+  fvinitial , oldfvmean , newfvmean , previousxopt , currentxopt , ...
+  simplex )
+  terminate = 0;
+  status = "continue";
+  //
+  // Termination Criteria from parent optimization class
+  //
+  [ this.optbase , terminate , status] = optimbase_terminate ( this.optbase , ...
+    fvinitial , newfvmean , previousxopt , currentxopt );
+  //
+  // Criteria #5 : standard deviation of function values
+  //
+  if (terminate == 0) then
+    if this.tolfstdeviationmethod == "enabled" then
+      fv = optimsimplex_getallfv ( simplex )
+      sd = st_deviation(fv);
+      this.optbase = optimbase_stoplog  ( this.optbase,sprintf("  > st_deviation(fv)=%e < tolfstdeviation=%e",...
+        sd, this.tolfstdeviation));
+      if sd < this.tolfstdeviation then
+        terminate = 1;
+        status = "tolfstdev";
+      end
+    end
+  end
+  //
+  // Criteria #6 : simplex absolute + relative size
+  //
+  if (terminate == 0) then
+    if this.tolsimplexizemethod == "enabled" then
+      ssize = optimsimplex_size ( simplex , "sigmaplus" );
+      this.optbase = optimbase_stoplog  ( this.optbase,sprintf("  > simplex size=%e < %e + %e * %e",...
+        ssize, this.tolsimplexizeabsolute , this.tolsimplexizerelative , this.simplexsize0 ));
+      if ssize < this.tolsimplexizeabsolute + this.tolsimplexizerelative * this.simplexsize0 then
+        terminate = 1;
+        status = "tolsize";
+      end
+    end
+  end
+  //
+  // Criteria #7 : simplex absolute size + difference in function values (Matlab-like)
+  //
+  if (terminate == 0) then
+    if this.tolssizedeltafvmethod == "enabled" then
+      ssize = optimsimplex_size ( simplex , "sigmaplus" );
+      this.optbase = optimbase_stoplog  ( this.optbase,sprintf("  > simplex size=%e < %e",...
+        ssize, this.tolsimplexizeabsolute));
+      shiftfv = abs(optimsimplex_deltafvmax( simplex ))
+      this.optbase = optimbase_stoplog  ( this.optbase,sprintf("  > abs(fv(n+1) - fv(1))=%e < toldeltafv=%e",...
+        shiftfv, this.toldeltafv));
+      if ssize < this.tolsimplexizeabsolute & shiftfv < this.toldeltafv then
+        terminate = 1;
+        status = "tolsizedeltafv";
+      end
+    end
+  end
+  //
+  // Criteria #8 : Kelley stagnation, based on
+  // a sufficient decrease condition
+  //
+  if ( terminate == 0 ) then
+    if ( this.kelleystagnationflag==1 ) then
+      [ sg , this ] = optimsimplex_gradientfv ( simplex , neldermead_costf , "forward" , this );
+      nsg = sg' * sg;
+      sgstr = strcat(string(sg)," ");
+      this.optbase = optimbase_stoplog ( this.optbase , sprintf ( "Test Stagnation : nsg = %e, sg = "+sgstr, nsg) );
+      this.optbase = optimbase_stoplog ( this.optbase , ...
+        sprintf ( "Test Stagnation : newfvmean=%e >= oldfvmean=%e - %e * %e" , newfvmean, oldfvmean , this.kelleyalpha , nsg ) );
+      if ( newfvmean >= oldfvmean - this.kelleyalpha * nsg ) then
+        terminate = 1;
+        status = "kelleystagnation";
+      end
+    end
+  end
+endfunction
+  
+
+//
+// neldermead_outputcmd --
+//   Calls back user's output command
+// Arguments
+//   this : the current object
+//   state : the state of the algorithm,
+//     "init", "done", "iter"
+//   simplex : the current simplex
+//
+function  neldermead_outputcmd ( this, ...
+   state , simplex )
+  outputcmd = optimbase_cget ( this.optbase , "-outputcommand" );
+  if typeof(outputcmd) <> "string" then
+    brutedata = optimbase_outstruct ( this.optbase );
+    data = tlist(["T_NMDATA",...
+      "x","fval","iteration","funccount",...
+      "simplex"]);
+    data.x = brutedata.x;
+    data.fval = brutedata.fval;
+    data.iteration = brutedata.iteration;
+    data.funccount = brutedata.funccount;
+    data.simplex = simplex;
+    optimbase_outputcmd ( this.optbase , state , data );
+  end
+endfunction
+//
+// neldermead_storehistory --
+//   Stores the history into the data structure.
+// Arguments, input
+//   this : current object
+//   n : the number of unknown parameters
+//   fopt : the current value of the function at optimum
+//   xopt : arrary with size n, current optimum
+//   xcoords : array with size n x n+1, coordinates of the n+1 vertices
+//
+function this = neldermead_storehistory ( this , n , fopt , xopt , xcoords )
+  storehistory = optimbase_cget ( this.optbase , "-storehistory" );
+  iterations = optimbase_get ( this.optbase , "-iterations" );
+  if storehistory == 1 then
+    this.optbase = optimbase_histset ( this.optbase , iterations , "-fopt" , fopt );
+    this.optbase = optimbase_histset ( this.optbase , iterations , "-xopt" , xopt(1:n)' );
+    this.historysimplex ( iterations , 1:n+1,1:n) = xcoords(1:n,1:n+1)';
+  end
+endfunction
+
+//
+// neldermead_istorestart --
+//   Returns 1 if the optimization is to restart.
+// Arguments
+//   istorestart : 1 of the the optimization is to restart.
+//
+function [ this , istorestart ] = neldermead_istorestart ( this )
+  select this.restartdetection
+  case "oneill"
+    [ this , istorestart ] = neldermead_isroneill ( this )
+  case "kelley"
+    [ this , istorestart ] = neldermead_isrkelley ( this )
+  else
+    errmsg = sprintf("Unknown restart method %s",this.restartmethod)
+    error(errmsg)
+  end
+endfunction
+//
+// neldermead_isrkelley--
+//   Returns 1 if the optimization is to restart.
+//   Use kelleystagnation as a criteria for restart.
+// Arguments
+//   istorestart : 1 of the the optimization is to restart.
+//
+function [ this , istorestart ] = neldermead_isrkelley ( this )
+  istorestart = 0
+  if ( this.kelleystagnationflag==1 ) then
+    status = optimbase_get ( this.optbase , "-status" );
+    if ( status =="kelleystagnation" ) then
+       istorestart = 1
+    end
+  end
+endfunction
+//
+// neldermead_isroneill --
+//   Returns 1 if the optimization is to restart.
+//   Use O'Neill method as a criteria for restart.
+//   It is a axis by axis search for optimality.
+// Arguments
+//   xopt : the optimum, as a st of n values
+//   fopt : function value at optimum
+//   eps : a small value
+//   step : a list of n values, representing
+//     the "size" of each parameter
+//   istorestart : 1 of the the optimization is to restart.
+//
+function [ this , istorestart ] = neldermead_isroneill ( this )
+  n = optimbase_cget ( this.optbase , "-numberofvariables" );
+  //
+  // If required, make a vector step from the scalar step
+  //
+  defaultstep = this.restartstep;
+  stepn = length ( defaultstep );
+  if ( stepn <> n ) then
+    step = defaultstep * ones(n,1);
+  else
+    step = defaultstep;
+  end
+
+  xopt = optimbase_get ( this.optbase , "-xopt" );
+  fopt = optimbase_get ( this.optbase , "-fopt" );
+
+    istorestart = 0
+    for ix = 1:n
+      stepix = step ( ix )
+      del = stepix * this.restarteps
+      if ( del==0.0 ) then
+         del = eps
+      end
+      xoptix =  xopt ( ix )
+      xopt ( ix ) = xoptix + del
+      [ this , fv ] = neldermead_function ( this , xopt )
+      if ( fv < fopt ) then
+        istorestart = 1
+        break
+      end
+      xopt ( ix ) = xoptix - del
+      [ this , fv ] = neldermead_function ( this , xopt )
+      if ( fv < fopt ) then
+        istorestart = 1
+        break
+      end
+      xopt ( ix ) = xoptix
+    end
+endfunction
+
+//
+// neldermead_startup --
+//   Startup the algorithm.
+//   Computes the initial simplex, depending on the -simplex0method.
+//
+function this = neldermead_startup (this)
+  [ this.optbase , hasbounds ] = optimbase_hasbounds ( this.optbase );
+  if ( hasbounds ) then
+    [ this.optbase , isok ] = optimbase_checkbounds ( this.optbase );
+    if ( ~isok ) then
+      error ( "Bounds are not consistent." )
+    end
+  end
+  x0 = optimbase_cget ( this.optbase , "-x0" );
+  select this.simplex0method
+  case "given" then
+    [ simplex0 , this ] = optimsimplex_new ( this.coords0 , ...
+      neldermead_costf , this );
+  case "axes" then
+    simplex0 = optimsimplex_new ( );
+    [ simplex0 , this ] = optimsimplex_axes ( simplex0 , ...
+      x0' , neldermead_costf , this.simplex0length , this );
+  case "spendley" then
+    simplex0 = optimsimplex_new ( );
+    [ simplex0 , this ] = optimsimplex_spendley ( simplex0 , ...
+      x0' , neldermead_costf , this.simplex0length , this );
+  case "pfeffer" then
+    simplex0 = optimsimplex_new ( );
+    [ simplex0 , this ] = optimsimplex_pfeffer ( simplex0 , ...
+      x0' , neldermead_costf , this.simplex0deltausual , ...
+      this.simplex0deltazero , this );
+  case "randbounds" then
+    //
+    // Initialize the random number generator, so that the results are always the
+    // same.
+    //
+    rand("seed" , 0)
+    simplex0 = optimsimplex_new ( );
+    if ( this.boxnbpoints == "2n" ) then
+      this.boxnbpointseff = 2 * this.optbase.numberofvariables;
+    else
+      this.boxnbpointseff = this.boxnbpoints;
+    end
+    if ( ~hasbounds ) then
+      error ( "Randomized bounds initial simplex is not available without bounds." )
+    end
+    [ simplex0 , this ] = optimsimplex_randbounds ( simplex0 , x0' , ...
+      neldermead_costf , this.optbase.boundsmin , this.optbase.boundsmax , ...
+      this.boxnbpointseff  , this );
+  else
+    errmsg = sprintf("Unknown -simplex0method : %s",this.simplex0method);
+    error(errmsg);
+  end
+  //
+  // Scale the simplex into the bounds and the nonlinear inequality constraints, if any
+  //
+  if ( hasbounds | this.optbase.nbineqconst > 0 ) then
+    this = neldermead_log (this,sprintf("Scaling initial simplex into nonlinear inequality constraints..."));
+    nbve = optimsimplex_getnbve ( simplex0 );
+    for ive = 1 : nbve
+      x = optimsimplex_getx ( simplex0 , ive );
+      this = neldermead_log (this,sprintf("Scaling vertex #%d/%d at ["+...
+        strcat(string(x)," ")+"]... " , ...
+        ive , nbve ));
+      [ this , status , xp ] = _scaleinconstraints ( this , x , x0 );
+      if ( ~status ) then
+        errmsg = sprintf("Impossible to scale the vertex #%d/%d at ["+...
+          strcat(string(x)," ")+"] into inequality constraints", ...
+          ive , nbve );
+        error(errmsg);
+      end
+      if ( or ( x <> xp ) ) then
+        [ this , fv ] = neldermead_function ( this , xp );
+        simplex0 = optimsimplex_setve ( simplex0 , ive , fv , xp );
+      end
+    end
+  end
+  //
+  // Store the simplex
+  //
+  this.simplex0 = optimsimplex_destroy ( this.simplex0 );
+  this.simplex0 = simplex0;
+  this.simplexsize0 = optimsimplex_size ( simplex0 );
+  fx0 = optimsimplex_getfv ( this.simplex0 , 1 );
+  this.optbase = optimbase_set ( this.optbase , "-fx0" , fx0 );
+  this.optbase = optimbase_set ( this.optbase , "-xopt" , x0 );
+  this.optbase = optimbase_set ( this.optbase , "-fopt" , fx0 );
+  this.optbase = optimbase_set ( this.optbase , "-iterations" , 0 );
+  if ( this.kelleystagnationflag == 1 ) then
+    this = neldermead_kelleystag ( this );
+  end
+endfunction
+
+//
+// neldermead_kelleystag --
+//   Initialize Kelley's stagnation detection system when normalization is required,
+//   by computing kelleyalpha.
+//   If the simplex gradient is zero, then
+//   use alpha0 as alpha.
+// Arguments
+//   status : the status after the failing
+//     optimization process
+//   simplex : the simplex computed at the end of the failing
+//     optimization process
+//
+function this = neldermead_kelleystag ( this )
+    if this.kelleystagnationflag == 1 then
+      if this.kelleynormalizationflag == 0 then
+        this.kelleyalpha = this.kelleystagnationalpha0
+      else
+        [sg,this] = optimsimplex_gradientfv ( this.simplex0 , neldermead_costf , "forward" , this )
+        nsg = sg' * sg
+        sigma0 = optimsimplex_size ( this.simplex0 , "sigmaplus" )
+        if nsg==0.0 then 
+          this.kelleyalpha = this.kelleystagnationalpha0
+        else
+          this.kelleyalpha = this.kelleystagnationalpha0 * sigma0 / nsg
+        end
+      end
+      this = neldermead_log (this,sprintf("Test Stagnation Kelley : alpha0 = %e", this.kelleyalpha));
+    end
+endfunction
+  //
+  // _scaleinconstraints --
+  //   Given a point to scale and a reference point which satisfies the constraints, 
+  //   scale the point towards the reference point until it satisfies all the constraints.
+  //   Returns a list of key values with the following
+  //   keys : -status 0/1 -x x, where status
+  //   is 0 if the procedure has failed after -boxnbnlloops
+  //   iterations.
+  // Arguments
+  //   x : the point to scale
+  //   xref : the reference point
+  //   status : %T or %F
+  //   p : scaled point
+  //
+function [ this , status , p ] = _scaleinconstraints ( this , x , xref )
+  p = x
+  //
+  // Project the point into the bounds
+  //
+  [ this.optbase , hasbounds ] = optimbase_hasbounds ( this.optbase );
+  if ( hasbounds ) then
+    [ this.optbase , p ] = optimbase_proj2bnds ( this.optbase ,  p );
+    this = neldermead_log (this,sprintf(" > After projection into bounds p = [%s]" , ...
+      strcat(string(p)," ")));
+  end
+  //
+  // Adjust point to satisfy nonlinear inequality constraints
+  //
+  nbnlc = optimbase_cget ( this.optbase , "-nbineqconst" )
+  if ( nbnlc == 0 ) then
+    scaled = %T
+  else
+    scaled = %F
+    //
+    // Try the current point and see if the constraints are satisfied.
+    // If not, move the point "halfway" to the centroid,
+    // which should satisfy the constraints, if
+    // the constraints are convex.
+    // Perform this loop until the constraints are satisfied.
+    // If all loops have been performed without success, the scaling
+    // has failed.
+    //
+    for i = 1 : this.nbineqloops
+      [ this , constlist ] = neldermead_function ( this , p , index=2 );
+      feasible = %T
+      for ic = 1 : this.optbase.nbineqconst;
+        const = constlist ( ic );
+        if ( const < 0.0 ) then
+          this = neldermead_log (this,sprintf("Constraint #%d/%d is not satisfied", ...
+            ic , this.optbase.nbineqconst ));
+          feasible = %F;
+          break;
+        end
+      end
+      if ( feasible ) then
+        scaled = %T;
+        break;
+      else
+        this = neldermead_log (this,sprintf("Scaling inequality constraint at loop #%d/%d", ...
+          i , this.nbineqloops));
+        p = ( xref + p ) * this.ineqscaling;
+      end
+    end
+    this = neldermead_log (this,sprintf(" > After scaling into inequality constraints p = [%s]" , ...
+      strcat(string(p)," ") ) );
+  end
+  if ( scaled ) then
+    status = %T
+  else
+    status = %F
+    this = neldermead_log (this,sprintf(" > Impossible to scale into constraints after %d loops" , ...
+      this.optbase.nbineqconst ));
+  end
+endfunction
+//
+// neldermead_box --
+//   The Nelder-Mead algorithm, with variable-size simplex
+//   and modifications by Box for bounds and
+//   inequality constraints.
+//
+function this = neldermead_box ( this )
+  //
+  // Order the vertices for the first time
+  //
+  simplex = this.simplex0;
+  n = optimbase_cget ( this.optbase , "-numberofvariables" );
+  fvinitial = optimbase_get ( this.optbase , "-fx0" );
+  // Sort function values and x points by increasing function value order
+  this = neldermead_log (this,"Step #1 : order");
+  simplex = optimsimplex_sort ( simplex );
+  currentcenter = optimsimplex_center ( simplex );
+  currentxopt = optimbase_cget ( this.optbase , "-x0" );
+  newfvmean = optimsimplex_fvmean ( simplex );
+  nbve = optimsimplex_getnbve ( simplex );
+  ihigh = nbve;
+  inext = ihigh - 1
+  ilow = 1
+  [ this.optbase , hasbounds ] = optimbase_hasbounds ( this.optbase );
+  nbnlc = optimbase_cget ( this.optbase , "-nbineqconst" )
+  //
+  // Initialize
+  //
+  terminate = 0;
+  iter = 0;
+  //
+  // Nelder-Mead Loop
+  //
+  while ( terminate == 0 )
+    this.optbase = optimbase_incriter ( this.optbase );
+    iter = iter + 1;
+    xlow = optimsimplex_getx ( simplex , ilow )
+    flow = optimsimplex_getfv ( simplex , ilow )
+    xhigh = optimsimplex_getx ( simplex , ihigh )
+    fhigh = optimsimplex_getfv ( simplex , ihigh )
+    xn = optimsimplex_getx ( simplex , inext )
+    fn = optimsimplex_getfv ( simplex , inext )
+    //
+    // Store history
+    //
+    xcoords = optimsimplex_getallx ( simplex )
+    this = neldermead_storehistory ( this , n , flow , xlow , xcoords );
+    deltafv = abs(optimsimplex_deltafvmax ( simplex ));
+    currentfopt = flow;
+    previousxopt = currentxopt;
+    currentxopt = xlow;
+    previouscenter = currentcenter;
+    currentcenter = optimsimplex_center ( simplex );
+    oldfvmean = newfvmean;
+    newfvmean = optimsimplex_fvmean ( simplex );
+    totaliter = optimbase_get ( this.optbase , "-iterations" );
+    funevals = optimbase_get ( this.optbase , "-funevals" );
+    ssize = optimsimplex_size ( simplex )
+    this = neldermead_log (this,sprintf("================================================================="));
+    this = neldermead_log (this,sprintf("Iteration #%d (total = %d)",iter,totaliter));
+    this = neldermead_log (this,sprintf("Function Eval #%d",funevals));
+    this = neldermead_log (this,sprintf("Xopt : [%s]",strcat(string(xlow)," ")));
+    this = neldermead_log (this,sprintf("Fopt : %e",flow));
+    this = neldermead_log (this,sprintf("DeltaFv : %e",deltafv));
+    this = neldermead_log (this,sprintf("Center : [%s]",strcat(string(currentcenter)," ")));
+    this = neldermead_log (this,sprintf("Size : %e",ssize));
+    str = optimsimplex_tostring ( simplex )
+    for i = 1:nbve
+      this = neldermead_log (this,str(i));
+    end
+    neldermead_outputcmd ( this, "iter" , simplex )
+
+    //
+    // Update termination flag
+    //
+    if ( iter > 1 ) then
+      [this , terminate , status] = neldermead_termination (this , ...
+        fvinitial , oldfvmean , newfvmean , previouscenter , currentcenter , simplex );
+      if (terminate==1) then
+        this = neldermead_log (this,sprintf("Terminate with status : %s",status));
+        break
+      end
+    end
+    //
+    // Compute xbar, center of better vertices
+    //
+    this = neldermead_log (this,sprintf("Reflect"));
+    xbar = optimsimplex_xbar ( simplex );
+    this = neldermead_log (this,sprintf("xbar=[%s]" , strcat(string(xbar)," ")));
+    //
+    // Reflect the worst point with respect to center
+    //
+    xr = neldermead_interpolate ( xbar , xhigh , this.rho );
+    // Adjust point to satisfy bounds and nonlinear inequality constraints
+    if ( hasbounds | nbnlc > 0 ) then
+      [ this , status , xr ] = _scaleinconstraints ( this , xr , xbar )
+      if ( ~status ) then
+        status = "impossibleconstr"
+        break
+      end
+    end
+    [ this , fr ] = neldermead_function ( this , xr );
+    this = neldermead_log (this,sprintf("xr=[%s], f(xr)=%f", strcat(string(xr)," ") , fr));
+    if ( fr >= flow & fr < fn ) then
+      this = neldermead_log (this,sprintf("  > Perform reflection"));
+      simplex = optimsimplex_setve ( simplex , ihigh , fr , xr )
+    elseif ( fr < flow ) then
+      // Expand
+      this = neldermead_log (this,sprintf("Expand"));
+      xe = neldermead_interpolate ( xbar , xhigh , this.rho*this.chi );
+      // Adjust point to satisfy bounds and nonlinear inequality constraints
+      if ( hasbounds | nbnlc > 0 ) then
+        [ this , status , xe ] = _scaleinconstraints ( this , xe , xbar )
+        if ( ~status ) then
+          status = "impossibleconstr"
+          break
+        end
+      end
+      [ this ,fe] = neldermead_function ( this ,xe);
+      this = neldermead_log (this,sprintf("xe=[%s], f(xe)=%f", strcat(string(xe)," ") , fe ));
+      if (fe < fr) then
+        this = neldermead_log (this,sprintf("  > Perform Expansion"));
+        simplex = optimsimplex_setve ( simplex , ihigh , fe , xe )
+      else
+        this = neldermead_log (this,sprintf("  > Perform reflection"));
+        simplex = optimsimplex_setve ( simplex , ihigh , fr , xr )
+      end
+    elseif ( fr >= fn & fr < fhigh ) then
+      // Outside contraction
+      this = neldermead_log (this,sprintf("Contract - outside"));
+      xc = neldermead_interpolate ( xbar , xhigh , this.rho*this.gamma );
+      // Adjust point to satisfy bounds and nonlinear inequality constraints
+      if ( hasbounds | nbnlc > 0 ) then
+        [ this , status , xc ] = _scaleinconstraints ( this , xc , xbar )
+        if ( ~status ) then
+          status = "impossibleconstr"
+          break
+        end
+      end
+      [ this ,fc] = neldermead_function ( this ,xc);
+      this = neldermead_log (this,sprintf("xc=[%s], f(xc)=%f", strcat(string(xc)," ") , fc));
+      if ( fc <= fr ) then
+        this = neldermead_log (this,sprintf("  > Perform Outside Contraction"));
+        simplex = optimsimplex_setve ( simplex , ihigh , fc , xc )
+      else
+        //  Shrink
+        this = neldermead_log (this,sprintf("  > Perform Shrink"));
+        [ simplex , this ] = optimsimplex_shrink ( simplex , neldermead_costf , this.sigma , this );
+      end
+    else
+      // ( fr >= fn & fr >= fhigh )  
+      // Inside contraction
+      this = neldermead_log (this,sprintf("Contract - inside"));
+      xc = neldermead_interpolate ( xbar , xhigh , -this.gamma );
+      // Adjust point to satisfy bounds and nonlinear inequality constraints
+      if ( hasbounds | nbnlc > 0 ) then
+        [ this , status , xc ] = _scaleinconstraints ( this , xc , xbar )
+        if ( ~status ) then
+          status = "impossibleconstr"
+          break
+        end
+      end
+      [ this ,fc] = neldermead_function ( this ,xc);
+      this = neldermead_log (this,sprintf("xc=[%s], f(xc)=%f", strcat(string(xc)," ") , fc));
+      if ( fc < fhigh ) then
+        this = neldermead_log (this,sprintf("  > Perform Inside Contraction"));
+        simplex = optimsimplex_setve ( simplex , ihigh , fc , xc )
+      else
+        //  Shrink
+        this = neldermead_log (this,sprintf("  > Perform Shrink"));
+        [ simplex , this ] = optimsimplex_shrink ( simplex , neldermead_costf , this.sigma , this )
+      end
+    end
+    //
+    // Sort simplex
+    //
+    this = neldermead_log (this,sprintf("Sort"));
+    simplex  = optimsimplex_sort ( simplex );
+  end
+  this.optbase = optimbase_set ( this.optbase , "-xopt" , xlow );
+  this.optbase = optimbase_set ( this.optbase , "-fopt" , flow );
+  this.optbase = optimbase_set ( this.optbase , "-status" , status );
+  this.simplexopt = simplex;
+endfunction
+
diff --git a/scilab/modules/optimization/macros/neldermead/neldermead_updatesimp.sci b/scilab/modules/optimization/macros/neldermead/neldermead_updatesimp.sci
new file mode 100644 (file)
index 0000000..6c09069
--- /dev/null
@@ -0,0 +1,89 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+//
+// neldermead_updatesimp --
+//   Update the initial simplex simplex0 for a restart.
+// Arguments
+//   <>
+//
+function this = neldermead_updatesimp ( this )
+  simplex0 = optimsimplex_new ( );
+  xopt = optimbase_get ( this.optbase , "-xopt" );
+  select this.restartsimplexmethod
+  case "oriented" then
+    [ simplex0 , this ] = optimsimplex_oriented ( this.simplexopt , neldermead_costf , this )
+  case "axes" then
+    [ simplex0 , this ] = optimsimplex_axes ( simplex0 , ...
+      xopt' , neldermead_costf , this.simplex0length , this );
+  case "spendley" then
+    [ simplex0 , this ] = optimsimplex_spendley ( simplex0 , ...
+      xopt' , neldermead_costf , this.simplex0length , this );
+  case "pfeffer" then
+    [ simplex0 , this ] = optimsimplex_pfeffer ( simplex0 , ...
+      xopt' , neldermead_costf , this.simplex0deltausual , ...
+      this.simplex0deltazero , this );
+  case "randbounds" then
+    if ( this.boxnbpoints=="2n" ) then
+      this.boxnbpointseff = 2 * this.numberofvariables
+    else
+      this.boxnbpointseff = this.boxnbpoints
+    end
+    if ( ~hasbounds ) then
+      error ( "Randomized bounds initial simplex is not available without bounds." )
+    end
+    [ simplex0 , this ] = optimsimplex_randbounds ( simplex0 , xopt' , ...
+      neldermead_costf , this.optbase.boundsmin , this.optbase.boundsmax , ...
+      this.boxnbpointseff  , this )
+  else
+    errmsg = sprintf("Unknown restart simplex method %s",this.restartsimplexmethod)
+    error(errmsg)
+  end
+  //
+  // Scale the simplex into the bounds and the nonlinear inequality constraints, if any
+  //
+  nbve = optimsimplex_getnbve ( simplex0 );
+  this = neldermead_log (this,"Before scaling:");
+    str = optimsimplex_tostring ( simplex0 )
+    for i = 1:nbve
+      this = neldermead_log (this,str(i));
+    end
+  [ this.optbase , hasbounds ] = optimbase_hasbounds ( this.optbase );
+  if ( hasbounds | this.optbase.nbineqconst > 0 ) then
+    this = neldermead_log (this,sprintf("Scaling initial simplex into nonlinear inequality constraints..."));
+    nbve = optimsimplex_getnbve ( simplex0 )
+    for ive = 1 : nbve
+      x = optimsimplex_getx ( simplex0 , ive )
+      this = neldermead_log (this,sprintf("Scaling vertex #%d/%d at ["+...
+        strcat(string(x)," ")+"]... " , ...
+        ive , nbve ));
+      [ this , status , xp ] = _scaleinconstraints ( this , x , xopt )
+      if ( ~status ) then
+        errmsg = sprintf("Impossible to scale the vertex #%d/%d at ["+...
+          strcat(string(x)," ")+"] into inequality constraints", ...
+          ive , nbve );
+        error(errmsg);
+      end
+      if ( or(x <> xp) ) then
+        [ this , fv ] = neldermead_function ( this , xp )
+        simplex0 = optimsimplex_setve ( simplex0 , ive , fv , xp )
+      end
+    end
+  end
+  this = neldermead_log (this,"After scaling:");
+    str = optimsimplex_tostring ( simplex0 )
+    for i = 1:nbve
+      this = neldermead_log (this,str(i));
+    end
+  this.simplex0 = optimsimplex_destroy ( this.simplex0 )
+  this.simplex0 = simplex0;
+  this.simplexsize0 = optimsimplex_size ( simplex0 );
+  this.simplex0 = optimsimplex_sort ( this.simplex0 )
+endfunction
+
diff --git a/scilab/modules/optimization/macros/neldermead/nmplot_cget.sci b/scilab/modules/optimization/macros/neldermead/nmplot_cget.sci
new file mode 100644 (file)
index 0000000..94f2415
--- /dev/null
@@ -0,0 +1,31 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+
+//
+// nmplot_cget --
+//   Get the value for the given key.
+//   If the key is unknown, generates an error.
+//
+function value = nmplot_cget (this,key)
+  select key
+  case "-verbose" then
+    value = this.verbose;
+  case "-simplexfn" then
+    value = this.simplexfn;
+  case "-fbarfn" then
+    value = this.fbarfn;
+  case "-foptfn" then
+    value = this.foptfn;
+  case "-sigmafn" then
+    value = this.sigmafn;
+  else
+    this.nmbase = neldermead_configure ( this.nmbase , key , value )
+  end
+endfunction
diff --git a/scilab/modules/optimization/macros/neldermead/nmplot_configure.sci b/scilab/modules/optimization/macros/neldermead/nmplot_configure.sci
new file mode 100644 (file)
index 0000000..10971ea
--- /dev/null
@@ -0,0 +1,33 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+//
+// nmplot_configure --
+//   Configure nmplot and returns the modified object.
+//
+function this = nmplot_configure (this,key,value)
+  select key
+  case "-verbose" then
+    this.verbose = value;
+    this.nmbase = neldermead_configure ( this.nmbase , "-verbose" , value )
+  case "-simplexfn" then
+    this.simplexfn = value;
+  case "-fbarfn" then
+    this.fbarfn = value;
+  case "-foptfn" then
+    this.foptfn = value;
+  case "-sigmafn" then
+    this.sigmafn = value;
+  case "-outputcommand" then
+    errmsg = sprintf("Unknown key %s",key)
+    error(errmsg)
+  else
+    this.nmbase = neldermead_configure ( this.nmbase , key , value )
+  end
+endfunction
diff --git a/scilab/modules/optimization/macros/neldermead/nmplot_contour.sci b/scilab/modules/optimization/macros/neldermead/nmplot_contour.sci
new file mode 100644 (file)
index 0000000..03fe734
--- /dev/null
@@ -0,0 +1,32 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+//
+// nmplot_contour --
+//   Plot the contours of the cost function.
+//   The cost function must be a function with two parameters.
+// Arguments
+//   xmin , xmax , ymin , ymax : the bounds for the contour plot
+//   nx , ny : the number of points in the directions x, y
+//   xdata , ydata , zdata : vectors of data, as required by the contour command
+//
+function [this , xdata , ydata , zdata ] = nmplot_contour ( this , xmin , xmax , ymin , ymax , nx , ny )
+  stepx = (xmax - xmin)/nx
+  xdata = xmin:stepx:xmax;
+  stepy = (ymax - ymin)/ny
+  ydata = ymin:stepy:ymax;
+  for ix = 1:length(xdata)
+    for iy = 1:length(ydata)
+      x = [xdata(ix) ydata(iy)]
+      [this.nmbase,f] = neldermead_function ( this.nmbase , x );
+      zdata ( ix , iy ) = f;
+    end
+  end
+endfunction
+
diff --git a/scilab/modules/optimization/macros/neldermead/nmplot_destroy.sci b/scilab/modules/optimization/macros/neldermead/nmplot_destroy.sci
new file mode 100644 (file)
index 0000000..b921a5f
--- /dev/null
@@ -0,0 +1,16 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+//
+// nmplot_destroy --
+//   Destroy a Nelder-Mead plot object.
+//
+function this = nmplot_destroy (this)
+  this.nmbase = neldermead_destroy ( this.nmbase )
+endfunction
diff --git a/scilab/modules/optimization/macros/neldermead/nmplot_display.sci b/scilab/modules/optimization/macros/neldermead/nmplot_display.sci
new file mode 100644 (file)
index 0000000..63abb86
--- /dev/null
@@ -0,0 +1,18 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+//
+// nmplot_display --
+//   Display a Nelder-Mead engine
+// Arguments
+//
+function this = nmplot_display ( this )
+  this.nmbase = neldermead_display ( this.nmbase )
+endfunction
+
diff --git a/scilab/modules/optimization/macros/neldermead/nmplot_get.sci b/scilab/modules/optimization/macros/neldermead/nmplot_get.sci
new file mode 100644 (file)
index 0000000..ad41484
--- /dev/null
@@ -0,0 +1,19 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+
+//
+// nmplot_get --
+//   Get the value for the given key.
+//   If the key is unknown, generates an error.
+//
+function value = nmplot_get (this,key)
+  value = neldermead_get ( this.nmbase );
+endfunction
+
diff --git a/scilab/modules/optimization/macros/neldermead/nmplot_historyplot.sci b/scilab/modules/optimization/macros/neldermead/nmplot_historyplot.sci
new file mode 100644 (file)
index 0000000..33a4528
--- /dev/null
@@ -0,0 +1,39 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+//
+// nmplot_historyplot --
+//  Plots the history from the given data file
+// Arguments
+//  this : the current nmplot object
+//  datafile : the data file which contains the history
+//  mytitle , myxlabel , myylabel : the parameters of the plot
+//
+function nmplot_historyplot ( this , datafile  , mytitle , myxlabel , myylabel )
+  if (~isdef('mytitle','local')) then
+    mytitle = "";
+  end
+  if (~isdef('myxlabel','local')) then
+    myxlabel = "";
+  end
+  if (~isdef('myylabel','local')) then
+    myylabel = "";
+  end
+  exec(datafile,-1);
+  nbiter = size ( history , 1 )
+  n = neldermead_cget ( this.nmbase , "-numberofvariables" )
+  for iter = 1:nbiter
+    plot2d ( history(1:nbiter,1) , history(1:nbiter,2) )
+  end
+  f = gcf();
+  f.children.title.text = mytitle;
+  f.children.x_label.text = myxlabel;
+  f.children.y_label.text = myylabel;
+endfunction
+
diff --git a/scilab/modules/optimization/macros/neldermead/nmplot_log.sci b/scilab/modules/optimization/macros/neldermead/nmplot_log.sci
new file mode 100644 (file)
index 0000000..9888b32
--- /dev/null
@@ -0,0 +1,19 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+//
+// nmplot_log --
+//   Prints the given message.
+//
+function this = nmplot_log (this,msg)
+  if this.verbose == 1 then
+     mprintf("%s\n",msg);
+  end
+endfunction
+
diff --git a/scilab/modules/optimization/macros/neldermead/nmplot_new.sci b/scilab/modules/optimization/macros/neldermead/nmplot_new.sci
new file mode 100644 (file)
index 0000000..ff213ea
--- /dev/null
@@ -0,0 +1,33 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+//
+// nmplot_new --
+//   Creates a new Nelder - Mead plot object.
+//
+function newobj = nmplot_new ()
+  newobj = tlist(["T_NELDERMEADPLOT",...
+    "verbose","simplexfn","fbarfn","foptfn","sigmafn","nmbase",...
+    "simplexhandle","fbarhandle","fopthandle","sigmahandle"]);
+  newobj.verbose = 0;
+  newobj.simplexfn = "";
+  newobj.fbarfn = "";
+  newobj.foptfn = "";
+  newobj.sigmafn = "";
+  newobj.simplexhandle = 0;
+  newobj.fbarhandle = 0;
+  newobj.fopthandle = 0;
+  newobj.sigmahandle = 0;
+  //
+  // Create and configure parent class
+  //
+  newobj.nmbase = neldermead_new();
+  newobj.nmbase = neldermead_configure ( newobj.nmbase , "-outputcommand" , nmplot_outputcmd );
+endfunction
+
diff --git a/scilab/modules/optimization/macros/neldermead/nmplot_outputcmd.sci b/scilab/modules/optimization/macros/neldermead/nmplot_outputcmd.sci
new file mode 100644 (file)
index 0000000..4124ae9
--- /dev/null
@@ -0,0 +1,61 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licen