Browse Source

fixing quick power iteration

main
TimQu 8 years ago
parent
commit
4484cea360
  1. 13
      src/storm/solver/NativeLinearEquationSolver.cpp

13
src/storm/solver/NativeLinearEquationSolver.cpp

@ -580,8 +580,6 @@ namespace storm {
bool converged = false; bool converged = false;
bool terminate = false; bool terminate = false;
uint64_t iterations = 0; uint64_t iterations = 0;
bool doConvergenceCheck = true;
bool useDiffs = this->hasRelevantValues();
ValueType precision = storm::utility::convertNumber<ValueType>(env.solver().native().getPrecision()); ValueType precision = storm::utility::convertNumber<ValueType>(env.solver().native().getPrecision());
ValueType lowerValueBound, upperValueBound; ValueType lowerValueBound, upperValueBound;
bool relative = env.solver().native().getRelativeTerminationCriterion(); bool relative = env.solver().native().getRelativeTerminationCriterion();
@ -590,25 +588,25 @@ namespace storm {
} }
uint64_t maxIter = env.solver().native().getMaximalNumberOfIterations(); uint64_t maxIter = env.solver().native().getMaximalNumberOfIterations();
this->startMeasureProgress(); this->startMeasureProgress();
auto firstProb1EntryIt = stepBoundedStayProbabilities->begin(); uint64_t firstProb1Entry = 0;
while (!converged && !terminate && iterations < maxIter) { while (!converged && !terminate && iterations < maxIter) {
this->multiplier.multAdd(*this->A, *stepBoundedValues, &b, *tmp); this->multiplier.multAdd(*this->A, *stepBoundedValues, &b, *tmp);
std::swap(tmp, stepBoundedValues); std::swap(tmp, stepBoundedValues);
this->multiplier.multAdd(*this->A, *stepBoundedStayProbabilities, nullptr, *tmp); this->multiplier.multAdd(*this->A, *stepBoundedStayProbabilities, nullptr, *tmp);
std::swap(tmp, stepBoundedStayProbabilities); std::swap(tmp, stepBoundedStayProbabilities);
for (; firstProb1EntryIt != stepBoundedStayProbabilities->end(); ++firstProb1EntryIt) { for (; firstProb1Entry != stepBoundedStayProbabilities->size(); ++firstProb1Entry) {
static_assert(NumberTraits<ValueType>::IsExact || std::is_same<ValueType, double>::value, "Considered ValueType not handled."); static_assert(NumberTraits<ValueType>::IsExact || std::is_same<ValueType, double>::value, "Considered ValueType not handled.");
if (NumberTraits<ValueType>::IsExact) { if (NumberTraits<ValueType>::IsExact) {
if (storm::utility::isOne(*firstProb1EntryIt)) { if (storm::utility::isOne(stepBoundedStayProbabilities->at(firstProb1Entry))) {
break; break;
} }
} else { } else {
if (storm::utility::isAlmostOne(storm::utility::convertNumber<double>(*firstProb1EntryIt))) { if (storm::utility::isAlmostOne(storm::utility::convertNumber<double>(stepBoundedStayProbabilities->at(firstProb1Entry)))) {
break; break;
} }
} }
} }
if (firstProb1EntryIt == stepBoundedStayProbabilities->end()) { if (firstProb1Entry == stepBoundedStayProbabilities->size()) {
auto valIt = stepBoundedValues->begin(); auto valIt = stepBoundedValues->begin();
auto valIte = stepBoundedValues->end(); auto valIte = stepBoundedValues->end();
auto probIt = stepBoundedStayProbabilities->begin(); auto probIt = stepBoundedStayProbabilities->begin();
@ -625,6 +623,7 @@ namespace storm {
} }
STORM_LOG_ASSERT(!relative, "Relative termination criterion not implemented currently."); STORM_LOG_ASSERT(!relative, "Relative termination criterion not implemented currently.");
converged = largestStayProb * (upperValueBound - lowerValueBound) < precision; converged = largestStayProb * (upperValueBound - lowerValueBound) < precision;
STORM_LOG_INFO_COND(!converged, "Lower value bound: " << lowerValueBound << " Upper value bound: " << upperValueBound << " Largest stay prob.: " << largestStayProb);
} }
// Potentially show progress. // Potentially show progress.

|||||||
100:0
Loading…
Cancel
Save