-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a check to unfeasible analyzer : mainly extract class VariablesBo…
…undsConsistency in separate source files
- Loading branch information
1 parent
7dc22fb
commit 4bffb5f
Showing
7 changed files
with
79 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/solver/infeasible-problem-analysis/variables-bounds-consistency.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "variables-bounds-consistency.h" | ||
#include <antares/logs/logs.h> | ||
|
||
namespace Antares::Optimization | ||
{ | ||
|
||
void VariablesBoundsConsistency::run() | ||
{ | ||
for (auto& var : problem_->variables()) | ||
{ | ||
double lowBound = var->lb(); | ||
double upBound = var->ub(); | ||
std::string name = var->name(); | ||
if (lowBound > upBound) | ||
{ | ||
storeIncorrectVariable(name, lowBound, upBound); | ||
} | ||
} | ||
|
||
if (foundIncorrectVariables()) | ||
hasDetectedInfeasibilityCause_ = true; | ||
} | ||
|
||
void VariablesBoundsConsistency::storeIncorrectVariable(std::string name, double lowBound, double upBound) | ||
{ | ||
incorrectVars_.push_back(VariableBounds(name, lowBound, upBound)); | ||
} | ||
|
||
bool VariablesBoundsConsistency::foundIncorrectVariables() | ||
{ | ||
return !incorrectVars_.empty(); | ||
} | ||
|
||
void VariablesBoundsConsistency::printReport() | ||
{ | ||
for (auto& var : incorrectVars_) | ||
{ | ||
logs.notice() << var.name << " : low bound = " << var.lowBound << ", up bound = " << var.upBound; | ||
} | ||
} | ||
} // namespace Antares::Optimization |
33 changes: 33 additions & 0 deletions
33
src/solver/infeasible-problem-analysis/variables-bounds-consistency.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
|
||
#include "unfeasibility-analysis.h" | ||
|
||
namespace Antares::Optimization | ||
{ | ||
|
||
struct VariableBounds | ||
{ | ||
VariableBounds(std::string var_name, double low_bound, double up_bound) | ||
: name(var_name), lowBound(low_bound), upBound(up_bound) | ||
{} | ||
|
||
std::string name; | ||
double lowBound; | ||
double upBound; | ||
}; | ||
|
||
class VariablesBoundsConsistency : public UnfeasibilityAnalysis | ||
{ | ||
using UnfeasibilityAnalysis::UnfeasibilityAnalysis; | ||
public: | ||
void run() override; | ||
void printReport() override; | ||
std::string title() override { return "Variables bounds consistency check"; } | ||
|
||
private: | ||
void storeIncorrectVariable(std::string name, double lowBound, double upBound); | ||
bool foundIncorrectVariables(); | ||
|
||
std::vector<VariableBounds> incorrectVars_; | ||
}; | ||
} |