4#pragma warning(disable : 4267)
13#include <json/reader.h>
25#include "ProblemFormat.h"
27enum class MasterFormulation
41typedef std::map<std::string, double> Point;
43typedef std::shared_ptr<Point> PointPtr;
45const double EPSILON_PREDICATE = 1e-8;
47using problem_names = std::set<std::string>;
48using VariableMap = std::map<std::string, int>;
49using Int2Str = std::map<int, std::string>;
50using Str2Dbl = std::map<std::string, double>;
51using IntVector = std::vector<int>;
52using CharVector = std::vector<char>;
53using DblVector = std::vector<double>;
54using StrVector = std::vector<std::string>;
55using CouplingMap = std::map<std::string, VariableMap>;
57using SlaveCutId = std::map<std::string, IntVector>;
58using ActiveCut = std::tuple<int, std::string, int, bool>;
59using ActiveCutStorage = std::vector<ActiveCut>;
61using mps_coupling = std::pair<std::string, std::string>;
62using mps_coupling_list = std::list<mps_coupling>;
64enum class BENDERSMETHOD
69 BENDERS_BY_BATCH_OUTERLOOP
72inline std::string bendersmethod_to_string(BENDERSMETHOD method)
76 case BENDERSMETHOD::BENDERS:
78 case BENDERSMETHOD::BENDERS_BY_BATCH:
79 return "Benders by batch";
80 case BENDERSMETHOD::BENDERS_OUTERLOOP:
81 return "Outerloop around Benders";
82 case BENDERSMETHOD::BENDERS_BY_BATCH_OUTERLOOP:
83 return "Outerloop around Benders by batch";
91 bool operator()(
const PointPtr& lhs,
const PointPtr& rhs)
const
96 bool operator()(
const Point& lhs,
const Point& rhs)
const
98 Point::const_iterator it1(lhs.begin());
99 Point::const_iterator it2(rhs.begin());
101 Point::const_iterator end1(lhs.end());
102 Point::const_iterator end2(rhs.end());
104 while (it1 != end1 && it2 != end2)
106 if (it1->first != it2->first)
108 return it1->first < it2->first;
112 if (std::fabs(it1->second - it2->second) < EPSILON_PREDICATE)
119 return it1->second < it2->second;
124 if (it1 == end1 && it2 == end2)
130 return (it1 == end1);
142inline std::ostream& operator<<(std::ostream& stream,
const Point& rhs)
144 for (
const auto& kvp: rhs)
156 stream << kvp.second;
160 else if (kvp.second < 0)
162 stream << kvp.second;
169double norm_point(
const Point& x0,
const Point& x1);
171std::ostream& operator<<(std::ostream& stream,
const std::vector<IntVector>& rhs);
173const std::string SUBPROBLEM_WEIGHT_CST_STR(
"CONSTANT");
174const std::string SUBPROBLEM_WEIGHT_UNIFORM_CST_STR(
"UNIFORM");
175const std::string WEIGHT_SUM_CST_STR(
"WEIGHT_SUM");
176const std::string MPS_SUFFIX =
".mps";
177const std::string SAVE_SUFFIX =
".svf";
181 std::string OUTPUTROOT;
182 std::string INPUTROOT;
183 std::string STRUCTURE_FILE;
184 std::string LAST_ITERATION_JSON_FILE;
185 std::string MASTER_NAME;
186 ProblemsFormat PROBLEMS_FORMAT = ProblemsFormat::MPS_FILE;
187 std::string SOLVER_NAME;
188 std::string SLAVE_WEIGHT;
189 std::string AREA_FILE;
193 double SLAVE_WEIGHT_VALUE = 0;
203 bool DO_OUTER_LOOP =
false;
204 std::string OUTER_LOOP_OPTION_FILE;
214 int MAX_ITERATIONS = -1;
216 double ABSOLUTE_GAP = 0;
217 double RELATIVE_GAP = 0;
218 double RELAXED_GAP = 0;
219 double TIME_LIMIT = 0;
220 double SEPARATION_PARAM = 1;
222 bool AGGREGATION =
false;
224 bool BOUND_ALPHA =
false;
226 MasterFormulation MASTER_FORMULATION;
228 std::string CSV_NAME;
229 std::string LAST_MASTER_MPS;
230 std::string LAST_MASTER_BASIS;
238Json::Value get_json_file_content(
const std::filesystem::path& json_file);