Skip to content

Commit

Permalink
Simplifying infeasibility analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
guilpier-code committed Jul 2, 2024
1 parent e46bc1f commit eec4b4f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
25 changes: 5 additions & 20 deletions src/solver/infeasible-problem-analysis/constraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
* You should have received a copy of the Mozilla Public Licence 2.0
* along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/
#include "antares/solver/infeasible-problem-analysis/constraint.h"

#include <algorithm>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <boost/regex.hpp>
#include <boost/algorithm/string/regex.hpp>

#include "antares/solver/infeasible-problem-analysis/constraint.h"

namespace
{
Expand All @@ -40,24 +42,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 eec4b4f

Please sign in to comment.