Skip to content

Instantly share code, notes, and snippets.

@flomnes
Created July 9, 2024 09:03
Show Gist options
  • Save flomnes/620f2767094586dbb4180914fb7bd19b to your computer and use it in GitHub Desktop.
Save flomnes/620f2767094586dbb4180914fb7bd19b to your computer and use it in GitHub Desktop.
Infeasible constraint
class WatchedConstraint
{
public:
WatchedConstraint(std::string name, std::string regexID, std::string infeasibility, std::string infeasibilityCause) :
name(name),
regexID(regexID),
infeasibility(infeasibility),
infeasibilityCause(infeasibilityCause) {
}
std::string formattedInfeasibility(std::string constraintName) const {
// use boost::split_regex to determine areaName, shortName, etc. from constraintName
std::string ret = infeasibility;
if (shortName)
boost::replace_all(ret, "%n", shortName);
if (areaName)
boost::replace_all(ret, "%a", areaName);
if (timeStep)
boost::replace_all(ret, "%t", timeStep);
if (subName)
boost::replace_all(ret, "%s", subName); // ST storage name, etc.
return ret;
}
private:
const std::string name;
const std::string regexID;
const std::string infeasibility;
const std::string infeasibilityCause;
};
const static std::vector<WatchedConstraint> constraintTypes
{
WatchedConstraint("Daily binding constraint", "::daily::", "Daily BC '%s' at day %t"),
WatchedConstraint("Weekly binding constraint", "::weekly::", "Weekly BC '%s'")
};
void InfeasibleProblemReport::logSuspiciousConstraints()
{
for (const auto& c: constraints_)
{
Antares::logs.error() << c->formattedInfeasibility(c.name());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment