Browse Source

Printing the number of performed iterations

tempestpy_adaptions
TimQu 7 years ago
parent
commit
b5399d0596
  1. 5
      src/storm/modelchecker/multiobjective/pcaa/StandardPcaaWeightVectorChecker.cpp
  2. 8
      src/storm/modelchecker/multiobjective/pcaa/StandardPcaaWeightVectorChecker.h
  3. 11
      src/storm/solver/AbstractEquationSolver.h
  4. 3
      src/storm/solver/IterativeMinMaxLinearEquationSolver.cpp
  5. 2
      src/storm/solver/NativeLinearEquationSolver.cpp
  6. 8
      src/storm/solver/TopologicalLinearEquationSolver.cpp
  7. 7
      src/storm/solver/TopologicalMinMaxLinearEquationSolver.cpp

5
src/storm/modelchecker/multiobjective/pcaa/StandardPcaaWeightVectorChecker.cpp

@ -194,7 +194,8 @@ namespace storm {
std::fill(ecQuotient->auxStateValues.begin(), ecQuotient->auxStateValues.end(), storm::utility::zero<ValueType>()); std::fill(ecQuotient->auxStateValues.begin(), ecQuotient->auxStateValues.end(), storm::utility::zero<ValueType>());
solver->solveEquations(env, ecQuotient->auxStateValues, ecQuotient->auxChoiceValues); solver->solveEquations(env, ecQuotient->auxStateValues, ecQuotient->auxChoiceValues);
this->overallPerformedIterations += solver->overallPerformedIterations;
solver->overallPerformedIterations = 0;
this->weightedResult = std::vector<ValueType>(transitionMatrix.getRowGroupCount()); this->weightedResult = std::vector<ValueType>(transitionMatrix.getRowGroupCount());
transformReducedSolutionToOriginalModel(ecQuotient->matrix, ecQuotient->auxStateValues, solver->getSchedulerChoices(), ecQuotient->ecqToOriginalChoiceMapping, ecQuotient->originalToEcqStateMapping, this->weightedResult, this->optimalChoices); transformReducedSolutionToOriginalModel(ecQuotient->matrix, ecQuotient->auxStateValues, solver->getSchedulerChoices(), ecQuotient->ecqToOriginalChoiceMapping, ecQuotient->originalToEcqStateMapping, this->weightedResult, this->optimalChoices);
@ -277,6 +278,8 @@ namespace storm {
STORM_LOG_THROW(req.empty(), storm::exceptions::UncheckedRequirementException, "At least one requirement of the LinearEquationSolver was not met."); STORM_LOG_THROW(req.empty(), storm::exceptions::UncheckedRequirementException, "At least one requirement of the LinearEquationSolver was not met.");
solver->solveEquations(env, x, b); solver->solveEquations(env, x, b);
this->overallPerformedIterations += solver->overallPerformedIterations;
solver->overallPerformedIterations = 0;
// Set the result for this objective accordingly // Set the result for this objective accordingly
storm::utility::vector::setVectorValues<ValueType>(objectiveResults[objIndex], maybeStates, x); storm::utility::vector::setVectorValues<ValueType>(objectiveResults[objIndex], maybeStates, x);

8
src/storm/modelchecker/multiobjective/pcaa/StandardPcaaWeightVectorChecker.h

@ -37,7 +37,13 @@ namespace storm {
StandardPcaaWeightVectorChecker(SparseMultiObjectivePreprocessorResult<SparseModelType> const& preprocessorResult); StandardPcaaWeightVectorChecker(SparseMultiObjectivePreprocessorResult<SparseModelType> const& preprocessorResult);
virtual ~StandardPcaaWeightVectorChecker() = default;
virtual ~StandardPcaaWeightVectorChecker() {
if (overallPerformedIterations != 0) {
std::cout << "PERFORMEDITERATIONS: " << overallPerformedIterations << std::endl;
}
}
mutable uint64_t overallPerformedIterations = 0;
/*! /*!
* - computes the optimal expected reward w.r.t. the weighted sum of the rewards of the individual objectives * - computes the optimal expected reward w.r.t. the weighted sum of the rewards of the individual objectives

11
src/storm/solver/AbstractEquationSolver.h

@ -3,7 +3,7 @@
#include <memory> #include <memory>
#include <chrono> #include <chrono>
#include <iostream>
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include "storm/solver/TerminationCondition.h" #include "storm/solver/TerminationCondition.h"
@ -17,6 +17,15 @@ namespace storm {
public: public:
AbstractEquationSolver(); AbstractEquationSolver();
virtual ~AbstractEquationSolver() {
if (overallPerformedIterations != 0) {
std::cout << "PERFORMEDITERATIONS: " << overallPerformedIterations << std::endl;
}
}
mutable uint64_t overallPerformedIterations = 0;
/*! /*!
* Sets a custom termination condition that is used together with the regular termination condition of the * Sets a custom termination condition that is used together with the regular termination condition of the
* solver. * solver.

3
src/storm/solver/IterativeMinMaxLinearEquationSolver.cpp

@ -582,6 +582,7 @@ namespace storm {
} }
reportStatus(status, iterations); reportStatus(status, iterations);
this->overallPerformedIterations += iterations;
// We take the means of the lower and upper bound so we guarantee the desired precision. // We take the means of the lower and upper bound so we guarantee the desired precision.
ValueType two = storm::utility::convertNumber<ValueType>(2.0); ValueType two = storm::utility::convertNumber<ValueType>(2.0);
@ -1035,6 +1036,8 @@ namespace storm {
reportStatus(status, iterations); reportStatus(status, iterations);
this->overallPerformedIterations += iterations;
if (!this->isCachingEnabled()) { if (!this->isCachingEnabled()) {
clearCache(); clearCache();
} }

2
src/storm/solver/NativeLinearEquationSolver.cpp

@ -549,6 +549,7 @@ namespace storm {
if (!this->isCachingEnabled()) { if (!this->isCachingEnabled()) {
clearCache(); clearCache();
} }
this->overallPerformedIterations += iterations;
this->logIterations(converged, terminate, iterations); this->logIterations(converged, terminate, iterations);
@ -734,6 +735,7 @@ namespace storm {
if (!this->isCachingEnabled()) { if (!this->isCachingEnabled()) {
clearCache(); clearCache();
} }
this->overallPerformedIterations += iterations;
this->logIterations(converged, terminate, iterations); this->logIterations(converged, terminate, iterations);
STORM_LOG_WARN_COND(hasMinValueBound && hasMaxValueBound, "Could not compute lower or upper bound within the given number of iterations."); STORM_LOG_WARN_COND(hasMinValueBound && hasMaxValueBound, "Could not compute lower or upper bound within the given number of iterations.");

8
src/storm/solver/TopologicalLinearEquationSolver.cpp

@ -91,6 +91,7 @@ namespace storm {
for (auto const& scc : *this->sortedSccDecomposition) { for (auto const& scc : *this->sortedSccDecomposition) {
if (scc.isTrivial()) { if (scc.isTrivial()) {
returnValue = solveTrivialScc(*scc.begin(), x, b) && returnValue; returnValue = solveTrivialScc(*scc.begin(), x, b) && returnValue;
++this->overallPerformedIterations;
} else { } else {
sccAsBitVector.clear(); sccAsBitVector.clear();
for (auto const& state : scc) { for (auto const& state : scc) {
@ -101,10 +102,17 @@ namespace storm {
} }
} }
if (this->sccSolver) {
this->overallPerformedIterations += this->sccSolver->overallPerformedIterations;
this->sccSolver->overallPerformedIterations = 0;
}
if (!this->isCachingEnabled()) { if (!this->isCachingEnabled()) {
clearCache(); clearCache();
} }
return returnValue; return returnValue;
} }

7
src/storm/solver/TopologicalMinMaxLinearEquationSolver.cpp

@ -109,6 +109,7 @@ namespace storm {
for (auto const& scc : *this->sortedSccDecomposition) { for (auto const& scc : *this->sortedSccDecomposition) {
if (scc.isTrivial()) { if (scc.isTrivial()) {
returnValue = solveTrivialScc(*scc.begin(), dir, x, b) && returnValue; returnValue = solveTrivialScc(*scc.begin(), dir, x, b) && returnValue;
++this->overallPerformedIterations;
} else { } else {
sccRowGroupsAsBitVector.clear(); sccRowGroupsAsBitVector.clear();
sccRowsAsBitVector.clear(); sccRowsAsBitVector.clear();
@ -132,6 +133,12 @@ namespace storm {
} }
} }
if (this->sccSolver) {
this->overallPerformedIterations += this->sccSolver->overallPerformedIterations;
this->sccSolver->overallPerformedIterations = 0;
}
if (!this->isCachingEnabled()) { if (!this->isCachingEnabled()) {
clearCache(); clearCache();
} }

Loading…
Cancel
Save