-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove the everest restart functionality
The restart functionality was added to support a research project. However it turned out to be unnecessary for that project. Since functionality should not be added for such a purpose only and the general usefulness of the feature is unclear it should be removed.
- Loading branch information
Showing
9 changed files
with
60 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import numpy as np | ||
from ropt.plan import OptimizationPlanRunner | ||
|
||
from everest.config import EverestConfig, SimulatorConfig | ||
from everest.optimizer.everest2ropt import everest2ropt | ||
from everest.simulator import Simulator | ||
from tests.everest.utils import relpath, tmp | ||
|
||
CONFIG_PATH = relpath("..", "..", "test-data", "everest", "math_func") | ||
CONFIG_FILE = "config_advanced_scipy.yml" | ||
|
||
|
||
def test_simulator_cache(monkeypatch): | ||
n_evals = 0 | ||
original_call = Simulator.__call__ | ||
|
||
def new_call(*args): | ||
nonlocal n_evals | ||
result = original_call(*args) | ||
n_evals += (result.evaluation_ids >= 0).sum() | ||
return result | ||
|
||
monkeypatch.setattr(Simulator, "__call__", new_call) | ||
|
||
with tmp(CONFIG_PATH): | ||
config = EverestConfig.load_file(CONFIG_FILE) | ||
config.simulator = SimulatorConfig(enable_cache=True) | ||
|
||
ropt_config = everest2ropt(config) | ||
simulator = Simulator(config) | ||
|
||
# Run once, populating the cache of the simulator: | ||
variables1 = ( | ||
OptimizationPlanRunner( | ||
enopt_config=ropt_config, | ||
evaluator=simulator, | ||
seed=config.environment.random_seed, | ||
) | ||
.run() | ||
.variables | ||
) | ||
assert variables1 is not None | ||
assert np.allclose(variables1, [0.1, 0, 0.4], atol=0.02) | ||
assert n_evals > 0 | ||
|
||
# Run again with the same simulator: | ||
n_evals = 0 | ||
variables2 = ( | ||
OptimizationPlanRunner( | ||
enopt_config=ropt_config, | ||
evaluator=simulator, | ||
seed=config.environment.random_seed, | ||
) | ||
.run() | ||
.variables | ||
) | ||
assert variables2 is not None | ||
assert n_evals == 0 | ||
|
||
assert np.array_equal(variables1, variables2) |