diff --git a/src/solver/infeasible-problem-analysis/constraint.cpp b/src/solver/infeasible-problem-analysis/constraint.cpp index c9aacb06aa..b43dc7dd95 100644 --- a/src/solver/infeasible-problem-analysis/constraint.cpp +++ b/src/solver/infeasible-problem-analysis/constraint.cpp @@ -25,6 +25,9 @@ #include #include +#include +#include + namespace { const std::string kUnknown = ""; @@ -40,24 +43,7 @@ Constraint::Constraint(const std::string& input, const double slackValue): std::size_t Constraint::extractComponentsFromName() { - const auto beg = name_.begin(); - const auto end = name_.end(); - std::size_t newPos = 0; - const std::size_t sepSize = 2; - const std::size_t inputSize = name_.size(); - for (std::size_t pos = 0; pos < inputSize; pos = newPos + sepSize) - { - newPos = name_.find("::", pos); - if (newPos == std::string::npos) - { - nameComponents_.emplace_back(beg + pos, end); - break; - } - if (newPos > pos) - { - nameComponents_.emplace_back(beg + pos, beg + newPos); - } - } + boost::algorithm::split_regex(nameComponents_, name_, boost::regex("::")); return nameComponents_.size(); } diff --git a/src/solver/infeasible-problem-analysis/report.cpp b/src/solver/infeasible-problem-analysis/report.cpp index bc493ff6bd..0964c251ab 100644 --- a/src/solver/infeasible-problem-analysis/report.cpp +++ b/src/solver/infeasible-problem-analysis/report.cpp @@ -63,10 +63,8 @@ void InfeasibleProblemReport::sortConstraints() void InfeasibleProblemReport::trimConstraints() { - if (nbMaxVariables <= constraints_.size()) - { - constraints_.resize(nbMaxVariables); - } + unsigned int nbConstraints = constraints_.size(); + constraints_.resize(std::min(nbMaxVariables, nbConstraints)); } void InfeasibleProblemReport::sortConstraintsByType()