Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
GoalStateMerger.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <memory>
5#include <optional>
6#include <set>
7#include <string>
8#include <unordered_map>
9#include <vector>
10
15
16namespace storm {
17namespace logic {
18class Formula;
21} // namespace logic
22namespace transformer {
23
24/*
25 * Merges the given target and sink states into single states with a selfloop.
26 * Supports Dtmc, Ctmc, Mdp, and MarkovAutomaton models.
27 */
28template<typename ValueType>
30 public:
31 struct ReturnType {
32 std::shared_ptr<storm::models::sparse::Model<ValueType>> model; // The output model
33 std::optional<uint64_t> targetState; // The target state of the output model (if reachable)
34 std::optional<uint64_t> sinkState; // The sink state of the output model (if reachable)
35 std::vector<uint64_t> oldToNewStateIndexMapping; // maps a state from the input model to the corresponding state of the output model. Invalid
36 // index if the state does not exist
37 storm::storage::BitVector keptChoices; // The choices of the input model that are still present in the output model
38 };
39
44
62 storm::storage::BitVector const& sinkStates,
63 std::vector<std::string> const& selectedRewardModels = std::vector<std::string>(),
64 std::optional<storm::storage::BitVector> const& choiceFilter = std::nullopt,
65 std::optional<uint64_t> representativeTargetState = std::nullopt,
66 std::optional<uint64_t> representativeSinkState = std::nullopt) const;
67
78 std::optional<ReturnType> mergeForFormula(storm::logic::Formula const& formula, bool const dropUnreachableFromInit) const;
79
80 private:
81 std::optional<ReturnType> mergeForUntilProbabilities(storm::logic::ProbabilityOperatorFormula const& formula, bool const dropUnreachableFromInit) const;
82 std::optional<ReturnType> mergeForBoundedUntilProbabilities(storm::logic::ProbabilityOperatorFormula const& formula,
83 bool const dropUnreachableFromInit) const;
84 std::optional<ReturnType> mergeForReachabilityRewards(storm::logic::RewardOperatorFormula const& formula, bool const dropUnreachableFromInit) const;
85 std::optional<ReturnType> mergeForCumulativeRewards(storm::logic::RewardOperatorFormula const& formula, bool const dropUnreachableFromInit) const;
86
87 storm::models::sparse::Model<ValueType> const& originalModel;
88
94 std::pair<ReturnType, uint64_t> initialize(storm::storage::BitVector const& maybeStates, storm::storage::BitVector const& targetStates,
95 storm::storage::BitVector const& sinkStates,
96 std::optional<storm::storage::BitVector> const& choiceFilter = std::nullopt) const;
97
101 storm::storage::SparseMatrix<ValueType> buildTransitionMatrix(storm::storage::BitVector const& maybeStates, ReturnType const& resultData,
102 uint64_t transitionCount) const;
103 storm::models::sparse::StateLabeling buildStateLabeling(storm::storage::BitVector const& maybeStates, storm::storage::BitVector const& targetStates,
104 storm::storage::BitVector const& sinkStates, ReturnType const& resultData,
105 std::optional<uint64_t> const representativeTargetState = std::nullopt,
106 std::optional<uint64_t> const representativeSinkState = std::nullopt) const;
107 std::unordered_map<std::string, storm::models::sparse::StandardRewardModel<ValueType>> buildRewardModels(
108 storm::storage::BitVector const& maybeStates, ReturnType const& resultData, std::vector<std::string> const& selectedRewardModels) const;
109};
110} // namespace transformer
111} // namespace storm
Base class for all sparse models.
Definition Model.h:34
This class manages the labeling of the state space with a number of (atomic) labels.
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
A class that holds a possibly non-square matrix in the compressed row storage format.
GoalStateMerger(storm::models::sparse::Model< ValueType > const &model)
ReturnType mergeTargetAndSinkStates(storm::storage::BitVector const &maybeStates, storm::storage::BitVector const &targetStates, storm::storage::BitVector const &sinkStates, std::vector< std::string > const &selectedRewardModels=std::vector< std::string >(), std::optional< storm::storage::BitVector > const &choiceFilter=std::nullopt, std::optional< uint64_t > representativeTargetState=std::nullopt, std::optional< uint64_t > representativeSinkState=std::nullopt) const
Computes a submodel of the specified model that only considers the states given by maybeStates as wel...
std::optional< ReturnType > mergeForFormula(storm::logic::Formula const &formula, bool const dropUnreachableFromInit) const
Identifies the maybeStates, targetStates, sinkStates (and, if applicable, the reward model and choice...
std::shared_ptr< storm::models::sparse::Model< ValueType > > model