CyberAgentAILab / cmaes

Python library for CMA Evolution Strategy.
https://arxiv.org/abs/2402.01373
MIT License
377 stars 66 forks source link

[Bug] Negative eigenvalue #36

Closed ColinBrosseauAlgolux closed 4 years ago

ColinBrosseauAlgolux commented 4 years ago

in cma.py CMA.tell() I somehow get to this point:

self._B, self._D = None, None
self._C = 
[[  8.14737017e-04   2.68770961e-02  -6.44404672e-03]
 [  2.68770961e-02   8.40956376e-01  -4.00553778e-01]
 [ -6.44404672e-03  -4.00553778e-01   2.18242242e+00]]
D2 = 
[ -6.44813495e-05   7.31257026e-01   2.29300099e+00]
D = 
[        nan  0.85513568  1.51426582]

This leads to 
self._C =
[[ nan  nan  nan]
 [ nan  nan  nan]
 [ nan  nan  nan]]
at the end of CMA.tell()

Then in CMA._sample_solution()
D2, B = np.linalg.eigh(self._C)
crashes for obvious reasons

LinAlgError: Eigenvalues did not converge
c-bata commented 4 years ago

Thank you for reporting. Do you have something reproducible code?

c-bata commented 4 years ago

And please tell me the version of cmaes.

c-bata commented 4 years ago

If you use cmaes v0.4.0 or older, please upgrade the version to v0.5.0.

ColinBrosseauAlgolux commented 4 years ago

This error happens once in a while. Hard to tell when. I'd need to work on a way to make it reproducible. I've just looked at https://github.com/CyberAgent/cmaes/pull/34 and it seems this is what I actually get. I'll try this PR to see if it fixes it.

I'm using 0.5.0

Also, I've seen some indications in the code like # (p.28) I think it refers to some book. Which one?

c-bata commented 4 years ago

I've just looked at #34 and it seems this is what I actually get. I'll try this PR to see if it fixes it.

Thanks!

Also, I've seen some indications in the code like # (p.28) I think it refers to some book. Which one?

It refers to "The CMA Evolution Strategy: A Tutorial" https://arxiv.org/abs/1604.00772.

c-bata commented 4 years ago

Hi @petit-pied-vert. #34 is merged and I released v0.5.1 which contains the changes: https://github.com/CyberAgent/cmaes/releases/tag/v0.5.1

Please upgrade the cmaes version.

c-bata commented 4 years ago

Let me close this issue. If you bump into the problem again, please feel free to reopen.

ColinBrosseauAlgolux commented 4 years ago

thank you @c-bata I'm testing #34 since friday and I've not found error again. Will tell you if problem appears again.

Also, I think I'll contribute to this project on my personal time.

c-bata commented 4 years ago

Thank you!