Skip to content

Commit

Permalink
Change num realizations check
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindeide committed Nov 17, 2023
1 parent cedb5a7 commit f83a99e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
26 changes: 13 additions & 13 deletions src/ert/run_models/base_run_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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}"
Expand Down
3 changes: 2 additions & 1 deletion src/ert/run_models/ensemble_smoother.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion src/ert/run_models/iterated_ensemble_smoother.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/ert/run_models/multiple_data_assimilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit f83a99e

Please sign in to comment.