From 8600760f3dd821aabd60bb5aaab3f94ae0605297 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 3 Feb 2022 11:08:24 +0100 Subject: [PATCH] Cleanup --- libsolutil/LP.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libsolutil/LP.cpp b/libsolutil/LP.cpp index 99a8c5365..9d66296f5 100644 --- a/libsolutil/LP.cpp +++ b/libsolutil/LP.cpp @@ -262,9 +262,9 @@ pair simplexPhaseI(Tableau _tableau) _tableau.data[i].resize(columns + rows); _tableau.data[i][columns + i] = 1; } - _tableau.objective.factors = - vector(columns, rational{}) + - vector(rows, rational{-1}); + _tableau.objective = {}; + _tableau.objective.resize(columns); + _tableau.objective.resize(columns + rows, rational{-1}); // This sets the objective factors of the slack variables // to zero (and thus selects a basic feasible solution). @@ -276,11 +276,13 @@ pair simplexPhaseI(Tableau _tableau) vector optimum = solutionVector(_tableau); + // If the solution needs a nonzero factor for a slack variable, + // the original system is infeasible. for (size_t i = columns - 1; i < optimum.size(); ++i) if (optimum[i] != 0) return make_pair(LPResult::Infeasible, Tableau{}); - _tableau.objective = originalObjective; + _tableau.objective = move(originalObjective); for (auto& row: _tableau.data) row.resize(columns);