diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f40fe83bfc..f205343e58 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.14) # FetchContent_MakeAvailable # Version set(ANTARES_VERSION_HI 8) set(ANTARES_VERSION_LO 8) -set(ANTARES_VERSION_REVISION 6) +set(ANTARES_VERSION_REVISION 7) # Beta release set(ANTARES_BETA 0) diff --git a/src/solver/optimisation/post_process_commands.cpp b/src/solver/optimisation/post_process_commands.cpp index 9e1bfc4c41..f864cc1c89 100644 --- a/src/solver/optimisation/post_process_commands.cpp +++ b/src/solver/optimisation/post_process_commands.cpp @@ -256,9 +256,9 @@ double CurtailmentSharingPostProcessCmd::calculateDensNewAndTotalLmrViolation() const auto& scratchpad = area_list_[Area]->scratchpad[thread_number_]; double dtgMrg = scratchpad.dispatchableGenerationMargin[hour]; // write down densNew values for all the hours - problemeHebdo_->ResultatsHoraires[Area].ValeursHorairesDENS[hour] - = std::max(0.0, densNew - dtgMrg); - ; + problemeHebdo_->ResultatsHoraires[Area].ValeursHorairesDENS[hour] = std::max( + 0.0, + densNew); // copy spilled Energy values into spilled Energy values after CSR problemeHebdo_->ResultatsHoraires[Area].ValeursHorairesSpilledEnergyAfterCSR[hour] = problemeHebdo_->ResultatsHoraires[Area] diff --git a/src/tools/batchrun/main.cpp b/src/tools/batchrun/main.cpp index dd0fb3187b..b905c6fac4 100644 --- a/src/tools/batchrun/main.cpp +++ b/src/tools/batchrun/main.cpp @@ -32,12 +32,16 @@ #include #include #include +#include #include #include #include #include +#include #include #include +#include + #ifdef YUNI_OS_WINDOWS #include #endif @@ -84,7 +88,8 @@ int main(int argc, char* argv[]) Antares::Resources::Initialize(argc, argv, true); // options - String optInput; + std::string optInput; + std::string ortoolsSolver; bool optNoTSImport = false; bool optIgnoreAllConstraints = false; bool optForceExpansion = false; @@ -95,6 +100,7 @@ int main(int argc, char* argv[]) bool optNoOutput = false; bool optParallel = false; bool optVerbose = false; + bool ortoolsUsed = false; Nullable optYears; Nullable optSolver; Nullable optName; @@ -143,6 +149,19 @@ int main(int argc, char* argv[]) ' ', "force-parallel", "Override the max number of years computed simultaneously"); + + // add option for ortools use + // --use-ortools + options.addFlag(ortoolsUsed, ' ', "use-ortools", "Use ortools library to launch solver"); + + //--ortools-solver + options.add(ortoolsSolver, + ' ', + "ortools-solver", + "Ortools solver used for simulation (only available with use-ortools " + "option)\nAvailable solver list : " + + availableOrToolsSolversString()); + options.remainingArguments(optInput); // Version options.addParagraph("\nMisc."); @@ -176,163 +195,179 @@ int main(int argc, char* argv[]) logs.error() << "contradictory options: --economy and --adequacy"; return EXIT_FAILURE; } - } - - // Source Folder - logs.debug() << "Folder : `" << optInput << '`'; - String solver; - if (optSolver.empty()) - { - Solver::FindLocation(solver); - if (solver.empty()) + if (ortoolsUsed) { - logs.fatal() << "The solver has not been found"; - return EXIT_FAILURE; - } - } - else - { - String tmp; - IO::MakeAbsolute(tmp, *optSolver); - IO::Normalize(solver, tmp); - if (not IO::File::Exists(solver)) - { - logs.fatal() << "The solver has not been found. specify --solver=" << solver; - return EXIT_FAILURE; + const auto availableSolvers = getAvailableOrtoolsSolverName(); + if (auto it + = std::find(availableSolvers.begin(), availableSolvers.end(), ortoolsSolver); + it == availableSolvers.end()) + { + logs.error() << "Please specify a solver using --ortools-solver. Available solvers " + << availableOrToolsSolversString() << ""; + return EXIT_FAILURE; + } } - } - logs.info() << " Solver: '" << solver << "'"; - logs.info(); - logs.info(); - logs.info() << "Searching for studies..."; - logs.info(); - MyStudyFinder finder; - finder.lookup(optInput); - finder.wait(); + // Source Folder + logs.debug() << "Folder : `" << optInput << '`'; - if (not finder.list.empty()) - { - if (finder.list.size() > 1) - logs.info() << "Found " << finder.list.size() << " studyies"; + String solver; + if (optSolver.empty()) + { + Solver::FindLocation(solver); + if (solver.empty()) + { + logs.fatal() << "The solver has not been found"; + return EXIT_FAILURE; + } + } else - logs.info() << "Found 1 study"; - logs.info() << "Starting..."; - - if (!(!optName)) { - String name; - name = *optName; - name.replace("\"", "\\\""); - *optName = name; + String tmp; + IO::MakeAbsolute(tmp, *optSolver); + IO::Normalize(solver, tmp); + if (not IO::File::Exists(solver)) + { + logs.fatal() << "The solver has not been found. specify --solver=" << solver; + return EXIT_FAILURE; + } } - // The folder that contains the solver - String dirname; - IO::parentPath(dirname, solver); + logs.info() << " Solver: '" << solver << "'"; + logs.info(); + logs.info(); + logs.info() << "Searching for studies..."; + logs.info(); + MyStudyFinder finder; + finder.lookup(optInput); + finder.wait(); - String cmd; - - uint studyIndx = 0; - foreach (auto& studypath, finder.list) + if (not finder.list.empty()) { - ++studyIndx; - - logs.info(); - if (optVerbose) - logs.info(); - - logs.checkpoint() << "Running simulation: `" << studypath << "` (" << studyIndx << '/' - << (uint)finder.list.size() << ')'; - if (optVerbose) - logs.debug(); - - cmd.clear(); - if (not System::windows) - cmd << "nice "; + if (finder.list.size() > 1) + logs.info() << "Found " << finder.list.size() << " studyies"; else - cmd << "call "; // why is it required for working ??? - cmd << "\"" << solver << "\""; - if (optForce) - cmd << " --force"; - if (optForceExpansion) - cmd << " --economy"; - if (optForceEconomy) - cmd << " --economy"; - if (optForceAdequacy) - cmd << " --adequacy"; + logs.info() << "Found 1 study"; + logs.info() << "Starting..."; + if (!(!optName)) - cmd << " --name=\"" << *optName << "\""; - if (!(!optYears)) - cmd << " --year=" << *optYears; - if (optNoOutput) - cmd << " --no-output"; - if (optYearByYear) - cmd << " --year-by-year"; - if (optNoTSImport) - cmd << " --no-ts-import"; - if (optIgnoreAllConstraints) - cmd << " --no-constraints"; - if (optParallel) - cmd << " --parallel"; - if (!(!optForceParallel)) - cmd << " --force-parallel=" << *optForceParallel; - cmd << " \"" << studypath << "\""; - if (!optVerbose) - cmd << sendToNull(); - - // Changing the current working directory - IO::Directory::Current::Set(dirname); - // Executing the converter - if (optVerbose) - logs.info() << "Executing " << cmd; + { + String name; + name = *optName; + name.replace("\"", "\\\""); + *optName = name; + } - // Execute the command - int cmd_return_code = system(cmd.c_str()); + // The folder that contains the solver + String dirname; + IO::parentPath(dirname, solver); - if (cmd_return_code != 0) - logs.error() << "An error occured."; - else - logs.info() << "Success."; + String cmd; - if (cmd_return_code == -1) + uint studyIndx = 0; + foreach (auto& studypath, finder.list) { -#ifdef YUNI_OS_WINDOWS - switch (errno) + ++studyIndx; + + logs.info(); + if (optVerbose) + logs.info(); + + logs.checkpoint() << "Running simulation: `" << studypath << "` (" << studyIndx + << '/' << (uint)finder.list.size() << ')'; + if (optVerbose) + logs.debug(); + + cmd.clear(); + if (not System::windows) + cmd << "nice "; + else + cmd << "call "; // why is it required for working ??? + cmd << "\"" << solver << "\""; + if (optForce) + cmd << " --force"; + if (optForceExpansion) + cmd << " --economy"; + if (optForceEconomy) + cmd << " --economy"; + if (optForceAdequacy) + cmd << " --adequacy"; + if (!(!optName)) + cmd << " --name=\"" << *optName << "\""; + if (!(!optYears)) + cmd << " --year=" << *optYears; + if (optNoOutput) + cmd << " --no-output"; + if (optYearByYear) + cmd << " --year-by-year"; + if (optNoTSImport) + cmd << " --no-ts-import"; + if (optIgnoreAllConstraints) + cmd << " --no-constraints"; + if (optParallel) + cmd << " --parallel"; + if (optForceParallel) + cmd << " --force-parallel=" << *optForceParallel; + if (ortoolsUsed) + cmd << " --use-ortools --ortools-solver=" << ortoolsSolver; + + cmd << " \"" << studypath << "\""; + if (!optVerbose) + cmd << sendToNull(); + + // Changing the current working directory + IO::Directory::Current::Set(dirname); + // Executing the converter + if (optVerbose) + logs.info() << "Executing " << cmd; + + // Execute the command + int cmd_return_code = system(cmd.c_str()); + + if (cmd_return_code != 0) + logs.error() << "An error occured."; + else + logs.info() << "Success."; + + if (cmd_return_code == -1) { - case E2BIG: - logs.error() << "Argument list (which is system dependent) is too big"; - break; - case ENOENT: - logs.error() << "Command interpreter cannot be found"; - break; - case ENOEXEC: - logs.error() - << "Command-interpreter file has invalid format and is not executable"; - break; - case ENOMEM: - logs.error() << "Not enough memory is available to execute command"; - break; - } +#ifdef YUNI_OS_WINDOWS + switch (errno) + { + case E2BIG: + logs.error() << "Argument list (which is system dependent) is too big"; + break; + case ENOENT: + logs.error() << "Command interpreter cannot be found"; + break; + case ENOEXEC: + logs.error() + << "Command-interpreter file has invalid format and is not executable"; + break; + case ENOMEM: + logs.error() << "Not enough memory is available to execute command"; + break; + } #endif + } } - } - logs.info() << "Done."; + logs.info() << "Done."; - // Time interval - if (optVerbose) + // Time interval + if (optVerbose) + { + logs.debug(); + logs.debug(); + } + } + else { - logs.debug(); - logs.debug(); + logs.fatal() << "No study has been found."; + return 4; } - } - else - { - logs.fatal() << "No study has been found."; - return 4; - } - return 0; + return 0; + } }