-
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
48 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,48 @@ | ||
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.optimization.max_function_evaluations = 2 | ||
config.optimization.perturbation_num = 2 | ||
config.simulator = SimulatorConfig(enable_cache=True) | ||
|
||
ropt_config = everest2ropt(config) | ||
simulator = Simulator(config) | ||
|
||
# Run once, populating the cache of the simulator: | ||
OptimizationPlanRunner( | ||
enopt_config=ropt_config, | ||
evaluator=simulator, | ||
seed=config.environment.random_seed, | ||
).run() | ||
assert n_evals == 12 | ||
|
||
# Run again with the same simulator: | ||
n_evals = 0 | ||
OptimizationPlanRunner( | ||
enopt_config=ropt_config, | ||
evaluator=simulator, | ||
seed=config.environment.random_seed, | ||
).run() | ||
assert n_evals == 0 |