Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ModuleAbstractor.cpp
Go to the documentation of this file.
2
11
12namespace storm::gbar {
13namespace abstraction {
14namespace prism {
15
16template<storm::dd::DdType DdType, typename ValueType>
18 std::shared_ptr<storm::utility::solver::SmtSolverFactory> const& smtSolverFactory, bool useDecomposition,
19 bool addPredicatesForValidBlocks, bool debug)
20 : smtSolverFactory(smtSolverFactory), abstractionInformation(abstractionInformation), commands(), module(module) {
21 // For each concrete command, we create an abstract counterpart.
22 for (auto const& command : module.getCommands()) {
23 commands.emplace_back(command, abstractionInformation, smtSolverFactory, useDecomposition, addPredicatesForValidBlocks, debug);
24 }
25}
26
27template<storm::dd::DdType DdType, typename ValueType>
28void ModuleAbstractor<DdType, ValueType>::refine(std::vector<uint_fast64_t> const& predicates) {
29 for (uint_fast64_t index = 0; index < commands.size(); ++index) {
30 STORM_LOG_TRACE("Refining command with index " << index << ".");
31 commands[index].refine(predicates);
32 }
33}
34
35template<storm::dd::DdType DdType, typename ValueType>
37 return commands[player1Choice].getGuard();
38}
39
40template<storm::dd::DdType DdType, typename ValueType>
41uint64_t ModuleAbstractor<DdType, ValueType>::getNumberOfUpdates(uint64_t player1Choice) const {
42 return commands[player1Choice].getNumberOfUpdates(player1Choice);
43}
44
45template<storm::dd::DdType DdType, typename ValueType>
46std::map<storm::expressions::Variable, storm::expressions::Expression> ModuleAbstractor<DdType, ValueType>::getVariableUpdates(uint64_t player1Choice,
47 uint64_t auxiliaryChoice) const {
48 return commands[player1Choice].getVariableUpdates(auxiliaryChoice);
49}
50
51template<storm::dd::DdType DdType, typename ValueType>
52std::set<storm::expressions::Variable> const& ModuleAbstractor<DdType, ValueType>::getAssignedVariables(uint64_t player1Choice) const {
53 return commands[player1Choice].getAssignedVariables();
54}
55
56template<storm::dd::DdType DdType, typename ValueType>
58 // First, we retrieve the abstractions of all commands.
59 std::vector<GameBddResult<DdType>> commandDdsAndUsedOptionVariableCounts;
60 uint_fast64_t maximalNumberOfUsedOptionVariables = 0;
61 for (auto& command : commands) {
62 commandDdsAndUsedOptionVariableCounts.push_back(command.abstract());
63 maximalNumberOfUsedOptionVariables =
64 std::max(maximalNumberOfUsedOptionVariables, commandDdsAndUsedOptionVariableCounts.back().numberOfPlayer2Variables);
65 }
66
67 // Then, we build the module BDD by adding the single command DDs. We need to make sure that all command
68 // DDs use the same amount DD variable encoding the choices of player 2.
69 storm::dd::Bdd<DdType> result = this->getAbstractionInformation().getDdManager().getBddZero();
70 for (auto const& commandDd : commandDdsAndUsedOptionVariableCounts) {
71 result |=
72 commandDd.bdd && this->getAbstractionInformation().encodePlayer2Choice(1, commandDd.numberOfPlayer2Variables, maximalNumberOfUsedOptionVariables);
73 }
74 return GameBddResult<DdType>(result, maximalNumberOfUsedOptionVariables);
75}
76
77template<storm::dd::DdType DdType, typename ValueType>
79 uint_fast64_t numberOfPlayer2Variables) {
80 BottomStateResult<DdType> result(this->getAbstractionInformation().getDdManager().getBddZero(),
81 this->getAbstractionInformation().getDdManager().getBddZero());
82
83 for (auto& command : commands) {
84 BottomStateResult<DdType> commandBottomStateResult = command.getBottomStateTransitions(reachableStates, numberOfPlayer2Variables);
85 result.states |= commandBottomStateResult.states;
86 result.transitions |= commandBottomStateResult.transitions;
87 }
88
89 return result;
90}
91
92template<storm::dd::DdType DdType, typename ValueType>
94 storm::dd::Add<DdType, ValueType> result = this->getAbstractionInformation().getDdManager().template getAddZero<ValueType>();
95 for (auto const& command : commands) {
96 result += command.getCommandUpdateProbabilitiesAdd();
97 }
98 return result;
99}
100
101template<storm::dd::DdType DdType, typename ValueType>
102std::vector<CommandAbstractor<DdType, ValueType>> const& ModuleAbstractor<DdType, ValueType>::getCommands() const {
103 return commands;
104}
105
106template<storm::dd::DdType DdType, typename ValueType>
107std::vector<CommandAbstractor<DdType, ValueType>>& ModuleAbstractor<DdType, ValueType>::getCommands() {
108 return commands;
109}
110
111template<storm::dd::DdType DdType, typename ValueType>
112AbstractionInformation<DdType> const& ModuleAbstractor<DdType, ValueType>::getAbstractionInformation() const {
113 return abstractionInformation.get();
114}
115
116template<storm::dd::DdType DdType, typename ValueType>
118 for (auto& command : commands) {
119 command.notifyGuardIsPredicate();
120 }
121}
122
126} // namespace prism
127} // namespace abstraction
128} // namespace storm::gbar
DdManager< LibraryType > & getDdManager() const
Retrieves the manager that is responsible for this DD.
Definition Dd.cpp:38
BottomStateResult< DdType > getBottomStateTransitions(storm::dd::Bdd< DdType > const &reachableStates, uint_fast64_t numberOfPlayer2Variables)
Retrieves the transitions to bottom states of this module.
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::dd::Add< DdType, ValueType > getCommandUpdateProbabilitiesAdd() const
Retrieves an ADD that maps the encodings of commands and their updates to their probabilities.
void refine(std::vector< uint_fast64_t > const &predicates)
Refines the abstract module with the given predicates.
GameBddResult< DdType > abstract()
Computes the abstraction of the module wrt.
std::vector< CommandAbstractor< DdType, ValueType > > const & getCommands() const
Retrieves the abstract commands of this abstract module.
ModuleAbstractor(storm::prism::Module const &module, 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 module.
storm::expressions::Expression const & getGuard(uint64_t player1Choice) const
Retrieves the guard of the given player 1 choice.
std::set< storm::expressions::Variable > const & getAssignedVariables(uint64_t player1Choice) const
Retrieves the variables assigned by the given player 1 choice.
uint64_t getNumberOfUpdates(uint64_t player1Choice) const
Retrieves the number of updates of the specified player 1 choice.
#define STORM_LOG_TRACE(message)
Definition logging.h:15