CMA-ES / libcmaes

libcmaes is a multithreaded C++11 library with Python bindings for high performance blackbox stochastic optimization using the CMA-ES algorithm for Covariance Matrix Adaptation Evolution Strategy
Other
321 stars 78 forks source link

Python ask/tell/eval interface? #159

Open wjaskowski opened 7 years ago

wjaskowski commented 7 years ago

I would like to evaluate all the candidate solutions at once (e.g., in order to coevolve them). Is that possible with the Python API?

beniz commented 7 years ago

Hi, the ask/tell/eval interface is not exposed to the Python API. Have you looked at https://github.com/CMA-ES/pycma ?

wjaskowski commented 7 years ago

Yeah, but this one does not have the VD-CMA variant.

On 30 March 2017 at 15:16, Emmanuel Benazera notifications@github.com wrote:

Hi, the ask/tell/eval interface is not exposed to the Python API. Have you looked at https://github.com/CMA-ES/pycma ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/beniz/libcmaes/issues/159#issuecomment-290407193, or mute the thread https://github.com/notifications/unsubscribe-auth/AEuSHao2OPoMhYnmYaNTQCIjPhpoAg0kks5rq6sZgaJpZM4MuR2i .

beniz commented 7 years ago

Exposing C++ functions to Python API is handled in https://github.com/beniz/libcmaes/blob/master/python/lcmaes.cc I've taken a quick look and I don't remember of any reason why I had not exposed the ask/tell/eval interface, but it is still possible that something was in the way.

If you'd like to first assess whether VD-CMA fits your need for your application, maybe you could start doing it in C++ and decide afterwards whether to add the interface ?

wjaskowski commented 7 years ago

Its a complicated stuff. I already have a lot of stuff in Python and must play with tensorflow. Anyway, I'll use the normal CMA or the sep-one for now and see what that will take me (altought I had a previous experience with CMA-VD which I ported from Shark (C++) to Java and I was quite impressed by its capabilities.

On 30 March 2017 at 15:27, Emmanuel Benazera notifications@github.com wrote:

Exposing C++ functions to Python API is handled in https://github.com/beniz/libcmaes/blob/master/python/lcmaes.cc I've taken a quick look and I don't remember of any reason why I had not exposed the ask/tell/eval interface, but it is still possible that something was in the way.

If you'd like to first assess whether VD-CMA fits your need for your application, maybe you could start doing it in C++ and decide afterwards whether to add the interface ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/beniz/libcmaes/issues/159#issuecomment-290410107, or mute the thread https://github.com/notifications/unsubscribe-auth/AEuSHbFSA_qoFp2neKmf2uwIS97p_xOFks5rq627gaJpZM4MuR2i .

beniz commented 7 years ago

Optimizing deep nets with CMA ? ^^ or NES for reinforcement learning ? Curious if you can share.

wjaskowski commented 7 years ago

RL, not very deep currently but I will get deeper...

Btw. AFAIK there is no VDCMA implementation in Python anywhere so this might be the first one. I am really surpised by that. As I said I used it for RL for SZ-Tetris and 30k parameters and it worked much better than sep-CMA.

On 30 Mar 2017 4:43 p.m., "Emmanuel Benazera" notifications@github.com wrote:

Optimzing deep nets with CMA ? ^^ or NES for reinforcement learning ? Curious if you can share.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/beniz/libcmaes/issues/159#issuecomment-290432909, or mute the thread https://github.com/notifications/unsubscribe-auth/AEuSHZMyuDwhShh-5pPJnD-_owemcmexks5rq7-MgaJpZM4MuR2i .

youheiakimoto commented 7 years ago

See https://drive.google.com/file/d/0B6Ayt4zjdvJ3Z081cGR0LXFOVkU/view for the Python implementation of VDCMA.

nikohansen commented 7 years ago

This https://github.com/CMA-ES/pycma/tree/generic-sampler-improvements also contains the implementation now. The usage is yet a little verbose:

    import cma
    import cma.restricted_gaussian_sampler as rgs
    es = cma.CMAEvolutionStrategy(20 * [1], 1, {
             'CMA_sampler': rgs.GaussVkDSampler,
             # 'CMA_sampler_options': {},
             'CMA_active': False, 
             'AdaptSigma': None,
     })
    es.optimize(cma.ff.cigar)
    es.plot()

The CMA_active and AdaptSigma option settings are necessary for the time being.

There might still be a bug, which leads sometimes to somewhat strange behaviour of the GaussVDSampler, see https://github.com/CMA-ES/pycma/issues/9