4#pragma warning(disable : 4267)
7#include <json/reader.h>
26#include "ProblemFormat.h"
28enum class MasterFormulation { INTEGER, RELAXED };
29enum class SOLVER { BENDERS, OUTER_LOOP, MERGE_MPS };
32typedef std::map<std::string, double> Point;
34typedef std::shared_ptr<Point> PointPtr;
36double const EPSILON_PREDICATE = 1e-8;
38typedef std::set<std::string> problem_names;
39typedef std::map<std::string, int> VariableMap;
40typedef std::map<int, std::string> Int2Str;
41typedef std::map<std::string, double> Str2Dbl;
42typedef std::vector<int> IntVector;
43typedef std::vector<char> CharVector;
44typedef std::vector<double> DblVector;
45typedef std::vector<std::string> StrVector;
46typedef std::map<std::string, VariableMap> CouplingMap;
48typedef std::map<std::string, IntVector> SlaveCutId;
49typedef std::tuple<int, std::string, int, bool> ActiveCut;
50typedef std::vector<ActiveCut> ActiveCutStorage;
52typedef std::pair<std::string, std::string> mps_coupling;
53typedef std::list<mps_coupling> mps_coupling_list;
55enum class BENDERSMETHOD {
59 BENDERS_BY_BATCH_OUTERLOOP
62inline std::string bendersmethod_to_string(BENDERSMETHOD method) {
64 case BENDERSMETHOD::BENDERS:
66 case BENDERSMETHOD::BENDERS_BY_BATCH:
67 return "Benders by batch";
68 case BENDERSMETHOD::BENDERS_OUTERLOOP:
69 return "Outerloop around Benders";
70 case BENDERSMETHOD::BENDERS_BY_BATCH_OUTERLOOP:
71 return "Outerloop around Benders by batch";
78 bool operator()(PointPtr
const &lhs, PointPtr
const &rhs)
const {
81 bool operator()(Point
const &lhs, Point
const &rhs)
const {
82 Point::const_iterator it1(lhs.begin());
83 Point::const_iterator it2(rhs.begin());
85 Point::const_iterator end1(lhs.end());
86 Point::const_iterator end2(rhs.end());
88 while (it1 != end1 && it2 != end2) {
89 if (it1->first != it2->first) {
90 return it1->first < it2->first;
92 if (std::fabs(it1->second - it2->second) < EPSILON_PREDICATE) {
96 return it1->second < it2->second;
101 if (it1 == end1 && it2 == end2) {
104 return (it1 == end1);
116inline std::ostream &operator<<(std::ostream &stream, Point
const &rhs) {
117 for (
auto const &kvp : rhs) {
118 if (kvp.second > 0) {
119 if (kvp.second == 1) {
124 stream << kvp.second;
127 }
else if (kvp.second < 0) {
128 stream << kvp.second;
135double norm_point(Point
const &x0, Point
const &x1);
137std::ostream &operator<<(std::ostream &stream,
138 std::vector<IntVector>
const &rhs);
140const std::string SUBPROBLEM_WEIGHT_CST_STR(
"CONSTANT");
141const std::string SUBPROBLEM_WEIGHT_UNIFORM_CST_STR(
"UNIFORM");
142const std::string WEIGHT_SUM_CST_STR(
"WEIGHT_SUM");
143const std::string MPS_SUFFIX =
".mps";
144const std::string SAVE_SUFFIX =
".svf";
147 std::string OUTPUTROOT;
148 std::string INPUTROOT;
149 std::string STRUCTURE_FILE;
150 std::string LAST_ITERATION_JSON_FILE;
151 std::string MASTER_NAME;
152 ProblemsFormat PROBLEMS_FORMAT = ProblemsFormat::MPS_FILE;
153 std::string SOLVER_NAME;
154 std::string SLAVE_WEIGHT;
155 std::string AREA_FILE;
159 double SLAVE_WEIGHT_VALUE = 0;
167 bool DO_OUTER_LOOP =
false;
168 std::string OUTER_LOOP_OPTION_FILE;
175 int MAX_ITERATIONS = -1;
177 double ABSOLUTE_GAP = 0;
178 double RELATIVE_GAP = 0;
179 double RELAXED_GAP = 0;
180 double TIME_LIMIT = 0;
181 double SEPARATION_PARAM = 1;
183 bool AGGREGATION =
false;
185 bool BOUND_ALPHA =
false;
187 MasterFormulation MASTER_FORMULATION;
189 std::string CSV_NAME;
190 std::string LAST_MASTER_MPS;
191 std::string LAST_MASTER_BASIS;
198Json::Value get_json_file_content(
const std::filesystem::path &json_file);