From 0b6e16983a40fd0a1b8aef5e310651a826f66c82 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 24 Mar 2022 01:45:46 +0100 Subject: [PATCH] Copy on write for fixed variables. --- libsolutil/LP.cpp | 6 +++--- libsolutil/LP.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libsolutil/LP.cpp b/libsolutil/LP.cpp index fa0187a99..36deb7bc9 100644 --- a/libsolutil/LP.cpp +++ b/libsolutil/LP.cpp @@ -815,7 +815,7 @@ LPResult LPSolver::setState(SolvingState _state) // We do not need to store reasons because at this point, we do not have any reasons yet. // We can add this and just need to store the reasons together with the variables. - m_fixedVariables = std::get(modelOrReasonSet); + m_fixedVariables = make_shared>(std::get>(modelOrReasonSet)); //cout << "Splitting..." << endl; ProblemSplitter splitter(*m_state); @@ -848,11 +848,11 @@ void LPSolver::addConstraint(Constraint _constraint) for (auto const& [index, entry]: _constraint.data.enumerateTail()) if (entry) { - if (m_fixedVariables.count(index)) + if (m_fixedVariables->count(index)) { // This can directly lead to a conflict. We will check it later during the // simplify run on the split problems. - _constraint.data[0] -= _constraint.data[index] * m_fixedVariables.at(index); + _constraint.data[0] -= _constraint.data[index] * m_fixedVariables->at(index); _constraint.data[index] = {}; } else if (m_subProblemsPerVariable[index] != static_cast(-1)) diff --git a/libsolutil/LP.h b/libsolutil/LP.h index 31a600edb..8e544e544 100644 --- a/libsolutil/LP.h +++ b/libsolutil/LP.h @@ -284,7 +284,7 @@ private: SolvingState stateFromSubProblem(size_t _index) const; ReasonSet reasonSetForSubProblem(SubProblem const& _subProblem); - std::map m_fixedVariables; + std::shared_ptr> m_fixedVariables; /// These use "copy on write". std::vector> m_subProblems; std::vector m_subProblemsPerVariable;