14namespace transformer {
16template<
typename SparseModelType>
21template<
typename SparseModelType>
24 simplifiedModel =
nullptr;
25 simplifiedFormula =
nullptr;
29 return simplifyForUntilProbabilities(probOpForm);
31 return simplifyForReachabilityProbabilities(probOpForm);
33 return simplifyForBoundedUntilProbabilities(probOpForm);
39 storm::exceptions::InvalidPropertyException,
40 "The reward model specified by formula " << formula <<
" is not available in the given model.");
42 return simplifyForReachabilityRewards(rewOpForm);
44 return simplifyForCumulativeRewards(rewOpForm);
48 STORM_LOG_DEBUG(
"Simplification not possible because the formula is not supported. Formula: " << formula);
52template<
typename SparseModelType>
54 STORM_LOG_THROW(simplifiedModel, storm::exceptions::InvalidStateException,
"Tried to get the simplified model but simplification was not invoked before.");
55 return simplifiedModel;
58template<
typename SparseModelType>
60 STORM_LOG_THROW(simplifiedFormula, storm::exceptions::InvalidStateException,
61 "Tried to get the simplified formula but simplification was not invoked before.");
62 return simplifiedFormula;
65template<
typename SparseModelType>
68 STORM_LOG_DEBUG(
"Simplification not possible because the formula is not supported. Formula: " << formula);
72template<
typename SparseModelType>
80template<
typename SparseModelType>
83 STORM_LOG_DEBUG(
"Simplification not possible because the formula is not supported. Formula: " << formula);
87template<
typename SparseModelType>
90 STORM_LOG_DEBUG(
"Simplification not possible because the formula is not supported. Formula: " << formula);
94template<
typename SparseModelType>
97 STORM_LOG_DEBUG(
"Simplification not possible because the formula is not supported. Formula: " << formula);
101template<
typename SparseModelType>
103 SparseModelType
const& model,
storm::storage::BitVector const& consideredStates, boost::optional<std::string>
const& rewardModelName) {
105 auto backwardsSparseMatrix = sparseMatrix.
transpose();
108 std::vector<typename SparseModelType::ValueType> actionRewards;
109 if (rewardModelName) {
110 actionRewards = model.getRewardModel(*rewardModelName).getTotalRewardVector(sparseMatrix);
112 actionRewards = std::vector<typename SparseModelType::ValueType>(model.getTransitionMatrix().getRowCount(),
113 storm::utility::zero<typename SparseModelType::ValueType>());
118 for (
auto state : consideredStates) {
121 for (
auto const& entry : sparseMatrix.
getRowGroup(state)) {
123 selectedStates.
set(state,
false);
127 if (state && this->preserveParametricTransitions) {
128 for (
auto const& entry : backwardsSparseMatrix.getRowGroup(state)) {
130 selectedStates.
set(state,
false);
136 selectedStates.
set(state,
false);
144 flexibleMatrix, flexibleBackwardTransitions, actionRewards);
145 for (
auto state : selectedStates) {
149 auto keptRows = sparseMatrix.
getRowFilter(selectedStates);
153 std::unordered_map<std::string, typename SparseModelType::RewardModelType> rewardModels;
154 if (rewardModelName) {
156 rewardModels.insert(std::make_pair(*rewardModelName,
typename SparseModelType::RewardModelType(std::nullopt, std::move(actionRewards))));
159 return std::make_shared<SparseModelType>(std::move(newTransitionMatrix), model.getStateLabeling().getSubLabeling(selectedStates), std::move(rewardModels));
162template<
typename SparseModelType>
164 this->preserveParametricTransitions = preserveParametricTransitions;
167template<
typename SparseModelType>
169 return this->preserveParametricTransitions;
void eliminateState(storm::storage::sparse::state_type state, bool removeForwardTransitions)
A bit vector that is internally represented as a vector of 64-bit values.
void complement()
Negates all bits in the bit vector.
void set(uint64_t index, bool value=true)
Sets the given truth value at the given index.
The flexible sparse matrix is used during state elimination.
storm::storage::SparseMatrix< ValueType > createSparseMatrix()
Creates a sparse matrix from the flexible sparse matrix.
A class that holds a possibly non-square matrix in the compressed row storage format.
const_rows getRowGroup(index_type rowGroup) const
Returns an object representing the given row group.
std::vector< index_type > const & getRowGroupIndices() const
Returns the grouping of rows of this matrix.
index_type getRowGroupSize(index_type group) const
Returns the size of the given row group.
storm::storage::SparseMatrix< value_type > transpose(bool joinGroups=false, bool keepZeros=false) const
Transposes the matrix.
storm::storage::BitVector getRowFilter(storm::storage::BitVector const &groupConstraint) const
Returns a bitvector representing the set of rows, with all indices set that correspond to one of the ...
#define STORM_LOG_DEBUG(message)
#define STORM_LOG_THROW(cond, exception, message)
void filterVectorInPlace(std::vector< Type > &v, storm::storage::BitVector const &filter)
bool isConstant(ValueType const &)