18template<storm::dd::DdType DdType,
typename ValueType>
23template<storm::dd::DdType DdType,
typename ValueType>
25 std::pair<storm::expressions::Variable, storm::expressions::Variable>
const& blockVariables, uint64_t numberOfBlocks,
27 : partition(partitionAdd),
28 changedStates(changedStates),
29 blockVariables(blockVariables),
30 numberOfBlocks(numberOfBlocks),
31 nextFreeBlockIndex(nextFreeBlockIndex) {
35template<storm::dd::DdType DdType,
typename ValueType>
37 std::pair<storm::expressions::Variable, storm::expressions::Variable>
const& blockVariables, uint64_t numberOfBlocks,
39 : partition(partitionBdd),
40 changedStates(changedStates),
41 blockVariables(blockVariables),
42 numberOfBlocks(numberOfBlocks),
43 nextFreeBlockIndex(nextFreeBlockIndex) {
47template<storm::dd::DdType DdType,
typename ValueType>
49 return this->partition == other.partition && this->blockVariables == other.blockVariables && this->numberOfBlocks == other.numberOfBlocks &&
50 this->nextFreeBlockIndex == other.nextFreeBlockIndex;
53template<storm::dd::DdType DdType,
typename ValueType>
55 uint64_t nextFreeBlockIndex,
60template<storm::dd::DdType DdType,
typename ValueType>
62 uint64_t nextFreeBlockIndex,
67template<storm::dd::DdType DdType,
typename ValueType>
68boost::optional<std::pair<std::shared_ptr<storm::logic::Formula const>, std::shared_ptr<storm::logic::Formula const>>>
70 boost::optional<std::pair<std::shared_ptr<storm::logic::Formula const>, std::shared_ptr<storm::logic::Formula const>>> result;
79 result = std::pair<std::shared_ptr<storm::logic::Formula const>, std::shared_ptr<storm::logic::Formula const>>();
87 result = std::pair<std::shared_ptr<storm::logic::Formula const>, std::shared_ptr<storm::logic::Formula const>>();
88 result.get().first = std::make_shared<storm::logic::BooleanLiteralFormula>(
true);
95template<storm::dd::DdType DdType,
typename ValueType>
98 std::vector<std::shared_ptr<storm::logic::Formula const>>
const& formulas,
100 boost::optional<std::pair<std::shared_ptr<storm::logic::Formula const>, std::shared_ptr<storm::logic::Formula const>>> constraintTargetFormulas;
102 constraintTargetFormulas = extractConstraintTargetFormulas(*formulas.front());
106 return createDistanceBased(model, *constraintTargetFormulas.get().first, *constraintTargetFormulas.get().second);
112template<storm::dd::DdType DdType,
typename ValueType>
116 std::vector<storm::expressions::Expression> expressionVector;
117 for (
auto const& expression : preservationInformation.
getExpressions()) {
118 expressionVector.emplace_back(expression);
121 return create(model, expressionVector, bisimulationType);
124template<storm::dd::DdType DdType,
typename ValueType>
130 std::unique_ptr<storm::modelchecker::CheckResult> subresult = propositionalChecker.check(constraintFormula);
132 subresult = propositionalChecker.check(targetFormula);
135 return createDistanceBased(model, constraintStates, targetStates);
138template<storm::dd::DdType DdType,
typename ValueType>
144 std::pair<storm::expressions::Variable, storm::expressions::Variable> blockVariables = createBlockVariables(model);
146 auto start = std::chrono::high_resolution_clock::now();
153 uint64_t blockCount = 0;
157 while (!backwardFrontier.
isZero()) {
158 partitionBdd |= backwardFrontier && manager.getEncoding(blockVariables.first, blockCount++,
false);
159 coveredStates |= backwardFrontier;
161 !coveredStates && constraintStates;
166 partitionBdd |= (model.
getReachableStates() && !coveredStates) && manager.getEncoding(blockVariables.first, blockCount++,
false);
172 auto end = std::chrono::high_resolution_clock::now();
173 STORM_LOG_INFO(
"Created distance and label-based initial partition in " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()
178 return Partition<DdType, ValueType>(partitionBdd.template toAdd<ValueType>(), blockVariables, blockCount, blockCount);
184template<storm::dd::DdType DdType,
typename ValueType>
185std::pair<storm::expressions::Variable, storm::expressions::Variable> Partition<DdType, ValueType>::createBlockVariables(
186 storm::models::symbolic::Model<DdType, ValueType>
const& model) {
189 uint64_t numberOfDdVariables = 0;
191 auto const& ddMetaVariable =
manager.getMetaVariable(metaVariable);
192 numberOfDdVariables += ddMetaVariable.getNumberOfDdVariables();
195 auto mdp = model.template as<storm::models::symbolic::Mdp<DdType, ValueType>>();
196 for (
auto const& metaVariable : mdp->getNondeterminismVariables()) {
197 auto const& ddMetaVariable =
manager.getMetaVariable(metaVariable);
198 numberOfDdVariables += ddMetaVariable.getNumberOfDdVariables();
202 return createBlockVariables(manager, numberOfDdVariables);
205template<storm::dd::DdType DdType,
typename ValueType>
207 std::vector<storm::expressions::Expression>
const& expressions,
210 "Currently only strong bisimulation is supported.");
212 std::pair<storm::expressions::Variable, storm::expressions::Variable> blockVariables = createBlockVariables(model);
214 std::vector<storm::dd::Bdd<DdType>> stateSets;
215 for (
auto const& expression : expressions) {
216 stateSets.emplace_back(model.
getStates(expression));
218 auto start = std::chrono::high_resolution_clock::now();
219 std::pair<storm::dd::Bdd<DdType>, uint64_t> partitionBddAndBlockCount = createPartitionBdd(model.
getManager(), model, stateSets, blockVariables.first);
220 auto end = std::chrono::high_resolution_clock::now();
221 STORM_LOG_INFO(
"Created label-based initial partition in " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).
count() <<
"ms.");
225 return Partition<DdType, ValueType>(partitionBddAndBlockCount.first.template toAdd<ValueType>(), blockVariables, partitionBddAndBlockCount.second,
226 partitionBddAndBlockCount.second);
229 partitionBddAndBlockCount.second);
233template<storm::dd::DdType DdType,
typename ValueType>
236 std::pair<storm::expressions::Variable, storm::expressions::Variable>
const& blockVariables) {
248template<storm::dd::DdType DdType,
typename ValueType>
250 return this->
getStates().getNonZeroCount();
253template<storm::dd::DdType DdType,
typename ValueType>
262template<storm::dd::DdType DdType,
typename ValueType>
264 return static_cast<bool>(changedStates);
267template<storm::dd::DdType DdType,
typename ValueType>
269 return boost::get<storm::dd::Add<DdType, ValueType>>(changedStates.get());
272template<storm::dd::DdType DdType,
typename ValueType>
274 return boost::get<storm::dd::Bdd<DdType>>(changedStates.get());
277template<storm::dd::DdType DdType,
typename ValueType>
279 return numberOfBlocks;
282template<storm::dd::DdType DdType,
typename ValueType>
284 return partition.which() == 1;
287template<storm::dd::DdType DdType,
typename ValueType>
289 return partition.which() == 0;
292template<storm::dd::DdType DdType,
typename ValueType>
294 return boost::get<storm::dd::Add<DdType, ValueType>>(partition);
297template<storm::dd::DdType DdType,
typename ValueType>
299 return boost::get<storm::dd::Bdd<DdType>>(partition);
302template<storm::dd::DdType DdType,
typename ValueType>
304 return blockVariables;
307template<storm::dd::DdType DdType,
typename ValueType>
309 return blockVariables.first;
312template<storm::dd::DdType DdType,
typename ValueType>
314 return blockVariables.second;
317template<storm::dd::DdType DdType,
typename ValueType>
319 return nextFreeBlockIndex;
322template<storm::dd::DdType DdType,
typename ValueType>
325 return asBdd().getNodeCount();
327 return asAdd().getNodeCount();
331template<storm::dd::DdType DdType>
334 if (currentStateSet.
isZero()) {
337 if (offset == stateSets.size()) {
338 callback(currentStateSet);
340 enumerateBlocksRec(stateSets, currentStateSet && stateSets[offset], offset + 1, blockVariable, callback);
341 enumerateBlocksRec(stateSets, currentStateSet && !stateSets[offset], offset + 1, blockVariable, callback);
345template<storm::dd::DdType DdType,
typename ValueType>
346std::pair<storm::dd::Bdd<DdType>, uint64_t> Partition<DdType, ValueType>::createPartitionBdd(
storm::dd::DdManager<DdType> const& manager,
350 uint64_t blockCount = 0;
356 partitionBdd |= (stateSet && manager.getEncoding(blockVariable, blockCount, false));
363 return std::make_pair(partitionBdd, blockCount);
366template<storm::dd::DdType DdType,
typename ValueType>
367std::pair<storm::expressions::Variable, storm::expressions::Variable> Partition<DdType, ValueType>::createBlockVariables(
storm::dd::DdManager<DdType>& manager,
368 uint64_t numberOfDdVariables) {
369 std::vector<storm::expressions::Variable> blockVariables;
370 if (manager.hasMetaVariable(
"blocks")) {
372 while (manager.hasMetaVariable(
"block" + std::to_string(counter))) {
375 blockVariables = manager.addBitVectorMetaVariable(
"blocks" + std::to_string(counter), numberOfDdVariables, 2);
377 blockVariables =
manager.addBitVectorMetaVariable(
"blocks", numberOfDdVariables, 2);
379 return std::make_pair(blockVariables[0], blockVariables[1]);
Bdd< LibraryType > notZero() const
Computes a BDD that represents the function in which all assignments with a function value unequal to...
Bdd< LibraryType > inverseRelationalProduct(Bdd< LibraryType > const &relation, std::set< storm::expressions::Variable > const &rowMetaVariables, std::set< storm::expressions::Variable > const &columnMetaVariables) const
Computes the inverse relational product of the current BDD and the given BDD representing a relation.
bool isZero() const
Retrieves whether this DD represents the constant zero function.
Bdd< LibraryType > swapVariables(std::vector< std::pair< storm::expressions::Variable, storm::expressions::Variable > > const &metaVariablePairs) const
Swaps the given pairs of meta variables in the BDD.
static Partition createTrivialChoicePartition(storm::models::symbolic::NondeterministicModel< DdType, ValueType > const &model, std::pair< storm::expressions::Variable, storm::expressions::Variable > const &blockVariables)
storm::expressions::Variable const & getBlockVariable() const
bool hasChangedStates() const
Retrieves whether this partition has information about the states whose partition block assignment ch...
storm::dd::Bdd< DdType > const & asBdd() const
storm::expressions::Variable const & getPrimedBlockVariable() const
uint64_t getNumberOfBlocks() const
storm::dd::Bdd< DdType > getStates() const
bool operator==(Partition< DdType, ValueType > const &other) const
uint64_t getNextFreeBlockIndex() const
storm::dd::Add< DdType, ValueType > const & changedStatesAsAdd() const
Retrieves the DD representing the states whose partition block assignment changed.
uint64_t getNodeCount() const
static Partition create(storm::models::symbolic::Model< DdType, ValueType > const &model, storm::storage::BisimulationType const &bisimulationType, PreservationInformation< DdType, ValueType > const &preservationInformation)
std::pair< storm::expressions::Variable, storm::expressions::Variable > const & getBlockVariables() const
storm::dd::Bdd< DdType > const & changedStatesAsBdd() const
storm::dd::Add< DdType, ValueType > const & asAdd() const
uint64_t getNumberOfStates() const
Partition< DdType, ValueType > replacePartition(storm::dd::Add< DdType, ValueType > const &newPartitionAdd, uint64_t numberOfBlocks, uint64_t nextFreeBlockIndex, boost::optional< storm::dd::Add< DdType, ValueType > > const &changedStates=boost::none) const
virtual ModelType getType() const
Return the actual type of the model.
Base class for all symbolic models.
storm::dd::DdManager< Type > & getManager() const
Retrieves the manager responsible for the DDs that represent this model.
storm::dd::Add< Type, ValueType > const & getTransitionMatrix() const
Retrieves the matrix representing the transitions of the model.
std::set< storm::expressions::Variable > const & getColumnVariables() const
Retrieves the meta variables used to encode the columns of the transition matrix and the vector indic...
virtual std::set< storm::expressions::Variable > const & getNondeterminismVariables() const
Retrieves all meta variables used to encode the nondeterminism.
std::vector< std::pair< storm::expressions::Variable, storm::expressions::Variable > > const & getRowColumnMetaVariablePairs() const
Retrieves the pairs of row and column meta variables.
std::set< storm::expressions::Variable > const & getRowVariables() const
Retrieves the meta variables used to encode the rows of the transition matrix and the vector indices.
virtual storm::dd::Bdd< Type > getStates(std::string const &label) const
Returns the sets of states labeled with the given label.
storm::dd::Bdd< Type > const & getReachableStates() const
Retrieves the reachable states of the model.
Base class for all nondeterministic symbolic models.
storm::dd::Bdd< Type > const & getIllegalMask() const
Retrieves a BDD characterizing all illegal nondeterminism encodings in the model.
#define STORM_LOG_INFO(message)
#define STORM_LOG_TRACE(message)
#define STORM_LOG_THROW(cond, exception, message)
void enumerateBlocksRec(std::vector< storm::dd::Bdd< DdType > > const &stateSets, storm::dd::Bdd< DdType > const ¤tStateSet, uint64_t offset, storm::expressions::Variable const &blockVariable, std::function< void(storm::dd::Bdd< DdType > const &)> const &callback)
FragmentSpecification propositional()
std::pair< storm::RationalNumber, storm::RationalNumber > count(std::vector< storm::storage::BitVector > const &origSets, std::vector< storm::storage::BitVector > const &intersects, std::vector< storm::storage::BitVector > const &intersectsInfo, storm::RationalNumber val, bool plus, uint64_t remdepth)
SettingsManager const & manager()
Retrieves the settings manager.
InitialPartitionMode initialPartitionMode