From f83a99e9bd058882c3bda345269e5016c1abc3ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Eide?= Date: Thu, 16 Nov 2023 15:16:42 +0100 Subject: [PATCH] Change num realizations check --- src/ert/run_models/base_run_model.py | 26 +++++++++---------- src/ert/run_models/ensemble_smoother.py | 3 ++- .../run_models/iterated_ensemble_smoother.py | 3 ++- .../run_models/multiple_data_assimilation.py | 3 ++- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/ert/run_models/base_run_model.py b/src/ert/run_models/base_run_model.py index c3ab0334456..b4cb6410a03 100644 --- a/src/ert/run_models/base_run_model.py +++ b/src/ert/run_models/base_run_model.py @@ -325,21 +325,18 @@ def get_runtime(self) -> Union[int, float]: def isIndeterminate(self) -> bool: return not self.isFinished() and self._indeterminate - def checkHaveSufficientRealizations(self, num_successful_realizations: int) -> None: + @staticmethod + def checkHaveSufficientRealizations( + num_successful_realizations: int, minimum_realizations: int + ) -> None: if num_successful_realizations == 0: raise ErtRunError("Experiment failed! All realizations failed!") - if not self.ert_config.analysis_config.have_enough_realisations( - num_successful_realizations - ): + if num_successful_realizations < minimum_realizations: raise ErtRunError( - "Too many realizations have failed! " - f"Number of successful realizations: {num_successful_realizations}, " - "number of active realizations: " - f"{self._simulation_arguments.active_realizations.count(True)}, " - "expected minimal number of successful realizations: " - f"{self.ert_config.analysis_config.minimum_required_realizations}\n" - "You can add/adjust MIN_REALIZATIONS " - "to allow (more) failures in your experiments." + f"Too many realizations have failed! Number of successful realizations:" + f" {num_successful_realizations}, expected minimal number of successful" + f" realizations: {minimum_realizations}\n You can add/adjust " + f"MIN_REALIZATIONS to allow (more) failures in your experiments." ) def run_ensemble_evaluator( @@ -491,7 +488,10 @@ def _evaluate_and_postprocess( num_successful_realizations += ( self._simulation_arguments.prev_successful_realizations ) - self.checkHaveSufficientRealizations(num_successful_realizations) + self.checkHaveSufficientRealizations( + num_successful_realizations, + self._simulation_arguments.minimum_required_realizations, + ) event_logger.info( f"Experiment ran on QUEUESYSTEM: {self._queue_config.queue_system}" diff --git a/src/ert/run_models/ensemble_smoother.py b/src/ert/run_models/ensemble_smoother.py index 08c3edfc974..dcd79d9fbcc 100644 --- a/src/ert/run_models/ensemble_smoother.py +++ b/src/ert/run_models/ensemble_smoother.py @@ -65,7 +65,8 @@ def run_experiment( self, evaluator_server_config: EvaluatorServerConfig ) -> RunContext: self.checkHaveSufficientRealizations( - self._simulation_arguments.active_realizations.count(True) + self._simulation_arguments.active_realizations.count(True), + self.update_settings.min_required_realizations ) log_msg = "Running ES" diff --git a/src/ert/run_models/iterated_ensemble_smoother.py b/src/ert/run_models/iterated_ensemble_smoother.py index 6b421baaa12..158d8b7cb18 100644 --- a/src/ert/run_models/iterated_ensemble_smoother.py +++ b/src/ert/run_models/iterated_ensemble_smoother.py @@ -102,7 +102,8 @@ def run_experiment( self, evaluator_server_config: EvaluatorServerConfig ) -> RunContext: self.checkHaveSufficientRealizations( - self._simulation_arguments.active_realizations.count(True) + self._simulation_arguments.active_realizations.count(True), + self.update_settings.min_required_realizations ) iteration_count = self.facade.get_number_of_iterations() phase_count = iteration_count + 1 diff --git a/src/ert/run_models/multiple_data_assimilation.py b/src/ert/run_models/multiple_data_assimilation.py index dba33c8d04c..b03900639dd 100644 --- a/src/ert/run_models/multiple_data_assimilation.py +++ b/src/ert/run_models/multiple_data_assimilation.py @@ -67,7 +67,8 @@ def run_experiment( self, evaluator_server_config: EvaluatorServerConfig ) -> RunContext: self.checkHaveSufficientRealizations( - self._simulation_arguments.active_realizations.count(True) + self._simulation_arguments.active_realizations.count(True), + self.update_settings.min_required_realizations ) weights = self.parseWeights(self._simulation_arguments.weights)