Antares Xpansion
Investment simulations for Antares studies
Loading...
Searching...
No Matches
AdditionalConstraints.h
1#pragma once
2
3#include <map>
4#include <set>
5#include <string>
6#include <utility>
7
8#include "antares-xpansion/lpnamer/helper/ProblemGenerationLogger.h"
9
17class AdditionalConstraint : public std::map<std::string, double> {
18 private:
19 std::string _sectionName;
20 std::string _name;
21 std::string _sign;
22 double _rhs = 0.0;
23
24 public:
29
40 AdditionalConstraint(std::string sectionName_p, std::string constraintName_p,
41 std::string sign_p, double rhs_p)
42 : _sectionName(std::move(sectionName_p)),
43 _name(std::move(constraintName_p)),
44 _sign(std::move(sign_p)),
45 _rhs(rhs_p) {}
46
50 virtual ~AdditionalConstraint() = default;
51
57 [[nodiscard]] std::string getName() const { return _name; }
58
64 [[nodiscard]] double getRHS() const { return _rhs; }
65
72 [[nodiscard]] std::string getSign() const { return _sign; }
73
80 void setCoeff(const std::string& varName_p, const double varCoeff_p) {
81 (*this)[varName_p] = varCoeff_p;
82 }
83};
84
93 : public std::map<std::string, AdditionalConstraint> {
94 private:
95 // set of variables to which a binary corresponding variable will be created
96 std::map<std::string, std::string> _variablesToBinarise;
97 std::set<std::string> _binaryVariables;
98 std::string constraintsFilePath_;
99 std::shared_ptr<ProblemGenerationLog::ProblemGenerationLogger> logger_;
100
101 public:
106 std::shared_ptr<ProblemGenerationLog::ProblemGenerationLogger> logger)
107 : logger_(std::move(logger)) {}
108
115 explicit AdditionalConstraints(
116 std::string constraints_file_path,
117 std::shared_ptr<ProblemGenerationLog::ProblemGenerationLogger> logger);
118
119 void SetConstraintsFile(std::string const& constraints_file_path) {
120 constraintsFilePath_ = constraints_file_path;
121 }
122 void ReadConstraintsFile();
133 void addVariableToBinarise(const std::string& oldVarName_p,
134 const std::string& binVarName_p);
135
147 std::map<std::string, std::string> const& variables_section);
148
156 [[nodiscard]] std::map<std::string, std::string> const&
158
166 const std::string& sectionName_l,
167 const std::map<std::string, std::string>& constarintsSection_l);
168
176 [[nodiscard]] std::string checkAndReturnConstraintName(
177 const std::string& sectionName_l,
178 const std::map<std::string, std::string>& constarintsSection_l) const;
179
187 [[nodiscard]] std::string checkAndReturnSectionSign(
188 const std::string& sectionName_l,
189 const std::map<std::string, std::string>& constarintsSection_l) const;
190
197 [[nodiscard]] double checkAndReturnSectionRhs(
198 const std::string& sectionName_l,
199 const std::map<std::string, std::string>& constarintsSection_l) const;
200};
additional constraint to add to master problem
Definition AdditionalConstraints.h:17
std::string getSign() const
AdditionalConstraint::_sign getter.
Definition AdditionalConstraints.h:72
virtual ~AdditionalConstraint()=default
AdditionalConstraint destructor.
AdditionalConstraint()=default
AdditionalConstraint default constructor.
double getRHS() const
AdditionalConstraint::_rhs getter.
Definition AdditionalConstraints.h:64
void setCoeff(const std::string &varName_p, const double varCoeff_p)
adds a term to the constraint
Definition AdditionalConstraints.h:80
std::string getName() const
AdditionalConstraint::_name getter.
Definition AdditionalConstraints.h:57
AdditionalConstraint(std::string sectionName_p, std::string constraintName_p, std::string sign_p, double rhs_p)
AdditionalConstraint constructor.
Definition AdditionalConstraints.h:40
candidate exclusion constraint structure
Definition AdditionalConstraints.h:93
void constructAdditionalConstraints(const std::string &sectionName_l, const std::map< std::string, std::string > &constarintsSection_l)
the method is responsible for creating and filling constraints
Definition AdditionalConstraints.cpp:56
std::string checkAndReturnConstraintName(const std::string &sectionName_l, const std::map< std::string, std::string > &constarintsSection_l) const
the method is responsible for checking that section has defined a unique constraint name
Definition AdditionalConstraints.cpp:107
std::string checkAndReturnSectionSign(const std::string &sectionName_l, const std::map< std::string, std::string > &constarintsSection_l) const
the method is responsible for checking that section has defined a sign
Definition AdditionalConstraints.cpp:130
std::map< std::string, std::string > const & getVariablesToBinarise() const
getter for AdditionalConstraints::_variablesToBinarise
Definition AdditionalConstraints.cpp:52
void addVariablesToBinarise(std::map< std::string, std::string > const &variables_section)
adds a binary variable to be created and links it to the corresponding variable
Definition AdditionalConstraints.cpp:44
double checkAndReturnSectionRhs(const std::string &sectionName_l, const std::map< std::string, std::string > &constarintsSection_l) const
the method is responsible for checking that section has defined a rhs
Definition AdditionalConstraints.cpp:148
void addVariableToBinarise(const std::string &oldVarName_p, const std::string &binVarName_p)
adds a binary variable to be created and links it to the corresponding variable
Definition AdditionalConstraints.cpp:34
AdditionalConstraints(std::shared_ptr< ProblemGenerationLog::ProblemGenerationLogger > logger)
default constructor for struct AdditionalConstraints
Definition AdditionalConstraints.h:105