DOCUMENTATION (...not comprehensive but hopefully quite useful...)
First of all you should spent 2-10 minutes to have a look at the files
cmaes_interface.h, and
example1.c,
not necessarily in this ordering.
Then, what follows is the more detailed documentation of the
functions from cmaes_interface.h.
double *
cmaes_init(cmaes_t * evo_ptr, int dimension ,
double *initialX, double *initialStdDev,
long seed, int lambda, const char *input_parameter_filename);
DEFAULTS of input parameters (invoked by 0 or NULL respectively):
dimension : 0 /* no default available */
initialX : [0.5,...,0.5]+Normal(0,initialStdDev^2), N-dimensional.
initialStdDev : [0.3,...,0.3], N-dimensional vector.
seed : random, see file actpar...
lambda : 4+(int)(3*log(N))
input_parameter_filename : "initials.par"
Input parameters:
evo_ptr: Pointer to CMA-ES struct cmaes_t will be initialized
within cmaes_init
Optional (default values invoked by zero):
dimension, int : Search space dimension N. Must be defined here
or in the input parameter file.
initialX, double *: Initial point in search space.
initialStdDev, double * : double array of size dimension
N. Coordinatewise initial standard deviation of the sample
distribution (sigma*sqrt(C[i][i])==initialStdDev[i]). The
expected initial distance between initialX and the optimum per
coordinate should be roughly initialStdDev. The entries should
not differ by several orders of magnitude (see doc.txt).
seed, int (randomly chosen by default): Random seed, written
to actparcmaes.par.
lambda, int : population size, number of sampled candidate
solutions per generation.
input_parameter_filename, char *: File which should be edited
properly. Filename "non" omits reading and writing of any
parameters in cmaes_init(), "writeonly" omits reading but
still writes used parameters to file "actparcmaes.par".
Return, double *: array of size lambda==popsize that can be
used to assign fitness values and pass them to
cmaes_UpdateDistribution().
Details: The dimension has to be defined > 0 here or in the
input parameter file ("initials.par").
CAVEAT: All input values are overwritten by values given in the parameter
input file initials.par.
char *
cmaes_SayHello(cmaes_t *): well, says hello, returns eg.
"(5,10)-CMA-ES(mu_eff=3.4), Ver="1.00.00.beta", dimension=9"
void
cmaes_resume_distribution(cmaes_t *evo_ptr, char *filename):
Input parameters:
evo_ptr, cmaes_t *: Pointer to cma-es struct.
filename: A file, that was written presumably by
cmaes_WriteToFile(evo_ptr, "resume", filename).
Details: Allows to restart with saved internal state (distribution)
variables (use cmaes_WriteToFile for saving). Keyword "resume"
followed by a filename in initials.par invokes this function during
initialization. Searches in filename for the last occurrence
of word "resume", followed by a dimension number, and reads the
subsequent values for xmean, evolution paths ps and pc, sigma
and covariance matrix. Note that cmaes_init() needs to be
called before calling cmaes_resume_distribution()
explicitely. In the former all the remaining
(strategy-)parameters are set. It can be useful to edit the
written parameters, in particular to increase sigma, before
resume.
Remarks: Not all internal state parameters are recovered. In
particular generation number and xbestever are not restored. For
covariance matrices with large condition numbers the writing
precision of 6 digits is not sufficient and resume will lead
to poor result.
void
cmaes_exit(cmaes_t *) releases the dynamically allocated memory,
including that of the return value of cmaes_init().
double *const*pop
cmaes_SamplePopulation(cmaes_t *evo_ptr)
Input parameters:
evo_ptr, cmaes_t *: Pointer to cma-es struct.
Return, double **: A pointer to a "population" of lambda
N-dimensional multivariate normally distributed samples.
double * const * x
cmaes_ReSampleSingle(cmaes_t evo_ptr, int index)
Input parameters:
evo_ptr, cmaes_t *: Pointer to cma-es struct.
index, int: index to an element of the returned value
of cmaes_SamplePopulation, double **pop. pop[index]
will be resampled where 0<=index<cmaes_Get("lambda")
must hold.
Return, double *: A pointer to the resampled "population".
Details: Can be called after cmaes_SamplePopulation to
resample single solutions of the population as often
as desired. Useful to implement a box constraints (boundary)
handling.
double * x
cmaes_SampleSingleInto(cmaes_t evo_ptr, double *x)
Input parameters:
evo_ptr, cmaes_t *: Pointer to cma-es struct.
x, double *: Solution vector that gets sampled
a new value. If x==NULL new memory is allocated
and must be released by the user.
Return, double *: A pointer to the resampled solution
vector, equals input x for x!=NULL on input.
Details: Can be called after cmaes_SamplePopulation to
resample single solutions. In general, the function
can be used to sample as many independent
mean+sigma*Normal(0,C) distributed vectors as desired.
Input x can be a pointer to an element of the vector
returned by SamplePopulation(), double * const * pop,
but this is inconsistent with the const qualifier
of the returned value and therefore rather ReSampleSingle()
should be used.
See also ReSampleSingle()
double * const x
cmaes_ReSampleSingle_old(cmaes_t evo_ptr, double *x)
Depreciated: use (redefined) ReSampleSingle() or
SampleSingleInto()
Input parameters:
evo_ptr, cmaes_t *: Pointer to cma-es struct.
x, double const *: element of the return value of
cmaes_SamplePopulation, double **pop, that is
pop[0..len-1] where len=cmaes_Get("lambda").
This solution vector of the population gets sampled
a new value.
Return, double *: A pointer to the resampled "population"
member.
Details: Can be called after cmaes_SamplePopulation to
resample single solutions. In general,
the function can be used tos ample as many independent
mean+sigma*Normal(0,C) distributed vectors as desired.
double *
cmaes_UpdateDistribution(cmaes_t *, const double *rgFuncValue);
Input parameters:
evo_ptr, cmaes_t *: Pointer to cma-es struct.
rgFuncValue, const double *: An array of lambda function
values.
Return, double *: Mean value of the new distribution.
Details: Core procedure of the CMA-ES algorithm. Sets a new mean
value and estimates the new covariance matrix and a new step
size for the normal search distribution.
void
cmaes_ReadSignals(cmaes_t *, char *filename)
Input parameters:
evo_ptr, cmaes_t *: Pointer to cma-es struct.
filename, const char *: by default "signals.par"
Details: Reads commands from filename to stop the run
or output data to the console or to a file. Uses function
cmaes_WriteToFile(), hence the same key sequences
are available. See there and also file signals.par for
more details.
double
cmaes_Get(cmaes_t *evo_ptr, const char *szKeyWord)
Input parameters:
evo_ptr, cmaes_t *: Pointer to cma-es struct.
szKeyWord, const char *: keyword like "eval" for number of
评论1