CMA-ES / pycma

Python implementation of CMA-ES
Other
1.1k stars 178 forks source link

Can I change the dimensions of solutions during the iterations? #157

Open meiyangjie opened 3 years ago

meiyangjie commented 3 years ago

Hi, I want to ask a question that can I change the dimensions of solutions during the iterations?

Like the code: import cma xopt,es = cma.fmin2(cma.ff.rosen,8*[0],0.5)

the dimensions of the problem is set to be 8 dimensions, I try to use some kind of method like PCA to reduce the dimensions of the problem, which means the dimension of the solutions will be changed, too. Thus, can I change the dimensions of solution while the ES iterations?

Best, Yangejie.

nikohansen commented 3 years ago

In principle yes, but there is no support from the module to do that easily online. Reducing the dimension seems algorithmically simple (in a way the 'fixed_variables' option does that statically when generating the generic initial state).

I am pretty sure an implementation should use the ask-and-tell interface instead of fmin. A workaround may be to create a new instance with reduced variables and set its state from the original instance. The CMAEvolutionStrategy._copy_light method could be used as a starting point to understand what is needed (it doesn't copy the evolution paths though). It may be as simple as adding an optional variable deletion argument to this method (akin to 'fixed_variables').