optimas-org / optimas

Optimization at scale, powered by libEnsemble
https://optimas.readthedocs.io
Other
22 stars 13 forks source link

[WIP] Enable using Xopt generators in optimas #151

Open RemiLehe opened 9 months ago

RemiLehe commented 9 months ago

Attempt to use Xopt generators directly.

The tests currently fail with:

  File "/Users/rlehe/Documents/codes/optimas/optimas/generators/base.py", line 237, in tell
    self._tell(trials)
  File "/Users/rlehe/Documents/codes/optimas/optimas/generators/xopt/nelder_mead.py", line 56, in _tell
    self.xopt_gen.add_data(df)
  File "/Users/rlehe/miniconda3/envs/optimas/lib/python3.12/site-packages/xopt/generators/scipy/neldermead.py", line 137, in add_data
    assert self.future_state is not None

TODO:

RemiLehe commented 7 months ago

When using only 1 worker (instead of 2), the test run, but eventually gives:

[INFO 02-16 07:48:13] optimas.generators.base: Generated trial 79 with parameters {'x0': 0.1001368227796458, 'x1': 2.940237902665191}
[INFO 02-16 07:48:13] optimas.generators.base: Completed trial 79 with objective(s) {'f': (19.68546661624322, None)}
[0]  2024-02-16 07:48:13,945 libensemble.manager (ERROR): Traceback (most recent call last):
  File "/Users/rlehe/miniconda3/envs/optimas/lib/python3.12/site-packages/libensemble/manager.py", line 644, in run
    assert self.term_test() or any(
AssertionError: alloc_f did not return any work, although all workers are idle.
RemiLehe commented 7 months ago

I looked more closely at the error with 2 workers, here is the log:

[INFO 02-16 07:54:38] optimas.generators.base: Generated trial 0 with parameters {'x0': -1.0, 'x1': 3.5}
[INFO 02-16 07:54:38] optimas.generators.base: Generated trial 1 with parameters {'x0': -1.0, 'x1': 3.5}
[INFO 02-16 07:54:39] optimas.generators.base: Completed trial 0 with objective(s) {'f': (5.205621232603963, None)}

and then

  File "/Users/rlehe/Documents/codes/optimas/optimas/gen_functions.py", line 108, in persistent_generator
    generator.tell([trial])
  File "/Users/rlehe/Documents/codes/optimas/optimas/generators/base.py", line 237, in tell
    self._tell(trials)
  File "/Users/rlehe/Documents/codes/optimas/optimas/generators/xopt/nelder_mead.py", line 59, in _tell
    self.xopt_gen.add_data(df)
  File "/Users/rlehe/miniconda3/envs/optimas/lib/python3.12/site-packages/xopt/generators/scipy/neldermead.py", line 137, in add_data
    assert self.future_state is not None
AssertionError

so it looks like the error is not when calling generate several times (this simply returned the same point), but rather when calling add_data several times (without calling generate in-between`).

RemiLehe commented 1 month ago

This is superseded by https://github.com/optimas-org/optimas/pull/228