fr.inria.optimization.cmaes
Class CMAEvolutionStrategy

java.lang.Object
  extended by fr.inria.optimization.cmaes.CMAEvolutionStrategy
All Implemented Interfaces:
java.io.Serializable

public class CMAEvolutionStrategy
extends java.lang.Object
implements java.io.Serializable

implements the Covariance Matrix Adaptation Evolution Strategy (CMA-ES) for non-linear, non-convex, non-smooth, global function minimization. The CMA-Evolution Strategy (CMA-ES) is a reliable stochastic optimization method which should be applied, if derivative based methods, e.g. quasi-Newton BFGS or conjugate gradient, fail due to a rugged search landscape (e.g. noise, local optima, outlier, etc.) of the objective function. Like a quasi-Newton method the CMA-ES learns and applies a variable metric of the underlying search space. Unlike a quasi-Newton method the CMA-ES does neither estimate nor use gradients, making it considerably more reliable in terms of finding a good, or even close to optimal, solution, finally.

In general, on smooth objective functions the CMA-ES is roughly ten times slower than BFGS (counting objective function evaluations, no gradients provided). For up to N=10 variables also the derivative-free simplex direct search method (Nelder & Mead) can be faster, but it is far less reliable than CMA-ES.

The CMA-ES is particularly well suited for non-separable and/or badly conditioned problems. To observe the advantage of CMA compared to a conventional evolution strategy, it will usually take about 30×N function evaluations. On difficult problems the complete optimization (a single run) is expected to take roughly between 30×N and 300×N2 function evaluations.

The main functionality is provided by the methods double[][] samplePopulation() and updateDistribution(double[]) or updateDistribution(double[][], double[]). Here is an example code snippet, see file CMAExample1.java for a similar example, and CMAExample2.java for a more extended example with multi-starts implemented.

        // new a CMA-ES and set some initial values
        CMAEvolutionStrategy cma = new CMAEvolutionStrategy();
        cma.readProperties(); // read options, see file CMAEvolutionStrategy.properties
        cma.setDimension(10); // overwrite some loaded properties
        cma.setTypicalX(0.5); // in each dimension, setInitialX can be used as well
        cma.setInitialStandardDeviation(0.2); // also a mandatory setting 
        cma.opts.stopFitness = 1e-9;          // optional setting

        // initialize cma and get fitness array to fill in later
        double[] fitness = cma.init();  // new double[cma.parameters.getPopulationSize()];

        // initial output to files
        cma.writeToDefaultFilesHeaders(0); // 0 == overwrites old files

        // iteration loop
        while(cma.stopConditions.getNumber() == 0) {

            // core iteration step 
            double[][] pop = cma.samplePopulation(); // get a new population of solutions
            for(int i = 0; i < pop.length; ++i) {    // for each candidate solution i
                fitness[i] = fitfun.valueOf(pop[i]); //    compute fitness value, where fitfun
            }                                        //    is the function to be minimized
            cma.updateDistribution(fitness);         // use fitness array to update search distribution

            // output to files
            cma.writeToDefaultFiles();
            ...in case, print output to console, eg. cma.println(), 
               or process best found solution, getBestSolution()...
        } // while 

        // evaluate mean value as it is the best estimator for the optimum
        cma.setFitnessOfMeanX(fitfun.valueOf(cma.getMeanX())); // updates the best ever solution 
        ...retrieve best solution, termination criterion via stopConditions etc...    

        return cma.getBestX(); // best evaluated search point 

   
The output generated by the function writeToDefaultFiles can be plotted in Matlab or Scilab using plotcmaesdat.m or plotcmaesdat.sci respectively, see writeToDefaultFiles().

The implementation follows very closely [3]. It supports small and large population sizes, the latter by using the rank-µ-update [2], together with weighted recombination for the covariance matrix, an improved parameter setting for large populations [3] and an (initially) diagonal covariance matrix [5]. The latter is particularly useful for large dimension, e.g. larger 100. The default population size is small [1]. An independent restart procedure with increasing population size [4] is implemented in class cmaes.examples.CMAExample2.

Practical hint: In order to solve an optimization problem in reasonable time it needs to be reasonably encoded. In particular the domain width of variables should be similar for all objective variables (decision variables), such that the initial standard deviation can be chosen the same for each variable. For example, an affine-linear transformation could be applied to each variable, such that its typical domain becomes the interval [0,10]. For positive variables a log-encoding or a square-encoding should be considered, to avoid the need to set a hard boundary at zero, see here for a few more details.

References

Author:
Nikolaus Hansen, 1996, 2003, 2005, 2007
See Also:
samplePopulation(), updateDistribution(double[]), Serialized Form

Nested Class Summary
 class CMAEvolutionStrategy.CMAException
          very provisional error handling.
 class CMAEvolutionStrategy.StopCondition
          Interface to whether and which termination criteria are satisfied
 
Field Summary
 CMAOptions options
          options that can be changed (fields can be assigned) at any time to control the running behavior
 CMAParameters parameters
          strategy parameters that can be set initially
 double[][] population
          recent population, no idea whether this is useful to be public
 CMAEvolutionStrategy.StopCondition stopConditions
          permits access to whether and which termination conditions were satisfied
 java.lang.String versionNumber
           
 
Constructor Summary
CMAEvolutionStrategy()
          postpones most initialization.
CMAEvolutionStrategy(int dimension)
           
CMAEvolutionStrategy(java.util.Properties properties)
          retrieves options and strategy parameters from properties input, see file CMAEvolutionStrategy.properties for valid properties
CMAEvolutionStrategy(java.lang.String propertiesFileName)
          reads properties (options, strategy parameter settings) from file propertiesFileName
 
Method Summary
 double getAxisRatio()
          ratio between length of longest and shortest axis of the distribution ellipsoid, which is the square root of the largest divided by the smallest eigenvalue of the covariance matrix
 long getBestEvaluationNumber()
           
 double getBestFunctionValue()
          objective function value of best solution found so far.
 double getBestRecentFunctionValue()
          objective function value of the, best solution in the recent iteration (population)
 ISolutionPoint getBestRecentSolution()
          Get best evaluated solution of the last (recent) iteration.
 double[] getBestRecentX()
          best search point of the recent iteration.
 CMASolution getBestSolution()
          get best evaluated solution found so far.
 double[] getBestX()
          get best evaluated search point found so far.
 long getCountEval()
          number of objective function evaluations counted so far
 long getCountIter()
          number of iterations conducted so far
 java.lang.String getDataC()
          correlations and covariances of the search distribution.
 java.lang.String getDataRowAxlen()
          6-th to last column are sorted axis lengths axlen
 java.lang.String getDataRowFitness()
           
 java.lang.String getDataRowStddev()
           
 java.lang.String getDataRowXMean()
           
 java.lang.String getDataRowXRecentBest()
           
 int getDimension()
           
 double[] getInitialX()
          the final setting of initial x can be retrieved only after init() was called
 double[] getMeanX()
          Get mean of the current search distribution.
 CMAParameters getParameterDefaults()
          get default parameters in new CMAParameters instance, dimension must have been set before calling getDefaults
 CMAParameters getParameterDefaults(int N)
          get default parameters in new CMAParameters instance
 java.lang.String getPrintAnnotation()
          returns an annotation string for the printings of method println().
 java.lang.String getPrintLine()
          printing output in a viewable formatting style.
 java.util.Properties getProperties()
          get properties previously read from a property file.
 java.util.Random getRand()
          get used random number generator instance
 long getSeed()
           
 double getWorstRecentFunctionValue()
          objective function value of the, worst solution of the recent iteration.
 java.lang.String helloWorld()
          returns an informative initial message of the CMA-ES optimizer
 double[] init()
           
 double[] init(int dimension)
           
 double[] init(int dimension, double[] initialX, double[] initialStandardDeviations)
          initialization providing all mandatory input arguments at once.
 double mahalanobisNorm(double[] x, double[] mean)
          compute Mahalanobis norm of x - mean w.r.t.
 void println()
          calls println(getPrintLine())
 void println(java.lang.String s)
          calls System.out.println(s) and writes s to the file outcmaesdisp.dat by default, if writeDisplayToFile option is > 0
 void printlnAnnotation()
           
 void printlnHelloWorld()
          calls println(helloWorld())
 java.util.Properties readProperties()
          reads properties from default input file CMAEvolutionStrategy.properties and sets options and strategy parameter settings accordingly.
 java.util.Properties readProperties(java.lang.String fileName)
          reads properties from fileName and sets strategy parameters and options accordingly
 double[] resampleSingle(int index)
          re-generate the index-th solution.
 double[][] samplePopulation()
          Samples the recent search distribution lambda times
 long setCountEval(long c)
          number of objective function evaluations counted so far
 void setDimension(int n)
          search space dimensions must be set before the optimization is started.
 CMASolution setFitnessOfMeanX(double fitness)
          eventually replaces the best-ever solution
 void setFromProperties(java.util.Properties properties)
          reads properties from Properties class input and sets options and parameters accordingly
 void setInitialStandardDeviation(double startsigma)
           
 void setInitialStandardDeviations(double[] startsigma)
           
 void setInitialX(double x)
          sets initialX to the same value in each coordinate
 void setInitialX(double[] x)
          set initial search point to input value x.
 void setInitialX(double[] l, double[] u)
          set initial seach point x coordinate-wise uniform between l and u, dimension needs to have been set before
 void setInitialX(double l, double u)
          set initial seach point xmean coordinate-wise uniform between l and u, dimension needs to have been set before
 void setRand(java.util.Random rand)
           
 void setSeed(long seed)
          Setter for the seed for the random number generator java.util.Random(seed).
 void setTypicalX(double x)
          sets typicalX value, the same value in each coordinate
 void setTypicalX(double[] x)
          sets typicalX value, which will be overwritten by initialX setting from properties or setInitialX(double[]) function call.
 void updateDistribution(double[] functionValues)
          update of the search distribution after samplePopulation().
 void updateDistribution(double[][] population, double[] functionValues)
          update of the search distribution from a population and its function values, see updateDistribution(double[][], double[], 0).
 void updateDistribution(double[][] population, double[] functionValues, int nInjected)
          update of the search distribution from a population and its function values, an alternative interface for updateDistribution(double[] functionValues).
 void writeToDefaultFiles()
          writes data output to default files.
 void writeToDefaultFiles(int flgForce)
          writes data output to default files.
 void writeToDefaultFiles(java.lang.String fileNamePrefix)
          writes data to files fileNamePrefixfit.dat, ...xmean.dat ...xbest.dat, ...std.dat, ...axlen.dat.
 void writeToDefaultFilesHeaders(int flgAppend)
          writes header lines to the default files.
 void writeToDefaultFilesHeaders(java.lang.String fileNamePrefix, int flgAppend)
          Writes headers (column annotations) to files fit.dat, ...xmean.dat ...xbest.dat, ...std.dat, ...axlen.dat, and in case the first data line, usually with the initial values.
 void writeToFile(java.lang.String filename, java.lang.String data, int flgAppend)
          writes a string to a file, overwrites first, appends afterwards.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionNumber

public final java.lang.String versionNumber

options

public CMAOptions options
options that can be changed (fields can be assigned) at any time to control the running behavior


parameters

public CMAParameters parameters
strategy parameters that can be set initially


stopConditions

public CMAEvolutionStrategy.StopCondition stopConditions
permits access to whether and which termination conditions were satisfied


population

public double[][] population
recent population, no idea whether this is useful to be public

Constructor Detail

CMAEvolutionStrategy

public CMAEvolutionStrategy()
postpones most initialization. For initialization use setInitial... methods or set up a properties file, see file "CMAEvolutionStrategy.properties".


CMAEvolutionStrategy

public CMAEvolutionStrategy(java.util.Properties properties)
retrieves options and strategy parameters from properties input, see file CMAEvolutionStrategy.properties for valid properties


CMAEvolutionStrategy

public CMAEvolutionStrategy(java.lang.String propertiesFileName)
reads properties (options, strategy parameter settings) from file propertiesFileName


CMAEvolutionStrategy

public CMAEvolutionStrategy(int dimension)
Parameters:
dimension - search space dimension, dimension of the objective functions preimage, number of variables
Method Detail

init

public double[] init(int dimension,
                     double[] initialX,
                     double[] initialStandardDeviations)
initialization providing all mandatory input arguments at once. The following two is equivalent
          cma.init(N, X, SD);
 
and
          cma.setInitalX(X);  // 
          cma.setInitialStandardDeviations(SD);
          cma.init(N);
 
The call to init is a point of no return for parameter settings, and demands all mandatory input be set. init then forces the setting up of everything and calls parameters.supplementRemainders(). If init was not called before, it is called once in samplePopulation(). The return value is only provided for sake of convenience.

Parameters:
dimension -
initialX - double[] can be of size one, where all variables are set to the same value, or of size dimension
initialStandardDeviations - can be of size one, where all standard deviations are set to the same value, or of size dimension
Returns:
double[] fitness of length population size lambda to assign and pass objective function values to updateDistribution(double[])
See Also:
init(), init(int), setInitialX(double[]), setTypicalX(double[]), setInitialStandardDeviations(double[]), samplePopulation(), CMAParameters.supplementRemainders(int, CMAOptions)

init

public double[] init(int dimension)
Parameters:
dimension - search space dimension
See Also:
init(int, double[], double[])

init

public double[] init()
See Also:
init(int, double[], double[])

getParameterDefaults

public CMAParameters getParameterDefaults()
get default parameters in new CMAParameters instance, dimension must have been set before calling getDefaults

See Also:
CMAParameters.getDefaults(int)

getParameterDefaults

public CMAParameters getParameterDefaults(int N)
get default parameters in new CMAParameters instance

See Also:
CMAParameters.getDefaults(int)

readProperties

public java.util.Properties readProperties()
reads properties from default input file CMAEvolutionStrategy.properties and sets options and strategy parameter settings accordingly. Options values can be changed at any time using this function.


readProperties

public java.util.Properties readProperties(java.lang.String fileName)
reads properties from fileName and sets strategy parameters and options accordingly

Parameters:
fileName - of properties file

setFromProperties

public void setFromProperties(java.util.Properties properties)
reads properties from Properties class input and sets options and parameters accordingly

Parameters:
properties - java.util.Properties key-value hash table
See Also:
readProperties()

samplePopulation

public double[][] samplePopulation()
Samples the recent search distribution lambda times

Returns:
double[][] population, lambda times dimension array of sampled solutions, where lambda == parameters.getPopulationSize()
See Also:
resampleSingle(int), updateDistribution(double[]), CMAParameters.getPopulationSize()

resampleSingle

public double[] resampleSingle(int index)
re-generate the index-th solution. After getting lambda solution points with samplePopulation() the i-th point, i=0...lambda-1, can be sampled anew by resampleSingle(i).
 double[][] pop = cma.samplePopulation();
 // check some stuff, i-th solution went wrong, therefore
 pop[i] = cma.resampleSingle(i); // assignment to keep the population consistent
 for (i = 0,...)
   fitness[i] = fitfun.valueof(pop[i]);
 

See Also:
samplePopulation()

mahalanobisNorm

public double mahalanobisNorm(double[] x,
                              double[] mean)
compute Mahalanobis norm of x - mean w.r.t. the current distribution (using covariance matrix times squared step-size for the inner product). TODO: to be tested.

Parameters:
x -
mean -
Returns:
Malanobis norm of x - mean: sqrt((x-mean)' C^-1 (x-mean)) / sigma

updateDistribution

public void updateDistribution(double[][] population,
                               double[] functionValues)
update of the search distribution from a population and its function values, see updateDistribution(double[][], double[], 0). This might become updateDistribution(double[][], double[], popsize) in future.

Parameters:
population - double[lambda][N], lambda solutions
functionValues - double[lambda], respective objective values of population
See Also:
samplePopulation(), updateDistribution(double[]), updateDistribution(double[][], double[], int)

updateDistribution

public void updateDistribution(double[][] population,
                               double[] functionValues,
                               int nInjected)
update of the search distribution from a population and its function values, an alternative interface for updateDistribution(double[] functionValues). functionValues is used to establish an ordering of the elements in population. The first nInjected elements do not need to originate from #samplePopulation() or can have been modified (TODO: to be tested).

Parameters:
population - double[lambda][N], lambda solutions
functionValues - double[lambda], respective objective values of population
nInjected - int, first nInjected solutions of population were not sampled by samplePopulation() or modified afterwards
See Also:
samplePopulation(), updateDistribution(double[])

updateDistribution

public void updateDistribution(double[] functionValues)
update of the search distribution after samplePopulation(). functionValues determines the selection order (ranking) for the solutions in the previously sampled population. This is just a different interface for updateDistribution(double[][], double[]).

See Also:
samplePopulation(), updateDistribution(double[][], double[])

getAxisRatio

public double getAxisRatio()
ratio between length of longest and shortest axis of the distribution ellipsoid, which is the square root of the largest divided by the smallest eigenvalue of the covariance matrix


getBestSolution

public CMASolution getBestSolution()
get best evaluated solution found so far. Remark that the distribution mean was not evaluated but is expected to have an even better function value.

Example: getBestSolution

Returns:
best solution (search point) found so far
See Also:
getBestRecentSolution(), getBestX(), getMeanX()

setFitnessOfMeanX

public CMASolution setFitnessOfMeanX(double fitness)
eventually replaces the best-ever solution

Parameters:
fitness - function value computed for the solution getMeanX()
Returns:
best-ever solution

getBestX

public double[] getBestX()
get best evaluated search point found so far. Remark that the distribution mean was not evaluated but is expected to have an even better function value.

Returns:
best search point found so far as double[]
See Also:
getMeanX()

getBestFunctionValue

public double getBestFunctionValue()
objective function value of best solution found so far.

Returns:
objective function value of best solution found so far
See Also:
getBestSolution()

getBestEvaluationNumber

public long getBestEvaluationNumber()

getBestRecentSolution

public ISolutionPoint getBestRecentSolution()
Get best evaluated solution of the last (recent) iteration. This solution is supposed to be more robust than the best ever solution in particular in possible case of mis-attributed good fitness values. Remark that the distribution mean was not evaluated but is expected to have an better function value.

Returns:
best solution (search point) in recent iteration
See Also:
getBestSolution(), getBestRecentX(), getMeanX()

getBestRecentX

public double[] getBestRecentX()
best search point of the recent iteration.

Returns:
Returns the recentFunctionValue.
See Also:
getBestRecentFunctionValue()

getBestRecentFunctionValue

public double getBestRecentFunctionValue()
objective function value of the, best solution in the recent iteration (population)

Returns:
Returns the recentFunctionValue.
See Also:
getBestEvaluationNumber(), getBestFunctionValue()

getWorstRecentFunctionValue

public double getWorstRecentFunctionValue()
objective function value of the, worst solution of the recent iteration.

Returns:
Returns the recentMaxFunctionValue.

getMeanX

public double[] getMeanX()
Get mean of the current search distribution. The mean should be regarded as the best estimator for the global optimimum at the given iteration. In particular for noisy problems the distribution mean is the solution of choice preferable to the best or recent best. The return value is not a copy. Therefore it should not be change it, without deep knowledge of the code (the effect of a mean change depends on the chosen transscription/implementation of the algorithm).

Returns:
mean value of the current search distribution
See Also:
getBestX(), getBestRecentX()

getDimension

public int getDimension()

getCountEval

public long getCountEval()
number of objective function evaluations counted so far


getCountIter

public long getCountIter()
number of iterations conducted so far


getInitialX

public double[] getInitialX()
the final setting of initial x can be retrieved only after init() was called

Returns:
double[] initialX start point chosen for distribution mean value xmean

getRand

public java.util.Random getRand()
get used random number generator instance


getProperties

public java.util.Properties getProperties()
get properties previously read from a property file.

Returns:
java.util.Properties key-value hash table
See Also:
readProperties()

getSeed

public long getSeed()
See Also:
setSeed(long)

setCountEval

public long setCountEval(long c)
number of objective function evaluations counted so far


setDimension

public void setDimension(int n)
search space dimensions must be set before the optimization is started.


setTypicalX

public void setTypicalX(double x)
sets typicalX value, the same value in each coordinate

See Also:
setTypicalX(double[])

setTypicalX

public void setTypicalX(double[] x)
sets typicalX value, which will be overwritten by initialX setting from properties or setInitialX(double[]) function call. Otherwise the initialX is sampled normally distributed from typicalX with initialStandardDeviations

See Also:
setTypicalX(double), setInitialX(double[]), setInitialStandardDeviations(double[])

setInitialStandardDeviation

public void setInitialStandardDeviation(double startsigma)

setInitialStandardDeviations

public void setInitialStandardDeviations(double[] startsigma)

setInitialX

public void setInitialX(double x)
sets initialX to the same value in each coordinate

Parameters:
x - value
See Also:
setInitialX(double[])

setInitialX

public void setInitialX(double l,
                        double u)
set initial seach point xmean coordinate-wise uniform between l and u, dimension needs to have been set before

Parameters:
l - double lower value
u - double upper value
See Also:
setInitialX(double[]), setInitialX(double[], double[])

setInitialX

public void setInitialX(double[] l,
                        double[] u)
set initial seach point x coordinate-wise uniform between l and u, dimension needs to have been set before

Parameters:
l - double lower value
u - double upper value

setInitialX

public void setInitialX(double[] x)
set initial search point to input value x. x.length==1 is possible, otherwise the search space dimension is set to x.length irrevocably

Parameters:
x - double[] initial point
See Also:
setInitialX(double), setInitialX(double, double)

setRand

public void setRand(java.util.Random rand)

setSeed

public void setSeed(long seed)
Setter for the seed for the random number generator java.util.Random(seed). Changing the seed will only take effect before init() was called.

Parameters:
seed - a long value to initialize java.util.Random(seed)

getPrintLine

public java.lang.String getPrintLine()
printing output in a viewable formatting style. The printing
 Iteration,#Fevals: rb Function Value Delta( best ,worst) |idx: Max SD idx: Min SD  | minsigD  sigma Axisratio | time, in eig
   164( 8),   1638: 5.5061568003892640e-08 (-4e-08,3e-08) |  0: 3.3e-05  8: 1.5e-05 | 1.4e-05 5.6e-05   2.34   |  0.1  0.0 
shows the value of getPrintAnnotation() in the first line and in the second line
  • 164 iteration number
  • ( 8) recently sampled search point in this iteration,
  • 1638: number of function evaluations
  • 5.5061568003892640e-08 objective function value F of the best point in the recent generation
  • (-4e-08, difference between the best ever evaluated function value to F,
  • 3e-08) | difference between the worst function value of the recent generation to F
  • 0: index of coordinate with largest standard deviation
  • 3.3e-05 respective standard deviation
  • 8: index of coordinate with smallest standard deviation
  • 1.5e-05 | respective standard deviation
  • index of coordinate with smallest standard deviation: respective standard deviation
  • | 1.4e-05 standard deviation in smallest principal axis direction
  • 5.6e-05 sigma
  • 2.34 axisratio, ie. quotient between the standard deviations in largest an smallest principal axis directions, ie. square root of the quotient between largest and smallest eigenvalue of covariance matrix C
  • 0.1 time, overall elapsed time in seconds
  • 0.0 in eig, overall time spent within eigendecompostion

    See Also:
    getPrintAnnotation()

  • getPrintAnnotation

    public java.lang.String getPrintAnnotation()
    returns an annotation string for the printings of method println().


    helloWorld

    public java.lang.String helloWorld()
    returns an informative initial message of the CMA-ES optimizer


    println

    public void println(java.lang.String s)
    calls System.out.println(s) and writes s to the file outcmaesdisp.dat by default, if writeDisplayToFile option is > 0

    See Also:
    getPrintLine()

    println

    public void println()
    calls println(getPrintLine())

    See Also:
    getPrintLine()

    printlnAnnotation

    public void printlnAnnotation()
    See Also:
    getPrintAnnotation()

    printlnHelloWorld

    public void printlnHelloWorld()
    calls println(helloWorld())

    See Also:
    helloWorld(), println(String)

    getDataRowFitness

    public java.lang.String getDataRowFitness()

    getDataRowXRecentBest

    public java.lang.String getDataRowXRecentBest()

    getDataRowXMean

    public java.lang.String getDataRowXMean()

    getDataRowAxlen

    public java.lang.String getDataRowAxlen()
    6-th to last column are sorted axis lengths axlen


    getDataRowStddev

    public java.lang.String getDataRowStddev()

    getDataC

    public java.lang.String getDataC()
    correlations and covariances of the search distribution. The first, '%#'-commented row contains itertation number, evaluation number, and sigma. In the remaining rows the upper triangular part contains variances and covariances sigma*sigma*c_ij. The lower part contains correlations c_ij / sqrt(c_ii * c_jj).


    writeToFile

    public void writeToFile(java.lang.String filename,
                            java.lang.String data,
                            int flgAppend)
    writes a string to a file, overwrites first, appends afterwards.

    Example: cma.writeToFile("cmaescorr.dat", cma.writeC());

    Parameters:
    filename - is a String giving the name of the file to be written
    data - is a String of text/data to be written
    flgAppend - for flgAppend>0 old data are not overwritten

    writeToDefaultFiles

    public void writeToDefaultFiles()
    writes data output to default files. Uses opts.outputFileNamesPrefix to create filenames. Columns 1-2 are iteration number and function evaluation count, columns 6- are the data according to the filename. Maximum time spent for writing can be controlled in the properties file.

    The output is written to files that can be printed in Matlab or Scilab (a free and easy to install Matlab "clone").

    Matlab:

              cd 'directory_where_outfiles_and_plotcmaesdat.m_file_are'
              plotcmaesdat;
     
    Scilab:
              cd 'directory_where_outfiles_and_plotcmaesdat.sci_file_are'
              getf('plotcmaesdat.sci');
              plotcmaesdat;
     

    See Also:
    writeToDefaultFiles(String fileNamePrefix), writeToDefaultFiles(int)

    writeToDefaultFiles

    public void writeToDefaultFiles(int flgForce)
    writes data output to default files. Maximum time spent for writing can be controlled in the properties file. For negative values no writing takes place, overruling the flgForce input parameter below.

    Parameters:
    flgForce - 0==write depending on time spent with writing, 1==write if the iteration count has changed, 2==write always, overruled by negative values of maxTimeFractionForWriteToDefaultFiles property
    See Also:
    writeToDefaultFiles()

    writeToDefaultFiles

    public void writeToDefaultFiles(java.lang.String fileNamePrefix)
    writes data to files fileNamePrefixfit.dat, ...xmean.dat ...xbest.dat, ...std.dat, ...axlen.dat.

    Parameters:
    fileNamePrefix - prefix String for filenames created to write data
    See Also:
    writeToDefaultFiles()

    writeToDefaultFilesHeaders

    public void writeToDefaultFilesHeaders(int flgAppend)
    writes header lines to the default files. Could become XML if needed.

    Parameters:
    flgAppend - == 0 means overwrite files, == 1 means append to files

    writeToDefaultFilesHeaders

    public void writeToDefaultFilesHeaders(java.lang.String fileNamePrefix,
                                           int flgAppend)
    Writes headers (column annotations) to files fit.dat, ...xmean.dat ...xbest.dat, ...std.dat, ...axlen.dat, and in case the first data line, usually with the initial values.

    Parameters:
    fileNamePrefix - String for filenames created to write data