Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
AutomatonAbstractor.cpp
Go to the documentation of this file.
2
12
13namespace storm::gbar {
14namespace abstraction {
15namespace jani {
16
18
19template<storm::dd::DdType DdType, typename ValueType>
21 std::shared_ptr<storm::utility::solver::SmtSolverFactory> const& smtSolverFactory,
22 bool useDecomposition, bool addPredicatesForValidBlocks, bool debug)
23 : smtSolverFactory(smtSolverFactory), abstractionInformation(abstractionInformation), edges(), automaton(automaton) {
24 // For each concrete command, we create an abstract counterpart.
25 uint64_t edgeId = 0;
26 for (auto const& edge : automaton.getEdges()) {
27 edges.emplace_back(edgeId, edge, abstractionInformation, smtSolverFactory, useDecomposition, addPredicatesForValidBlocks, debug);
28 ++edgeId;
29 }
30
31 if (automaton.getNumberOfLocations() > 1) {
32 locationVariables = abstractionInformation.addLocationVariables(automaton.getLocationExpressionVariable(), automaton.getNumberOfLocations() - 1).first;
33 }
34}
35
36template<storm::dd::DdType DdType, typename ValueType>
37void AutomatonAbstractor<DdType, ValueType>::refine(std::vector<uint_fast64_t> const& predicates) {
38 for (uint_fast64_t index = 0; index < edges.size(); ++index) {
39 STORM_LOG_TRACE("Refining edge with index " << index << ".");
40 edges[index].refine(predicates);
41 }
42}
43
44template<storm::dd::DdType DdType, typename ValueType>
46 return edges[player1Choice].getGuard();
47}
48
49template<storm::dd::DdType DdType, typename ValueType>
50uint64_t AutomatonAbstractor<DdType, ValueType>::getNumberOfUpdates(uint64_t player1Choice) const {
51 return edges[player1Choice].getNumberOfUpdates(player1Choice);
52}
53
54template<storm::dd::DdType DdType, typename ValueType>
55std::map<storm::expressions::Variable, storm::expressions::Expression> AutomatonAbstractor<DdType, ValueType>::getVariableUpdates(
56 uint64_t player1Choice, uint64_t auxiliaryChoice) const {
57 return edges[player1Choice].getVariableUpdates(auxiliaryChoice);
58}
59
60template<storm::dd::DdType DdType, typename ValueType>
61std::set<storm::expressions::Variable> const& AutomatonAbstractor<DdType, ValueType>::getAssignedVariables(uint64_t player1Choice) const {
62 return edges[player1Choice].getAssignedVariables();
63}
64
65template<storm::dd::DdType DdType, typename ValueType>
67 // First, we retrieve the abstractions of all commands.
68 std::vector<GameBddResult<DdType>> edgeDdsAndUsedOptionVariableCounts;
69 uint_fast64_t maximalNumberOfUsedOptionVariables = 0;
70 for (auto& edge : edges) {
71 edgeDdsAndUsedOptionVariableCounts.push_back(edge.abstract());
72 maximalNumberOfUsedOptionVariables = std::max(maximalNumberOfUsedOptionVariables, edgeDdsAndUsedOptionVariableCounts.back().numberOfPlayer2Variables);
73 }
74
75 // Then, we build the module BDD by adding the single command DDs. We need to make sure that all command
76 // DDs use the same amount DD variable encoding the choices of player 2.
77 storm::dd::Bdd<DdType> result = this->getAbstractionInformation().getDdManager().getBddZero();
78 for (auto const& edgeDd : edgeDdsAndUsedOptionVariableCounts) {
79 result |= edgeDd.bdd && this->getAbstractionInformation().encodePlayer2Choice(1, edgeDd.numberOfPlayer2Variables, maximalNumberOfUsedOptionVariables);
80 }
81 return GameBddResult<DdType>(result, maximalNumberOfUsedOptionVariables);
82}
83
84template<storm::dd::DdType DdType, typename ValueType>
86 uint_fast64_t numberOfPlayer2Variables) {
87 BottomStateResult<DdType> result(this->getAbstractionInformation().getDdManager().getBddZero(),
88 this->getAbstractionInformation().getDdManager().getBddZero());
89
90 for (auto& edge : edges) {
91 BottomStateResult<DdType> commandBottomStateResult = edge.getBottomStateTransitions(reachableStates, numberOfPlayer2Variables, locationVariables);
92 result.states |= commandBottomStateResult.states;
93 result.transitions |= commandBottomStateResult.transitions;
94 }
95
96 return result;
97}
98
99template<storm::dd::DdType DdType, typename ValueType>
101 storm::dd::Add<DdType, ValueType> result = this->getAbstractionInformation().getDdManager().template getAddZero<ValueType>();
102 for (auto const& edge : edges) {
103 result += edge.getEdgeDecoratorAdd(locationVariables);
104 }
105 return result;
106}
107
108template<storm::dd::DdType DdType, typename ValueType>
110 if (automaton.get().getNumberOfLocations() == 1) {
111 return this->getAbstractionInformation().getDdManager().getBddOne();
112 }
113
114 std::set<uint64_t> const& initialLocationIndices = automaton.get().getInitialLocationIndices();
115 storm::dd::Bdd<DdType> result = this->getAbstractionInformation().getDdManager().getBddZero();
116 for (auto const& initialLocationIndex : initialLocationIndices) {
117 result |= this->getAbstractionInformation().encodeLocation(locationVariables.get().first, initialLocationIndex);
118 }
119 return result;
120}
121
122template<storm::dd::DdType DdType, typename ValueType>
123std::vector<EdgeAbstractor<DdType, ValueType>> const& AutomatonAbstractor<DdType, ValueType>::getEdges() const {
124 return edges;
125}
126
127template<storm::dd::DdType DdType, typename ValueType>
128std::vector<EdgeAbstractor<DdType, ValueType>>& AutomatonAbstractor<DdType, ValueType>::getEdges() {
129 return edges;
130}
131
132template<storm::dd::DdType DdType, typename ValueType>
134 return edges.size();
135}
136
137template<storm::dd::DdType DdType, typename ValueType>
139 return abstractionInformation.get();
140}
141
142template<storm::dd::DdType DdType, typename ValueType>
144 for (auto& edge : edges) {
145 edge.notifyGuardIsPredicate();
146 }
147}
148
152} // namespace jani
153} // namespace abstraction
154} // namespace storm::gbar
DdManager< LibraryType > & getDdManager() const
Retrieves the manager that is responsible for this DD.
Definition Dd.cpp:38
std::pair< std::pair< storm::expressions::Variable, storm::expressions::Variable >, uint64_t > addLocationVariables(storm::expressions::Variable const &locationExpressionVariable, uint64_t highestLocationIndex)
Adds a location variable of appropriate range and returns the pair of meta variables.
std::set< storm::expressions::Variable > const & getAssignedVariables(uint64_t player1Choice) const
Retrieves the variables assigned by the given player 1 choice.
std::size_t getNumberOfEdges() const
Retrieves the number of abstract edges of this abstract automaton.
BottomStateResult< DdType > getBottomStateTransitions(storm::dd::Bdd< DdType > const &reachableStates, uint_fast64_t numberOfPlayer2Variables)
Retrieves the transitions to bottom states of this automaton.
uint64_t getNumberOfUpdates(uint64_t player1Choice) const
Retrieves the number of updates of the specified player 1 choice.
GameBddResult< DdType > abstract()
Computes the abstraction of the module wrt.
storm::expressions::Expression const & getGuard(uint64_t player1Choice) const
Retrieves the guard of the given player 1 choice.
AutomatonAbstractor(storm::jani::Automaton const &automaton, AbstractionInformation< DdType > &abstractionInformation, std::shared_ptr< storm::utility::solver::SmtSolverFactory > const &smtSolverFactory, bool useDecomposition, bool addPredicatesForValidBlocks, bool debug)
Constructs an abstract module from the given automaton.
storm::dd::Add< DdType, ValueType > getEdgeDecoratorAdd() const
Retrieves an ADD that maps the encodings of edges, source/target locations and their updates to their...
std::vector< EdgeAbstractor< DdType, ValueType > > const & getEdges() const
Retrieves the abstract edges of this abstract automton.
void refine(std::vector< uint_fast64_t > const &predicates)
Refines the abstract automaton with the given predicates.
storm::dd::Bdd< DdType > getInitialLocationsBdd() const
Retrieves a BDD that encodes all initial locations of this abstract automaton.
std::map< storm::expressions::Variable, storm::expressions::Expression > getVariableUpdates(uint64_t player1Choice, uint64_t auxiliaryChoice) const
Retrieves a mapping from variables to expressions that define their updates wrt.
storm::expressions::Variable const & getLocationExpressionVariable() const
Retrieves the expression variable that represents the location of this automaton.
uint64_t getNumberOfLocations() const
Retrieves the number of locations.
std::vector< Edge > & getEdges()
Retrieves the edges of the automaton.
This class represents the settings for the abstraction procedures.
#define STORM_LOG_TRACE(message)
Definition logging.h:12