Skip to content

Commit

Permalink
Add missing parameter to command built by batchrun for OR-Tools (#1984)
Browse files Browse the repository at this point in the history
  • Loading branch information
flomnes committed Mar 19, 2024
1 parent 7c89461 commit cc1efb3
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 168 deletions.
4 changes: 3 additions & 1 deletion src/solver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ include("cmake/simulation.cmake")
include("cmake/ts-generator.cmake")
include("cmake/constraints-builder.cmake")

add_subdirectory(utils)
#
# Resource file for Windows
#
Expand Down Expand Up @@ -89,7 +90,8 @@ set(ANTARES_SOLVER_LIBS ${ANTARES_SOLVER_LIBS}
libantares-solver-simulation
libantares-solver-ts-generator
libmodel_antares
libantares-core)
libantares-core
antares-utils)

target_link_libraries(antares-solver
PRIVATE
Expand Down
12 changes: 1 addition & 11 deletions src/solver/cmake/solver.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,6 @@ set(RTESOLVER_OPT
optimisation/adequacy_patch_csr/count_constraints_variables.cpp

optimisation/opt_period_string_generator_base.h

utils/ortools_utils.h
utils/ortools_utils.cpp
utils/filename.h
utils/filename.cpp
utils/named_problem.h
utils/named_problem.cpp
utils/mps_utils.h
utils/mps_utils.cpp
utils/opt_period_string_generator.h
utils/opt_period_string_generator.cpp
)


Expand All @@ -108,4 +97,5 @@ target_link_libraries(libmodel_antares
sirius_solver
infeasible_problem_analysis
libantares-solver-simulation
antares-utils
)
14 changes: 0 additions & 14 deletions src/solver/misc/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,6 @@ using namespace Yuni;
using namespace Antares;
using namespace Antares::Data;

static std::string availableOrToolsSolversString()
{
const std::list<std::string> availableSolverList = getAvailableOrtoolsSolverName();
std::string availableSolverListStr;
for (auto it = availableSolverList.begin(); it != availableSolverList.end(); it++)
{
availableSolverListStr += *it + ";";
}
// Remove last semicolumn
if (!availableSolverListStr.empty())
availableSolverListStr.pop_back();
return availableSolverListStr;
}

std::unique_ptr<GetOpt::Parser> CreateParser(Settings& settings,
Antares::Data::StudyLoadOptions& options)
{
Expand Down
4 changes: 3 additions & 1 deletion src/solver/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ target_link_libraries(utils

target_include_directories(utils
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/solver/utils
)

add_library(antares-utils ALIAS utils)
17 changes: 15 additions & 2 deletions src/solver/utils/ortools_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ using namespace operations_research;

const char* const XPRESS_PARAMS = "THREADS 1 SCALING 0";

std::string availableOrToolsSolversString()
{
const std::list<std::string> availableSolverList = getAvailableOrtoolsSolverName();
std::string availableSolverListStr;
for (auto it = availableSolverList.begin(); it != availableSolverList.end(); it++)
{
availableSolverListStr += *it + ";";
}
// Remove last semicolumn
if (!availableSolverListStr.empty())
availableSolverListStr.pop_back();
return availableSolverListStr;
}

static void transferVariables(MPSolver* solver,
const double* bMin,
const double* bMax,
Expand Down Expand Up @@ -315,8 +329,7 @@ MPSolver* ORTOOLS_Simplexe(Antares::Optimization::PROBLEME_SIMPLEXE_NOMME* Probl
// Provide an initial simplex basis, if any
if (warmStart && Probleme->basisExists() && !Probleme->isMIP())
{
solver->SetStartingLpBasis(Probleme->StatutDesVariables,
Probleme->StatutDesContraintes);
solver->SetStartingLpBasis(Probleme->StatutDesVariables, Probleme->StatutDesContraintes);
}

if (solveAndManageStatus(solver, Probleme->ExistenceDUneSolution, params))
Expand Down
2 changes: 2 additions & 0 deletions src/solver/utils/ortools_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ void ORTOOLS_EcrireJeuDeDonneesLineaireAuFormatMPS(MPSolver* solver,
*/
std::list<std::string> getAvailableOrtoolsSolverName();

std::string availableOrToolsSolversString();

/*!
* \brief Create a MPSolver with correct linear or mixed variant
*
Expand Down
1 change: 1 addition & 0 deletions src/tools/batchrun/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ INSTALL(EXPORT antares-batchrun

set(BATCHRUN_LIBS
libantares-core
antares-utils
libantares-core-calendar
yuni-static-core
${CMAKE_THREADS_LIBS_INIT}
Expand Down
Loading

0 comments on commit cc1efb3

Please sign in to comment.