4#pragma warning(disable : 4267)
13#include <json/reader.h>
25#include "antares-xpansion/core/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>;
66 bool operator()(
const PointPtr& lhs,
const PointPtr& rhs)
const
71 bool operator()(
const Point& lhs,
const Point& rhs)
const
73 Point::const_iterator it1(lhs.begin());
74 Point::const_iterator it2(rhs.begin());
76 Point::const_iterator end1(lhs.end());
77 Point::const_iterator end2(rhs.end());
79 while (it1 != end1 && it2 != end2)
81 if (it1->first != it2->first)
83 return it1->first < it2->first;
87 if (std::fabs(it1->second - it2->second) < EPSILON_PREDICATE)
94 return it1->second < it2->second;
99 if (it1 == end1 && it2 == end2)
105 return (it1 == end1);
117inline std::ostream& operator<<(std::ostream& stream,
const Point& rhs)
119 for (
const auto& kvp: rhs)
131 stream << kvp.second;
135 else if (kvp.second < 0)
137 stream << kvp.second;
144double norm_point(
const Point& x0,
const Point& x1);
146std::ostream& operator<<(std::ostream& stream,
const std::vector<IntVector>& rhs);
148const std::string SUBPROBLEM_WEIGHT_CST_STR(
"CONSTANT");
149const std::string SUBPROBLEM_WEIGHT_UNIFORM_CST_STR(
"UNIFORM");
150const std::string WEIGHT_SUM_CST_STR(
"WEIGHT_SUM");
151const std::string MPS_SUFFIX =
".mps";
152const std::string SAVE_SUFFIX =
".svf";
158 std::string INPUTROOT;
159 std::string OUTPUTROOT;
160 std::string STRUCTURE_FILE;
161 std::string MASTER_NAME;
162 std::string SOLVER_NAME;
164 ProblemsFormat PROBLEMS_FORMAT = ProblemsFormat::MPS_FILE;
177 std::string FULL_DIR;
189 std::string SLAVE_WEIGHT;
190 double SLAVE_WEIGHT_VALUE = 0;
198 bool DO_OUTER_LOOP =
false;
199 std::string OUTER_LOOP_OPTION_FILE;
209 int MAX_ITERATIONS = -1;
211 double ABSOLUTE_GAP = 0;
212 double RELATIVE_GAP = 0;
213 double RELAXED_GAP = 0;
214 double TIME_LIMIT = 0;
215 double SEPARATION_PARAM = 1;
216 double MASTER_SOLUTION_TOLERANCE = 1e-4;
217 double CUT_COEFFICIENT_TOLERANCE = 5e-3;
220 bool AGGREGATION =
false;
222 bool BOUND_ALPHA =
false;
223 bool CACHE_PROBLEMS =
false;
225 MasterFormulation MASTER_FORMULATION;
227 std::string AREA_FILE;
228 std::string CSV_NAME;
229 std::string LAST_MASTER_MPS;
230 std::string LAST_MASTER_BASIS;
231 std::string LAST_ITERATION_JSON_FILE;
240Json::Value get_json_file_content(
const std::filesystem::path& json_file);
242bool mkdir(
const std::filesystem::path& path_to_folder);
246 { os << obj } -> std::same_as<std::ostream&>;
252template<OStreamable MPSPath, OStreamable Cand
idateName, OStreamableIntegral ColId>
253void export_structure_file(
const std::filesystem::path& output_path,
254 const std::map<MPSPath, std::map<CandidateName, ColId>>& structure)
256 std::ofstream structure_file{output_path};
257 for (
const auto& [mps_file_path, candidates_name_and_colId]: structure)
259 for (
const auto& [candidate_name, colId]: candidates_name_and_colId)
263 structure_file << std::setw(50) << mps_file_path;
264 structure_file <<
" " << std::setw(50) << candidate_name;
265 structure_file <<
" " << std::setw(10) << colId;
266 structure_file << std::endl;
269 structure_file.close();