From 83c4b1647c7a9918926a82440e2eda551484813b Mon Sep 17 00:00:00 2001 From: dehnert Date: Tue, 28 Jun 2016 18:48:14 +0200 Subject: [PATCH] solvers now can allocated auxiliary memory Former-commit-id: 76dc1a16798b92567a2ce6c4f9cae54ca9343677 --- .../csl/helper/SparseCtmcCslHelper.cpp | 2 +- .../helper/SparseMarkovAutomatonCslHelper.cpp | 2 +- .../prctl/helper/SparseMdpPrctlHelper.cpp | 2 +- src/solver/GmmxxLinearEquationSolver.cpp | 52 ++++++------ src/solver/GmmxxLinearEquationSolver.h | 10 +-- src/solver/LinearEquationSolver.cpp | 50 ++++++----- src/solver/LinearEquationSolver.h | 36 ++++---- src/solver/MinMaxLinearEquationSolver.cpp | 6 +- src/solver/MinMaxLinearEquationSolver.h | 6 +- src/solver/NativeLinearEquationSolver.cpp | 52 ++++++------ src/solver/NativeLinearEquationSolver.h | 12 +-- .../StandardMinMaxLinearEquationSolver.cpp | 82 +++++++++---------- .../StandardMinMaxLinearEquationSolver.h | 19 ++--- .../TopologicalMinMaxLinearEquationSolver.cpp | 18 +--- .../TopologicalMinMaxLinearEquationSolver.h | 4 +- .../GmmxxMinMaxLinearEquationSolverTest.cpp | 10 +-- .../NativeMinMaxLinearEquationSolverTest.cpp | 10 +-- 17 files changed, 178 insertions(+), 195 deletions(-) diff --git a/src/modelchecker/csl/helper/SparseCtmcCslHelper.cpp b/src/modelchecker/csl/helper/SparseCtmcCslHelper.cpp index 186762a3d..dab1449de 100644 --- a/src/modelchecker/csl/helper/SparseCtmcCslHelper.cpp +++ b/src/modelchecker/csl/helper/SparseCtmcCslHelper.cpp @@ -629,7 +629,7 @@ namespace storm { } std::unique_ptr> solver = linearEquationSolverFactory.create(std::move(uniformizedMatrix)); - solver->allocateAuxStorage(storm::solver::LinearEquationSolverOperation::MultiplyRepeatedly); + solver->allocateAuxMemory(storm::solver::LinearEquationSolverOperation::MultiplyRepeatedly); if (!useMixedPoissonProbabilities && std::get<0>(foxGlynnResult) > 1) { // Perform the matrix-vector multiplications (without adding). diff --git a/src/modelchecker/csl/helper/SparseMarkovAutomatonCslHelper.cpp b/src/modelchecker/csl/helper/SparseMarkovAutomatonCslHelper.cpp index b77a19825..7817dc644 100644 --- a/src/modelchecker/csl/helper/SparseMarkovAutomatonCslHelper.cpp +++ b/src/modelchecker/csl/helper/SparseMarkovAutomatonCslHelper.cpp @@ -86,7 +86,7 @@ namespace storm { } std::unique_ptr> solver = minMaxLinearEquationSolverFactory.create(aProbabilistic); - solver->allocateAuxStorage(storm::solver::MinMaxLinearEquationSolverOperation::SolveEquations); + solver->allocateAuxMemory(storm::solver::MinMaxLinearEquationSolverOperation::SolveEquations); // Perform the actual value iteration // * loop until the step bound has been reached diff --git a/src/modelchecker/prctl/helper/SparseMdpPrctlHelper.cpp b/src/modelchecker/prctl/helper/SparseMdpPrctlHelper.cpp index 483169789..75fbfdfea 100644 --- a/src/modelchecker/prctl/helper/SparseMdpPrctlHelper.cpp +++ b/src/modelchecker/prctl/helper/SparseMdpPrctlHelper.cpp @@ -67,7 +67,7 @@ namespace storm { storm::utility::vector::setVectorValues(result, nextStates, storm::utility::one()); std::unique_ptr> solver = minMaxLinearEquationSolverFactory.create(transitionMatrix); - solver->repeatedMultiply(dir, result); + solver->repeatedMultiply(dir, result, nullptr, 1); return result; } diff --git a/src/solver/GmmxxLinearEquationSolver.cpp b/src/solver/GmmxxLinearEquationSolver.cpp index 139a969dd..76d38f726 100644 --- a/src/solver/GmmxxLinearEquationSolver.cpp +++ b/src/solver/GmmxxLinearEquationSolver.cpp @@ -111,12 +111,12 @@ namespace storm { } template - GmmxxLinearEquationSolver::GmmxxLinearEquationSolver(storm::storage::SparseMatrix const& A, GmmxxLinearEquationSolverSettings const& settings) : localA(nullptr), A(nullptr), gmmxxMatrix(nullptr), settings(settings), auxiliaryJacobiStorage(nullptr) { + GmmxxLinearEquationSolver::GmmxxLinearEquationSolver(storm::storage::SparseMatrix const& A, GmmxxLinearEquationSolverSettings const& settings) : localA(nullptr), A(nullptr), gmmxxMatrix(nullptr), settings(settings), auxiliaryJacobiMemory(nullptr) { this->setMatrix(A); } template - GmmxxLinearEquationSolver::GmmxxLinearEquationSolver(storm::storage::SparseMatrix&& A, GmmxxLinearEquationSolverSettings const& settings) : localA(nullptr), A(nullptr), gmmxxMatrix(nullptr), settings(settings), auxiliaryJacobiStorage(nullptr) { + GmmxxLinearEquationSolver::GmmxxLinearEquationSolver(storm::storage::SparseMatrix&& A, GmmxxLinearEquationSolverSettings const& settings) : localA(nullptr), A(nullptr), gmmxxMatrix(nullptr), settings(settings), auxiliaryJacobiMemory(nullptr) { this->setMatrix(std::move(A)); } @@ -202,9 +202,9 @@ namespace storm { template uint_fast64_t GmmxxLinearEquationSolver::solveLinearEquationSystemWithJacobi(storm::storage::SparseMatrix const& A, std::vector& x, std::vector const& b) const { - bool allocatedAuxStorage = !this->hasAuxStorage(LinearEquationSolverOperation::SolveEquations); - if (allocatedAuxStorage) { - auxiliaryJacobiStorage = std::make_unique>(x.size()); + bool allocatedAuxMemory = !this->hasAuxMemory(LinearEquationSolverOperation::SolveEquations); + if (allocatedAuxMemory) { + this->allocateAuxMemory(LinearEquationSolverOperation::SolveEquations); } // Get a Jacobi decomposition of the matrix A. @@ -214,7 +214,7 @@ namespace storm { std::unique_ptr> gmmLU = storm::adapters::GmmxxAdapter::toGmmxxSparseMatrix(std::move(jacobiDecomposition.first)); std::vector* currentX = &x; - std::vector* nextX = auxiliaryJacobiStorage.get(); + std::vector* nextX = auxiliaryJacobiMemory.get(); // Set up additional environment variables. uint_fast64_t iterationCount = 0; @@ -237,13 +237,13 @@ namespace storm { // If the last iteration did not write to the original x we have to swap the contents, because the // output has to be written to the input parameter x. - if (currentX == auxiliaryJacobiStorage.get()) { + if (currentX == auxiliaryJacobiMemory.get()) { std::swap(x, *currentX); } - // If we allocated auxiliary storage, we need to dispose of it now. - if (allocatedAuxStorage) { - auxiliaryJacobiStorage.reset(); + // If we allocated auxiliary memory, we need to dispose of it now. + if (allocatedAuxMemory) { + this->deallocateAuxMemory(LinearEquationSolverOperation::SolveEquations); } return iterationCount; @@ -260,53 +260,53 @@ namespace storm { } template - bool GmmxxLinearEquationSolver::allocateAuxStorage(LinearEquationSolverOperation operation) { + bool GmmxxLinearEquationSolver::allocateAuxMemory(LinearEquationSolverOperation operation) const { bool result = false; if (operation == LinearEquationSolverOperation::SolveEquations) { if (this->getSettings().getSolutionMethod() == GmmxxLinearEquationSolverSettings::SolutionMethod::Jacobi) { - if (!auxiliaryJacobiStorage) { - auxiliaryJacobiStorage = std::make_unique>(this->getMatrixRowCount()); + if (!auxiliaryJacobiMemory) { + auxiliaryJacobiMemory = std::make_unique>(this->getMatrixRowCount()); result = true; } } } - result |= LinearEquationSolver::allocateAuxStorage(operation); + result |= LinearEquationSolver::allocateAuxMemory(operation); return result; } template - bool GmmxxLinearEquationSolver::deallocateAuxStorage(LinearEquationSolverOperation operation) { + bool GmmxxLinearEquationSolver::deallocateAuxMemory(LinearEquationSolverOperation operation) const { bool result = false; if (operation == LinearEquationSolverOperation::SolveEquations) { - if (auxiliaryJacobiStorage) { + if (auxiliaryJacobiMemory) { result = true; + auxiliaryJacobiMemory.reset(); } - auxiliaryJacobiStorage.reset(); } - result |= LinearEquationSolver::deallocateAuxStorage(operation); + result |= LinearEquationSolver::deallocateAuxMemory(operation); return result; } template - bool GmmxxLinearEquationSolver::reallocateAuxStorage(LinearEquationSolverOperation operation) { + bool GmmxxLinearEquationSolver::reallocateAuxMemory(LinearEquationSolverOperation operation) const { bool result = false; if (operation == LinearEquationSolverOperation::SolveEquations) { - if (auxiliaryJacobiStorage != nullptr) { - result = auxiliaryJacobiStorage->size() != this->getMatrixColumnCount(); - auxiliaryJacobiStorage->resize(this->getMatrixRowCount()); + if (auxiliaryJacobiMemory) { + result = auxiliaryJacobiMemory->size() != this->getMatrixColumnCount(); + auxiliaryJacobiMemory->resize(this->getMatrixRowCount()); } } - result |= LinearEquationSolver::reallocateAuxStorage(operation); + result |= LinearEquationSolver::reallocateAuxMemory(operation); return result; } template - bool GmmxxLinearEquationSolver::hasAuxStorage(LinearEquationSolverOperation operation) const { + bool GmmxxLinearEquationSolver::hasAuxMemory(LinearEquationSolverOperation operation) const { bool result = false; if (operation == LinearEquationSolverOperation::SolveEquations) { - result |= auxiliaryJacobiStorage != nullptr; + result |= static_cast(auxiliaryJacobiMemory); } - result |= LinearEquationSolver::hasAuxStorage(operation); + result |= LinearEquationSolver::hasAuxMemory(operation); return result; } diff --git a/src/solver/GmmxxLinearEquationSolver.h b/src/solver/GmmxxLinearEquationSolver.h index 57386677d..e7ab4c828 100644 --- a/src/solver/GmmxxLinearEquationSolver.h +++ b/src/solver/GmmxxLinearEquationSolver.h @@ -98,10 +98,10 @@ namespace storm { GmmxxLinearEquationSolverSettings& getSettings(); GmmxxLinearEquationSolverSettings const& getSettings() const; - virtual bool allocateAuxStorage(LinearEquationSolverOperation operation) override; - virtual bool deallocateAuxStorage(LinearEquationSolverOperation operation) override; - virtual bool reallocateAuxStorage(LinearEquationSolverOperation operation) override; - virtual bool hasAuxStorage(LinearEquationSolverOperation operation) const override; + virtual bool allocateAuxMemory(LinearEquationSolverOperation operation) const override; + virtual bool deallocateAuxMemory(LinearEquationSolverOperation operation) const override; + virtual bool reallocateAuxMemory(LinearEquationSolverOperation operation) const override; + virtual bool hasAuxMemory(LinearEquationSolverOperation operation) const override; private: /*! @@ -136,7 +136,7 @@ namespace storm { GmmxxLinearEquationSolverSettings settings; // Auxiliary storage for the Jacobi method. - mutable std::unique_ptr> auxiliaryJacobiStorage; + mutable std::unique_ptr> auxiliaryJacobiMemory; }; template diff --git a/src/solver/LinearEquationSolver.cpp b/src/solver/LinearEquationSolver.cpp index feafdfde2..81dc4124b 100644 --- a/src/solver/LinearEquationSolver.cpp +++ b/src/solver/LinearEquationSolver.cpp @@ -14,21 +14,21 @@ namespace storm { namespace solver { template - LinearEquationSolver::LinearEquationSolver() : auxiliaryRepeatedMultiplyStorage(nullptr) { + LinearEquationSolver::LinearEquationSolver() : auxiliaryRepeatedMultiplyMemory(nullptr) { // Intentionally left empty. } template void LinearEquationSolver::repeatedMultiply(std::vector& x, std::vector const* b, uint_fast64_t n) const { - bool allocatedAuxStorage = !this->hasAuxStorage(LinearEquationSolverOperation::MultiplyRepeatedly); - if (allocatedAuxStorage) { - auxiliaryRepeatedMultiplyStorage = std::make_unique>(x.size()); + bool allocatedAuxMemory = !this->hasAuxMemory(LinearEquationSolverOperation::MultiplyRepeatedly); + if (allocatedAuxMemory) { + this->allocateAuxMemory(LinearEquationSolverOperation::MultiplyRepeatedly); } // Set up some temporary variables so that we can just swap pointers instead of copying the result after // each iteration. std::vector* currentX = &x; - std::vector* nextX = auxiliaryRepeatedMultiplyStorage.get(); + std::vector* nextX = auxiliaryRepeatedMultiplyMemory.get(); // Now perform matrix-vector multiplication as long as we meet the bound. for (uint_fast64_t i = 0; i < n; ++i) { @@ -38,54 +38,52 @@ namespace storm { // If we performed an odd number of repetitions, we need to swap the contents of currentVector and x, // because the output is supposed to be stored in the input vector x. - if (currentX == auxiliaryRepeatedMultiplyStorage.get()) { + if (currentX == auxiliaryRepeatedMultiplyMemory.get()) { std::swap(x, *currentX); } - // If we allocated auxiliary storage, we need to dispose of it now. - if (allocatedAuxStorage) { - auxiliaryRepeatedMultiplyStorage.reset(); + // If we allocated auxiliary memory, we need to dispose of it now. + if (allocatedAuxMemory) { + this->deallocateAuxMemory(LinearEquationSolverOperation::MultiplyRepeatedly); } } template - bool LinearEquationSolver::allocateAuxStorage(LinearEquationSolverOperation operation) { - if (this->hasAuxStorage(operation)) { - return false; + bool LinearEquationSolver::allocateAuxMemory(LinearEquationSolverOperation operation) const { + if (!auxiliaryRepeatedMultiplyMemory) { + auxiliaryRepeatedMultiplyMemory = std::make_unique>(this->getMatrixColumnCount()); + return true; } - - auxiliaryRepeatedMultiplyStorage = std::make_unique>(this->getMatrixColumnCount()); - return true; + return false; } template - bool LinearEquationSolver::deallocateAuxStorage(LinearEquationSolverOperation operation) { + bool LinearEquationSolver::deallocateAuxMemory(LinearEquationSolverOperation operation) const { if (operation == LinearEquationSolverOperation::MultiplyRepeatedly) { - bool result = auxiliaryRepeatedMultiplyStorage != nullptr; - if (result) { - auxiliaryRepeatedMultiplyStorage.reset(); + if (auxiliaryRepeatedMultiplyMemory) { + auxiliaryRepeatedMultiplyMemory.reset(); + return true; } - return result; } return false; } template - bool LinearEquationSolver::reallocateAuxStorage(LinearEquationSolverOperation operation) { + bool LinearEquationSolver::reallocateAuxMemory(LinearEquationSolverOperation operation) const { bool result = false; if (operation == LinearEquationSolverOperation::MultiplyRepeatedly) { - if (auxiliaryRepeatedMultiplyStorage != nullptr) { - result = auxiliaryRepeatedMultiplyStorage->size() != this->getMatrixColumnCount(); - auxiliaryRepeatedMultiplyStorage->resize(this->getMatrixColumnCount()); + if (auxiliaryRepeatedMultiplyMemory) { + result = auxiliaryRepeatedMultiplyMemory->size() != this->getMatrixColumnCount(); + auxiliaryRepeatedMultiplyMemory->resize(this->getMatrixColumnCount()); } } return result; } template - bool LinearEquationSolver::hasAuxStorage(LinearEquationSolverOperation operation) const { + bool LinearEquationSolver::hasAuxMemory(LinearEquationSolverOperation operation) const { if (operation == LinearEquationSolverOperation::MultiplyRepeatedly) { - return auxiliaryRepeatedMultiplyStorage != nullptr; + return static_cast(auxiliaryRepeatedMultiplyMemory); } return false; } diff --git a/src/solver/LinearEquationSolver.h b/src/solver/LinearEquationSolver.h index 2e18ecd0c..aa243d593 100644 --- a/src/solver/LinearEquationSolver.h +++ b/src/solver/LinearEquationSolver.h @@ -69,36 +69,36 @@ namespace storm { // Methods related to allocating/freeing auxiliary storage. /*! - * Allocates auxiliary storage that can be used to perform the provided operation. Repeated calls to the - * corresponding function can then be run without allocating/deallocating this storage repeatedly. - * Note: Since the allocated storage is fit to the currently selected options of the solver, they must not - * be changed any more after allocating the auxiliary storage until the storage is deallocated again. + * Allocates auxiliary memory that can be used to perform the provided operation. Repeated calls to the + * corresponding function can then be run without allocating/deallocating this memory repeatedly. + * Note: Since the allocated memory is fit to the currently selected options of the solver, they must not + * be changed any more after allocating the auxiliary memory until it is deallocated again. * - * @return True iff auxiliary storage was allocated. + * @return True iff auxiliary memory was allocated. */ - virtual bool allocateAuxStorage(LinearEquationSolverOperation operation); + virtual bool allocateAuxMemory(LinearEquationSolverOperation operation) const; /*! - * Destroys previously allocated auxiliary storage for the provided operation. + * Destroys previously allocated auxiliary memory for the provided operation. * - * @return True iff auxiliary storage was deallocated. + * @return True iff auxiliary memory was deallocated. */ - virtual bool deallocateAuxStorage(LinearEquationSolverOperation operation); + virtual bool deallocateAuxMemory(LinearEquationSolverOperation operation) const; /*! - * If the matrix dimensions changed and auxiliary storage was allocated, this function needs to be called to - * update the auxiliary storage. + * If the matrix dimensions changed and auxiliary memory was allocated, this function needs to be called to + * update the auxiliary memory. * - * @return True iff the auxiliary storage was reallocated. + * @return True iff the auxiliary memory was reallocated. */ - virtual bool reallocateAuxStorage(LinearEquationSolverOperation operation); + virtual bool reallocateAuxMemory(LinearEquationSolverOperation operation) const; /*! - * Checks whether the solver has allocated auxiliary storage for the provided operation. + * Checks whether the solver has allocated auxiliary memory for the provided operation. * - * @return True iff auxiliary storage was previously allocated (and not yet deallocated). + * @return True iff auxiliary memory was previously allocated (and not yet deallocated). */ - virtual bool hasAuxStorage(LinearEquationSolverOperation operation) const; + virtual bool hasAuxMemory(LinearEquationSolverOperation operation) const; private: /*! @@ -111,8 +111,8 @@ namespace storm { */ virtual uint64_t getMatrixColumnCount() const = 0; - // Auxiliary storage for repeated matrix-vector multiplication. - mutable std::unique_ptr> auxiliaryRepeatedMultiplyStorage; + // Auxiliary memory for repeated matrix-vector multiplication. + mutable std::unique_ptr> auxiliaryRepeatedMultiplyMemory; }; template diff --git a/src/solver/MinMaxLinearEquationSolver.cpp b/src/solver/MinMaxLinearEquationSolver.cpp index bb070c036..a92f19dd9 100644 --- a/src/solver/MinMaxLinearEquationSolver.cpp +++ b/src/solver/MinMaxLinearEquationSolver.cpp @@ -80,17 +80,17 @@ namespace storm { } template - bool MinMaxLinearEquationSolver::allocateAuxStorage(MinMaxLinearEquationSolverOperation operation) { + bool MinMaxLinearEquationSolver::allocateAuxMemory(MinMaxLinearEquationSolverOperation operation) const { return false; } template - bool MinMaxLinearEquationSolver::deallocateAuxStorage(MinMaxLinearEquationSolverOperation operation) { + bool MinMaxLinearEquationSolver::deallocateAuxMemory(MinMaxLinearEquationSolverOperation operation) const { return false; } template - bool MinMaxLinearEquationSolver::hasAuxStorage(MinMaxLinearEquationSolverOperation operation) const { + bool MinMaxLinearEquationSolver::hasAuxMemory(MinMaxLinearEquationSolverOperation operation) const { return false; } diff --git a/src/solver/MinMaxLinearEquationSolver.h b/src/solver/MinMaxLinearEquationSolver.h index 565306756..0582269fb 100644 --- a/src/solver/MinMaxLinearEquationSolver.h +++ b/src/solver/MinMaxLinearEquationSolver.h @@ -126,21 +126,21 @@ namespace storm { * * @return True iff auxiliary storage was allocated. */ - virtual bool allocateAuxStorage(MinMaxLinearEquationSolverOperation operation); + virtual bool allocateAuxMemory(MinMaxLinearEquationSolverOperation operation) const; /*! * Destroys previously allocated auxiliary storage for the provided operation. * * @return True iff auxiliary storage was deallocated. */ - virtual bool deallocateAuxStorage(MinMaxLinearEquationSolverOperation operation); + virtual bool deallocateAuxMemory(MinMaxLinearEquationSolverOperation operation) const; /*! * Checks whether the solver has allocated auxiliary storage for the provided operation. * * @return True iff auxiliary storage was previously allocated (and not yet deallocated). */ - virtual bool hasAuxStorage(MinMaxLinearEquationSolverOperation operation) const; + virtual bool hasAuxMemory(MinMaxLinearEquationSolverOperation operation) const; protected: /// The optimization direction to use for calls to functions that do not provide it explicitly. Can also be unset. diff --git a/src/solver/NativeLinearEquationSolver.cpp b/src/solver/NativeLinearEquationSolver.cpp index 0eb5d758e..ea39a075c 100644 --- a/src/solver/NativeLinearEquationSolver.cpp +++ b/src/solver/NativeLinearEquationSolver.cpp @@ -84,12 +84,12 @@ namespace storm { } template - NativeLinearEquationSolver::NativeLinearEquationSolver(storm::storage::SparseMatrix const& A, NativeLinearEquationSolverSettings const& settings) : localA(nullptr), A(nullptr), settings(settings), auxiliarySolvingStorage(nullptr) { + NativeLinearEquationSolver::NativeLinearEquationSolver(storm::storage::SparseMatrix const& A, NativeLinearEquationSolverSettings const& settings) : localA(nullptr), A(nullptr), settings(settings), auxiliarySolvingMemory(nullptr) { this->setMatrix(A); } template - NativeLinearEquationSolver::NativeLinearEquationSolver(storm::storage::SparseMatrix&& A, NativeLinearEquationSolverSettings const& settings) : localA(nullptr), A(nullptr), settings(settings), auxiliarySolvingStorage(nullptr) { + NativeLinearEquationSolver::NativeLinearEquationSolver(storm::storage::SparseMatrix&& A, NativeLinearEquationSolverSettings const& settings) : localA(nullptr), A(nullptr), settings(settings), auxiliarySolvingMemory(nullptr) { this->setMatrix(std::move(A)); } @@ -107,9 +107,9 @@ namespace storm { template void NativeLinearEquationSolver::solveEquations(std::vector& x, std::vector const& b) const { - bool allocatedAuxStorage = !this->hasAuxStorage(LinearEquationSolverOperation::SolveEquations); + bool allocatedAuxStorage = !this->hasAuxMemory(LinearEquationSolverOperation::SolveEquations); if (allocatedAuxStorage) { - auxiliarySolvingStorage = std::make_unique>(x.size()); + this->allocateAuxMemory(LinearEquationSolverOperation::SolveEquations); } if (this->getSettings().getSolutionMethod() == NativeLinearEquationSolverSettings::SolutionMethod::SOR || this->getSettings().getSolutionMethod() == NativeLinearEquationSolverSettings::SolutionMethod::GaussSeidel) { @@ -124,11 +124,11 @@ namespace storm { A->performSuccessiveOverRelaxationStep(omega, x, b); // Now check if the process already converged within our precision. - converged = storm::utility::vector::equalModuloPrecision(*auxiliarySolvingStorage, x, static_cast(this->getSettings().getPrecision()), this->getSettings().getRelativeTerminationCriterion()) || (this->hasCustomTerminationCondition() && this->getTerminationCondition().terminateNow(x)); + converged = storm::utility::vector::equalModuloPrecision(*auxiliarySolvingMemory, x, static_cast(this->getSettings().getPrecision()), this->getSettings().getRelativeTerminationCriterion()) || (this->hasCustomTerminationCondition() && this->getTerminationCondition().terminateNow(x)); // If we did not yet converge, we need to backup the contents of x. if (!converged) { - *auxiliarySolvingStorage = x; + *auxiliarySolvingMemory = x; } // Increase iteration count so we can abort if convergence is too slow. @@ -139,7 +139,7 @@ namespace storm { std::pair, std::vector> jacobiDecomposition = A->getJacobiDecomposition(); std::vector* currentX = &x; - std::vector* nextX = auxiliarySolvingStorage.get(); + std::vector* nextX = auxiliarySolvingMemory.get(); // Set up additional environment variables. uint_fast64_t iterationCount = 0; @@ -163,14 +163,14 @@ namespace storm { // If the last iteration did not write to the original x we have to swap the contents, because the // output has to be written to the input parameter x. - if (currentX == auxiliarySolvingStorage.get()) { + if (currentX == auxiliarySolvingMemory.get()) { std::swap(x, *currentX); } } - // If we allocated auxiliary storage, we need to dispose of it now. + // If we allocated auxiliary memory, we need to dispose of it now. if (allocatedAuxStorage) { - auxiliarySolvingStorage.reset(); + this->deallocateAuxMemory(LinearEquationSolverOperation::SolveEquations); } } @@ -202,51 +202,51 @@ namespace storm { } template - bool NativeLinearEquationSolver::allocateAuxStorage(LinearEquationSolverOperation operation) { + bool NativeLinearEquationSolver::allocateAuxMemory(LinearEquationSolverOperation operation) const { bool result = false; if (operation == LinearEquationSolverOperation::SolveEquations) { - if (!auxiliarySolvingStorage) { - auxiliarySolvingStorage = std::make_unique>(this->getMatrixRowCount()); + if (!auxiliarySolvingMemory) { + auxiliarySolvingMemory = std::make_unique>(this->getMatrixRowCount()); result = true; } } - result |= LinearEquationSolver::allocateAuxStorage(operation); + result |= LinearEquationSolver::allocateAuxMemory(operation); return result; } template - bool NativeLinearEquationSolver::deallocateAuxStorage(LinearEquationSolverOperation operation) { + bool NativeLinearEquationSolver::deallocateAuxMemory(LinearEquationSolverOperation operation) const { bool result = false; if (operation == LinearEquationSolverOperation::SolveEquations) { - if (auxiliarySolvingStorage) { + if (auxiliarySolvingMemory) { result = true; + auxiliarySolvingMemory.reset(); } - auxiliarySolvingStorage.reset(); } - result |= LinearEquationSolver::deallocateAuxStorage(operation); + result |= LinearEquationSolver::deallocateAuxMemory(operation); return result; } template - bool NativeLinearEquationSolver::reallocateAuxStorage(LinearEquationSolverOperation operation) { + bool NativeLinearEquationSolver::reallocateAuxMemory(LinearEquationSolverOperation operation) const { bool result = false; if (operation == LinearEquationSolverOperation::SolveEquations) { - if (auxiliarySolvingStorage) { - result = auxiliarySolvingStorage->size() != this->getMatrixColumnCount(); - auxiliarySolvingStorage->resize(this->getMatrixRowCount()); + if (auxiliarySolvingMemory) { + result = auxiliarySolvingMemory->size() != this->getMatrixColumnCount(); + auxiliarySolvingMemory->resize(this->getMatrixRowCount()); } } - result |= LinearEquationSolver::reallocateAuxStorage(operation); + result |= LinearEquationSolver::reallocateAuxMemory(operation); return result; } template - bool NativeLinearEquationSolver::hasAuxStorage(LinearEquationSolverOperation operation) const { + bool NativeLinearEquationSolver::hasAuxMemory(LinearEquationSolverOperation operation) const { bool result = false; if (operation == LinearEquationSolverOperation::SolveEquations) { - result |= auxiliarySolvingStorage != nullptr; + result |= static_cast(auxiliarySolvingMemory); } - result |= LinearEquationSolver::hasAuxStorage(operation); + result |= LinearEquationSolver::hasAuxMemory(operation); return result; } diff --git a/src/solver/NativeLinearEquationSolver.h b/src/solver/NativeLinearEquationSolver.h index 19722debe..436e5cd36 100644 --- a/src/solver/NativeLinearEquationSolver.h +++ b/src/solver/NativeLinearEquationSolver.h @@ -55,10 +55,10 @@ namespace storm { NativeLinearEquationSolverSettings& getSettings(); NativeLinearEquationSolverSettings const& getSettings() const; - virtual bool allocateAuxStorage(LinearEquationSolverOperation operation) override; - virtual bool deallocateAuxStorage(LinearEquationSolverOperation operation) override; - virtual bool reallocateAuxStorage(LinearEquationSolverOperation operation) override; - virtual bool hasAuxStorage(LinearEquationSolverOperation operation) const override; + virtual bool allocateAuxMemory(LinearEquationSolverOperation operation) const override; + virtual bool deallocateAuxMemory(LinearEquationSolverOperation operation) const override; + virtual bool reallocateAuxMemory(LinearEquationSolverOperation operation) const override; + virtual bool hasAuxMemory(LinearEquationSolverOperation operation) const override; private: virtual uint64_t getMatrixRowCount() const override; @@ -75,8 +75,8 @@ namespace storm { // The settings used by the solver. NativeLinearEquationSolverSettings settings; - // Auxiliary storage for the equation solving methods. - mutable std::unique_ptr> auxiliarySolvingStorage; + // Auxiliary memory for the equation solving methods. + mutable std::unique_ptr> auxiliarySolvingMemory; }; template diff --git a/src/solver/StandardMinMaxLinearEquationSolver.cpp b/src/solver/StandardMinMaxLinearEquationSolver.cpp index 2af6527e7..4e0609e80 100644 --- a/src/solver/StandardMinMaxLinearEquationSolver.cpp +++ b/src/solver/StandardMinMaxLinearEquationSolver.cpp @@ -106,7 +106,7 @@ namespace storm { // Create a solver that we will use throughout the procedure. We will modify the matrix in each iteration. auto solver = linearEquationSolverFactory->create(std::move(submatrix)); - solver->allocateAuxStorage(LinearEquationSolverOperation::SolveEquations); + solver->allocateAuxMemory(LinearEquationSolverOperation::SolveEquations); Status status = Status::InProgress; uint64_t iterations = 0; @@ -183,14 +183,13 @@ namespace storm { template void StandardMinMaxLinearEquationSolver::solveEquationsValueIteration(OptimizationDirection dir, std::vector& x, std::vector const& b) const { std::unique_ptr> solver = linearEquationSolverFactory->create(A); - bool allocatedAuxStorage = !this->hasAuxStorage(MinMaxLinearEquationSolverOperation::SolveEquations); - if (allocatedAuxStorage) { - auxiliarySolvingMultiplyStorage = std::make_unique>(this->A.getRowCount()); - auxiliarySolvingVectorStorage = std::make_unique>(x.size()); + bool allocatedAuxMemory = !this->hasAuxMemory(MinMaxLinearEquationSolverOperation::SolveEquations); + if (allocatedAuxMemory) { + this->allocateAuxMemory(MinMaxLinearEquationSolverOperation::SolveEquations); } std::vector* currentX = &x; - std::vector* newX = auxiliarySolvingVectorStorage.get(); + std::vector* newX = auxiliarySolvingVectorMemory.get(); // Proceed with the iterations as long as the method did not converge or reach the maximum number of iterations. uint64_t iterations = 0; @@ -198,10 +197,10 @@ namespace storm { Status status = Status::InProgress; while (status == Status::InProgress) { // Compute x' = A*x + b. - solver->multiply(*currentX, &b, *auxiliarySolvingMultiplyStorage); + solver->multiply(*currentX, &b, *auxiliarySolvingMultiplyMemory); // Reduce the vector x' by applying min/max for all non-deterministic choices. - storm::utility::vector::reduceVectorMinOrMax(dir, *auxiliarySolvingMultiplyStorage, *newX, this->A.getRowGroupIndices()); + storm::utility::vector::reduceVectorMinOrMax(dir, *auxiliarySolvingMultiplyMemory, *newX, this->A.getRowGroupIndices()); // Determine whether the method converged. if (storm::utility::vector::equalModuloPrecision(*currentX, *newX, this->getSettings().getPrecision(), this->getSettings().getRelativeTerminationCriterion())) { @@ -218,37 +217,36 @@ namespace storm { // If we performed an odd number of iterations, we need to swap the x and currentX, because the newest result // is currently stored in currentX, but x is the output vector. - if (currentX == auxiliarySolvingVectorStorage.get()) { + if (currentX == auxiliarySolvingVectorMemory.get()) { std::swap(x, *currentX); } - // If we allocated auxiliary storage, we need to dispose of it now. - if (allocatedAuxStorage) { - auxiliarySolvingMultiplyStorage.reset(); - auxiliarySolvingVectorStorage.reset(); + // If we allocated auxiliary memory, we need to dispose of it now. + if (allocatedAuxMemory) { + this->deallocateAuxMemory(MinMaxLinearEquationSolverOperation::SolveEquations); } } template - void StandardMinMaxLinearEquationSolver::multiply(OptimizationDirection dir, std::vector& x, std::vector* b, uint_fast64_t n) const { - bool allocatedAuxStorage = !this->hasAuxStorage(MinMaxLinearEquationSolverOperation::MultiplyRepeatedly); - if (allocatedAuxStorage) { - auxiliaryRepeatedMultiplyStorage = std::make_unique>(this->A.getRowCount()); + void StandardMinMaxLinearEquationSolver::repeatedMultiply(OptimizationDirection dir, std::vector& x, std::vector* b, uint_fast64_t n) const { + bool allocatedAuxMemory = !this->hasAuxMemory(MinMaxLinearEquationSolverOperation::MultiplyRepeatedly); + if (allocatedAuxMemory) { + this->allocateAuxMemory(MinMaxLinearEquationSolverOperation::MultiplyRepeatedly); } std::unique_ptr> solver = linearEquationSolverFactory->create(A); for (uint64_t i = 0; i < n; ++i) { - solver->multiply(x, b, *auxiliaryRepeatedMultiplyStorage); + solver->multiply(x, b, *auxiliaryRepeatedMultiplyMemory); // Reduce the vector x' by applying min/max for all non-deterministic choices as given by the topmost // element of the min/max operator stack. - storm::utility::vector::reduceVectorMinOrMax(dir, *auxiliaryRepeatedMultiplyStorage, x, this->A.getRowGroupIndices()); + storm::utility::vector::reduceVectorMinOrMax(dir, *auxiliaryRepeatedMultiplyMemory, x, this->A.getRowGroupIndices()); } - // If we allocated auxiliary storage, we need to dispose of it now. - if (allocatedAuxStorage) { - auxiliaryRepeatedMultiplyStorage.reset(); + // If we allocated auxiliary memory, we need to dispose of it now. + if (allocatedAuxMemory) { + this->deallocateAuxMemory(MinMaxLinearEquationSolverOperation::MultiplyRepeatedly); } } @@ -286,47 +284,44 @@ namespace storm { } template - bool StandardMinMaxLinearEquationSolver::allocateAuxStorage(MinMaxLinearEquationSolverOperation operation) { + bool StandardMinMaxLinearEquationSolver::allocateAuxMemory(MinMaxLinearEquationSolverOperation operation) const { bool result = false; if (operation == MinMaxLinearEquationSolverOperation::SolveEquations) { if (this->getSettings().getSolutionMethod() == StandardMinMaxLinearEquationSolverSettings::SolutionMethod::ValueIteration) { - if (!auxiliarySolvingMultiplyStorage) { + if (!auxiliarySolvingMultiplyMemory) { result = true; - auxiliarySolvingMultiplyStorage = std::make_unique>(this->A.getRowCount()); + auxiliarySolvingMultiplyMemory = std::make_unique>(this->A.getRowCount()); } - if (!auxiliarySolvingVectorStorage) { + if (!auxiliarySolvingVectorMemory) { result = true; - auxiliarySolvingVectorStorage = std::make_unique>(this->A.getRowGroupCount()); + auxiliarySolvingVectorMemory = std::make_unique>(this->A.getRowGroupCount()); } } else if (this->getSettings().getSolutionMethod() == StandardMinMaxLinearEquationSolverSettings::SolutionMethod::PolicyIteration) { - if (!auxiliarySolvingVectorStorage) { - result = true; - auxiliarySolvingVectorStorage = std::make_unique>(this->A.getRowGroupCount()); - } + // Nothing to do in this case. } else { STORM_LOG_ASSERT(false, "Cannot allocate aux storage for this method."); } } else { - if (!auxiliaryRepeatedMultiplyStorage) { + if (!auxiliaryRepeatedMultiplyMemory) { result = true; - auxiliaryRepeatedMultiplyStorage = std::make_unique>(this->A.getRowCount()); + auxiliaryRepeatedMultiplyMemory = std::make_unique>(this->A.getRowCount()); } } return result; } template - bool StandardMinMaxLinearEquationSolver::deallocateAuxStorage(MinMaxLinearEquationSolverOperation operation) { + bool StandardMinMaxLinearEquationSolver::deallocateAuxMemory(MinMaxLinearEquationSolverOperation operation) const { bool result = false; if (operation == MinMaxLinearEquationSolverOperation::SolveEquations) { if (this->getSettings().getSolutionMethod() == StandardMinMaxLinearEquationSolverSettings::SolutionMethod::ValueIteration) { - if (auxiliarySolvingMultiplyStorage) { + if (auxiliarySolvingMultiplyMemory) { result = true; - auxiliarySolvingMultiplyStorage.reset(); + auxiliarySolvingMultiplyMemory.reset(); } - if (auxiliarySolvingVectorStorage) { + if (auxiliarySolvingVectorMemory) { result = true; - auxiliarySolvingVectorStorage.reset(); + auxiliarySolvingVectorMemory.reset(); } } else if (this->getSettings().getSolutionMethod() == StandardMinMaxLinearEquationSolverSettings::SolutionMethod::PolicyIteration) { // Nothing to do in this case. @@ -334,23 +329,24 @@ namespace storm { STORM_LOG_ASSERT(false, "Cannot allocate aux storage for this method."); } } else { - if (auxiliaryRepeatedMultiplyStorage) { + if (auxiliaryRepeatedMultiplyMemory) { result = true; - auxiliaryRepeatedMultiplyStorage.reset(); + auxiliaryRepeatedMultiplyMemory.reset(); } } + return result; } template - bool StandardMinMaxLinearEquationSolver::hasAuxStorage(MinMaxLinearEquationSolverOperation operation) const { + bool StandardMinMaxLinearEquationSolver::hasAuxMemory(MinMaxLinearEquationSolverOperation operation) const { if (operation == MinMaxLinearEquationSolverOperation::SolveEquations) { if (this->getSettings().getSolutionMethod() == StandardMinMaxLinearEquationSolverSettings::SolutionMethod::ValueIteration) { - return auxiliarySolvingMultiplyStorage && auxiliarySolvingVectorStorage; + return auxiliarySolvingMultiplyMemory && auxiliarySolvingVectorMemory; } else { return false; } } else { - return static_cast(auxiliaryRepeatedMultiplyStorage); + return static_cast(auxiliaryRepeatedMultiplyMemory); } } diff --git a/src/solver/StandardMinMaxLinearEquationSolver.h b/src/solver/StandardMinMaxLinearEquationSolver.h index 523266c04..0c0b37f79 100644 --- a/src/solver/StandardMinMaxLinearEquationSolver.h +++ b/src/solver/StandardMinMaxLinearEquationSolver.h @@ -39,14 +39,14 @@ namespace storm { StandardMinMaxLinearEquationSolver(storm::storage::SparseMatrix&& A, std::unique_ptr>&& linearEquationSolverFactory, StandardMinMaxLinearEquationSolverSettings const& settings = StandardMinMaxLinearEquationSolverSettings()); virtual void solveEquations(OptimizationDirection dir, std::vector& x, std::vector const& b) const override; - virtual void multiply(OptimizationDirection dir, std::vector& x, std::vector* b, uint_fast64_t n) const override; + virtual void repeatedMultiply(OptimizationDirection dir, std::vector& x, std::vector* b, uint_fast64_t n) const override; StandardMinMaxLinearEquationSolverSettings const& getSettings() const; StandardMinMaxLinearEquationSolverSettings& getSettings(); - virtual bool allocateAuxStorage(MinMaxLinearEquationSolverOperation operation) override; - virtual bool deallocateAuxStorage(MinMaxLinearEquationSolverOperation operation) override; - virtual bool hasAuxStorage(MinMaxLinearEquationSolverOperation operation) const override; + virtual bool allocateAuxMemory(MinMaxLinearEquationSolverOperation operation) const override; + virtual bool deallocateAuxMemory(MinMaxLinearEquationSolverOperation operation) const override; + virtual bool hasAuxMemory(MinMaxLinearEquationSolverOperation operation) const override; private: void solveEquationsPolicyIteration(OptimizationDirection dir, std::vector& x, std::vector const& b) const; @@ -75,13 +75,12 @@ namespace storm { // the reference refers to localA. storm::storage::SparseMatrix const& A; - // Auxiliary storage for equation solving. - // Auxiliary storage for repeated matrix-vector multiplication. - mutable std::unique_ptr> auxiliarySolvingMultiplyStorage; - mutable std::unique_ptr> auxiliarySolvingVectorStorage; + // Auxiliary memory for equation solving. + mutable std::unique_ptr> auxiliarySolvingMultiplyMemory; + mutable std::unique_ptr> auxiliarySolvingVectorMemory; - // Auxiliary storage for repeated matrix-vector multiplication. - mutable std::unique_ptr> auxiliaryRepeatedMultiplyStorage; + // Auxiliary memory for repeated matrix-vector multiplication. + mutable std::unique_ptr> auxiliaryRepeatedMultiplyMemory; }; template diff --git a/src/solver/TopologicalMinMaxLinearEquationSolver.cpp b/src/solver/TopologicalMinMaxLinearEquationSolver.cpp index 6ef7d231e..909c41c30 100644 --- a/src/solver/TopologicalMinMaxLinearEquationSolver.cpp +++ b/src/solver/TopologicalMinMaxLinearEquationSolver.cpp @@ -33,7 +33,7 @@ namespace storm { } template - void TopologicalMinMaxLinearEquationSolver::solveEquations(OptimizationDirection dir, std::vector& x, std::vector const& b, std::vector* multiplyResult, std::vector* newX) const { + void TopologicalMinMaxLinearEquationSolver::solveEquations(OptimizationDirection dir, std::vector& x, std::vector const& b) const { #ifdef GPU_USE_FLOAT #define __FORCE_FLOAT_CALCULATION true @@ -49,7 +49,7 @@ namespace storm { std::vector new_x = storm::utility::vector::toValueType(x); std::vector const new_b = storm::utility::vector::toValueType(b); - newSolver.solveEquations(dir, new_x, new_b, nullptr, nullptr); + newSolver.solveEquations(dir, new_x, new_b); for (size_t i = 0, size = new_x.size(); i < size; ++i) { x.at(i) = new_x.at(i); @@ -422,14 +422,8 @@ namespace storm { } template - void TopologicalMinMaxLinearEquationSolver::multiply(OptimizationDirection dir, std::vector& x, std::vector* b, uint_fast64_t n, std::vector* multiplyResult) const { - - // If scratch memory was not provided, we need to create it. - bool multiplyResultMemoryProvided = true; - if (multiplyResult == nullptr) { - multiplyResult = new std::vector(this->A.getRowCount()); - multiplyResultMemoryProvided = false; - } + void TopologicalMinMaxLinearEquationSolver::repeatedMultiply(OptimizationDirection dir, std::vector& x, std::vector* b, uint_fast64_t n) const { + std::unique_ptr> multiplyResult = std::make_unique>(this->A.getRowCount()); // Now perform matrix-vector multiplication as long as we meet the bound of the formula. for (uint_fast64_t i = 0; i < n; ++i) { @@ -445,10 +439,6 @@ namespace storm { storm::utility::vector::reduceVectorMinOrMax(dir, *multiplyResult, x, this->A.getRowGroupIndices()); } - - if (!multiplyResultMemoryProvided) { - delete multiplyResult; - } } template diff --git a/src/solver/TopologicalMinMaxLinearEquationSolver.h b/src/solver/TopologicalMinMaxLinearEquationSolver.h index e6cc87997..5eac4a976 100644 --- a/src/solver/TopologicalMinMaxLinearEquationSolver.h +++ b/src/solver/TopologicalMinMaxLinearEquationSolver.h @@ -32,9 +32,9 @@ namespace storm { */ TopologicalMinMaxLinearEquationSolver(storm::storage::SparseMatrix const& A, double precision = 1e-6, uint_fast64_t maximalNumberOfIterations = 20000, bool relative = true); - virtual void solveEquations(OptimizationDirection dir, std::vector& x, std::vector const& b, std::vector* multiplyResult = nullptr, std::vector* newX = nullptr) const override; + virtual void solveEquations(OptimizationDirection dir, std::vector& x, std::vector const& b) const override; - virtual void multiply(OptimizationDirection dir, std::vector& x, std::vector* b, uint_fast64_t n, std::vector* multiplyResult) const override; + virtual void repeatedMultiply(OptimizationDirection dir, std::vector& x, std::vector* b, uint_fast64_t n) const override; private: storm::storage::SparseMatrix const& A; diff --git a/test/functional/solver/GmmxxMinMaxLinearEquationSolverTest.cpp b/test/functional/solver/GmmxxMinMaxLinearEquationSolverTest.cpp index 4f86c25b1..94f49c2bf 100644 --- a/test/functional/solver/GmmxxMinMaxLinearEquationSolverTest.cpp +++ b/test/functional/solver/GmmxxMinMaxLinearEquationSolverTest.cpp @@ -78,23 +78,23 @@ TEST(GmmxxMinMaxLinearEquationSolver, MatrixVectorMultiplication) { auto factory = storm::solver::GmmxxMinMaxLinearEquationSolverFactory(); auto solver = factory.create(A); - ASSERT_NO_THROW(solver->multiply(storm::OptimizationDirection::Minimize, x, nullptr, 1)); + ASSERT_NO_THROW(solver->repeatedMultiply(storm::OptimizationDirection::Minimize, x, nullptr, 1)); ASSERT_LT(std::abs(x[0] - 0.099), storm::settings::getModule().getPrecision()); x = {0, 1, 0}; - ASSERT_NO_THROW(solver->multiply(storm::OptimizationDirection::Minimize, x, nullptr, 2)); + ASSERT_NO_THROW(solver->repeatedMultiply(storm::OptimizationDirection::Minimize, x, nullptr, 2)); ASSERT_LT(std::abs(x[0] - 0.1881), storm::settings::getModule().getPrecision()); x = {0, 1, 0}; - ASSERT_NO_THROW(solver->multiply(storm::OptimizationDirection::Minimize, x, nullptr, 20)); + ASSERT_NO_THROW(solver->repeatedMultiply(storm::OptimizationDirection::Minimize, x, nullptr, 20)); ASSERT_LT(std::abs(x[0] - 0.5), storm::settings::getModule().getPrecision()); x = {0, 1, 0}; - ASSERT_NO_THROW(solver->multiply(storm::OptimizationDirection::Maximize, x, nullptr, 1)); + ASSERT_NO_THROW(solver->repeatedMultiply(storm::OptimizationDirection::Maximize, x, nullptr, 1)); ASSERT_LT(std::abs(x[0] - 0.5), storm::settings::getModule().getPrecision()); x = {0, 1, 0}; - ASSERT_NO_THROW(solver->multiply(storm::OptimizationDirection::Maximize, x, nullptr, 20)); + ASSERT_NO_THROW(solver->repeatedMultiply(storm::OptimizationDirection::Maximize, x, nullptr, 20)); ASSERT_LT(std::abs(x[0] - 0.9238082658), storm::settings::getModule().getPrecision()); } diff --git a/test/functional/solver/NativeMinMaxLinearEquationSolverTest.cpp b/test/functional/solver/NativeMinMaxLinearEquationSolverTest.cpp index fdf595193..4a61de149 100644 --- a/test/functional/solver/NativeMinMaxLinearEquationSolverTest.cpp +++ b/test/functional/solver/NativeMinMaxLinearEquationSolverTest.cpp @@ -49,23 +49,23 @@ TEST(NativeMinMaxLinearEquationSolver, MatrixVectorMultiplication) { auto factory = storm::solver::NativeMinMaxLinearEquationSolverFactory(); auto solver = factory.create(A); - ASSERT_NO_THROW(solver->multiply(storm::OptimizationDirection::Minimize, x, nullptr, 1)); + ASSERT_NO_THROW(solver->repeatedMultiply(storm::OptimizationDirection::Minimize, x, nullptr, 1)); ASSERT_LT(std::abs(x[0] - 0.099), storm::settings::getModule().getPrecision()); x = {0, 1, 0}; - ASSERT_NO_THROW(solver->multiply(storm::OptimizationDirection::Minimize, x, nullptr, 2)); + ASSERT_NO_THROW(solver->repeatedMultiply(storm::OptimizationDirection::Minimize, x, nullptr, 2)); ASSERT_LT(std::abs(x[0] - 0.1881), storm::settings::getModule().getPrecision()); x = {0, 1, 0}; - ASSERT_NO_THROW(solver->multiply(storm::OptimizationDirection::Minimize, x, nullptr, 20)); + ASSERT_NO_THROW(solver->repeatedMultiply(storm::OptimizationDirection::Minimize, x, nullptr, 20)); ASSERT_LT(std::abs(x[0] - 0.5), storm::settings::getModule().getPrecision()); x = {0, 1, 0}; - ASSERT_NO_THROW(solver->multiply(storm::OptimizationDirection::Maximize, x, nullptr, 1)); + ASSERT_NO_THROW(solver->repeatedMultiply(storm::OptimizationDirection::Maximize, x, nullptr, 1)); ASSERT_LT(std::abs(x[0] - 0.5), storm::settings::getModule().getPrecision()); x = {0, 1, 0}; - ASSERT_NO_THROW(solver->multiply(storm::OptimizationDirection::Maximize, x, nullptr, 20)); + ASSERT_NO_THROW(solver->repeatedMultiply(storm::OptimizationDirection::Maximize, x, nullptr, 20)); ASSERT_LT(std::abs(x[0] - 0.9238082658), storm::settings::getModule().getPrecision()); }