Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
BisimulationDecomposition.h
Go to the documentation of this file.
1#pragma once
2
10
11namespace storm {
12namespace logic {
13class Formula;
14}
15
16namespace storage {
17
21template<typename ModelType, typename BlockDataType>
22class BisimulationDecomposition : public Decomposition<StateBlock> {
23 public:
24 typedef typename ModelType::ValueType ValueType;
25 typedef typename ModelType::RewardModelType RewardModelType;
26
27 // A class that offers the possibility to customize the bisimulation.
28 struct Options {
38 Options(ModelType const& model, storm::logic::Formula const& formula, ValueType const& tolerance);
39
49 Options(ModelType const& model, std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas, ValueType const& tolerance);
50
57 static Options preservingAllLabels(ValueType const& tolerance);
58
64 void preserveFormula(storm::logic::Formula const& formula);
65
72 if (t == BisimulationType::Weak) {
73 STORM_LOG_WARN_COND(!bounded, "Weak bisimulation does not preserve bounded properties.");
74 STORM_LOG_WARN_COND(!discounted, "Weak bisimulation does not preserve discounted properties.");
75 bounded = false;
76 discounted = false;
77 }
78 type = t;
79 }
80
82 return this->type;
83 }
84
85 bool getBounded() const {
86 return this->bounded;
87 }
88
89 bool getDiscounted() const {
90 return this->discounted;
91 }
92
93 bool getKeepRewards() const {
94 return this->keepRewards;
95 }
96
97 void setKeepRewards(bool keepRewards) {
98 this->keepRewards = keepRewards;
99 }
100
102 return static_cast<bool>(optimalityType);
103 }
104
108
110 tolerance = value;
111 }
112
114 STORM_LOG_ASSERT(optimalityType, "Optimality type not set.");
115 return optimalityType.value();
116 }
117
118 // A flag that indicates whether a measure driven initial partition is to be used. If this flag is set
119 // to true, the two optional pairs phiStatesAndLabel and psiStatesAndLabel must be set. Then, the
120 // measure driven initial partition wrt. to the states phi and psi is taken.
122 std::optional<storm::storage::BitVector> phiStates;
123 std::optional<storm::storage::BitVector> psiStates;
124
127 std::optional<std::set<std::string>> respectedAtomicPropositions;
128
130 bool buildQuotient = true;
131
132 private:
133 std::optional<OptimizationDirection> optimalityType;
134
137 bool keepRewards = false;
138
141
144 bool bounded = false;
145
148 bool discounted = false;
149
151 ValueType tolerance;
152
157 explicit Options(ValueType const& tolerance);
158
165 void preserveSingleFormula(ModelType const& model, storm::logic::Formula const& formula);
166
173 void addToRespectedAtomicPropositions(std::vector<std::shared_ptr<storm::logic::AtomicExpressionFormula const>> const& expressions,
174 std::vector<std::shared_ptr<storm::logic::AtomicLabelFormula const>> const& labels);
175
176 /*
177 * Checks whether a measure driven partition is possible with the given formula and sets the necessary
178 * data if this is the case.
179 *
180 * @param model The model for which to derive the data.
181 * @param formula The formula for which to derive the data for the measure driven initial partition (if
182 * applicable).
183 */
184 void checkAndSetMeasureDrivenInitialPartition(ModelType const& model, storm::logic::Formula const& formula);
185 };
186
193 BisimulationDecomposition(ModelType const& model, Options const& options);
194
195 virtual ~BisimulationDecomposition() = default;
196
202 std::shared_ptr<ModelType> getQuotient() const;
203
209
210 protected:
219
226
235 std::vector<bisimulation::Block<BlockDataType>*>& splitterVector) = 0;
236
240 virtual void buildQuotient() = 0;
241
245 virtual void initializeLabelBasedPartition();
246
251
255 virtual void initialize();
256
263 virtual std::pair<storm::storage::BitVector, storm::storage::BitVector> getStatesWithProbability01() = 0;
264
269
273 virtual void splitInitialPartitionBasedOnRewards(std::vector<ValueType> const& rewardVector);
274
278 virtual void splitInitialPartitionBasedOnActionRewards(std::vector<std::set<ValueType>> const& rewardVector);
279
284
285 // The model to decompose.
286 ModelType const& model;
287
288 // The backward transitions of the model.
290
291 // The options used during construction.
293
294 // The current partition (used by partition refinement).
296
297 // A comparator used for comparing the distances of constants.
299
300 // The quotient, if it was build. Otherwise a null pointer.
301 std::shared_ptr<ModelType> quotient;
302};
303} // namespace storage
304} // namespace storm
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.
BisimulationDecomposition(ModelType const &model, Options const &options)
Decomposes the given model into equivalence classes of a bisimulation.
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.
A class that holds a possibly non-square matrix in the compressed row storage format.
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:9
#define STORM_LOG_WARN_COND(cond, message)
Definition macros.h:36
ValueType zero()
Definition constants.cpp:24
solver::OptimizationDirection OptimizationDirection
static const bool IsExact
void preserveFormula(storm::logic::Formula const &formula)
Changes the options in a way that the given formula is preserved.
static Options preservingAllLabels(ValueType const &tolerance)
Creates an object representing the options necessary to obtain the quotient that respects all atomic ...
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...
Options(ModelType const &model, storm::logic::Formula const &formula, ValueType const &tolerance)
Creates an object representing the options necessary to obtain the quotient while still preserving th...
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