Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
GoalStateMerger.h
Go to the documentation of this file.
1#pragma once
2
3#include <boost/optional.hpp>
4#include <memory>
5#include <string>
6#include <unordered_map>
7#include <vector>
8
12
13namespace storm {
14namespace transformer {
15
16/*
17 * Merges the given target and sink states into single states with a selfloop
18 */
19template<typename SparseModelType>
21 public:
22 struct ReturnType {
23 std::shared_ptr<SparseModelType> model; // The output model
24 boost::optional<uint_fast64_t> targetState; // The target state of the output model (if reachable)
25 boost::optional<uint_fast64_t> sinkState; // The sink state of the output model (if reachable)
26 std::vector<uint_fast64_t> oldToNewStateIndexMapping; // maps a state from the input model to the corresponding state of the output model. Invalid
27 // index if the state does not exist
28 storm::storage::BitVector keptChoices; // The choices of the input model that are still present in the output model
29 };
30
31 GoalStateMerger(SparseModelType const& model);
32
33 /* Computes a submodel of the specified model that only considers the states given by maybeStates as well as
34 * * one target state to which all transitions to a state selected by targetStates are redirected and
35 * * one sink state to which all transitions to a state selected by sinkStates are redirected.
36 *
37 * If a choiceFilter is given, choices on maybestates that are not selected by the filter will be removed.
38 *
39 * Notes:
40 * * the target (or sink) state is not created, if it is not reachable
41 * * the target (or sink) state will get a label iff it is reachable and at least one of the given targetStates (sinkStates) have that label.
42 * * Only the selected reward models will be kept. The target and sink states will not get any reward.
43 * * Choices that lead from a maybeState to a ~(target | sink) state will be removed. An exception is thrown if this leads to deadlocks.
44 * * It is assumed that maybeStates, targetStates, and sinkStates are pairwise disjoint. Otherwise an exception is thrown.
45 * * The order of the maybeStates will not be affected (i.e. s_1 < s_2 in the input model implies s'_1 < s'_2 in the output model).
46 */
48 storm::storage::BitVector const& sinkStates,
49 std::vector<std::string> const& selectedRewardModels = std::vector<std::string>(),
50 boost::optional<storm::storage::BitVector> const& choiceFilter = boost::none) const;
51
52 private:
53 SparseModelType const& originalModel;
54
60 std::pair<ReturnType, uint_fast64_t> initialize(storm::storage::BitVector const& maybeStates, storm::storage::BitVector const& targetStates,
61 storm::storage::BitVector const& sinkStates,
62 boost::optional<storm::storage::BitVector> const& choiceFilter = boost::none) const;
63
68 ReturnType const& resultData, uint_fast64_t transitionCount) const;
69 storm::models::sparse::StateLabeling buildStateLabeling(storm::storage::BitVector const& maybeStates, storm::storage::BitVector const& targetStates,
70 storm::storage::BitVector const& sinkStates, ReturnType const& resultData) const;
71 std::unordered_map<std::string, typename SparseModelType::RewardModelType> buildRewardModels(storm::storage::BitVector const& maybeStates,
72 ReturnType const& resultData,
73 std::vector<std::string> const& selectedRewardModels) const;
74 std::shared_ptr<SparseModelType> buildOutputModel(storm::storage::BitVector const& maybeStates, ReturnType const& resultData,
77 std::unordered_map<std::string, typename SparseModelType::RewardModelType>&& rewardModels) const;
78};
79} // namespace transformer
80} // namespace storm
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:18
A class that holds a possibly non-square matrix in the compressed row storage format.
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 >(), boost::optional< storm::storage::BitVector > const &choiceFilter=boost::none) const
LabParser.cpp.
Definition cli.cpp:18
boost::optional< uint_fast64_t > sinkState
std::shared_ptr< SparseModelType > model
boost::optional< uint_fast64_t > targetState
std::vector< uint_fast64_t > oldToNewStateIndexMapping