diff --git a/src/cpp/exe/full_run/main.cpp b/src/cpp/exe/full_run/main.cpp index fdc826b3ef..b96660ef8d 100644 --- a/src/cpp/exe/full_run/main.cpp +++ b/src/cpp/exe/full_run/main.cpp @@ -1,3 +1,5 @@ +#include + #include #include #include @@ -8,8 +10,27 @@ #include "RunProblemGeneration.h" #include "StudyUpdateRunner.h" #include "common_mpi.h" +#include "default_json.h" namespace po = boost::program_options; +void BendersPreActions(std::filesystem::path option_file) { + if (std::filesystem::exists(option_file) && + std::filesystem::is_regular_file(option_file)) { + return; // TODO: Cas python dejà passé par là. On garde on non ? + } + + std::istringstream option_stream(DefaultJson::BendersOptions); + std::string err; + Json::CharReaderBuilder builder; + Json::Value root; + if (!Json::parseFromStream(builder, option_stream, &root, &err)) { + // TODO: log + } + + std::ofstream outStream(option_file); + outStream << root; +} + int main(int argc, char** argv) { mpi::environment env(argc, argv); mpi::communicator world; @@ -48,6 +69,8 @@ int main(int argc, char** argv) { const auto options_file = options_parser.BendersOptionsFile(); const auto benders_method = options_parser.Method(); + BendersPreActions(options_file); + auto benders_factory = BendersMainFactory(argc_, argv, benders_method, options_file, env, world); benders_factory.Run(); diff --git a/src/cpp/full_run/CMakeLists.txt b/src/cpp/full_run/CMakeLists.txt index fefcd33e5a..c3ee11f3b0 100644 --- a/src/cpp/full_run/CMakeLists.txt +++ b/src/cpp/full_run/CMakeLists.txt @@ -12,6 +12,7 @@ add_library (full_run_lib STATIC ${CMAKE_CURRENT_SOURCE_DIR}/FullRunOptionsParser.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/include/default_json.h ) diff --git a/src/cpp/full_run/include/default_json.h b/src/cpp/full_run/include/default_json.h new file mode 100644 index 0000000000..bbddfce419 --- /dev/null +++ b/src/cpp/full_run/include/default_json.h @@ -0,0 +1,28 @@ +// +// Created by marechaljas on 25/10/23. +// + +#pragma once +#include + +namespace DefaultJson { +std::string BendersOptions = + "{ \ + \"MAX_ITERATIONS\": -1,\n \ + \"ABSOLUTE_GAP\": 1.0,\n \ + \"RELATIVE_GAP\": 1e-06,\n \ + \"RELAXED_GAP\": 1e-05,\n \ + \"AGGREGATION\": false,\n \ + \"OUTPUTROOT\": \".\",\n \ + \"TRACE\": true,\n \ + \"SLAVE_WEIGHT\": \"CONSTANT\",\n \ + \"SLAVE_WEIGHT_VALUE\": 1,\n \ + \"MASTER_NAME\": \"master\",\n \ + \"STRUCTURE_FILE\": \"structure.txt\",\n \ + \"INPUTROOT\": \".\",\n \ + \"CSV_NAME\": \"benders_output_trace\",\n \ + \"BOUND_ALPHA\": true,\n \ + \"SEPARATION_PARAM\": 0.5,\n \ + \"BATCH_SIZE\": 0,\n \ + }"; +} \ No newline at end of file