Skip to content

Commit

Permalink
Infeasibility analyzer : small simplifications (#2226)
Browse files Browse the repository at this point in the history
Purpose : as the title says

This PR is attached to ticket [ticket
ANT-1825](https://gopro-tickets.rte-france.com/browse/ANT-1825).
Some improvements were made or tried by taking care of the ticket.
The result is this PR.

---------

Co-authored-by: Florian OMNES <[email protected]>
  • Loading branch information
guilpier-code and flomnes authored Jul 3, 2024
1 parent fb6d65f commit ecccb29
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
22 changes: 4 additions & 18 deletions src/solver/infeasible-problem-analysis/constraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#include <iomanip>
#include <sstream>

#include <boost/algorithm/string/regex.hpp>
#include <boost/regex.hpp>

namespace
{
const std::string kUnknown = "<unknown>";
Expand All @@ -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();
}

Expand Down
6 changes: 2 additions & 4 deletions src/solver/infeasible-problem-analysis/report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit ecccb29

Please sign in to comment.