q-optimize / c3

Toolset for control, calibration and characterization of physical systems
https://c3-toolset.readthedocs.io/
Apache License 2.0
66 stars 36 forks source link

CMAES optimisers can silently make parameters be OOB #235

Closed YonatanGideoni closed 2 years ago

YonatanGideoni commented 2 years ago

Bug description

CMAES, being currently implemented as an unconstrained optimiser, can sometimes give (and internally use) parameters that are out-of-bounds (OOB). No error or warning is raised so this fails silently.

To Reproduce

MWE shown in this .py file: https://drive.google.com/file/d/1nc6D195WnUTvDr-K9Sn7gvzar_67sYsE/view?usp=sharing

Expected behavior

For the optimiser not to give OOB results and if there are such results then for a warning/error to be raised.

Environment

Additional context

There are two solutions that need to be implemented here:

  1. Following the example in https://github.com/CMA-ES/pycma/blob/master/notebooks/notebook-usecases-constraints.ipynb, make our CMAES implementation be constrained.
  2. Make this not be a silent failure - have it raise a warning/error. This should deal with such cases also in the future and with other such existing optimisers, if there are any.
YonatanGideoni commented 2 years ago

It seems that the solution given in (1) in practice doesn't work all that well, nor does artificially making the function be in an infinite well such that infeasible solutions have a cost of $\infty$. As #236 at least makes this not be a silent failure and currently there does not seem to be a reasonable way to make CMAES be constrained, I will mark #236 as closing this issue.