From 3c9d8717c71fb65183ed5269cbe4d1cff3927da1 Mon Sep 17 00:00:00 2001 From: Peter Verveer Date: Wed, 18 Dec 2024 08:24:53 +0000 Subject: [PATCH] f --- src/ert/run_models/everest_run_model.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/ert/run_models/everest_run_model.py b/src/ert/run_models/everest_run_model.py index fdf68b0a396..cb00eef4d03 100644 --- a/src/ert/run_models/everest_run_model.py +++ b/src/ert/run_models/everest_run_model.py @@ -40,8 +40,6 @@ from .base_run_model import BaseRunModel, StatusEvents if TYPE_CHECKING: - import numpy.typing as npt - from ert.storage import Ensemble, Experiment @@ -105,7 +103,6 @@ def __init__( everest_config: EverestConfig, simulation_callback: SimulationCallback, optimization_callback: OptimizerCallback, - display_all_jobs: bool = True, ): Path(everest_config.log_dir).mkdir(parents=True, exist_ok=True) Path(everest_config.optimization_output_dir).mkdir(parents=True, exist_ok=True) @@ -126,7 +123,6 @@ def __init__( self._sim_callback = simulation_callback self._opt_callback = optimization_callback self._fm_errors: dict[int, dict[str, Any]] = {} - self._display_all_jobs = display_all_jobs self._result: OptimalResult | None = None self._exit_code: EverestExitCode | None = None self._evaluator_cache: _EvaluatorCache | None = ( @@ -152,8 +148,6 @@ def __init__( active_realizations=[], # Set dynamically in run_forward_model() ) - self.num_retries_per_iter = 0 # OK? - @classmethod def create( cls, @@ -232,7 +226,7 @@ def run_experiment( ) if self._exit_code is None: - self._exit_code = self._get_exit_code(optimizer_exit_code) + self._exit_code = self._get_everest_exit_code(optimizer_exit_code) def _create_optimizer(self) -> BasicOptimizer: RESULT_COLUMNS = { @@ -334,7 +328,9 @@ def _create_optimizer(self) -> BasicOptimizer: return optimizer - def _get_exit_code(self, optimizer_exit_code: OptimizerExitCode) -> EverestExitCode: + def _get_everest_exit_code( + self, optimizer_exit_code: OptimizerExitCode + ) -> EverestExitCode: match optimizer_exit_code: case OptimizerExitCode.MAX_FUNCTIONS_REACHED: return EverestExitCode.MAX_FUNCTIONS_REACHED @@ -610,8 +606,8 @@ def onerror( def _gather_results( self, ensemble: Ensemble - ) -> list[dict[str, npt.NDArray[np.float64]]]: - results: list[dict[str, npt.NDArray[np.float64]]] = [] + ) -> list[dict[str, NDArray[np.float64]]]: + results: list[dict[str, NDArray[np.float64]]] = [] for sim_id, successful in enumerate(self.active_realizations): if not successful: logger.error(f"Simulation {sim_id} failed.") @@ -632,7 +628,7 @@ def _get_evaluator_result( control_values: NDArray[np.float64], evaluator_context: EvaluatorContext, case_data: dict[int, Any], - results: list[dict[str, npt.NDArray[np.float64]]], + results: list[dict[str, NDArray[np.float64]]], cached_results: dict[int, Any], ) -> EvaluatorResult: # We minimize the negative of the objectives: @@ -800,7 +796,7 @@ def add( def get( self, realization_id: int, controls: NDArray[np.float64] - ) -> tuple[Any, ...] | None: + ) -> tuple[NDArray[np.float64], NDArray[np.float64] | None] | None: for control_values, objectives, constraints in self._data.get( realization_id, [] ):