|
|
@ -11,6 +11,7 @@ |
|
|
|
|
|
|
|
#include "src/settings/SettingsManager.h"
|
|
|
|
|
|
|
|
#include "src/utility/graph.h"
|
|
|
|
#include "src/utility/macros.h"
|
|
|
|
#include "src/utility/constants.h"
|
|
|
|
#include "src/exceptions/InvalidStateException.h"
|
|
|
@ -95,7 +96,7 @@ namespace storm { |
|
|
|
} |
|
|
|
|
|
|
|
template<typename ValueType> |
|
|
|
std::shared_ptr<StatePriorityQueue> createStatePriorityQueue(boost::optional<std::vector<uint_fast64_t>> const& distanceBasedStatePriorities, storm::storage::FlexibleSparseMatrix<ValueType> const& transitionMatrix, storm::storage::FlexibleSparseMatrix<ValueType> const& backwardTransitions, std::vector<ValueType>& oneStepProbabilities, storm::storage::BitVector const& states) { |
|
|
|
std::shared_ptr<StatePriorityQueue> createStatePriorityQueue(boost::optional<std::vector<uint_fast64_t>> const& distanceBasedStatePriorities, storm::storage::FlexibleSparseMatrix<ValueType> const& transitionMatrix, storm::storage::FlexibleSparseMatrix<ValueType> const& backwardTransitions, std::vector<ValueType> const& oneStepProbabilities, storm::storage::BitVector const& states) { |
|
|
|
|
|
|
|
STORM_LOG_TRACE("Creating state priority queue for states " << states); |
|
|
|
|
|
|
@ -147,20 +148,73 @@ namespace storm { |
|
|
|
return std::make_shared<StaticStatePriorityQueue>(states); |
|
|
|
} |
|
|
|
|
|
|
|
template<typename ValueType> |
|
|
|
std::vector<uint_fast64_t> getDistanceBasedPriorities(storm::storage::SparseMatrix<ValueType> const& transitionMatrix, storm::storage::SparseMatrix<ValueType> const& transitionMatrixTransposed, storm::storage::BitVector const& initialStates, std::vector<ValueType> const& oneStepProbabilities, bool forward, bool reverse) { |
|
|
|
std::vector<uint_fast64_t> statePriorities(transitionMatrix.getRowCount()); |
|
|
|
std::vector<storm::storage::sparse::state_type> states(transitionMatrix.getRowCount()); |
|
|
|
for (std::size_t index = 0; index < states.size(); ++index) { |
|
|
|
states[index] = index; |
|
|
|
} |
|
|
|
|
|
|
|
std::vector<uint_fast64_t> distances = getStateDistances(transitionMatrix, transitionMatrixTransposed, initialStates, oneStepProbabilities, |
|
|
|
storm::settings::getModule<storm::settings::modules::EliminationSettings>().getEliminationOrder() == storm::settings::modules::EliminationSettings::EliminationOrder::Forward || |
|
|
|
storm::settings::getModule<storm::settings::modules::EliminationSettings>().getEliminationOrder() == storm::settings::modules::EliminationSettings::EliminationOrder::ForwardReversed); |
|
|
|
|
|
|
|
// In case of the forward or backward ordering, we can sort the states according to the distances.
|
|
|
|
if (forward ^ reverse) { |
|
|
|
std::sort(states.begin(), states.end(), [&distances] (storm::storage::sparse::state_type const& state1, storm::storage::sparse::state_type const& state2) { return distances[state1] < distances[state2]; } ); |
|
|
|
} else { |
|
|
|
// Otherwise, we sort them according to descending distances.
|
|
|
|
std::sort(states.begin(), states.end(), [&distances] (storm::storage::sparse::state_type const& state1, storm::storage::sparse::state_type const& state2) { return distances[state1] > distances[state2]; } ); |
|
|
|
} |
|
|
|
|
|
|
|
// Now convert the ordering of the states to priorities.
|
|
|
|
for (uint_fast64_t index = 0; index < states.size(); ++index) { |
|
|
|
statePriorities[states[index]] = index; |
|
|
|
} |
|
|
|
|
|
|
|
return statePriorities; |
|
|
|
} |
|
|
|
|
|
|
|
template<typename ValueType> |
|
|
|
std::vector<uint_fast64_t> getStateDistances(storm::storage::SparseMatrix<ValueType> const& transitionMatrix, storm::storage::SparseMatrix<ValueType> const& transitionMatrixTransposed, storm::storage::BitVector const& initialStates, std::vector<ValueType> const& oneStepProbabilities, bool forward) { |
|
|
|
if (forward) { |
|
|
|
return storm::utility::graph::getDistances(transitionMatrix, initialStates); |
|
|
|
} else { |
|
|
|
// Since the target states were eliminated from the matrix already, we construct a replacement by
|
|
|
|
// treating all states that have some non-zero probability to go to a target state in one step as target
|
|
|
|
// states.
|
|
|
|
storm::storage::BitVector pseudoTargetStates(transitionMatrix.getRowCount()); |
|
|
|
for (std::size_t index = 0; index < oneStepProbabilities.size(); ++index) { |
|
|
|
if (oneStepProbabilities[index] != storm::utility::zero<ValueType>()) { |
|
|
|
pseudoTargetStates.set(index); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return storm::utility::graph::getDistances(transitionMatrixTransposed, pseudoTargetStates); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
template uint_fast64_t estimateComplexity(double const& value); |
|
|
|
template std::shared_ptr<StatePriorityQueue> createStatePriorityQueue(boost::optional<std::vector<uint_fast64_t>> const& distanceBasedStatePriorities, storm::storage::FlexibleSparseMatrix<double> const& transitionMatrix, storm::storage::FlexibleSparseMatrix<double> const& backwardTransitions, std::vector<double>& oneStepProbabilities, storm::storage::BitVector const& states); |
|
|
|
template std::shared_ptr<StatePriorityQueue> createStatePriorityQueue(boost::optional<std::vector<uint_fast64_t>> const& distanceBasedStatePriorities, storm::storage::FlexibleSparseMatrix<double> const& transitionMatrix, storm::storage::FlexibleSparseMatrix<double> const& backwardTransitions, std::vector<double> const& oneStepProbabilities, storm::storage::BitVector const& states); |
|
|
|
template uint_fast64_t computeStatePenalty(storm::storage::sparse::state_type const& state, storm::storage::FlexibleSparseMatrix<double> const& transitionMatrix, storm::storage::FlexibleSparseMatrix<double> const& backwardTransitions, std::vector<double> const& oneStepProbabilities); |
|
|
|
template uint_fast64_t computeStatePenaltyRegularExpression(storm::storage::sparse::state_type const& state, storm::storage::FlexibleSparseMatrix<double> const& transitionMatrix, storm::storage::FlexibleSparseMatrix<double> const& backwardTransitions, std::vector<double> const& oneStepProbabilities); |
|
|
|
|
|
|
|
template std::vector<uint_fast64_t> getDistanceBasedPriorities(storm::storage::SparseMatrix<double> const& transitionMatrix, storm::storage::SparseMatrix<double> const& transitionMatrixTransposed, storm::storage::BitVector const& initialStates, std::vector<double> const& oneStepProbabilities, bool forward, bool reverse); |
|
|
|
template std::vector<uint_fast64_t> getStateDistances(storm::storage::SparseMatrix<double> const& transitionMatrix, storm::storage::SparseMatrix<double> const& transitionMatrixTransposed, storm::storage::BitVector const& initialStates, std::vector<double> const& oneStepProbabilities, bool forward); |
|
|
|
|
|
|
|
template uint_fast64_t estimateComplexity(storm::RationalNumber const& value); |
|
|
|
template std::shared_ptr<StatePriorityQueue> createStatePriorityQueue(boost::optional<std::vector<uint_fast64_t>> const& distanceBasedStatePriorities, storm::storage::FlexibleSparseMatrix<storm::RationalNumber> const& transitionMatrix, storm::storage::FlexibleSparseMatrix<storm::RationalNumber> const& backwardTransitions, std::vector<storm::RationalNumber>& oneStepProbabilities, storm::storage::BitVector const& states); |
|
|
|
template std::shared_ptr<StatePriorityQueue> createStatePriorityQueue(boost::optional<std::vector<uint_fast64_t>> const& distanceBasedStatePriorities, storm::storage::FlexibleSparseMatrix<storm::RationalNumber> const& transitionMatrix, storm::storage::FlexibleSparseMatrix<storm::RationalNumber> const& backwardTransitions, std::vector<storm::RationalNumber> const& oneStepProbabilities, storm::storage::BitVector const& states); |
|
|
|
template uint_fast64_t computeStatePenalty(storm::storage::sparse::state_type const& state, storm::storage::FlexibleSparseMatrix<storm::RationalNumber> const& transitionMatrix, storm::storage::FlexibleSparseMatrix<storm::RationalNumber> const& backwardTransitions, std::vector<storm::RationalNumber> const& oneStepProbabilities); |
|
|
|
template uint_fast64_t computeStatePenaltyRegularExpression(storm::storage::sparse::state_type const& state, storm::storage::FlexibleSparseMatrix<storm::RationalNumber> const& transitionMatrix, storm::storage::FlexibleSparseMatrix<storm::RationalNumber> const& backwardTransitions, std::vector<storm::RationalNumber> const& oneStepProbabilities); |
|
|
|
template std::vector<uint_fast64_t> getDistanceBasedPriorities(storm::storage::SparseMatrix<storm::RationalNumber> const& transitionMatrix, storm::storage::SparseMatrix<storm::RationalNumber> const& transitionMatrixTransposed, storm::storage::BitVector const& initialStates, std::vector<storm::RationalNumber> const& oneStepProbabilities, bool forward, bool reverse); |
|
|
|
template std::vector<uint_fast64_t> getStateDistances(storm::storage::SparseMatrix<storm::RationalNumber> const& transitionMatrix, storm::storage::SparseMatrix<storm::RationalNumber> const& transitionMatrixTransposed, storm::storage::BitVector const& initialStates, std::vector<storm::RationalNumber> const& oneStepProbabilities, bool forward); |
|
|
|
|
|
|
|
template uint_fast64_t estimateComplexity(storm::RationalFunction const& value); |
|
|
|
template std::shared_ptr<StatePriorityQueue> createStatePriorityQueue(boost::optional<std::vector<uint_fast64_t>> const& distanceBasedStatePriorities, storm::storage::FlexibleSparseMatrix<storm::RationalFunction> const& transitionMatrix, storm::storage::FlexibleSparseMatrix<storm::RationalFunction> const& backwardTransitions, std::vector<storm::RationalFunction>& oneStepProbabilities, storm::storage::BitVector const& states); |
|
|
|
template std::shared_ptr<StatePriorityQueue> createStatePriorityQueue(boost::optional<std::vector<uint_fast64_t>> const& distanceBasedStatePriorities, storm::storage::FlexibleSparseMatrix<storm::RationalFunction> const& transitionMatrix, storm::storage::FlexibleSparseMatrix<storm::RationalFunction> const& backwardTransitions, std::vector<storm::RationalFunction> const& oneStepProbabilities, storm::storage::BitVector const& states); |
|
|
|
template uint_fast64_t computeStatePenalty(storm::storage::sparse::state_type const& state, storm::storage::FlexibleSparseMatrix<storm::RationalFunction> const& transitionMatrix, storm::storage::FlexibleSparseMatrix<storm::RationalFunction> const& backwardTransitions, std::vector<storm::RationalFunction> const& oneStepProbabilities); |
|
|
|
template uint_fast64_t computeStatePenaltyRegularExpression(storm::storage::sparse::state_type const& state, storm::storage::FlexibleSparseMatrix<storm::RationalFunction> const& transitionMatrix, storm::storage::FlexibleSparseMatrix<storm::RationalFunction> const& backwardTransitions, std::vector<storm::RationalFunction> const& oneStepProbabilities); |
|
|
|
template std::vector<uint_fast64_t> getDistanceBasedPriorities(storm::storage::SparseMatrix<storm::RationalFunction> const& transitionMatrix, storm::storage::SparseMatrix<storm::RationalFunction> const& transitionMatrixTransposed, storm::storage::BitVector const& initialStates, std::vector<storm::RationalFunction> const& oneStepProbabilities, bool forward, bool reverse); |
|
|
|
template std::vector<uint_fast64_t> getStateDistances(storm::storage::SparseMatrix<storm::RationalFunction> const& transitionMatrix, storm::storage::SparseMatrix<storm::RationalFunction> const& transitionMatrixTransposed, storm::storage::BitVector const& initialStates, std::vector<storm::RationalFunction> const& oneStepProbabilities, bool forward); |
|
|
|
} |
|
|
|
} |
|
|
|
} |