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

Fixing parameters does not work #132

Open agrayver opened 9 years ago

agrayver commented 9 years ago

I have my minimization working well until I try to call set_fixed_p(...) on one of the parameters. In this case, I get a bunch of errors like:

FATAL - error in shifting pwq bounds in dimension 31: lb=0 / ub=10 / al=0.05 / au=0.55 / x_s=-9.28442e+10 / x=-4.73175e+10 / xlow=-5.1 / xup=16.1 / r=21.2 FATAL - error in shifting pwq bounds in dimension 34: lb=0 / ub=10 / al=0.05 / au=0.55 / x_s=-9.3096e+10 / x=4.75693e+10 / xlow=-5.1 / xup=16.1 / r=21.2 FATAL - error in shifting pwq bounds in dimension 43: lb=0 / ub=10 / al=0.05 / au=0.55 / x_s=-1.08441e+11 / x=-6.29145e+10 / xlow=-5.1 / xup=16.1 / r=21.2

Any idea why?

beniz commented 9 years ago

I've seen this before, and I will check it again. If it fails it is clearly a bug.

FYI, in m own usage, I've switched to reducing the size of the problem instead, but this may not be what you are trying to achieve just now, especially if you are fixing parameters in & out during the optimization.

beniz commented 9 years ago

I can't reproduce by setting bounds + using set_fixed_p, so you will need to give me more details about what you're doing. Most useful would be the relevant pieces of code.

lydiarong commented 5 years ago

I have the same problem,can you tell me how to solve it?

beniz commented 5 years ago

Hi, it's possible that the bound shifting sometimes fails on a parameter that is frozen. If you have a way to modify to problem so that the parameter is fixed within the function, thus reducing the size of the problem, that might circumvent the issue.

The potential problem may come from the bound shifting code not checking whether a parameter is frozen. This might be something to consider.

scyomantion commented 1 year ago

Hi, I also had the error

FATAL - error in shifting pwq bounds in dimension 26: lb=0 / ub=10 / al=0.05 / au=0.55 / x_s=-1.0015e+11 / x=-5.4619e+10 / xlow=-5.1 / xup=16.1 / r=21.2

But I don't use fixing parameters. It was when using elitism set to 3 in aBIPOP strategy.

I think the problem is in method void pwqBoundStrategy::shift_into_feasible(const dVec &x, dVec &x_s) const. There is a static_cast to int of (xlow-x_s)/r. In this example it is:

(-5.1 - -1.0015e+11)/21.2 = 4,724,056,603.53

Integer limit is from -2,147,483,648 to 2,147,483,647. So the cast to int clearly overflows. Maybe it could be solved by using int64_t?