Storm 1.14.0.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
17template<storm::dd::DdType DdType, typename ValueType>
19 std::shared_ptr<storm::utility::solver::SmtSolverFactory> const& smtSolverFactory,
20 bool useDecomposition, bool addPredicatesForValidBlocks, bool debug)
21 : smtSolverFactory(smtSolverFactory), abstractionInformation(abstractionInformation), edges(), automaton(automaton) {
22 // For each concrete command, we create an abstract counterpart.
23 uint64_t edgeId = 0;
24 for (auto const& edge : automaton.getEdges()) {
25 edges.emplace_back(edgeId, edge, abstractionInformation, smtSolverFactory, useDecomposition, addPredicatesForValidBlocks, debug);
26 ++edgeId;
27 }
28
29 if (automaton.getNumberOfLocations() > 1) {
30 locationVariables = abstractionInformation.addLocationVariables(automaton.getLocationExpressionVariable(), automaton.getNumberOfLocations() - 1).first;
31 }
32}
33
34template<storm::dd::DdType DdType, typename ValueType>
35void AutomatonAbstractor<DdType, ValueType>::refine(std::vector<uint_fast64_t> const& predicates) {
36 for (uint_fast64_t index = 0; index < edges.size(); ++index) {
37 STORM_LOG_TRACE("Refining edge with index " << index << ".");
38 edges[index].refine(predicates);
39 }
40}
41
42template<storm::dd::DdType DdType, typename ValueType>
44 return edges[player1Choice].getGuard();
45}
46
47template<storm::dd::DdType DdType, typename ValueType>
48uint64_t AutomatonAbstractor<DdType, ValueType>::getNumberOfUpdates(uint64_t player1Choice) const {
49 return edges[player1Choice].getNumberOfUpdates(player1Choice);
50}
51
52template<storm::dd::DdType DdType, typename ValueType>
53std::map<storm::expressions::Variable, storm::expressions::Expression> AutomatonAbstractor<DdType, ValueType>::getVariableUpdates(
54 uint64_t player1Choice, uint64_t auxiliaryChoice) const {
55 return edges[player1Choice].getVariableUpdates(auxiliaryChoice);
56}
57
58template<storm::dd::DdType DdType, typename ValueType>
59std::set<storm::expressions::Variable> const& AutomatonAbstractor<DdType, ValueType>::getAssignedVariables(uint64_t player1Choice) const {
60 return edges[player1Choice].getAssignedVariables();
61}
62
63template<storm::dd::DdType DdType, typename ValueType>
65 // First, we retrieve the abstractions of all commands.
66 std::vector<GameBddResult<DdType>> edgeDdsAndUsedOptionVariableCounts;
67 uint_fast64_t maximalNumberOfUsedOptionVariables = 0;
68 for (auto& edge : edges) {
69 edgeDdsAndUsedOptionVariableCounts.push_back(edge.abstract());
70 maximalNumberOfUsedOptionVariables = std::max(maximalNumberOfUsedOptionVariables, edgeDdsAndUsedOptionVariableCounts.back().numberOfPlayer2Variables);
71 }
72
73 // Then, we build the module BDD by adding the single command DDs. We need to make sure that all command
74 // DDs use the same amount DD variable encoding the choices of player 2.
75 storm::dd::Bdd<DdType> result = this->getAbstractionInformation().getDdManager().getBddZero();
76 for (auto const& edgeDd : edgeDdsAndUsedOptionVariableCounts) {
77 result |= edgeDd.bdd && this->getAbstractionInformation().encodePlayer2Choice(1, edgeDd.numberOfPlayer2Variables, maximalNumberOfUsedOptionVariables);
78 }
79 return GameBddResult<DdType>(result, maximalNumberOfUsedOptionVariables);
80}
81
82template<storm::dd::DdType DdType, typename ValueType>
84 uint_fast64_t numberOfPlayer2Variables) {
85 BottomStateResult<DdType> result(this->getAbstractionInformation().getDdManager().getBddZero(),
86 this->getAbstractionInformation().getDdManager().getBddZero());
87
88 for (auto& edge : edges) {
89 BottomStateResult<DdType> commandBottomStateResult = edge.getBottomStateTransitions(reachableStates, numberOfPlayer2Variables, locationVariables);
90 result.states |= commandBottomStateResult.states;
91 result.transitions |= commandBottomStateResult.transitions;
92 }
93
94 return result;
95}
96
97template<storm::dd::DdType DdType, typename ValueType>
99 storm::dd::Add<DdType, ValueType> result = this->getAbstractionInformation().getDdManager().template getAddZero<ValueType>();
100 for (auto const& edge : edges) {
101 result += edge.getEdgeDecoratorAdd(locationVariables);
102 }
103 return result;
104}
105
106template<storm::dd::DdType DdType, typename ValueType>
108 if (automaton.get().getNumberOfLocations() == 1) {
109 return this->getAbstractionInformation().getDdManager().getBddOne();
110 }
111
112 std::set<uint64_t> const& initialLocationIndices = automaton.get().getInitialLocationIndices();
113 storm::dd::Bdd<DdType> result = this->getAbstractionInformation().getDdManager().getBddZero();
114 for (auto const& initialLocationIndex : initialLocationIndices) {
115 result |= this->getAbstractionInformation().encodeLocation(locationVariables.get().first, initialLocationIndex);
116 }
117 return result;
118}
119
120template<storm::dd::DdType DdType, typename ValueType>
121std::vector<EdgeAbstractor<DdType, ValueType>> const& AutomatonAbstractor<DdType, ValueType>::getEdges() const {
122 return edges;
123}
124
125template<storm::dd::DdType DdType, typename ValueType>
126std::vector<EdgeAbstractor<DdType, ValueType>>& AutomatonAbstractor<DdType, ValueType>::getEdges() {
127 return edges;
128}
129
130template<storm::dd::DdType DdType, typename ValueType>
132 return edges.size();
133}
134
135template<storm::dd::DdType DdType, typename ValueType>
136AbstractionInformation<DdType> const& AutomatonAbstractor<DdType, ValueType>::getAbstractionInformation() const {
137 return abstractionInformation.get();
138}
139
140template<storm::dd::DdType DdType, typename ValueType>
142 for (auto& edge : edges) {
143 edge.notifyGuardIsPredicate();
144 }
145}
146
150} // namespace jani
151} // namespace abstraction
152} // namespace storm::gbar
DdManager< LibraryType > & getDdManager() const
Retrieves the manager that is responsible for this DD.
Definition Dd.cpp:38
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.
#define STORM_LOG_TRACE(message)
Definition logging.h:15