Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
BisimulationDecomposition.h
Go to the documentation of this file.
1#pragma once
2
13
14namespace storm {
15namespace logic {
16class Formula;
17}
18
19namespace storage {
20
22 switch (c) {
28 if (storm::settings::getModule<storm::settings::modules::BisimulationSettings>().isWeakBisimulationSet()) {
30 } else {
32 }
33 }
35}
36
40template<typename ModelType, typename BlockDataType>
41class BisimulationDecomposition : public Decomposition<StateBlock> {
42 public:
43 typedef typename ModelType::ValueType ValueType;
44 typedef typename ModelType::RewardModelType RewardModelType;
45
46 // A class that offers the possibility to customize the bisimulation.
47 struct Options {
48 // Creates an object representing the default values for all options.
49 Options();
50
59 Options(ModelType const& model, storm::logic::Formula const& formula);
60
69 Options(ModelType const& model, std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas);
70
76 void preserveFormula(storm::logic::Formula const& formula);
77
84 if (t == BisimulationType::Weak) {
85 STORM_LOG_WARN_COND(!bounded, "Weak bisimulation does not preserve bounded properties.");
86 STORM_LOG_WARN_COND(!discounted, "Weak bisimulation does not preserve discounted properties.");
87 bounded = false;
88 discounted = false;
89 }
90 type = t;
91 }
92
94 return this->type;
95 }
96
97 bool getBounded() const {
98 return this->bounded;
99 }
100
101 bool getDiscounted() const {
102 return this->discounted;
103 }
104
105 bool getKeepRewards() const {
106 return this->keepRewards;
107 }
108
109 void setKeepRewards(bool keepRewards) {
110 this->keepRewards = keepRewards;
111 }
112
114 return static_cast<bool>(optimalityType);
115 }
116
119 ? storm::utility::zero<ValueType>()
120 : storm::utility::convertNumber<ValueType>(storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
121 }
122
124 STORM_LOG_ASSERT(optimalityType, "Optimality type not set.");
125 return optimalityType.value();
126 }
127
128 // A flag that indicates whether a measure driven initial partition is to be used. If this flag is set
129 // to true, the two optional pairs phiStatesAndLabel and psiStatesAndLabel must be set. Then, the
130 // measure driven initial partition wrt. to the states phi and psi is taken.
132 std::optional<storm::storage::BitVector> phiStates;
133 std::optional<storm::storage::BitVector> psiStates;
134
137 std::optional<std::set<std::string>> respectedAtomicPropositions;
138
141
142 private:
143 std::optional<OptimizationDirection> optimalityType;
144
147 bool keepRewards;
148
150 BisimulationType type;
151
154 bool bounded;
155
158 bool discounted;
159
166 void preserveSingleFormula(ModelType const& model, storm::logic::Formula const& formula);
167
174 void addToRespectedAtomicPropositions(std::vector<std::shared_ptr<storm::logic::AtomicExpressionFormula const>> const& expressions,
175 std::vector<std::shared_ptr<storm::logic::AtomicLabelFormula const>> const& labels);
176
177 /*
178 * Checks whether a measure driven partition is possible with the given formula and sets the necessary
179 * data if this is the case.
180 *
181 * @param model The model for which to derive the data.
182 * @param formula The formula for which to derive the data for the measure driven initial partition (if
183 * applicable).
184 */
185 void checkAndSetMeasureDrivenInitialPartition(ModelType const& model, storm::logic::Formula const& formula);
186 };
187
194 BisimulationDecomposition(ModelType const& model, Options const& options);
195
196 virtual ~BisimulationDecomposition() = default;
197
203 std::shared_ptr<ModelType> getQuotient() const;
204
210
211 protected:
220
227
236 std::vector<bisimulation::Block<BlockDataType>*>& splitterVector) = 0;
237
241 virtual void buildQuotient() = 0;
242
246 virtual void initializeLabelBasedPartition();
247
252
256 virtual void initialize();
257
264 virtual std::pair<storm::storage::BitVector, storm::storage::BitVector> getStatesWithProbability01() = 0;
265
270
274 virtual void splitInitialPartitionBasedOnRewards(std::vector<ValueType> const& rewardVector);
275
279 virtual void splitInitialPartitionBasedOnActionRewards(std::vector<std::set<ValueType>> const& rewardVector);
280
285
286 // The model to decompose.
287 ModelType const& model;
288
289 // The backward transitions of the model.
291
292 // The options used during construction.
294
295 // The current partition (used by partition refinement).
297
298 // A comparator used for comparing the distances of constants.
300
301 // The quotient, if it was build. Otherwise a null pointer.
302 std::shared_ptr<ModelType> quotient;
303};
304} // namespace storage
305} // namespace storm
This class is the superclass of all decompositions of a sparse model into its bisimulation quotient.
storm::storage::SparseMatrix< ValueType > backwardTransitions
virtual void buildQuotient()=0
Builds the quotient model based on the previously computed equivalence classes (stored in the blocks ...
virtual void refinePartitionBasedOnSplitter(bisimulation::Block< BlockDataType > &splitter, std::vector< bisimulation::Block< BlockDataType > * > &splitterVector)=0
Refines the partition by considering the given splitter.
storm::utility::ConstantsComparator< ValueType > comparator
std::shared_ptr< ModelType > getQuotient() const
Retrieves the quotient of the model under the computed bisimulation.
void performPartitionRefinement()
Performs the partition refinement on the model and thereby computes the equivalence classes under str...
virtual void splitInitialPartitionBasedOnRewards()
Splits the initial partition based on the (unique) reward model of the current model.
virtual void splitInitialPartitionBasedOnActionRewards(std::vector< std::set< ValueType > > const &rewardVector)
Splits the initial partition based on the given vector of action rewards.
storm::storage::bisimulation::Partition< BlockDataType > partition
void computeBisimulationDecomposition()
Computes the decomposition of the model into bisimulation equivalence classes.
void extractDecompositionBlocks()
Constructs the blocks of the decomposition object based on the current partition.
virtual std::pair< storm::storage::BitVector, storm::storage::BitVector > getStatesWithProbability01()=0
Computes the set of states with probability 0/1 for satisfying phi until psi.
virtual void initializeMeasureDrivenPartition()
Creates the measure-driven initial partition for reaching psi states from phi states.
virtual void initializeLabelBasedPartition()
Initializes the initial partition based on all respected labels.
virtual void initialize()
A function that can initialize auxiliary data structures.
This class represents the decomposition of a model into blocks which are of the template type.
A class that holds a possibly non-square matrix in the compressed row storage format.
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
#define STORM_LOG_WARN_COND(cond, message)
Definition macros.h:38
BisimulationType resolveBisimulationTypeChoice(BisimulationTypeChoice c)
void preserveFormula(storm::logic::Formula const &formula)
Changes the options in a way that the given formula is preserved.
void setType(BisimulationType t)
Sets the bisimulation type.
std::optional< storm::storage::BitVector > phiStates
bool buildQuotient
A flag that governs whether the quotient model is actually built or only the decomposition is compute...
std::optional< std::set< std::string > > respectedAtomicPropositions
An optional set of strings that indicate which of the atomic propositions of the model are to be resp...
std::optional< storm::storage::BitVector > psiStates