From 10634f2d12cfbc3cf87f407a2fbec8873a688993 Mon Sep 17 00:00:00 2001 From: Jason Marechal Date: Fri, 10 Jan 2025 17:34:58 +0100 Subject: [PATCH] Solver config Helper to handle solver_names casse --- src/cpp/lpnamer/main/ProblemGeneration.cpp | 35 ++++--- .../lpnamer/main/ProblemGeneration.h | 5 +- .../LinkProblemsGenerator.cpp | 4 +- .../MPSFileProblemProviderAdapter.cpp | 1 + .../problem_modifier/LinkProblemsGenerator.h | 16 +-- .../MPSFileProblemProviderAdapter.h | 1 + src/cpp/multisolver_interface/CMakeLists.txt | 2 + .../multisolver_interface/SolverConfig.cpp | 23 +++++ .../multisolver_interface/SolverFactory.cpp | 98 +++++++++++-------- .../multisolver_interface/SolverConfig.h | 26 +++++ .../multisolver_interface/SolverFactory.h | 24 +++-- 11 files changed, 160 insertions(+), 75 deletions(-) create mode 100644 src/cpp/multisolver_interface/SolverConfig.cpp create mode 100644 src/cpp/multisolver_interface/include/antares-xpansion/multisolver_interface/SolverConfig.h diff --git a/src/cpp/lpnamer/main/ProblemGeneration.cpp b/src/cpp/lpnamer/main/ProblemGeneration.cpp index ee7024def..9b4694f4c 100644 --- a/src/cpp/lpnamer/main/ProblemGeneration.cpp +++ b/src/cpp/lpnamer/main/ProblemGeneration.cpp @@ -61,19 +61,18 @@ ProblemGeneration::ProblemGeneration(ProblemGenerationOptions& options) } } -static std::string lowerCase(std::string data) { - std::transform(data.begin(), data.end(), data.begin(), - [](unsigned char c) { return std::tolower(c); }); - return data; +namespace { + bool islower(std::string_view str) { + return std::ranges::all_of(str, [](char c) { return std::islower(c); }); + } } - -static std::string solverXpansionToSimulator(const std::string& in) { +static std::string solverXpansionToSimulator(const SolverConfig& in) { // in could be Cbc or CBC depending on whether it is defined or not in the // settings file // Use lowerCase in any case to be robust to these subtleties - std::string lower_case_in = lowerCase(in); - if (lower_case_in == "xpress") return "xpress"; - if (lower_case_in == "cbc" || lower_case_in == "coin") return "coin"; + assert(islower(in.name)); + if (in.name == "xpress") return "xpress"; + if (in.name == "cbc" || in.name == "coin") return "coin"; throw std::invalid_argument("Invalid solver"); } @@ -81,7 +80,7 @@ void ProblemGeneration::performAntaresSimulation( const std::filesystem::path& output) { Antares::Solver::Optimization::OptimizationOptions optOptions; - optOptions.ortoolsSolver = solverXpansionToSimulator(solver_name_); + optOptions.ortoolsSolver = solverXpansionToSimulator(solver_config_); auto results = Antares::API::PerformSimulation(options_.StudyPath(), output, optOptions); // Add parallel @@ -249,7 +248,7 @@ void validateMasterFormulation( * @return */ std::vector> ProblemGeneration::getXpansionProblems( - SolverLogManager& solver_log_manager, const std::string& solver_name, + SolverLogManager& solver_log_manager, SolverConfig solver_name, const std::vector& mpsList, std::filesystem::path& lpDir_, std::shared_ptr reader, const Antares::Solver::LpsFromAntares& lps = {}) { @@ -260,16 +259,16 @@ std::vector> ProblemGeneration::getXpansionProblems( switch (mode_.value()) { case SimulationInputMode::FILE: { FileProblemsProviderAdapter adapter(lpDir_, problem_names); - return adapter.provideProblems(solver_name, solver_log_manager); + return adapter.provideProblems(solver_config_.name, solver_log_manager); } case SimulationInputMode::ARCHIVE: { ZipProblemsProviderAdapter adapter(lpDir_, std::move(reader), problem_names); - return adapter.provideProblems(solver_name, solver_log_manager); + return adapter.provideProblems(solver_config_.name, solver_log_manager); } case SimulationInputMode::ANTARES_API: { XpansionProblemsFromAntaresProvider adapter(lps); - return adapter.provideProblems(solver_name, solver_log_manager); + return adapter.provideProblems(solver_config_.name, solver_log_manager); } default: throw LogUtils::XpansionError( @@ -319,14 +318,14 @@ void ProblemGeneration::RunProblemGeneration( auto solver_log_manager = SolverLogManager(log_file_path); Couplings couplings; LinkProblemsGenerator linkProblemsGenerator( - lpDir_, links, solver_name_, logger, solver_log_manager, rename_problems); + lpDir_, links, solver_config_, logger, solver_log_manager, rename_problems); std::shared_ptr reader = antares_archive_path.empty() ? std::make_shared() : InstantiateZipReader(antares_archive_path); /* Main stuff */ std::vector> xpansion_problems = getXpansionProblems( - solver_log_manager, solver_name_, mpsList, lpDir_, reader, lps_); + solver_log_manager, solver_config_, mpsList, lpDir_, reader, lps_); std::vector, ProblemData>> problems_and_data; @@ -384,7 +383,7 @@ void ProblemGeneration::RunProblemGeneration( } MasterGeneration master_generation( xpansion_output_dir, links, additionalConstraints, couplings, - master_formulation, solver_name_, logger, solver_log_manager); + master_formulation, solver_config_.name, logger, solver_log_manager); (*logger)(LogUtils::LOGLEVEL::INFO) << "Problem Generation ran in: " << format_time_str(problem_generation_timer.elapsed()) << std::endl; @@ -394,7 +393,7 @@ void ProblemGeneration::set_solver( ProblemGenerationLog::ProblemGenerationLogger* logger) { SettingsReader settingsReader( study_dir / "user" / "expansion" / "settings.ini", logger); - solver_name_ = settingsReader.Solver(); + solver_config_ = settingsReader.Solver(); } std::shared_ptr InstantiateZipReader( diff --git a/src/cpp/lpnamer/main/include/antares-xpansion/lpnamer/main/ProblemGeneration.h b/src/cpp/lpnamer/main/include/antares-xpansion/lpnamer/main/ProblemGeneration.h index 6a7275edc..98ec4146c 100644 --- a/src/cpp/lpnamer/main/include/antares-xpansion/lpnamer/main/ProblemGeneration.h +++ b/src/cpp/lpnamer/main/include/antares-xpansion/lpnamer/main/ProblemGeneration.h @@ -19,6 +19,7 @@ #include "antares-xpansion/lpnamer/helper/ProblemGenerationLogger.h" #include "ProblemGenerationOptions.h" #include "antares-xpansion/multisolver_interface/SolverAbstract.h" +#include "antares-xpansion/multisolver_interface/SolverConfig.h" // clang-format on class ProblemGeneration { @@ -47,7 +48,7 @@ class ProblemGeneration { const std::filesystem::path& xpansion_output_dir, ProblemGenerationLog::ProblemGenerationLoggerSharedPointer logger); std::vector> getXpansionProblems( - SolverLogManager& solver_log_manager, const std::string& solver_name, + SolverLogManager& solver_log_manager, SolverConfig solver_name, const std::vector& mpsList, std::filesystem::path& lpDir_, std::shared_ptr reader, const Antares::Solver::LpsFromAntares& lps); @@ -59,5 +60,5 @@ class ProblemGeneration { std::optional mode_; virtual void performAntaresSimulation(const std::filesystem::path& output); std::filesystem::path simulation_dir_; - std::string solver_name_; + SolverConfig solver_config_{"Coin"}; }; diff --git a/src/cpp/lpnamer/problem_modifier/LinkProblemsGenerator.cpp b/src/cpp/lpnamer/problem_modifier/LinkProblemsGenerator.cpp index a32e3ca24..b06dc74f0 100644 --- a/src/cpp/lpnamer/problem_modifier/LinkProblemsGenerator.cpp +++ b/src/cpp/lpnamer/problem_modifier/LinkProblemsGenerator.cpp @@ -33,7 +33,7 @@ void LinkProblemsGenerator::treat( IProblemProviderPort *problem_provider, IProblemVariablesProviderPort *variable_provider, IProblemWriter *writer) { auto in_prblm = - problem_provider->provide_problem(_solver_name, solver_log_manager_); + problem_provider->provide_problem(solver_config_.name, solver_log_manager_); treat(problem_name, couplings, in_prblm.get(), variable_provider, writer); } @@ -76,7 +76,7 @@ void LinkProblemsGenerator::treatloop(const std::filesystem::path &root, auto adapter = std::make_unique( root, mps._problem_mps); auto problem = - adapter->provide_problem(_solver_name, solver_log_manager_); + adapter->provide_problem(solver_config_.name, solver_log_manager_); std::unique_ptr variables_provider; if (rename_problems_) { variables_provider = std::make_unique( diff --git a/src/cpp/lpnamer/problem_modifier/MPSFileProblemProviderAdapter.cpp b/src/cpp/lpnamer/problem_modifier/MPSFileProblemProviderAdapter.cpp index 78776ce83..97e7028cc 100644 --- a/src/cpp/lpnamer/problem_modifier/MPSFileProblemProviderAdapter.cpp +++ b/src/cpp/lpnamer/problem_modifier/MPSFileProblemProviderAdapter.cpp @@ -6,6 +6,7 @@ #include +#include "antares-xpansion/multisolver_interface/SolverConfig.h" #include "antares-xpansion/multisolver_interface/SolverFactory.h" std::shared_ptr MPSFileProblemProviderAdapter::provide_problem( const std::string& solver_name, diff --git a/src/cpp/lpnamer/problem_modifier/include/antares-xpansion/lpnamer/problem_modifier/LinkProblemsGenerator.h b/src/cpp/lpnamer/problem_modifier/include/antares-xpansion/lpnamer/problem_modifier/LinkProblemsGenerator.h index dcacc8866..e037d3dc5 100644 --- a/src/cpp/lpnamer/problem_modifier/include/antares-xpansion/lpnamer/problem_modifier/LinkProblemsGenerator.h +++ b/src/cpp/lpnamer/problem_modifier/include/antares-xpansion/lpnamer/problem_modifier/LinkProblemsGenerator.h @@ -1,7 +1,5 @@ #pragma once -#include "antares-xpansion/multisolver_interface/SolverAbstract.h" - #include #include #include @@ -10,14 +8,16 @@ #include "antares-xpansion/helpers/ArchiveReader.h" #include "antares-xpansion/helpers/ArchiveWriter.h" #include "antares-xpansion/helpers/FileInBuffer.h" +#include "antares-xpansion/lpnamer/helper/ProblemGenerationLogger.h" +#include "antares-xpansion/lpnamer/input_reader/MpsTxtWriter.h" +#include "antares-xpansion/lpnamer/input_reader/VariableFileReader.h" #include "antares-xpansion/lpnamer/problem_modifier/IProblemProviderPort.h" #include "antares-xpansion/lpnamer/problem_modifier/IProblemVariablesProviderPort.h" #include "antares-xpansion/lpnamer/problem_modifier/IProblemWriter.h" -#include "antares-xpansion/lpnamer/input_reader/MpsTxtWriter.h" -#include "antares-xpansion/lpnamer/helper/ProblemGenerationLogger.h" #include "antares-xpansion/lpnamer/problem_modifier/ProblemModifier.h" +#include "antares-xpansion/multisolver_interface/SolverAbstract.h" +#include "antares-xpansion/multisolver_interface/SolverConfig.h" #include "antares-xpansion/xpansion_interfaces/StringManip.h" -#include "antares-xpansion/lpnamer/input_reader/VariableFileReader.h" const std::string CANDIDATES_INI{"candidates.ini"}; const std::string STRUCTURE_FILE{"structure.txt"}; @@ -30,11 +30,11 @@ class LinkProblemsGenerator { public: LinkProblemsGenerator( std::filesystem::path& lpDir, const std::vector& links, - std::string solver_name, + SolverConfig solver_config, ProblemGenerationLog::ProblemGenerationLoggerSharedPointer logger, SolverLogManager& solver_log_manager, bool rename_problems) : _links(links), - _solver_name(std::move(solver_name)), + solver_config_(std::move(solver_config)), lpDir_(lpDir), logger_(std::move(logger)), rename_problems_(rename_problems), @@ -53,7 +53,7 @@ class LinkProblemsGenerator { private: const std::vector& _links; - std::string _solver_name; + SolverConfig solver_config_; std::filesystem::path lpDir_ = ""; ProblemGenerationLog::ProblemGenerationLoggerSharedPointer logger_; mutable std::mutex coupling_mutex_; diff --git a/src/cpp/lpnamer/problem_modifier/include/antares-xpansion/lpnamer/problem_modifier/MPSFileProblemProviderAdapter.h b/src/cpp/lpnamer/problem_modifier/include/antares-xpansion/lpnamer/problem_modifier/MPSFileProblemProviderAdapter.h index 069c2f62a..694a88ec7 100644 --- a/src/cpp/lpnamer/problem_modifier/include/antares-xpansion/lpnamer/problem_modifier/MPSFileProblemProviderAdapter.h +++ b/src/cpp/lpnamer/problem_modifier/include/antares-xpansion/lpnamer/problem_modifier/MPSFileProblemProviderAdapter.h @@ -5,6 +5,7 @@ #pragma once #include "antares-xpansion/lpnamer/problem_modifier/IProblemProviderPort.h" +#include "antares-xpansion/multisolver_interface/SolverConfig.h" class MPSFileProblemProviderAdapter : public IProblemProviderPort { public: MPSFileProblemProviderAdapter(std::filesystem::path root, diff --git a/src/cpp/multisolver_interface/CMakeLists.txt b/src/cpp/multisolver_interface/CMakeLists.txt index 4107dcc70..7f0bde982 100644 --- a/src/cpp/multisolver_interface/CMakeLists.txt +++ b/src/cpp/multisolver_interface/CMakeLists.txt @@ -15,8 +15,10 @@ # --------------------------------------------------------------------------- list(APPEND Solver_sources ${CMAKE_CURRENT_LIST_DIR}/SolverFactory.cpp + ${CMAKE_CURRENT_LIST_DIR}/SolverConfig.cpp ${CMAKE_CURRENT_SOURCE_DIR}/include/antares-xpansion/multisolver_interface/Solver.h ${CMAKE_CURRENT_SOURCE_DIR}/include/antares-xpansion/multisolver_interface/SolverAbstract.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/antares-xpansion/multisolver_interface/SolverConfig.h ${CMAKE_CURRENT_SOURCE_DIR}/include/antares-xpansion/multisolver_interface/SolverFactory.h ${CMAKE_CURRENT_SOURCE_DIR}/include/antares-xpansion/multisolver_interface/dynamic_library.h ${CMAKE_CURRENT_SOURCE_DIR}/include/antares-xpansion/multisolver_interface/environment.h diff --git a/src/cpp/multisolver_interface/SolverConfig.cpp b/src/cpp/multisolver_interface/SolverConfig.cpp new file mode 100644 index 000000000..f1b2f2f41 --- /dev/null +++ b/src/cpp/multisolver_interface/SolverConfig.cpp @@ -0,0 +1,23 @@ + +#include "antares-xpansion/multisolver_interface/SolverConfig.h" + +#include +#include + +const std::map SolverConfig::save_restore_support = { + {"clp", false}, {"cbc", false}, {"coin", false}, {"xpress", true}}; +SolverConfig::SolverConfig(std::string solver_name) { + init(std::move(solver_name)); +} +bool SolverConfig::operator==(const std::string& rhs) const { + return std::ranges::equal( + name, rhs, [](char a, char b) { return ::tolower(a) == ::tolower(b); }); +} +SolverConfig& SolverConfig::operator=(const std::string& rhs) { + init(rhs); + return *this; +} +void SolverConfig::init(std::string solver_name) { + std::ranges::transform(solver_name, std::back_inserter(name), ::tolower); + save_restore_supported = save_restore_support.at(name); +} diff --git a/src/cpp/multisolver_interface/SolverFactory.cpp b/src/cpp/multisolver_interface/SolverFactory.cpp index 950ac9d45..480f5bdc1 100644 --- a/src/cpp/multisolver_interface/SolverFactory.cpp +++ b/src/cpp/multisolver_interface/SolverFactory.cpp @@ -6,8 +6,9 @@ #include "SolverCbc.h" #include "SolverClp.h" #endif -#include "antares-xpansion/xpansion_interfaces/LogUtils.h" +#include "antares-xpansion/multisolver_interface/SolverConfig.h" #include "antares-xpansion/multisolver_interface/SolverFactory.h" +#include "antares-xpansion/xpansion_interfaces/LogUtils.h" std::vector available_solvers; std::vector SolverLoader::GetAvailableSolvers( @@ -35,91 +36,110 @@ SolverFactory::SolverFactory(std::shared_ptr logger) SolverAbstract::Ptr SolverFactory::create_solver( const std::string &solver_name, const SOLVER_TYPE solver_type) const { + return create_solver(SolverConfig(solver_name), solver_type); +} + +SolverAbstract::Ptr SolverFactory::create_solver( + const std::string &solver_name, const SOLVER_TYPE solver_type, + SolverLogManager &log_manager) const { + return create_solver(SolverConfig(solver_name), solver_type, log_manager); +} + +SolverAbstract::Ptr SolverFactory::create_solver( + std::string solver_name) const { + return create_solver(SolverConfig(std::move(solver_name))); +} + +SolverAbstract::Ptr SolverFactory::create_solver( + std::string solver_name, SolverLogManager &log_manager) const { + return create_solver(SolverConfig(std::move(solver_name)), log_manager); +} + +SolverAbstract::Ptr SolverFactory::create_solver( + const SolverConfig &solver_config) const { SolverAbstract::Ptr ret; - if (solver_name.empty()) { - throw InvalidSolverNameException(solver_name, LOGLOCATION); - } - else if (isXpress_available_ && solver_name == XPRESS_STR) { + if (solver_config.name.empty()) { + throw InvalidSolverNameException(solver_config.name, LOGLOCATION); + } else if (isXpress_available_ && solver_config == XPRESS_STR) { ret = std::make_shared(); } #ifdef COIN_OR - if (solver_name == COIN_STR && solver_type == SOLVER_TYPE::CONTINUOUS) { + else if (solver_config == CLP_STR) { ret = std::make_shared(); - } else if (solver_name == COIN_STR && solver_type == SOLVER_TYPE::INTEGER) { + } else if (solver_config == CBC_STR) { ret = std::make_shared(); } #endif else { - throw InvalidSolverNameException(solver_name, LOGLOCATION); + throw InvalidSolverNameException(solver_config.name, LOGLOCATION); } ret->init(); return ret; } SolverAbstract::Ptr SolverFactory::create_solver( - const std::string &solver_name, const SOLVER_TYPE solver_type, - SolverLogManager &log_manager) const { -#ifdef COIN_OR - if (solver_name == COIN_STR && solver_type == SOLVER_TYPE::CONTINUOUS) { - return std::make_shared(log_manager); - } else if (solver_name == COIN_STR && solver_type == SOLVER_TYPE::INTEGER) { - return std::make_shared(log_manager); - } -#endif - return create_solver(solver_name, log_manager); -} - -SolverAbstract::Ptr SolverFactory::create_solver( - std::string solver_name) const { + const SolverConfig &solver_config, const SOLVER_TYPE solver_type) const { SolverAbstract::Ptr ret; - std::transform(solver_name.begin(), solver_name.end(), solver_name.begin(), ::toupper); - if (solver_name.empty()) { - throw InvalidSolverNameException(solver_name, LOGLOCATION); - } else if (isXpress_available_ && solver_name == XPRESS_STR) { + if (solver_config.name.empty()) { + throw InvalidSolverNameException(solver_config.name, LOGLOCATION); + } else if (isXpress_available_ && solver_config == XPRESS_STR) { ret = std::make_shared(); } #ifdef COIN_OR - else if (solver_name == CLP_STR) { + if (solver_config == COIN_STR && solver_type == SOLVER_TYPE::CONTINUOUS) { ret = std::make_shared(); - } else if (solver_name == CBC_STR) { + } else if (solver_config == COIN_STR && solver_type == SOLVER_TYPE::INTEGER) { ret = std::make_shared(); } #endif else { - throw InvalidSolverNameException(solver_name, LOGLOCATION); + throw InvalidSolverNameException(solver_config.name, LOGLOCATION); } ret->init(); return ret; } SolverAbstract::Ptr SolverFactory::create_solver( - std::string solver_name, SolverLogManager &log_manager) const { - if (solver_name.empty()) { - throw InvalidSolverNameException(solver_name, LOGLOCATION); + const SolverConfig &solver_config, SolverLogManager &log_manager) const { + if (solver_config.name.empty()) { + throw InvalidSolverNameException(solver_config.name, LOGLOCATION); } - std::transform(solver_name.begin(), solver_name.end(), solver_name.begin(), ::toupper); SolverAbstract::Ptr ret; - if (isXpress_available_ && solver_name == XPRESS_STR) { + if (isXpress_available_ && solver_config == XPRESS_STR) { ret = std::make_shared(log_manager); } #ifdef COIN_OR - else if (solver_name == CLP_STR) { + else if (solver_config == CLP_STR) { ret = std::make_shared(log_manager); - } else if (solver_name == CBC_STR) { + } else if (solver_config == CBC_STR) { ret = std::make_shared(log_manager); } #endif else { - throw InvalidSolverNameException(solver_name, LOGLOCATION); + throw InvalidSolverNameException(solver_config.name, LOGLOCATION); } ret->init(); return ret; } +SolverAbstract::Ptr SolverFactory::create_solver( + const SolverConfig& solver_config, const SOLVER_TYPE solver_type, + SolverLogManager &log_manager) const { +#ifdef COIN_OR + if (solver_config == COIN_STR && solver_type == SOLVER_TYPE::CONTINUOUS) { + return std::make_shared(log_manager); + } else if (solver_config == COIN_STR && solver_type == SOLVER_TYPE::INTEGER) { + return std::make_shared(log_manager); + } +#endif + return create_solver(solver_config, log_manager); +} + SolverAbstract::Ptr SolverFactory::copy_solver( const std::shared_ptr &to_copy) const { std::string solver_name = to_copy->get_solver_name(); - std::transform(solver_name.begin(), solver_name.end(), solver_name.begin(), ::toupper); + std::transform(solver_name.begin(), solver_name.end(), solver_name.begin(), + ::toupper); if (solver_name.empty()) { throw InvalidSolverNameException(solver_name, LOGLOCATION); } @@ -138,7 +158,7 @@ SolverAbstract::Ptr SolverFactory::copy_solver( } } -SolverAbstract::Ptr SolverFactory::copy_solver(SolverAbstract::Ptr to_copy) { +SolverAbstract::Ptr SolverFactory::copy_solver(SolverAbstract::Ptr to_copy) const { return copy_solver( static_cast>(to_copy)); } diff --git a/src/cpp/multisolver_interface/include/antares-xpansion/multisolver_interface/SolverConfig.h b/src/cpp/multisolver_interface/include/antares-xpansion/multisolver_interface/SolverConfig.h new file mode 100644 index 000000000..95f3712a8 --- /dev/null +++ b/src/cpp/multisolver_interface/include/antares-xpansion/multisolver_interface/SolverConfig.h @@ -0,0 +1,26 @@ +#pragma once + +#include +#include + +/** + * @brief Class to store the configuration of a solver + * Invariant: name is lowercase + */ +class SolverConfig { + static const std::map save_restore_support; + void init(std::string solver_name); + + public: + explicit SolverConfig(std::string name); + SolverConfig(SolverConfig&&) = default; + SolverConfig(const SolverConfig&) = default; + SolverConfig& operator=(const SolverConfig&) = default; + SolverConfig& operator=(SolverConfig&&) = default; + ~SolverConfig() = default; + + std::string name; + bool save_restore_supported{false}; + bool operator==(const std::string& rhs) const; + SolverConfig& operator=(const std::string& rhs); +}; diff --git a/src/cpp/multisolver_interface/include/antares-xpansion/multisolver_interface/SolverFactory.h b/src/cpp/multisolver_interface/include/antares-xpansion/multisolver_interface/SolverFactory.h index 229f78e26..30a2db52e 100644 --- a/src/cpp/multisolver_interface/include/antares-xpansion/multisolver_interface/SolverFactory.h +++ b/src/cpp/multisolver_interface/include/antares-xpansion/multisolver_interface/SolverFactory.h @@ -2,8 +2,9 @@ #include -#include "antares-xpansion/xpansion_interfaces/ILogger.h" +#include "SolverConfig.h" #include "antares-xpansion/multisolver_interface/SolverAbstract.h" +#include "antares-xpansion/xpansion_interfaces/ILogger.h" /** * \enum mapper::SOLVER_TYPE @@ -45,21 +46,32 @@ class SolverFactory { * implementation * * @param solver_name : Name of the solver to use + * @param solver_type : Type of the solver {INTEGER, CONTINUOUS} + * @param log_manager : A logger */ SolverAbstract::Ptr create_solver(std::string solver_name) const; SolverAbstract::Ptr create_solver(std::string solver_name, SolverLogManager &log_manager) const; + SolverAbstract::Ptr create_solver(const std::string &solver_name, + const SOLVER_TYPE solver_type) const; + SolverAbstract::Ptr create_solver(const std::string &solver_name, + const SOLVER_TYPE solver_type, + SolverLogManager &log_manager) const; /** * @brief Creates and returns to an object solver from the wanted * implementation * - * @param solver_name : Name of the solver to use - * @param solver_type : Name of the solver to use + * @param solver_config : A solver configuration + * @param solver_type : Type of the solver {INTEGER, CONTINUOUS} + * @param log_manager : A logger */ - SolverAbstract::Ptr create_solver(const std::string &solver_name, + SolverAbstract::Ptr create_solver(const SolverConfig& solver_config) const; + SolverAbstract::Ptr create_solver(const SolverConfig& solver_config, const SOLVER_TYPE solver_type) const; - SolverAbstract::Ptr create_solver(const std::string &solver_name, + SolverAbstract::Ptr create_solver(const SolverConfig& solver_config, + SolverLogManager &log_manager) const; + SolverAbstract::Ptr create_solver(const SolverConfig& solver_config, const SOLVER_TYPE solver_type, SolverLogManager &log_manager) const; @@ -69,7 +81,7 @@ class SolverFactory { * * @param to_copy : solver to copy */ - SolverAbstract::Ptr copy_solver(SolverAbstract::Ptr to_copy); + SolverAbstract::Ptr copy_solver(SolverAbstract::Ptr to_copy) const; SolverAbstract::Ptr copy_solver( const std::shared_ptr &to_copy) const;