CMA-ES / c-cmaes

CMA-ES written in ANSI C (yet fairly object-oriented)
Other
56 stars 26 forks source link

How to modify parameters programmatically? #3

Closed chrisdembia closed 10 years ago

chrisdembia commented 10 years ago

I see that the parameters are stored in evo->sp. What is the best and safest way to modify these parameters programmatically instead of via input files?

My hunch is that the following sequence of calls would be safe:

cmaes_t evo;
cmaes_init(&evo, ...);
evo.sp.stopMaxIter = 500;
readpara_SupplementDefaults(&evo.sp);

I want to modify the readpara_t entries but I don't want to put the parameters in an inconsistent state, and I still want to benefit from the supplemented defaults. It seems that readpara_t.damps is set based on the value of stopMaxIter. If I update stopMaxIter, I must call readpara_SupplementDefaults to have a consistent value of damps. Are there other additional steps I must take?

Thanks!

nikohansen commented 10 years ago

Unfortunately, I don't think this works. readpara_SupplementDefaults is supposed to be called only once, because it checks for unset values to be set. It is not designed to "reset" values. In your particular case damps would be set depending on the "correct" value of damps which must be considered a bug.

For the time being you could just set evo.sp.stopMaxIter without calling to readpara_SupplementDefaults, as the dependency of damps on stopMaxIter is rather minor and of lesser importance.

Otherwise we would need to have (1) readpara_init not calling SupplementDefaults itself and (2) a version of cmaes_init that does not finalize the settings such that

cmaes_t evo; 
cmaes_init_para(&evo, ...); /* complement the same parameters as for cmaes_init */
evo.sp.stopMaxIter = ...
cmaes_init_finalize(&evo); 

or

cmaes_t evo; 
readpara_init(&evo.sp, ...); /* complement the same parameters as for cmaes_init */
evo.sp.stopMaxIter = ...
cmaes_init_finalize(&evo); 

would be working usecases.

nikohansen commented 10 years ago

I implemented the use case

cmaes_t evo; 
cmaes_init_para(&evo, ...); /* complement with the same parameters as for cmaes_init */
evo.sp.stopMaxIter = ...
cmaes_init_final(&evo);