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

get_candidate_x #214

Open answerIII opened 4 years ago

answerIII commented 4 years ago

Hi! I am working with surrogate CMAES where parameters have boundaries 0 to 1 on Python (surrpcmaes_pwqb). When I try to return the candidate by the method get_candidate_x, it returns values out of range.

This situation is in several cases: bcand = cmasols.best_candidate() best_x = lcmaes.get_candidate_x(bcand) or def ncsurrfunc(self, c, m): x = [] y = [] for ci in c: x.append(lcmaes.get_candidate_x(ci)) y.append(ci.get_fvalue())

nx = encode(x,m)

    self.traindt(x, y)

For example, output from x.append(lcmaes.get_candidate_x(ci)): [ 0.9738188 1.3144068 1.1626065 1.3041023 0.34624505 1.010639 0.7516571 0.7380347 0.90886545 1.177999 -0.17459498 -0.171487 0.41590154 0.9304276 -0.31608018 0.2693098 0.25694674 0.71747833 0.03769534 -0.41249585 0.09692293 0.0981518 0.15991642 1.3242306 0.6308082 1.2415276 1.022431 0.860485 0.52259076 0.6059855 0.3968408 -0.5575023 0.14020891 0.12876558 -0.15827467 0.4910336 0.66046447 0.44146934 -0.39034626 -0.46236753]

But in *.dat file CMAES and modifications of CMAES (sep, restart) store parameters correctly. I have fixed the first case by extracting best_candidate from this file. But how it could be fixed for the surrogate case?

beniz commented 3 years ago

Hi, I believe you may need to get your cmasols from a pwq genopho, let me know if the code snippet in https://github.com/beniz/libcmaes/issues/146#issuecomment-249194776 helps.