From e1047e787fc9154f994ce057e88492a29e0106c8 Mon Sep 17 00:00:00 2001 From: TimQu Date: Sun, 15 Jul 2018 13:44:29 +0100 Subject: [PATCH] handled case where no threshold for the number of iterations is provided --- .../environment/solver/EigenSolverEnvironment.cpp | 10 +++++++--- src/storm/environment/solver/GameSolverEnvironment.cpp | 6 +++++- .../environment/solver/GmmxxSolverEnvironment.cpp | 6 +++++- .../environment/solver/MinMaxSolverEnvironment.cpp | 6 +++++- .../environment/solver/NativeSolverEnvironment.cpp | 6 +++++- src/storm/solver/EigenLinearEquationSolver.cpp | 5 ++++- src/storm/solver/GmmxxLinearEquationSolver.cpp | 6 +++++- 7 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/storm/environment/solver/EigenSolverEnvironment.cpp b/src/storm/environment/solver/EigenSolverEnvironment.cpp index a36bd0062..4b1c561e0 100644 --- a/src/storm/environment/solver/EigenSolverEnvironment.cpp +++ b/src/storm/environment/solver/EigenSolverEnvironment.cpp @@ -14,7 +14,11 @@ namespace storm { methodSetFromDefault = eigenSettings.isLinearEquationSystemMethodSetFromDefault(); preconditioner = eigenSettings.getPreconditioningMethod(); restartThreshold = eigenSettings.getRestartIterationCount(); - maxIterationCount = eigenSettings.getMaximalIterationCount(); + if (eigenSettings.isMaximalIterationCountSet()) { + maxIterationCount = eigenSettings.getMaximalIterationCount(); + } else { + maxIterationCount = std::numeric_limits::max(); + } precision = storm::utility::convertNumber(eigenSettings.getPrecision()); } @@ -44,11 +48,11 @@ namespace storm { } uint64_t const& EigenSolverEnvironment::getRestartThreshold() const { - return maxIterationCount; + return restartThreshold; } void EigenSolverEnvironment::setRestartThreshold(uint64_t value) { - maxIterationCount = value; + restartThreshold = value; } uint64_t const& EigenSolverEnvironment::getMaximalNumberOfIterations() const { diff --git a/src/storm/environment/solver/GameSolverEnvironment.cpp b/src/storm/environment/solver/GameSolverEnvironment.cpp index aea27278d..9793312d3 100644 --- a/src/storm/environment/solver/GameSolverEnvironment.cpp +++ b/src/storm/environment/solver/GameSolverEnvironment.cpp @@ -12,7 +12,11 @@ namespace storm { gameMethod = gameSettings.getGameSolvingMethod(); methodSetFromDefault = gameSettings.isGameSolvingMethodSetFromDefaultValue(); - maxIterationCount = gameSettings.getMaximalIterationCount(); + if (gameSettings.isMaximalIterationCountSet()) { + maxIterationCount = gameSettings.getMaximalIterationCount(); + } else { + maxIterationCount = std::numeric_limits::max(); + } precision = storm::utility::convertNumber(gameSettings.getPrecision()); considerRelativeTerminationCriterion = gameSettings.getConvergenceCriterion() == storm::settings::modules::GameSolverSettings::ConvergenceCriterion::Relative; STORM_LOG_ASSERT(considerRelativeTerminationCriterion || gameSettings.getConvergenceCriterion() == storm::settings::modules::GameSolverSettings::ConvergenceCriterion::Absolute, "Unknown convergence criterion"); diff --git a/src/storm/environment/solver/GmmxxSolverEnvironment.cpp b/src/storm/environment/solver/GmmxxSolverEnvironment.cpp index 8b8992db4..d78f3e039 100644 --- a/src/storm/environment/solver/GmmxxSolverEnvironment.cpp +++ b/src/storm/environment/solver/GmmxxSolverEnvironment.cpp @@ -13,7 +13,11 @@ namespace storm { method = gmmxxSettings.getLinearEquationSystemMethod(); preconditioner = gmmxxSettings.getPreconditioningMethod(); restartThreshold = gmmxxSettings.getRestartIterationCount(); - maxIterationCount = gmmxxSettings.getMaximalIterationCount(); + if (gmmxxSettings.isMaximalIterationCountSet()) { + maxIterationCount = gmmxxSettings.getMaximalIterationCount(); + } else { + maxIterationCount = std::numeric_limits::max(); + } precision = storm::utility::convertNumber(gmmxxSettings.getPrecision()); } diff --git a/src/storm/environment/solver/MinMaxSolverEnvironment.cpp b/src/storm/environment/solver/MinMaxSolverEnvironment.cpp index 536bf5913..63cf5c698 100644 --- a/src/storm/environment/solver/MinMaxSolverEnvironment.cpp +++ b/src/storm/environment/solver/MinMaxSolverEnvironment.cpp @@ -12,7 +12,11 @@ namespace storm { minMaxMethod = minMaxSettings.getMinMaxEquationSolvingMethod(); methodSetFromDefault = minMaxSettings.isMinMaxEquationSolvingMethodSetFromDefaultValue(); - maxIterationCount = minMaxSettings.getMaximalIterationCount(); + if (minMaxSettings.isMaximalIterationCountSet()) { + maxIterationCount = minMaxSettings.getMaximalIterationCount(); + } else { + maxIterationCount = std::numeric_limits::max(); + } precision = storm::utility::convertNumber(minMaxSettings.getPrecision()); considerRelativeTerminationCriterion = minMaxSettings.getConvergenceCriterion() == storm::settings::modules::MinMaxEquationSolverSettings::ConvergenceCriterion::Relative; STORM_LOG_ASSERT(considerRelativeTerminationCriterion || minMaxSettings.getConvergenceCriterion() == storm::settings::modules::MinMaxEquationSolverSettings::ConvergenceCriterion::Absolute, "Unknown convergence criterion"); diff --git a/src/storm/environment/solver/NativeSolverEnvironment.cpp b/src/storm/environment/solver/NativeSolverEnvironment.cpp index 149a2feb6..9d152f92f 100644 --- a/src/storm/environment/solver/NativeSolverEnvironment.cpp +++ b/src/storm/environment/solver/NativeSolverEnvironment.cpp @@ -12,7 +12,11 @@ namespace storm { method = nativeSettings.getLinearEquationSystemMethod(); methodSetFromDefault = nativeSettings.isLinearEquationSystemTechniqueSetFromDefaultValue(); - maxIterationCount = nativeSettings.getMaximalIterationCount(); + if (nativeSettings.isMaximalIterationCountSet()) { + maxIterationCount = nativeSettings.getMaximalIterationCount(); + } else { + maxIterationCount = std::numeric_limits::max(); + } precision = storm::utility::convertNumber(nativeSettings.getPrecision()); considerRelativeTerminationCriterion = nativeSettings.getConvergenceCriterion() == storm::settings::modules::NativeEquationSolverSettings::ConvergenceCriterion::Relative; STORM_LOG_ASSERT(considerRelativeTerminationCriterion || nativeSettings.getConvergenceCriterion() == storm::settings::modules::NativeEquationSolverSettings::ConvergenceCriterion::Absolute, "Unknown convergence criterion"); diff --git a/src/storm/solver/EigenLinearEquationSolver.cpp b/src/storm/solver/EigenLinearEquationSolver.cpp index afbc88a3b..55046a495 100644 --- a/src/storm/solver/EigenLinearEquationSolver.cpp +++ b/src/storm/solver/EigenLinearEquationSolver.cpp @@ -116,7 +116,10 @@ namespace storm { } else { bool converged = false; uint64_t numberOfIterations = 0; - uint64_t maxIter = env.solver().eigen().getMaximalNumberOfIterations(); + StormEigen::Index maxIter = std::numeric_limits::max(); + if (env.solver().eigen().getMaximalNumberOfIterations() < static_cast(maxIter)) { + maxIter = env.solver().eigen().getMaximalNumberOfIterations(); + } uint64_t restartThreshold = env.solver().eigen().getRestartThreshold(); ValueType precision = storm::utility::convertNumber(env.solver().eigen().getPrecision()); EigenLinearEquationSolverPreconditioner preconditioner = env.solver().eigen().getPreconditioner(); diff --git a/src/storm/solver/GmmxxLinearEquationSolver.cpp b/src/storm/solver/GmmxxLinearEquationSolver.cpp index d2fefc60d..9ce51fa72 100644 --- a/src/storm/solver/GmmxxLinearEquationSolver.cpp +++ b/src/storm/solver/GmmxxLinearEquationSolver.cpp @@ -65,7 +65,11 @@ namespace storm { } // Prepare an iteration object that determines the accuracy and the maximum number of iterations. - gmm::iteration iter(storm::utility::convertNumber(env.solver().gmmxx().getPrecision()), 0, env.solver().gmmxx().getMaximalNumberOfIterations()); + gmm::size_type maxIter = std::numeric_limits::max(); + if (env.solver().gmmxx().getMaximalNumberOfIterations() < static_cast(maxIter)) { + maxIter = env.solver().gmmxx().getMaximalNumberOfIterations(); + } + gmm::iteration iter(storm::utility::convertNumber(env.solver().gmmxx().getPrecision()), 0, maxIter); // Invoke gmm with the corresponding settings if (method == GmmxxLinearEquationSolverMethod::Bicgstab) {