From 028e3096d1c6bb07ae65fdf95135ddee4c8c69b6 Mon Sep 17 00:00:00 2001 From: Sjoerd Geevers Date: Fri, 15 Nov 2024 11:09:14 +0100 Subject: [PATCH] seed: call pre and post at the correct place Call pre- and postprocessing at the correct place in SeedMixin, so only before and after the actaul optimization. --- src/rtctools/optimization/seed_mixin.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/rtctools/optimization/seed_mixin.py b/src/rtctools/optimization/seed_mixin.py index 29c2796..a9023fa 100644 --- a/src/rtctools/optimization/seed_mixin.py +++ b/src/rtctools/optimization/seed_mixin.py @@ -109,10 +109,18 @@ def optimize( postprocessing: bool = True, log_solver_failure_as_error: bool = True, ) -> bool: + if preprocessing: + self.pre() self._seed_timeseries = self.seed_options().seed_timeseries fallback = self.seed_options().fallback - success = super().optimize(preprocessing, postprocessing, log_solver_failure_as_error) + success = super().optimize( + preprocessing=False, + postprocessing=False, + log_solver_failure_as_error=log_solver_failure_as_error, + ) if not success and self._use_seed_timeseries() and fallback: self._seed_timeseries = None success = super().optimize(preprocessing, postprocessing, log_solver_failure_as_error) + if postprocessing: + self.post() return success