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