diff --git a/src/storm/solver/IterativeMinMaxLinearEquationSolver.cpp b/src/storm/solver/IterativeMinMaxLinearEquationSolver.cpp index 4815fc8a4..de02a1c79 100644 --- a/src/storm/solver/IterativeMinMaxLinearEquationSolver.cpp +++ b/src/storm/solver/IterativeMinMaxLinearEquationSolver.cpp @@ -91,7 +91,7 @@ namespace storm { } template - bool IterativeMinMaxLinearEquationSolver::solveEquations(OptimizationDirection dir, std::vector& x, std::vector const& b) const { + bool IterativeMinMaxLinearEquationSolver::internalSolveEquations(OptimizationDirection dir, std::vector& x, std::vector const& b) const { switch (this->getSettings().getSolutionMethod()) { case IterativeMinMaxLinearEquationSolverSettings::SolutionMethod::ValueIteration: return solveEquationsValueIteration(dir, x, b); @@ -464,7 +464,7 @@ namespace storm { } template - std::unique_ptr> IterativeMinMaxLinearEquationSolverFactory::internalCreate() const { + std::unique_ptr> IterativeMinMaxLinearEquationSolverFactory::create() const { STORM_LOG_ASSERT(this->linearEquationSolverFactory, "Linear equation solver factory not initialized."); std::unique_ptr> result = std::make_unique>(this->linearEquationSolverFactory->clone(), settings); diff --git a/src/storm/solver/IterativeMinMaxLinearEquationSolver.h b/src/storm/solver/IterativeMinMaxLinearEquationSolver.h index dc5cc656a..bd3ad9c0e 100644 --- a/src/storm/solver/IterativeMinMaxLinearEquationSolver.h +++ b/src/storm/solver/IterativeMinMaxLinearEquationSolver.h @@ -40,7 +40,7 @@ namespace storm { IterativeMinMaxLinearEquationSolver(storm::storage::SparseMatrix const& A, std::unique_ptr>&& linearEquationSolverFactory, IterativeMinMaxLinearEquationSolverSettings const& settings = IterativeMinMaxLinearEquationSolverSettings()); IterativeMinMaxLinearEquationSolver(storm::storage::SparseMatrix&& A, std::unique_ptr>&& linearEquationSolverFactory, IterativeMinMaxLinearEquationSolverSettings const& settings = IterativeMinMaxLinearEquationSolverSettings()); - virtual bool solveEquations(OptimizationDirection dir, std::vector& x, std::vector const& b) const override; + virtual bool internalSolveEquations(OptimizationDirection dir, std::vector& x, std::vector const& b) const override; IterativeMinMaxLinearEquationSolverSettings const& getSettings() const; void setSettings(IterativeMinMaxLinearEquationSolverSettings const& newSettings); @@ -87,8 +87,10 @@ namespace storm { virtual void setMinMaxMethod(MinMaxMethodSelection const& newMethod) override; virtual void setMinMaxMethod(MinMaxMethod const& newMethod) override; - protected: - virtual std::unique_ptr> internalCreate() const override; + // Make the other create methods visible. + using MinMaxLinearEquationSolverFactory::create; + + virtual std::unique_ptr> create() const override; private: IterativeMinMaxLinearEquationSolverSettings settings; diff --git a/src/storm/solver/LpMinMaxLinearEquationSolver.cpp b/src/storm/solver/LpMinMaxLinearEquationSolver.cpp index 45c76e029..5df72fe28 100644 --- a/src/storm/solver/LpMinMaxLinearEquationSolver.cpp +++ b/src/storm/solver/LpMinMaxLinearEquationSolver.cpp @@ -25,7 +25,7 @@ namespace storm { } template - bool LpMinMaxLinearEquationSolver::solveEquations(OptimizationDirection dir, std::vector& x, std::vector const& b) const { + bool LpMinMaxLinearEquationSolver::internalSolveEquations(OptimizationDirection dir, std::vector& x, std::vector const& b) const { // Set up the LP solver std::unique_ptr> solver = lpSolverFactory->create(""); @@ -124,7 +124,7 @@ namespace storm { } template - std::unique_ptr> LpMinMaxLinearEquationSolverFactory::internalCreate() const { + std::unique_ptr> LpMinMaxLinearEquationSolverFactory::create() const { STORM_LOG_ASSERT(this->lpSolverFactory, "Lp solver factory not initialized."); STORM_LOG_ASSERT(this->linearEquationSolverFactory, "Linear equation solver factory not initialized."); diff --git a/src/storm/solver/LpMinMaxLinearEquationSolver.h b/src/storm/solver/LpMinMaxLinearEquationSolver.h index 5491e7ca2..a31ac710b 100644 --- a/src/storm/solver/LpMinMaxLinearEquationSolver.h +++ b/src/storm/solver/LpMinMaxLinearEquationSolver.h @@ -14,7 +14,7 @@ namespace storm { LpMinMaxLinearEquationSolver(storm::storage::SparseMatrix const& A, std::unique_ptr>&& linearEquationSolverFactory, std::unique_ptr>&& lpSolverFactory); LpMinMaxLinearEquationSolver(storm::storage::SparseMatrix&& A, std::unique_ptr>&& linearEquationSolverFactory, std::unique_ptr>&& lpSolverFactory); - virtual bool solveEquations(OptimizationDirection dir, std::vector& x, std::vector const& b) const override; + virtual bool internalSolveEquations(OptimizationDirection dir, std::vector& x, std::vector const& b) const override; virtual void clearCache() const override; @@ -32,9 +32,10 @@ namespace storm { virtual void setMinMaxMethod(MinMaxMethodSelection const& newMethod) override; virtual void setMinMaxMethod(MinMaxMethod const& newMethod) override; - protected: - virtual std::unique_ptr> internalCreate() const override; - std::unique_ptr> createLpEquationSolverFactory() const; + // Make the other create methods visible. + using MinMaxLinearEquationSolverFactory::create; + + virtual std::unique_ptr> create() const override; private: std::unique_ptr> lpSolverFactory; diff --git a/src/storm/solver/MinMaxLinearEquationSolver.cpp b/src/storm/solver/MinMaxLinearEquationSolver.cpp index 872f7c03b..f1a7b1e3c 100644 --- a/src/storm/solver/MinMaxLinearEquationSolver.cpp +++ b/src/storm/solver/MinMaxLinearEquationSolver.cpp @@ -28,6 +28,11 @@ namespace storm { // Intentionally left empty. } + template + bool MinMaxLinearEquationSolver::solveEquations(OptimizationDirection d, std::vector& x, std::vector const& b) const { + return internalSolveEquations(d, x, b); + } + template void MinMaxLinearEquationSolver::solveEquations(std::vector& x, std::vector const& b) const { STORM_LOG_THROW(isSet(this->direction), storm::exceptions::IllegalFunctionCallException, "Optimization direction not set."); @@ -196,20 +201,20 @@ namespace storm { template std::vector MinMaxLinearEquationSolverFactory::getRequirements() const { // Create dummy solver and ask it for requirements. - std::unique_ptr> solver = this->internalCreate(); + std::unique_ptr> solver = this->create(); return solver->getRequirements(); } template std::unique_ptr> MinMaxLinearEquationSolverFactory::create(storm::storage::SparseMatrix const& matrix) const { - std::unique_ptr> solver = this->internalCreate(); + std::unique_ptr> solver = this->create(); solver->setMatrix(matrix); return solver; } template std::unique_ptr> MinMaxLinearEquationSolverFactory::create(storm::storage::SparseMatrix&& matrix) const { - std::unique_ptr> solver = this->internalCreate(); + std::unique_ptr> solver = this->create(); solver->setMatrix(std::move(matrix)); return solver; } @@ -220,7 +225,7 @@ namespace storm { } template - std::unique_ptr> GeneralMinMaxLinearEquationSolverFactory::internalCreate() const { + std::unique_ptr> GeneralMinMaxLinearEquationSolverFactory::create() const { std::unique_ptr> result; auto method = this->getMinMaxMethod(); if (method == MinMaxMethod::ValueIteration || method == MinMaxMethod::PolicyIteration || method == MinMaxMethod::Acyclic) { @@ -239,7 +244,7 @@ namespace storm { } template<> - std::unique_ptr> GeneralMinMaxLinearEquationSolverFactory::internalCreate() const { + std::unique_ptr> GeneralMinMaxLinearEquationSolverFactory::create() const { std::unique_ptr> result; auto method = this->getMinMaxMethod(); if (method == MinMaxMethod::ValueIteration || method == MinMaxMethod::PolicyIteration || method == MinMaxMethod::Acyclic) { diff --git a/src/storm/solver/MinMaxLinearEquationSolver.h b/src/storm/solver/MinMaxLinearEquationSolver.h index b00c7f155..0fe7d8fbe 100644 --- a/src/storm/solver/MinMaxLinearEquationSolver.h +++ b/src/storm/solver/MinMaxLinearEquationSolver.h @@ -55,7 +55,7 @@ namespace storm { * solver, but may be ignored. * @param b The vector to add after matrix-vector multiplication. */ - virtual bool solveEquations(OptimizationDirection d, std::vector& x, std::vector const& b) const = 0; + bool solveEquations(OptimizationDirection d, std::vector& x, std::vector const& b) const; /*! * Behaves the same as the other variant of solveEquations, with the distinction that @@ -184,6 +184,8 @@ namespace storm { bool getRequirementsChecked() const; protected: + virtual bool internalSolveEquations(OptimizationDirection d, std::vector& x, std::vector const& b) const = 0; + /// The optimization direction to use for calls to functions that do not provide it explicitly. Can also be unset. OptimizationDirectionSetting direction; @@ -217,7 +219,8 @@ namespace storm { virtual std::unique_ptr> create(storm::storage::SparseMatrix const& matrix) const; virtual std::unique_ptr> create(storm::storage::SparseMatrix&& matrix) const; - + virtual std::unique_ptr> create() const = 0; + void setTrackScheduler(bool value); bool isTrackSchedulerSet() const; @@ -228,9 +231,6 @@ namespace storm { std::vector getRequirements() const; - protected: - virtual std::unique_ptr> internalCreate() const = 0; - private: bool trackScheduler; MinMaxMethod method; @@ -241,8 +241,10 @@ namespace storm { public: GeneralMinMaxLinearEquationSolverFactory(MinMaxMethodSelection const& method = MinMaxMethodSelection::FROMSETTINGS, bool trackScheduler = false); - protected: - virtual std::unique_ptr> internalCreate() const override; + // Make the other create methods visible. + using MinMaxLinearEquationSolverFactory::create; + + virtual std::unique_ptr> create() const override; }; } // namespace solver diff --git a/src/storm/solver/StandardMinMaxLinearEquationSolver.cpp b/src/storm/solver/StandardMinMaxLinearEquationSolver.cpp index ab879a175..0b3f41a03 100644 --- a/src/storm/solver/StandardMinMaxLinearEquationSolver.cpp +++ b/src/storm/solver/StandardMinMaxLinearEquationSolver.cpp @@ -104,7 +104,7 @@ namespace storm { } template - std::unique_ptr> StandardMinMaxLinearEquationSolverFactory::internalCreate() const { + std::unique_ptr> StandardMinMaxLinearEquationSolverFactory::create() const { std::unique_ptr> result; auto method = this->getMinMaxMethod(); if (method == MinMaxMethod::ValueIteration || method == MinMaxMethod::PolicyIteration || method == MinMaxMethod::Acyclic) { diff --git a/src/storm/solver/StandardMinMaxLinearEquationSolver.h b/src/storm/solver/StandardMinMaxLinearEquationSolver.h index 765e24888..4529b2dc1 100644 --- a/src/storm/solver/StandardMinMaxLinearEquationSolver.h +++ b/src/storm/solver/StandardMinMaxLinearEquationSolver.h @@ -48,9 +48,12 @@ namespace storm { StandardMinMaxLinearEquationSolverFactory(std::unique_ptr>&& linearEquationSolverFactory, MinMaxMethodSelection const& method = MinMaxMethodSelection::FROMSETTINGS, bool trackScheduler = false); StandardMinMaxLinearEquationSolverFactory(EquationSolverType const& solverType, MinMaxMethodSelection const& method = MinMaxMethodSelection::FROMSETTINGS, bool trackScheduler = false); - protected: - virtual std::unique_ptr> internalCreate() const override; + // Make the other create methods visible. + using MinMaxLinearEquationSolverFactory::create; + virtual std::unique_ptr> create() const override; + + protected: std::unique_ptr> linearEquationSolverFactory; private: diff --git a/src/storm/solver/TopologicalMinMaxLinearEquationSolver.cpp b/src/storm/solver/TopologicalMinMaxLinearEquationSolver.cpp index f60fce272..6d70c7ea9 100644 --- a/src/storm/solver/TopologicalMinMaxLinearEquationSolver.cpp +++ b/src/storm/solver/TopologicalMinMaxLinearEquationSolver.cpp @@ -49,7 +49,7 @@ namespace storm { } template - bool TopologicalMinMaxLinearEquationSolver::solveEquations(OptimizationDirection dir, std::vector& x, std::vector const& b) const { + bool TopologicalMinMaxLinearEquationSolver::internalSolveEquations(OptimizationDirection dir, std::vector& x, std::vector const& b) const { #ifdef GPU_USE_FLOAT #define __FORCE_FLOAT_CALCULATION true @@ -478,7 +478,7 @@ namespace storm { } template - std::unique_ptr> TopologicalMinMaxLinearEquationSolverFactory::internalCreate() const { + std::unique_ptr> TopologicalMinMaxLinearEquationSolverFactory::create() const { return std::make_unique>(); } diff --git a/src/storm/solver/TopologicalMinMaxLinearEquationSolver.h b/src/storm/solver/TopologicalMinMaxLinearEquationSolver.h index 2488ead3f..27e261961 100644 --- a/src/storm/solver/TopologicalMinMaxLinearEquationSolver.h +++ b/src/storm/solver/TopologicalMinMaxLinearEquationSolver.h @@ -37,7 +37,7 @@ namespace storm { virtual void setMatrix(storm::storage::SparseMatrix const& matrix) override; virtual void setMatrix(storm::storage::SparseMatrix&& matrix) override; - virtual bool solveEquations(OptimizationDirection dir, std::vector& x, std::vector const& b) const override; + virtual bool internalSolveEquations(OptimizationDirection dir, std::vector& x, std::vector const& b) const override; virtual void repeatedMultiply(OptimizationDirection dir, std::vector& x, std::vector const* b, uint_fast64_t n) const override; @@ -151,7 +151,7 @@ namespace storm { TopologicalMinMaxLinearEquationSolverFactory(bool trackScheduler = false); protected: - virtual std::unique_ptr> internalCreate() const override; + virtual std::unique_ptr> create() const override; }; } // namespace solver