From 6078f4dd945dbb7ed25dd3a0c023bc8332d7d30c Mon Sep 17 00:00:00 2001 From: "Pablo R. Mier" Date: Sat, 21 Aug 2021 12:29:10 +0200 Subject: [PATCH] Assign reactions on copy This fixes #20 --- miom/__init__.py | 2 +- miom/miom.py | 13 +++++++++---- pyproject.toml | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/miom/__init__.py b/miom/__init__.py index 534a6ca..ba046b9 100644 --- a/miom/__init__.py +++ b/miom/__init__.py @@ -8,4 +8,4 @@ from miom.mio import load_gem __all__ = ["load", "load_gem", "Solvers", "Comparator", "ExtractionMode"] -__version__ = "0.9.0-beta.4" \ No newline at end of file +__version__ = "0.9.0-beta.5" \ No newline at end of file diff --git a/miom/miom.py b/miom/miom.py index eafa280..3756ed9 100644 --- a/miom/miom.py +++ b/miom/miom.py @@ -556,8 +556,7 @@ def subset_selection(self, rxn_weights, direction='max', eps=1e-2): # Calculate min valid EPS based on integrality tolerance min_eps = self._options["_min_eps"] if eps < min_eps: - warnings.warn(f"The minimum epsilon value for the current solver \ - parameters is {min_eps}, which is less than {eps}.") + warnings.warn(f"Minimum epsilon value below min. allowed value, changed to {min_eps}.") eps = max(eps, min_eps) if not isinstance(rxn_weights, Iterable): rxn_weights = [rxn_weights] * self.network.num_reactions @@ -920,6 +919,7 @@ def _copy(self, **kwargs): m = PicosModel(previous_step_model=self) m.problem = self.problem.copy() variables = m.problem._mutables.keys() + m.variables._assigned_reactions = self.variables._assigned_reactions if "X" in variables: m.variables._indicator_vars = m.problem._mutables.get("X") if "V" in variables: @@ -1069,8 +1069,13 @@ def _select_subnetwork(self, **kwargs): def _copy(self, **kwargs): m = PythonMipModel(previous_step_model=self) m.problem = self.problem.copy() - m.variables._flux_vars = [v for v in m.problem.vars if v.name.startswith("V_")] - m.variables._indicator_vars = [v for v in m.problem.vars if v.name.startswith("X_")] + m.variables._assigned_reactions = self.variables._assigned_reactions + fluxvars = [v for v in m.problem.vars if v.name.startswith("V_")] + indicators = [v for v in m.problem.vars if v.name.startswith("X_")] + if len(fluxvars) > 0: + m.variables._flux_vars = fluxvars + if len(indicators) > 0: + m.variables._indicator_vars = indicators return m diff --git a/pyproject.toml b/pyproject.toml index eb49775..90f069a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "miom" -version = "0.9.0-beta.4" +version = "0.9.0-beta.5" description = "Mixed Integer Optimization for Metabolism" authors = ["Pablo R. Mier "] keywords = ["optimization", "LP", "MIP", "metabolism", "metabolic-networks"]