From 1c43ab12f95e98a611b564d5561b7c5e4fd99380 Mon Sep 17 00:00:00 2001 From: Bernard Knueven Date: Wed, 11 Dec 2024 10:48:00 -0700 Subject: [PATCH] cleanup presolver object --- mpisppy/cylinders/reduced_costs_spoke.py | 4 ---- mpisppy/spopt.py | 11 +++++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/mpisppy/cylinders/reduced_costs_spoke.py b/mpisppy/cylinders/reduced_costs_spoke.py index dae9c502..544b4d95 100644 --- a/mpisppy/cylinders/reduced_costs_spoke.py +++ b/mpisppy/cylinders/reduced_costs_spoke.py @@ -89,10 +89,6 @@ def lagrangian_prep(self): self.opt.PH_Prep(attach_prox=False) self.opt._reenable_W() - if self.opt._presolver is not None: - # do this before we relax the integer variables - self.opt._presolver.presolve() - relax_integer_vars = pyo.TransformationFactory("core.relax_integer_vars") for s in self.opt.local_subproblems.values(): relax_integer_vars.apply_to(s) diff --git a/mpisppy/spopt.py b/mpisppy/spopt.py index 7b15561c..23d1a036 100644 --- a/mpisppy/spopt.py +++ b/mpisppy/spopt.py @@ -58,10 +58,13 @@ def __init__( self._save_active_objectives() self._subproblem_creation(options.get("verbose", False)) if options.get("presolve", False): - self._presolver = SPPresolve(self) - self._presolver.presolve() - else: - self._presolver = None + # NOTE: This creates another representation + # of each scenario subproblem in C++ + # to presolve the model on. For large + # models, it is imperative we allow this + # object to get garbage collected to + # free the memory the C++ model uses. + SPPresolve(self).presolve() self.current_solver_options = None self.extensions = extensions self.extension_kwargs = extension_kwargs