Browse Source

Renamed ConstTemplates to constants. Removed all calls to constGetZero, constGetOne and constGetInfinity by the new names. Created performance test for bit vector iteration.

Former-commit-id: 6d90ec961e
tempestpy_adaptions
dehnert 11 years ago
parent
commit
84bd5f3b40
  1. 2
      src/adapters/ExplicitModelAdapter.h
  2. 2
      src/adapters/GmmxxAdapter.h
  3. 2
      src/adapters/StormAdapter.h
  4. 4
      src/formula/Csl/ProbabilisticBoundOperator.h
  5. 2
      src/formula/Csl/SteadyStateBoundOperator.h
  6. 2
      src/formula/Prctl/ProbabilisticBoundOperator.h
  7. 2
      src/formula/Prctl/RewardBoundOperator.h
  8. 2
      src/formula/abstract/PathBoundOperator.h
  9. 4
      src/formula/abstract/ProbabilisticBoundOperator.h
  10. 4
      src/formula/abstract/RewardBoundOperator.h
  11. 2
      src/formula/abstract/StateBoundOperator.h
  12. 2
      src/formula/abstract/SteadyStateBoundOperator.h
  13. 38
      src/modelchecker/csl/SparseMarkovAutomatonCslModelChecker.h
  14. 2
      src/modelchecker/prctl/EigenDtmcPrctlModelChecker.h
  15. 18
      src/modelchecker/prctl/SparseDtmcPrctlModelChecker.h
  16. 16
      src/modelchecker/prctl/SparseMdpPrctlModelChecker.h
  17. 2
      src/models/AbstractDeterministicModel.h
  18. 2
      src/models/MarkovAutomaton.h
  19. 2
      src/models/Mdp.h
  20. 2
      src/parser/CslParser.cpp
  21. 8
      src/parser/DeterministicSparseTransitionParser.cpp
  22. 2
      src/parser/LtlParser.cpp
  23. 2
      src/parser/PrctlParser.cpp
  24. 2
      src/solver/GmmxxLinearEquationSolver.h
  25. 4
      src/storage/LabeledValues.h
  26. 37
      src/storage/SparseMatrix.cpp
  27. 16
      src/storage/SparseMatrix.h
  28. 38
      src/utility/constants.h
  29. 10
      src/utility/graph.h
  30. 2
      src/utility/matrix.h
  31. 4
      src/utility/vector.h
  32. 15
      test/performance/storage/BitVectorTest.cpp

2
src/adapters/ExplicitModelAdapter.h

@ -480,7 +480,7 @@ namespace storm {
// requested and issue an error otherwise.
if (totalNumberOfChoices == 0) {
if (storm::settings::Settings::getInstance()->isSet("fixDeadlocks")) {
transitionMatrix.insertNextValue(currentRow, currentState, storm::utility::constGetOne<ValueType>(), true);
transitionMatrix.insertNextValue(currentRow, currentState, storm::utility::constantOne<ValueType>(), true);
if (transitionRewards.size() > 0) {
transitionRewardMatrix.insertEmptyRow(true);
}

2
src/adapters/GmmxxAdapter.h

@ -10,6 +10,8 @@
#include <new>
#include "gmm/gmm_matrix.h"
#include "src/storage/SparseMatrix.h"
#include "src/utility/ConversionHelper.h"

2
src/adapters/StormAdapter.h

@ -8,6 +8,8 @@
#ifndef STORM_ADAPTERS_STORMADAPTER_H_
#define STORM_ADAPTERS_STORMADAPTER_H_
#include "gmm/gmm_matrix.h"
#include "Eigen/Sparse"
#include "src/storage/SparseMatrix.h"
#include "log4cplus/logger.h"

4
src/formula/Csl/ProbabilisticBoundOperator.h

@ -11,7 +11,7 @@
#include "AbstractStateFormula.h"
#include "AbstractPathFormula.h"
#include "src/formula/abstract/ProbabilisticBoundOperator.h"
#include "utility/ConstTemplates.h"
#include "utility/constants.h"
namespace storm {
namespace property {
@ -61,7 +61,7 @@ public:
* Empty constructor
*/
ProbabilisticBoundOperator() : storm::property::abstract::ProbabilisticBoundOperator<T, AbstractPathFormula<T>>
(LESS_EQUAL, storm::utility::constGetZero<T>(), nullptr) {
(LESS_EQUAL, storm::utility::constantZero<T>(), nullptr) {
// Intentionally left empty
}

2
src/formula/Csl/SteadyStateBoundOperator.h

@ -62,7 +62,7 @@ public:
* Empty constructor
*/
SteadyStateBoundOperator() : storm::property::abstract::SteadyStateBoundOperator<T, AbstractStateFormula<T>>
(LESS_EQUAL, storm::utility::constGetZero<T>(), nullptr) {
(LESS_EQUAL, storm::utility::constantZero<T>(), nullptr) {
// Intentionally left empty
}

2
src/formula/Prctl/ProbabilisticBoundOperator.h

@ -11,7 +11,7 @@
#include "AbstractStateFormula.h"
#include "AbstractPathFormula.h"
#include "src/formula/abstract/ProbabilisticBoundOperator.h"
#include "utility/ConstTemplates.h"
#include "utility/constants.h"
namespace storm {
namespace property {

2
src/formula/Prctl/RewardBoundOperator.h

@ -11,7 +11,7 @@
#include "AbstractPathFormula.h"
#include "AbstractStateFormula.h"
#include "src/formula/abstract/RewardBoundOperator.h"
#include "utility/ConstTemplates.h"
#include "utility/constants.h"
namespace storm {
namespace property {

2
src/formula/abstract/PathBoundOperator.h

@ -15,7 +15,7 @@
#include "src/formula/abstract/OptimizingOperator.h"
#include "src/utility/ConstTemplates.h"
#include "src/utility/constants.h"
namespace storm {

4
src/formula/abstract/ProbabilisticBoundOperator.h

@ -11,7 +11,7 @@
#include "src/formula/abstract/AbstractFormula.h"
#include "src/formula/abstract/PathBoundOperator.h"
#include "src/formula/abstract/OptimizingOperator.h"
#include "utility/ConstTemplates.h"
#include "utility/constants.h"
namespace storm {
namespace property {
@ -53,7 +53,7 @@ public:
* Empty constructor
*/
ProbabilisticBoundOperator() : PathBoundOperator<T, FormulaType>
(LESS_EQUAL, storm::utility::constGetZero<T>(), nullptr) {
(LESS_EQUAL, storm::utility::constantZero<T>(), nullptr) {
// Intentionally left empty
}

4
src/formula/abstract/RewardBoundOperator.h

@ -9,7 +9,7 @@
#define STORM_FORMULA_ABSTRACT_REWARDBOUNDOPERATOR_H_
#include "PathBoundOperator.h"
#include "utility/ConstTemplates.h"
#include "utility/constants.h"
namespace storm {
namespace property {
@ -47,7 +47,7 @@ public:
/*!
* Empty constructor
*/
RewardBoundOperator() : PathBoundOperator<T, FormulaType>(LESS_EQUAL, storm::utility::constGetZero<T>(), nullptr) {
RewardBoundOperator() : PathBoundOperator<T, FormulaType>(LESS_EQUAL, storm::utility::constantZero<T>(), nullptr) {
// Intentionally left empty
}

2
src/formula/abstract/StateBoundOperator.h

@ -12,7 +12,7 @@
#include "src/formula/abstract/AbstractFormula.h"
#include "src/formula/AbstractFormulaChecker.h"
#include "src/formula/ComparisonType.h"
#include "src/utility/ConstTemplates.h"
#include "src/utility/constants.h"
namespace storm {
namespace property {

2
src/formula/abstract/SteadyStateBoundOperator.h

@ -41,7 +41,7 @@ public:
* Empty constructor
*/
SteadyStateBoundOperator() : StateBoundOperator<T, FormulaType>
(LESS_EQUAL, storm::utility::constGetZero<T>(), nullptr) {
(LESS_EQUAL, storm::utility::constantZero<T>(), nullptr) {
// Intentionally left empty
}

38
src/modelchecker/csl/SparseMarkovAutomatonCslModelChecker.h

@ -98,9 +98,9 @@ namespace storm {
for (auto element : row) {
ValueType eTerm = std::exp(-exitRates[state] * delta);
if (element.column() == rowIndex) {
element.value() = (storm::utility::constGetOne<ValueType>() - eTerm) * element.value() + eTerm;
element.value() = (storm::utility::constantOne<ValueType>() - eTerm) * element.value() + eTerm;
} else {
element.value() = (storm::utility::constGetOne<ValueType>() - eTerm) * element.value();
element.value() = (storm::utility::constantOne<ValueType>() - eTerm) * element.value();
}
}
++rowIndex;
@ -125,7 +125,7 @@ namespace storm {
std::vector<ValueType> bMarkovianFixed;
bMarkovianFixed.reserve(markovianNonGoalStates.getNumberOfSetBits());
for (auto state : markovianNonGoalStates) {
bMarkovianFixed.push_back(storm::utility::constGetZero<ValueType>());
bMarkovianFixed.push_back(storm::utility::constantZero<ValueType>());
typename storm::storage::SparseMatrix<ValueType>::Rows row = transitionMatrix.getRow(nondeterministicChoiceIndices[state]);
for (auto element : row) {
@ -175,7 +175,7 @@ namespace storm {
}
// Check whether the given bounds were valid.
if (lowerBound < storm::utility::constGetZero<ValueType>() || upperBound < storm::utility::constGetZero<ValueType>() || upperBound < lowerBound) {
if (lowerBound < storm::utility::constantZero<ValueType>() || upperBound < storm::utility::constantZero<ValueType>() || upperBound < lowerBound) {
throw storm::exceptions::InvalidArgumentException() << "Illegal interval [";
}
@ -204,14 +204,14 @@ namespace storm {
computeBoundedReachability(min, transitionMatrix, nondeterministicChoiceIndices, exitRates, markovianStates, goalStates, markovianNonGoalStates, probabilisticNonGoalStates, vMarkovian, vProbabilistic, delta, numberOfSteps);
// (4) If the lower bound of interval was non-zero, we need to take the current values as the starting values for a subsequent value iteration.
if (lowerBound != storm::utility::constGetZero<ValueType>()) {
if (lowerBound != storm::utility::constantZero<ValueType>()) {
std::vector<ValueType> vAllProbabilistic((~markovianStates).getNumberOfSetBits());
std::vector<ValueType> vAllMarkovian(markovianStates.getNumberOfSetBits());
// Create the starting value vectors for the next value iteration based on the results of the previous one.
storm::utility::vector::setVectorValues<ValueType>(vAllProbabilistic, goalStates % ~markovianStates, storm::utility::constGetOne<ValueType>());
storm::utility::vector::setVectorValues<ValueType>(vAllProbabilistic, goalStates % ~markovianStates, storm::utility::constantOne<ValueType>());
storm::utility::vector::setVectorValues<ValueType>(vAllProbabilistic, ~goalStates % ~markovianStates, vProbabilistic);
storm::utility::vector::setVectorValues<ValueType>(vAllMarkovian, goalStates % markovianStates, storm::utility::constGetOne<ValueType>());
storm::utility::vector::setVectorValues<ValueType>(vAllMarkovian, goalStates % markovianStates, storm::utility::constantOne<ValueType>());
storm::utility::vector::setVectorValues<ValueType>(vAllMarkovian, ~goalStates % markovianStates, vMarkovian);
// Compute the number of steps to reach the target interval.
@ -231,7 +231,7 @@ namespace storm {
} else {
// Create the result vector out of 1_G, vProbabilistic and vMarkovian and return it.
std::vector<ValueType> result(this->getModel().getNumberOfStates());
storm::utility::vector::setVectorValues<ValueType>(result, goalStates, storm::utility::constGetOne<ValueType>());
storm::utility::vector::setVectorValues<ValueType>(result, goalStates, storm::utility::constantOne<ValueType>());
storm::utility::vector::setVectorValues(result, probabilisticNonGoalStates, vProbabilistic);
storm::utility::vector::setVectorValues(result, markovianNonGoalStates, vMarkovian);
return result;
@ -246,12 +246,12 @@ namespace storm {
// If there are no goal states, we avoid the computation and directly return zero.
if (goalStates.empty()) {
return std::vector<ValueType>(this->getModel().getNumberOfStates(), storm::utility::constGetZero<ValueType>());
return std::vector<ValueType>(this->getModel().getNumberOfStates(), storm::utility::constantZero<ValueType>());
}
// Likewise, if all bits are set, we can avoid the computation and set.
if ((~goalStates).empty()) {
return std::vector<ValueType>(this->getModel().getNumberOfStates(), storm::utility::constGetOne<ValueType>());
return std::vector<ValueType>(this->getModel().getNumberOfStates(), storm::utility::constantOne<ValueType>());
}
// Start by decomposing the Markov automaton into its MECs.
@ -312,7 +312,7 @@ namespace storm {
for (uint_fast64_t choice = nondeterministicChoiceIndices[state]; choice < nondeterministicChoiceIndices[state + 1]; ++choice, ++currentChoice) {
std::vector<ValueType> auxiliaryStateToProbabilityMap(mecDecomposition.size());
b.push_back(storm::utility::constGetZero<ValueType>());
b.push_back(storm::utility::constantZero<ValueType>());
typename storm::storage::SparseMatrix<ValueType>::Rows row = transitionMatrix.getRow(choice);
for (auto element : row) {
@ -349,7 +349,7 @@ namespace storm {
// If the choice is not contained in the MEC itself, we have to add a similar distribution to the auxiliary state.
if (!choicesInMec.contains(choice)) {
b.push_back(storm::utility::constGetZero<ValueType>());
b.push_back(storm::utility::constantZero<ValueType>());
typename storm::storage::SparseMatrix<ValueType>::Rows row = transitionMatrix.getRow(choice);
for (auto element : row) {
@ -413,8 +413,8 @@ namespace storm {
std::vector<ValueType> checkExpectedTime(bool min, storm::storage::BitVector const& goalStates) const {
// Reduce the problem of computing the expected time to computing expected rewards where the rewards
// for all probabilistic states are zero and the reward values of Markovian states is 1.
std::vector<ValueType> rewardValues(this->getModel().getNumberOfStates(), storm::utility::constGetZero<ValueType>());
storm::utility::vector::setVectorValues(rewardValues, this->getModel().getMarkovianStates(), storm::utility::constGetOne<ValueType>());
std::vector<ValueType> rewardValues(this->getModel().getNumberOfStates(), storm::utility::constantZero<ValueType>());
storm::utility::vector::setVectorValues(rewardValues, this->getModel().getMarkovianStates(), storm::utility::constantOne<ValueType>());
return this->computeExpectedRewards(min, goalStates, rewardValues);
}
@ -464,9 +464,9 @@ namespace storm {
}
variables.push_back(lraValueVariableIndex);
coefficients.push_back(storm::utility::constGetOne<ValueType>() / exitRates[state]);
coefficients.push_back(storm::utility::constantOne<ValueType>() / exitRates[state]);
solver->addConstraint("state" + std::to_string(state), variables, coefficients, min ? storm::solver::LpSolver::LESS_EQUAL : storm::solver::LpSolver::GREATER_EQUAL, goalStates.get(state) ? storm::utility::constGetOne<ValueType>() / exitRates[state] : storm::utility::constGetZero<ValueType>());
solver->addConstraint("state" + std::to_string(state), variables, coefficients, min ? storm::solver::LpSolver::LESS_EQUAL : storm::solver::LpSolver::GREATER_EQUAL, goalStates.get(state) ? storm::utility::constantOne<ValueType>() / exitRates[state] : storm::utility::constantZero<ValueType>());
} else {
// For probabilistic states, we want to add the constraint x_s <= sum P(s, a, s') * x_s' where a is the current action
// and the sum ranges over all states s'.
@ -483,7 +483,7 @@ namespace storm {
coefficients.push_back(-element.value());
}
solver->addConstraint("state" + std::to_string(state), variables, coefficients, min ? storm::solver::LpSolver::LESS_EQUAL : storm::solver::LpSolver::GREATER_EQUAL, storm::utility::constGetZero<ValueType>());
solver->addConstraint("state" + std::to_string(state), variables, coefficients, min ? storm::solver::LpSolver::LESS_EQUAL : storm::solver::LpSolver::GREATER_EQUAL, storm::utility::constantZero<ValueType>());
}
}
}
@ -582,8 +582,8 @@ namespace storm {
// Set values of resulting vector according to previous result and return the result.
storm::utility::vector::setVectorValues<ValueType>(result, maybeStates, x);
storm::utility::vector::setVectorValues(result, goalStates, storm::utility::constGetZero<ValueType>());
storm::utility::vector::setVectorValues(result, infinityStates, storm::utility::constGetInfinity<ValueType>());
storm::utility::vector::setVectorValues(result, goalStates, storm::utility::constantZero<ValueType>());
storm::utility::vector::setVectorValues(result, infinityStates, storm::utility::constantInfinity<ValueType>());
return result;
}

2
src/modelchecker/prctl/EigenDtmcPrctlModelChecker.h

@ -12,7 +12,7 @@
#include "src/models/Dtmc.h"
#include "src/modelchecker/prctl/SparseDtmcPrctlModelChecker.h"
#include "src/utility/ConstTemplates.h"
#include "src/utility/constants.h"
#include "src/exceptions/NoConvergenceException.h"
#include "Eigen/Sparse"

18
src/modelchecker/prctl/SparseDtmcPrctlModelChecker.h

@ -134,7 +134,7 @@ public:
// Create the vector with which to multiply.
std::vector<Type> subresult(statesWithProbabilityGreater0.getNumberOfSetBits());
storm::utility::vector::setVectorValues(subresult, rightStatesInReducedSystem, storm::utility::constGetOne<Type>());
storm::utility::vector::setVectorValues(subresult, rightStatesInReducedSystem, storm::utility::constantOne<Type>());
// Perform the matrix vector multiplication as often as required by the formula bound.
if (linearEquationSolver != nullptr) {
@ -145,7 +145,7 @@ public:
// Set the values of the resulting vector accordingly.
storm::utility::vector::setVectorValues(result, statesWithProbabilityGreater0, subresult);
storm::utility::vector::setVectorValues<Type>(result, ~statesWithProbabilityGreater0, storm::utility::constGetZero<Type>());
storm::utility::vector::setVectorValues<Type>(result, ~statesWithProbabilityGreater0, storm::utility::constantZero<Type>());
}
return result;
@ -168,7 +168,7 @@ public:
// Create the vector with which to multiply and initialize it correctly.
std::vector<Type> result(this->getModel().getNumberOfStates());
storm::utility::vector::setVectorValues(result, nextStates, storm::utility::constGetOne<Type>());
storm::utility::vector::setVectorValues(result, nextStates, storm::utility::constantOne<Type>());
// Perform one single matrix-vector multiplication.
if (linearEquationSolver != nullptr) {
@ -321,8 +321,8 @@ public:
}
// Set values of resulting vector that are known exactly.
storm::utility::vector::setVectorValues<Type>(result, statesWithProbability0, storm::utility::constGetZero<Type>());
storm::utility::vector::setVectorValues<Type>(result, statesWithProbability1, storm::utility::constGetOne<Type>());
storm::utility::vector::setVectorValues<Type>(result, statesWithProbability0, storm::utility::constantZero<Type>());
storm::utility::vector::setVectorValues<Type>(result, statesWithProbability1, storm::utility::constantOne<Type>());
return result;
}
@ -444,7 +444,7 @@ public:
<< " No exact rewards were computed.");
// Set the values for all maybe-states to 1 to indicate that their reward values
// are neither 0 nor infinity.
storm::utility::vector::setVectorValues<Type>(result, maybeStates, storm::utility::constGetOne<Type>());
storm::utility::vector::setVectorValues<Type>(result, maybeStates, storm::utility::constantOne<Type>());
} else {
// In this case we have to compute the reward values for the remaining states.
// We can eliminate the rows and columns from the original transition probability matrix.
@ -455,7 +455,7 @@ public:
// Initialize the x vector with 1 for each element. This is the initial guess for
// the iterative solvers.
std::vector<Type> x(submatrix.getColumnCount(), storm::utility::constGetOne<Type>());
std::vector<Type> x(submatrix.getColumnCount(), storm::utility::constantOne<Type>());
// Prepare the right-hand side of the equation system.
std::vector<Type> b(submatrix.getRowCount());
@ -495,8 +495,8 @@ public:
}
// Set values of resulting vector that are known exactly.
storm::utility::vector::setVectorValues(result, targetStates, storm::utility::constGetZero<Type>());
storm::utility::vector::setVectorValues(result, infinityStates, storm::utility::constGetInfinity<Type>());
storm::utility::vector::setVectorValues(result, targetStates, storm::utility::constantZero<Type>());
storm::utility::vector::setVectorValues(result, infinityStates, storm::utility::constantInfinity<Type>());
return result;
}

16
src/modelchecker/prctl/SparseMdpPrctlModelChecker.h

@ -126,13 +126,13 @@ namespace storm {
// Create the vector with which to multiply.
std::vector<Type> subresult(statesWithProbabilityGreater0.getNumberOfSetBits());
storm::utility::vector::setVectorValues(subresult, rightStatesInReducedSystem, storm::utility::constGetOne<Type>());
storm::utility::vector::setVectorValues(subresult, rightStatesInReducedSystem, storm::utility::constantOne<Type>());
this->nondeterministicLinearEquationSolver->performMatrixVectorMultiplication(this->minimumOperatorStack.top(), submatrix, subresult, subNondeterministicChoiceIndices, nullptr, stepBound);
// Set the values of the resulting vector accordingly.
storm::utility::vector::setVectorValues(result, statesWithProbabilityGreater0, subresult);
storm::utility::vector::setVectorValues(result, ~statesWithProbabilityGreater0, storm::utility::constGetZero<Type>());
storm::utility::vector::setVectorValues(result, ~statesWithProbabilityGreater0, storm::utility::constantZero<Type>());
}
return result;
@ -167,7 +167,7 @@ namespace storm {
virtual std::vector<Type> checkNext(storm::storage::BitVector const& nextStates, bool qualitative) const {
// Create the vector with which to multiply and initialize it correctly.
std::vector<Type> result(this->getModel().getNumberOfStates());
storm::utility::vector::setVectorValues(result, nextStates, storm::utility::constGetOne<Type>());
storm::utility::vector::setVectorValues(result, nextStates, storm::utility::constantOne<Type>());
this->nondeterministicLinearEquationSolver->performMatrixVectorMultiplication(this->minimumOperatorStack.top(), this->getModel().getTransitionMatrix(), result, this->getModel().getNondeterministicChoiceIndices());
@ -336,8 +336,8 @@ namespace storm {
}
// Set values of resulting vector that are known exactly.
storm::utility::vector::setVectorValues<Type>(result, statesWithProbability0, storm::utility::constGetZero<Type>());
storm::utility::vector::setVectorValues<Type>(result, statesWithProbability1, storm::utility::constGetOne<Type>());
storm::utility::vector::setVectorValues<Type>(result, statesWithProbability0, storm::utility::constantZero<Type>());
storm::utility::vector::setVectorValues<Type>(result, statesWithProbability1, storm::utility::constantOne<Type>());
// Finally, compute a scheduler that achieves the extramal value.
storm::storage::TotalScheduler scheduler = computeExtremalScheduler(minimize, transitionMatrix, nondeterministicChoiceIndices, result);
@ -477,7 +477,7 @@ namespace storm {
<< " No exact rewards were computed.");
// Set the values for all maybe-states to 1 to indicate that their reward values
// are neither 0 nor infinity.
storm::utility::vector::setVectorValues<Type>(result, maybeStates, storm::utility::constGetOne<Type>());
storm::utility::vector::setVectorValues<Type>(result, maybeStates, storm::utility::constantOne<Type>());
} else {
// In this case we have to compute the reward values for the remaining states.
@ -527,8 +527,8 @@ namespace storm {
}
// Set values of resulting vector that are known exactly.
storm::utility::vector::setVectorValues(result, targetStates, storm::utility::constGetZero<Type>());
storm::utility::vector::setVectorValues(result, infinityStates, storm::utility::constGetInfinity<Type>());
storm::utility::vector::setVectorValues(result, targetStates, storm::utility::constantZero<Type>());
storm::utility::vector::setVectorValues(result, infinityStates, storm::utility::constantInfinity<Type>());
// Finally, compute a scheduler that achieves the extramal value.
storm::storage::TotalScheduler scheduler = computeExtremalScheduler(this->minimumOperatorStack.top(), this->getModel().getTransitionMatrix(), this->getModel().getNondeterministicChoiceIndices(), result, this->getModel().hasStateRewards() ? &this->getModel().getStateRewardVector() : nullptr, this->getModel().hasTransitionRewards() ? &this->getModel().getTransitionRewardMatrix() : nullptr);

2
src/models/AbstractDeterministicModel.h

@ -98,7 +98,7 @@ class AbstractDeterministicModel: public AbstractModel<T> {
auto rowIt = this->transitionMatrix.begin();
for (uint_fast64_t i = 0; i < this->transitionMatrix.getRowCount(); ++i, ++rowIt) {
for (auto transitionIt = rowIt.begin(), transitionIte = rowIt.end(); transitionIt != transitionIte; ++transitionIt) {
if (transitionIt.value() != storm::utility::constGetZero<T>()) {
if (transitionIt.value() != storm::utility::constantZero<T>()) {
if (subsystem == nullptr || subsystem->get(transitionIt.column())) {
outStream << "\t" << i << " -> " << transitionIt.column() << " [ label= \"" << transitionIt.value() << "\" ];" << std::endl;
}

2
src/models/MarkovAutomaton.h

@ -101,7 +101,7 @@ namespace storm {
}
T getMaximalExitRate() const {
T result = storm::utility::constGetZero<T>();
T result = storm::utility::constantZero<T>();
for (auto markovianState : this->markovianStates) {
result = std::max(result, this->exitRates[markovianState]);
}

2
src/models/Mdp.h

@ -173,7 +173,7 @@ public:
// If no choice of the current state may be taken, we insert a self-loop to the state instead.
if (!stateHasValidChoice) {
nondeterministicChoiceIndices.push_back(currentRow);
transitionMatrix.insertNextValue(currentRow, state, storm::utility::constGetOne<T>(), true);
transitionMatrix.insertNextValue(currentRow, state, storm::utility::constantOne<T>(), true);
newChoiceLabeling.emplace_back();
++currentRow;
}

2
src/parser/CslParser.cpp

@ -7,7 +7,7 @@
#include "src/parser/CslParser.h"
#include "src/utility/OsDetection.h"
#include "src/utility/ConstTemplates.h"
#include "src/utility/constants.h"
// If the parser fails due to ill-formed data, this exception is thrown.
#include "src/exceptions/WrongFormatException.h"

8
src/parser/DeterministicSparseTransitionParser.cpp

@ -230,7 +230,7 @@ storm::storage::SparseMatrix<double> DeterministicSparseTransitionParser(std::st
if (lastRow != row) {
if ((lastRow != -1) && (!rowHadDiagonalEntry)) {
if (insertDiagonalEntriesIfMissing && !isRewardMatrix) {
resultMatrix.addNextValue(lastRow, lastRow, storm::utility::constGetZero<double>());
resultMatrix.addNextValue(lastRow, lastRow, storm::utility::constantZero<double>());
LOG4CPLUS_DEBUG(logger, "While parsing " << filename << ": state " << lastRow << " has no transition to itself. Inserted a 0-transition. (1)");
} else if (!isRewardMatrix) {
LOG4CPLUS_WARN(logger, "Warning while parsing " << filename << ": state " << lastRow << " has no transition to itself.");
@ -241,7 +241,7 @@ storm::storage::SparseMatrix<double> DeterministicSparseTransitionParser(std::st
for (int_fast64_t skippedRow = lastRow + 1; skippedRow < row; ++skippedRow) {
hadDeadlocks = true;
if (fixDeadlocks && !isRewardMatrix) {
resultMatrix.addNextValue(skippedRow, skippedRow, storm::utility::constGetOne<double>());
resultMatrix.addNextValue(skippedRow, skippedRow, storm::utility::constantOne<double>());
rowHadDiagonalEntry = true;
LOG4CPLUS_WARN(logger, "Warning while parsing " << filename << ": state " << skippedRow << " has no outgoing transitions. A self-loop was inserted.");
} else if (!isRewardMatrix) {
@ -258,7 +258,7 @@ storm::storage::SparseMatrix<double> DeterministicSparseTransitionParser(std::st
} else if (col > row && !rowHadDiagonalEntry) {
rowHadDiagonalEntry = true;
if (insertDiagonalEntriesIfMissing && !isRewardMatrix) {
resultMatrix.addNextValue(row, row, storm::utility::constGetZero<double>());
resultMatrix.addNextValue(row, row, storm::utility::constantZero<double>());
LOG4CPLUS_DEBUG(logger, "While parsing " << filename << ": state " << row << " has no transition to itself. Inserted a 0-transition. (2)");
} else if (!isRewardMatrix) {
LOG4CPLUS_WARN(logger, "Warning while parsing " << filename << ": state " << row << " has no transition to itself.");
@ -271,7 +271,7 @@ storm::storage::SparseMatrix<double> DeterministicSparseTransitionParser(std::st
if (!rowHadDiagonalEntry) {
if (insertDiagonalEntriesIfMissing && !isRewardMatrix) {
resultMatrix.addNextValue(lastRow, lastRow, storm::utility::constGetZero<double>());
resultMatrix.addNextValue(lastRow, lastRow, storm::utility::constantZero<double>());
LOG4CPLUS_DEBUG(logger, "While parsing " << filename << ": state " << lastRow << " has no transition to itself. Inserted a 0-transition. (3)");
} else if (!isRewardMatrix) {
LOG4CPLUS_WARN(logger, "Warning while parsing " << filename << ": state " << lastRow << " has no transition to itself.");

2
src/parser/LtlParser.cpp

@ -8,7 +8,7 @@
#include "LtlParser.h"
#include "src/utility/OsDetection.h"
#include "src/utility/ConstTemplates.h"
#include "src/utility/constants.h"
// If the parser fails due to ill-formed data, this exception is thrown.
#include "src/exceptions/WrongFormatException.h"

2
src/parser/PrctlParser.cpp

@ -1,6 +1,6 @@
#include "src/parser/PrctlParser.h"
#include "src/utility/OsDetection.h"
#include "src/utility/ConstTemplates.h"
#include "src/utility/constants.h"
// If the parser fails due to ill-formed data, this exception is thrown.
#include "src/exceptions/WrongFormatException.h"

2
src/solver/GmmxxLinearEquationSolver.h

@ -3,7 +3,7 @@
#include "AbstractLinearEquationSolver.h"
#include "src/adapters/GmmxxAdapter.h"
#include "src/utility/ConstTemplates.h"
#include "src/utility/constants.h"
#include "src/settings/Settings.h"
#include "src/utility/vector.h"

4
src/storage/LabeledValues.h

@ -14,7 +14,7 @@
namespace storm {
namespace utility {
template<class ValueType>
static ValueType constGetZero();
static ValueType constantZero();
}
namespace storage {
@ -186,7 +186,7 @@ namespace storm {
* @return The sum of the values.
*/
ValueType getSum() const {
ValueType sum = storm::utility::constGetZero<ValueType>();
ValueType sum = storm::utility::constantZero<ValueType>();
for (auto const& valueLabelListPair : *this) {
sum += valueLabelListPair.first;
}

37
src/storage/SparseMatrix.cpp

@ -6,6 +6,9 @@
*/
#include <iomanip>
#include <boost/functional/hash.hpp>
#include "gmm/gmm_matrix.h"
#include "src/storage/SparseMatrix.h"
@ -439,10 +442,10 @@ namespace storage {
// If there is at least one nonzero entry in this row, we can just set it to one, modify its
// column indication to the one given by the parameter and set all subsequent elements of this
// row to zero.
valueStorage[rowStart] = storm::utility::constGetOne<T>();
valueStorage[rowStart] = storm::utility::constantOne<T>();
columnIndications[rowStart] = column;
for (uint_fast64_t index = rowStart + 1; index < rowEnd; ++index) {
valueStorage[index] = storm::utility::constGetZero<T>();
valueStorage[index] = storm::utility::constantZero<T>();
columnIndications[index] = 0;
}
@ -613,14 +616,14 @@ namespace storage {
if (index == columnIndications[j]) {
insertedDiagonalElement = true;
} else if (insertDiagonalEntries && !insertedDiagonalElement && columnIndications[j] > index) {
result.addNextValue(rowCount, bitsSetBeforeIndex[index], storm::utility::constGetZero<T>());
result.addNextValue(rowCount, bitsSetBeforeIndex[index], storm::utility::constantZero<T>());
insertedDiagonalElement = true;
}
result.addNextValue(rowCount, bitsSetBeforeIndex[columnIndications[j]], valueStorage[j]);
}
}
if (insertDiagonalEntries && !insertedDiagonalElement) {
result.addNextValue(rowCount, bitsSetBeforeIndex[index], storm::utility::constGetZero<T>());
result.addNextValue(rowCount, bitsSetBeforeIndex[index], storm::utility::constantZero<T>());
}
++rowCount;
@ -675,13 +678,13 @@ namespace storage {
if (columnIndications[i] == rowGroupIndex) {
insertedDiagonalElement = true;
} else if (insertDiagonalEntries && !insertedDiagonalElement && columnIndications[i] > rowGroupIndex) {
submatrix.addNextValue(rowGroupIndex, rowGroupIndex, storm::utility::constGetZero<T>());
submatrix.addNextValue(rowGroupIndex, rowGroupIndex, storm::utility::constantZero<T>());
insertedDiagonalElement = true;
}
submatrix.addNextValue(rowGroupIndex, columnIndications[i], valueStorage[i]);
}
if (insertDiagonalEntries && !insertedDiagonalElement) {
submatrix.addNextValue(rowGroupIndex, rowGroupIndex, storm::utility::constGetZero<T>());
submatrix.addNextValue(rowGroupIndex, rowGroupIndex, storm::utility::constantZero<T>());
}
}
@ -758,7 +761,7 @@ namespace storage {
// Now iterate over all rows and set the diagonal elements to the inverted value.
// If there is a row without the diagonal element, an exception is thrown.
T one = storm::utility::constGetOne<T>();
T one = storm::utility::constantOne<T>();
bool foundDiagonalElement = false;
for (uint_fast64_t row = 0; row < rowCount; ++row) {
uint_fast64_t rowStart = rowIndications[row];
@ -814,12 +817,12 @@ namespace storage {
resultDinv.initialize(rowCount);
// constant 1 for diagonal inversion
T constOne = storm::utility::constGetOne<T>();
T constOne = storm::utility::constantOne<T>();
// copy diagonal entries to other matrix
for (uint_fast64_t i = 0; i < rowCount; ++i) {
resultDinv.addNextValue(i, i, constOne / resultLU.getValue(i, i));
resultLU.getValue(i, i) = storm::utility::constGetZero<T>();
resultLU.getValue(i, i) = storm::utility::constantZero<T>();
}
resultDinv.finalize();
@ -829,7 +832,7 @@ namespace storage {
template<typename T>
std::vector<T> SparseMatrix<T>::getPointwiseProductRowSumVector(storm::storage::SparseMatrix<T> const& otherMatrix) const {
// Prepare result.
std::vector<T> result(rowCount, storm::utility::constGetZero<T>());
std::vector<T> result(rowCount, storm::utility::constantZero<T>());
// Iterate over all elements of the current matrix and either continue with the next element
// in case the given matrix does not have a non-zero element at this column position, or
@ -860,7 +863,7 @@ namespace storage {
ConstRowIterator rowIt = this->begin();
for (auto resultIt = result.begin(), resultIte = result.end(); resultIt != resultIte; ++resultIt, ++rowIt) {
*resultIt = storm::utility::constGetZero<T>();
*resultIt = storm::utility::constantZero<T>();
for (auto elementIt = rowIt.begin(), elementIte = rowIt.end(); elementIt != elementIte; ++elementIt) {
*resultIt += elementIt.value() * vector[elementIt.column()];
@ -958,7 +961,7 @@ namespace storage {
template<typename T>
T SparseMatrix<T>::getRowSum(uint_fast64_t row) const {
T sum = storm::utility::constGetZero<T>();
T sum = storm::utility::constantZero<T>();
for (auto it = this->constValueIteratorBegin(row), ite = this->constValueIteratorEnd(row); it != ite; ++it) {
sum += *it;
}
@ -1064,9 +1067,9 @@ namespace storage {
boost::hash_combine(result, nonZeroEntryCount);
boost::hash_combine(result, currentSize);
boost::hash_combine(result, lastRow);
boost::hash_combine(result, storm::utility::Hash<T>::getHash(valueStorage));
boost::hash_combine(result, storm::utility::Hash<uint_fast64_t>::getHash(columnIndications));
boost::hash_combine(result, storm::utility::Hash<uint_fast64_t>::getHash(rowIndications));
boost::hash_combine(result, boost::hash_range(valueStorage.begin(), valueStorage.end()));
boost::hash_combine(result, boost::hash_range(columnIndications.begin(), columnIndications.end()));
boost::hash_combine(result, boost::hash_range(rowIndications.begin(), rowIndications.end()));
return result;
}
@ -1085,7 +1088,7 @@ namespace storage {
bool SparseMatrix<T>::prepareInternalStorage(bool initializeElements) {
if (initializeElements) {
// Set up the arrays for the elements that are not on the diagonal.
valueStorage.resize(nonZeroEntryCount, storm::utility::constGetZero<T>());
valueStorage.resize(nonZeroEntryCount, storm::utility::constantZero<T>());
columnIndications.resize(nonZeroEntryCount, 0);
// Set up the rowIndications vector and reserve one element more than there are rows in
@ -1122,7 +1125,7 @@ namespace storage {
uint_fast64_t indexEnd = matrixA->rowIndications.at(row + 1);
// Initialize the result to be 0.
T element = storm::utility::constGetZero<T>();
T element = storm::utility::constantZero<T>();
for (; index != indexEnd; ++index) {
element += matrixA->valueStorage.at(index) * vectorX->at(matrixA->columnIndications.at(index));

16
src/storage/SparseMatrix.h

@ -11,29 +11,19 @@
# include <iterator>
#endif
#include <exception>
#include <new>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <set>
#include <cstdint>
#include "src/storage/BitVector.h"
#include "src/utility/constants.h"
#include "src/exceptions/InvalidStateException.h"
#include "src/exceptions/InvalidArgumentException.h"
#include "src/exceptions/OutOfRangeException.h"
#include "src/exceptions/FileIoException.h"
#include "src/storage/BitVector.h"
#include "src/utility/ConstTemplates.h"
#include "src/utility/Hash.h"
#include "Eigen/Sparse"
#include "gmm/gmm_matrix.h"
#include "log4cplus/logger.h"
#include "log4cplus/loggingmacros.h"
extern log4cplus::Logger logger;
// Forward declaration for adapter classes.

38
src/utility/ConstTemplates.h → src/utility/constants.h

@ -1,5 +1,5 @@
/*
* ConstTemplates.h
* constants.h
*
* Created on: 11.10.2012
* Author: Thomas Heinemann
@ -33,12 +33,12 @@ namespace utility {
*
* @note
* The template parameter is just inferred by the return type; GCC is not able to infer this
* automatically, hence the type should always be stated explicitly (e.g. @c constGetZero<int>();)
* automatically, hence the type should always be stated explicitly (e.g. @c constantZero<int>();)
*
* @return Value 0, fit to the return type
*/
template<typename _Scalar>
static inline _Scalar constGetZero() {
static inline _Scalar constantZero() {
return _Scalar(0);
}
@ -51,7 +51,7 @@ static inline _Scalar constGetZero() {
* @return Value 0, fit to the type int_fast32_t
*/
template <>
inline int_fast32_t constGetZero() {
inline int_fast32_t constantZero() {
return 0;
}
@ -60,7 +60,7 @@ inline int_fast32_t constGetZero() {
* @return Value 0, fit to the type uint_fast64_t
*/
template <>
inline uint_fast64_t constGetZero() {
inline uint_fast64_t constantZero() {
return 0;
}
@ -69,7 +69,7 @@ inline uint_fast64_t constGetZero() {
* @return Value 0.0, fit to the type double
*/
template <>
inline double constGetZero() {
inline double constantZero() {
return 0.0;
}
@ -78,7 +78,7 @@ inline double constGetZero() {
* @return A LabeledValues object that represents a value of 0.
*/
template<>
inline storm::storage::LabeledValues<double> constGetZero() {
inline storm::storage::LabeledValues<double> constantZero() {
return storm::storage::LabeledValues<double>(0.0);
}
@ -91,12 +91,12 @@ inline storm::storage::LabeledValues<double> constGetZero() {
*
* @note
* The template parameter is just inferred by the return type; GCC is not able to infer this
* automatically, hence the type should always be stated explicitly (e.g. @c constGetOne<int>();)
* automatically, hence the type should always be stated explicitly (e.g. @c constantOne<int>();)
*
* @return Value 1, fit to the return type
*/
template<typename _Scalar>
static inline _Scalar constGetOne() {
static inline _Scalar constantOne() {
return _Scalar(1);
}
@ -109,7 +109,7 @@ static inline _Scalar constGetOne() {
* @return Value 1, fit to the type int_fast32_t
*/
template<>
inline int_fast32_t constGetOne() {
inline int_fast32_t constantOne() {
return 1;
}
@ -118,7 +118,7 @@ inline int_fast32_t constGetOne() {
* @return Value 1, fit to the type uint_fast61_t
*/
template<>
inline uint_fast64_t constGetOne() {
inline uint_fast64_t constantOne() {
return 1;
}
@ -127,7 +127,7 @@ inline uint_fast64_t constGetOne() {
* @return Value 1.0, fit to the type double
*/
template<>
inline double constGetOne() {
inline double constantOne() {
return 1.0;
}
@ -136,7 +136,7 @@ inline double constGetOne() {
* @return A LabeledValues object that represents a value of 1.
*/
template<>
inline storm::storage::LabeledValues<double> constGetOne() {
inline storm::storage::LabeledValues<double> constantOne() {
return storm::storage::LabeledValues<double>(1.0);
}
@ -149,12 +149,12 @@ inline storm::storage::LabeledValues<double> constGetOne() {
*
* @note
* The template parameter is just inferred by the return type; GCC is not able to infer this
* automatically, hence the type should always be stated explicitly (e.g. @c constGetOne<int>();)
* automatically, hence the type should always be stated explicitly (e.g. @c constantOne<int>();)
*
* @return Value Infinity, fit to the return type
*/
template<typename _Scalar>
static inline _Scalar constGetInfinity() {
static inline _Scalar constantInfinity() {
return std::numeric_limits<_Scalar>::infinity();
}
@ -167,7 +167,7 @@ static inline _Scalar constGetInfinity() {
* @return Value Infinity, fit to the type uint_fast32_t
*/
template<>
inline int_fast32_t constGetInfinity() {
inline int_fast32_t constantInfinity() {
throw storm::exceptions::InvalidArgumentException() << "Integer has no infinity.";
return std::numeric_limits<int_fast32_t>::max();
}
@ -177,7 +177,7 @@ inline int_fast32_t constGetInfinity() {
* @return Value Infinity, fit to the type uint_fast64_t
*/
template<>
inline uint_fast64_t constGetInfinity() {
inline uint_fast64_t constantInfinity() {
throw storm::exceptions::InvalidArgumentException() << "Integer has no infinity.";
return std::numeric_limits<uint_fast64_t>::max();
}
@ -187,7 +187,7 @@ inline uint_fast64_t constGetInfinity() {
* @return Value Infinity, fit to the type double
*/
template<>
inline double constGetInfinity() {
inline double constantInfinity() {
return std::numeric_limits<double>::infinity();
}
@ -196,7 +196,7 @@ inline double constGetInfinity() {
* @return Value Infinity, fit to the type LabeledValues.
*/
template<>
inline storm::storage::LabeledValues<double> constGetInfinity() {
inline storm::storage::LabeledValues<double> constantInfinity() {
return storm::storage::LabeledValues<double>(std::numeric_limits<double>::infinity());
}

10
src/utility/graph.h

@ -20,7 +20,7 @@
#include "src/models/AbstractDeterministicModel.h"
#include "src/models/AbstractNondeterministicModel.h"
#include "ConstTemplates.h"
#include "constants.h"
#include "src/exceptions/InvalidArgumentException.h"
#include "log4cplus/logger.h"
@ -668,8 +668,8 @@ namespace storm {
LOG4CPLUS_INFO(logger, "Performing Dijkstra search.");
const uint_fast64_t noPredecessorValue = storm::utility::constGetZero<uint_fast64_t>();
std::vector<T> probabilities(model.getNumberOfStates(), storm::utility::constGetZero<T>());
const uint_fast64_t noPredecessorValue = storm::utility::constantZero<uint_fast64_t>();
std::vector<T> probabilities(model.getNumberOfStates(), storm::utility::constantZero<T>());
std::vector<uint_fast64_t> predecessors(model.getNumberOfStates(), noPredecessorValue);
// Set the probability to 1 for all starting states.
@ -679,8 +679,8 @@ namespace storm {
std::set<std::pair<T, uint_fast64_t>, DistanceCompare<T>> probabilityStateSet;
#endif
for (auto state : startingStates) {
probabilityStateSet.emplace(storm::utility::constGetOne<T>(), state);
probabilities[state] = storm::utility::constGetOne<T>();
probabilityStateSet.emplace(storm::utility::constantOne<T>(), state);
probabilities[state] = storm::utility::constantOne<T>();
}
// As long as there is one reachable state, we need to consider it.

2
src/utility/matrix.h

@ -37,7 +37,7 @@ namespace storm {
}
} else {
// If no valid choice for the state is defined, we insert a self-loop.
result.insertNextValue(state, state, storm::utility::constGetOne<T>());
result.insertNextValue(state, state, storm::utility::constantOne<T>());
}
}

4
src/utility/vector.h

@ -2,7 +2,7 @@
#define STORM_UTILITY_VECTOR_H_
#include "Eigen/Core"
#include "ConstTemplates.h"
#include "constants.h"
#include <iostream>
#include <algorithm>
#include <functional>
@ -130,7 +130,7 @@ namespace storm {
template<class T>
void subtractFromConstantOneVector(std::vector<T>& vector) {
for (auto& element : vector) {
element = storm::utility::constGetOne<T>() - element;
element = storm::utility::constantOne<T>() - element;
}
}

15
test/performance/storage/BitVectorTest.cpp

@ -0,0 +1,15 @@
#include "gtest/gtest.h"
#include "src/storage/BitVector.h"
TEST(BitVectorTest, IterationTest) {
storm::storage::BitVector vector(819200, true);
for (uint_fast64_t i = 0; i < 10000; ++i) {
for (auto bit : vector) {
// The following can never be true, but prevents the compiler from optimizing away the loop.
if (bit == 819200) {
ASSERT_TRUE(false);
}
}
}
}
Loading…
Cancel
Save