From b007d45543d4e52e1920a3f63b96089e61975725 Mon Sep 17 00:00:00 2001 From: sjunges Date: Wed, 2 Sep 2015 12:43:43 +0200 Subject: [PATCH] Extended lp solver factory interface Former-commit-id: 437e62619dcd9fa7af5cff06ebe5bd6271fd8962 --- src/utility/solver.cpp | 25 +++++++++++++++++-------- src/utility/solver.h | 3 ++- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/utility/solver.cpp b/src/utility/solver.cpp index c5c3ecaa0..6c63004bd 100644 --- a/src/utility/solver.cpp +++ b/src/utility/solver.cpp @@ -133,28 +133,37 @@ namespace storm { } - std::unique_ptr LpSolverFactory::create(std::string const& name) const { - storm::solver::LpSolverType lpSolver = storm::settings::generalSettings().getLpSolver(); - switch (lpSolver) { + std::unique_ptr LpSolverFactory::create(std::string const& name, storm::solver::LpSolverTypeSelection solvT) const { + storm::solver::LpSolverType t; + if(solvT == storm::solver::LpSolverTypeSelection::FROMSETTINGS) { + t = storm::settings::generalSettings().getLpSolver(); + } else { + t = convert(solvT); + } + switch (t) { case storm::solver::LpSolverType::Gurobi: return std::unique_ptr(new storm::solver::GurobiLpSolver(name)); case storm::solver::LpSolverType::Glpk: return std::unique_ptr(new storm::solver::GlpkLpSolver(name)); - default: return std::unique_ptr(new storm::solver::GurobiLpSolver(name)); } } + std::unique_ptr LpSolverFactory::create(std::string const& name) const { + return LpSolverFactory::create(name, storm::solver::LpSolverTypeSelection::FROMSETTINGS); + } + std::unique_ptr GlpkLpSolverFactory::create(std::string const& name) const { - return std::unique_ptr(new storm::solver::GlpkLpSolver(name)); + return LpSolverFactory::create(name, storm::solver::LpSolverTypeSelection::Glpk); } std::unique_ptr GurobiLpSolverFactory::create(std::string const& name) const { - return std::unique_ptr(new storm::solver::GurobiLpSolver(name)); + return LpSolverFactory::create(name, storm::solver::LpSolverTypeSelection::Gurobi); } - std::unique_ptr getLpSolver(std::string const& name) { + std::unique_ptr getLpSolver(std::string const& name, storm::solver::LpSolverTypeSelection solvType) { std::unique_ptr factory(new LpSolverFactory()); - return factory->create(name); + return factory->create(name, solvType); } + template class SymbolicLinearEquationSolverFactory; template class SymbolicMinMaxLinearEquationSolverFactory; template class SymbolicGameSolverFactory; diff --git a/src/utility/solver.h b/src/utility/solver.h index e18f435d6..ff5abb3e2 100644 --- a/src/utility/solver.h +++ b/src/utility/solver.h @@ -112,6 +112,7 @@ namespace storm { * @return A pointer to the newly created solver. */ virtual std::unique_ptr create(std::string const& name) const; + virtual std::unique_ptr create(std::string const& name, storm::solver::LpSolverTypeSelection solvType) const; }; class GlpkLpSolverFactory : public LpSolverFactory { @@ -124,7 +125,7 @@ namespace storm { virtual std::unique_ptr create(std::string const& name) const override; }; - std::unique_ptr getLpSolver(std::string const& name); + std::unique_ptr getLpSolver(std::string const& name, storm::solver::LpSolverTypeSelection solvType = storm::solver::LpSolverTypeSelection::FROMSETTINGS) ; } } }