Provides several direct search optimization algorithms based on the simplex method.
this = nmplot_display ( this )
This class provides several direct search optimization algorithms based on the simplex method.
The goal of this class is to provide a neldermead component with plotting features. It enables to make fast plots of the algorithm progress through the iterations.
It is a specialized neldermead class, with a specific output command. This output function allows to store the history of several datas through the iterations of the algorithm. These datas are :
the history of the coordinates of the simplex ,
the history of the function value (averaged on the vertices),
the history of the minimum function value in the simplex,
the history of the size of the simplex (as computed with the sigma+ method).
These data are stored into several data files during the optimization process. Several methods allows to plot the data stored into these data files.
The nmplot component is built on top of the neldermead component. The -outputcommand option (of the neldermead class) is not available since the nmplot class uses its own output function. Additionnal options -simplexfn, -fbarfn, -foptfn and -sigmafn are provided, which allows to configure the file names where the data is stored.
The nmplot class can be considered as a sample test case of the -outputcommand option of the neldermead class. It gives an example of the situation where the user wants to get specialized outputs out of the neldermead class.
Display the current settings in the console.
The current object.
In the following example, we use the fixed shape Spendley et al. simplex algorithm and find the minimum of a quadratic function. We begin by defining a quadratic function associated with 2 input variables. We then define an nmplot object and configure the object so that the "fixed" shape simplex algorithm is used with the regular initial simplex associated with the "spendley" key. Four files are configured, which will contain the history of the simplex, the history of fbar, fopt and sigma through the iterations. The search is performed by the nmplot_search function, which writes the 4 data files during the iterations. The nmplot_contour function is called in order to compute the arrays xdata, ydata and zdata which are required as input to the contour function. The nmplot_simplexhistory then uses the history of the simplex, as stored in the rosenbrock.fixed.history.simplex.txt data file, and plot the various simplices on the contour plot. The nmplot_historyplot is used with the files rosenbrock.fixed.history.fbar.txt, rosenbrock.fixed.history.fopt.txt and rosenbrock.fixed.history.sigma.txt, which produces 3 plots of the history of the optimization algorithm through the iterations.
mprintf("Defining quadratic function...\n"); function y=quadratic(x) y = x(1)^2 + x(2)^2 - x(1) * x(2); endfunction mprintf("Creating nmplot object...\n"); nm = nmplot_new (); nm = nmplot_configure(nm,"-numberofvariables",2); nm = nmplot_configure(nm,"-function",quadratic); nm = nmplot_configure(nm,"-x0",[2.0 2.0]'); nm = nmplot_configure(nm,"-maxiter",100); nm = nmplot_configure(nm,"-maxfunevals",300); nm = nmplot_configure(nm,"-tolxrelative",1.e-8); nm = nmplot_configure(nm,"-simplex0method","spendley"); nm = nmplot_configure(nm,"-method","fixed"); // // Setup output files // nm = nmplot_configure(nm,"-simplexfn","rosenbrock.fixed.history.simplex.txt"); nm = nmplot_configure(nm,"-fbarfn","rosenbrock.fixed.history.fbar.txt"); nm = nmplot_configure(nm,"-foptfn","rosenbrock.fixed.history.fopt.txt"); nm = nmplot_configure(nm,"-sigmafn","rosenbrock.fixed.history.sigma.txt"); // // Perform optimization // mprintf("Searching for minimum...\n"); nm = nmplot_search(nm); nmplot_display(nm); deletefile("rosenbrock.fixed.history.simplex.txt"); deletefile("rosenbrock.fixed.history.fbar.txt"); deletefile("rosenbrock.fixed.history.fopt.txt"); deletefile("rosenbrock.fixed.history.sigma.txt"); nm = nmplot_destroy(nm); | ![]() | ![]() |
Michael Baudin - INRIA - 2008-2009
Michael Baudin - Digiteo - 2009
Version | Description |
5.4.0 | nmplot_display was published up to Scilab 5.4.0
It is replaced with an overload of disp. |