Browse Source

only expanding epsilon in sound power methods when the absolute convergence criterion is used

tempestpy_adaptions
dehnert 7 years ago
parent
commit
99832d2694
  1. 6
      src/storm/solver/IterativeMinMaxLinearEquationSolver.cpp
  2. 6
      src/storm/solver/NativeLinearEquationSolver.cpp
  3. 15
      src/storm/solver/SolverGuarantee.h

6
src/storm/solver/IterativeMinMaxLinearEquationSolver.cpp

@ -399,6 +399,10 @@ namespace storm {
Status status = Status::InProgress;
ValueType upperDiff;
ValueType lowerDiff;
ValueType precision = static_cast<ValueType>(this->getSettings().getPrecision());
if (!this->getSettings().getRelativeTerminationCriterion()) {
precision *= storm::utility::convertNumber<ValueType>(2.0);
}
while (status == Status::InProgress && iterations < this->getSettings().getMaximalNumberOfIterations()) {
// In every thousandth iteration, we improve both bounds.
if (iterations % 1000 == 0) {
@ -443,7 +447,7 @@ namespace storm {
}
// Determine whether the method converged.
if (storm::utility::vector::equalModuloPrecision<ValueType>(*lowerX, *upperX, storm::utility::convertNumber<ValueType>(2.0) * this->getSettings().getPrecision(), this->getSettings().getRelativeTerminationCriterion())) {
if (storm::utility::vector::equalModuloPrecision<ValueType>(*lowerX, *upperX, precision, this->getSettings().getRelativeTerminationCriterion())) {
status = Status::Converged;
}

6
src/storm/solver/NativeLinearEquationSolver.cpp

@ -448,6 +448,10 @@ namespace storm {
bool doConvergenceCheck = false;
ValueType upperDiff;
ValueType lowerDiff;
ValueType precision = static_cast<ValueType>(this->getSettings().getPrecision());
if (!this->getSettings().getRelativeTerminationCriterion()) {
precision *= storm::utility::convertNumber<ValueType>(2.0);
}
while (!converged && !terminate && iterations < this->getSettings().getMaximalNumberOfIterations()) {
// Remember in which directions we took steps in this iteration.
bool lowerStep = false;
@ -510,7 +514,7 @@ namespace storm {
// Now check if the process already converged within our precision. Note that we double the target
// precision here. Doing so, we need to take the means of the lower and upper values later to guarantee
// the original precision.
converged = storm::utility::vector::equalModuloPrecision<ValueType>(*lowerX, *upperX, storm::utility::convertNumber<ValueType>(2.0) * static_cast<ValueType>(this->getSettings().getPrecision()), this->getSettings().getRelativeTerminationCriterion());
converged = storm::utility::vector::equalModuloPrecision<ValueType>(*lowerX, *upperX, precision, this->getSettings().getRelativeTerminationCriterion());
if (lowerStep) {
terminate |= this->terminateNow(*lowerX, SolverGuarantee::GreaterOrEqual);
}

15
src/storm/solver/SolverGuarantee.h

@ -0,0 +1,15 @@
#pragma once
#include <ostream>
namespace storm {
namespace solver {
enum class SolverGuarantee {
GreaterOrEqual, LessOrEqual, None
};
std::ostream& operator<<(std::ostream& out, SolverGuarantee const& guarantee);
}
}
Loading…
Cancel
Save