Skip to content

Commit

Permalink
Preserve reward models in graph-preserving bisim
Browse files Browse the repository at this point in the history
  • Loading branch information
glatteis committed Aug 5, 2024
1 parent f739523 commit 3fae532
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/storm/api/bisimulation.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <any>
#include "storm/models/sparse/Ctmc.h"
#include "storm/models/sparse/Dtmc.h"
#include "storm/models/sparse/Mdp.h"
Expand All @@ -24,8 +25,16 @@ std::shared_ptr<ModelType> performDeterministicSparseBisimulationMinimization(st
if (!formulas.empty() && graphPreserving) {
options = typename storm::storage::DeterministicModelBisimulationDecomposition<ModelType>::Options(*model, formulas);
}
// If we cannot use formula-based decomposition because of
// non-graph-preserving regions but there are reward models, we need to
// preserve those
if (!graphPreserving && std::any_of(formulas.begin(), formulas.end(), [](auto const& formula) {
return formula->getReferencedRewardModels().size() > 0;
})) {
options.setKeepRewards(true);
}
options.setType(type);

storm::storage::DeterministicModelBisimulationDecomposition<ModelType> bisimulationDecomposition(*model, options);
bisimulationDecomposition.computeBisimulationDecomposition();
return bisimulationDecomposition.getQuotient();
Expand All @@ -39,6 +48,14 @@ std::shared_ptr<ModelType> performNondeterministicSparseBisimulationMinimization
if (!formulas.empty() && graphPreserving) {
options = typename storm::storage::NondeterministicModelBisimulationDecomposition<ModelType>::Options(*model, formulas);
}
// If we cannot use formula-based decomposition because of
// non-graph-preserving regions but there are reward models, we need to
// preserve those
if (!graphPreserving && std::any_of(formulas.begin(), formulas.end(), [](auto const& formula) {
return formula->getReferencedRewardModels().size() > 0;
})) {
options.setKeepRewards(true);
}
options.setType(type);

storm::storage::NondeterministicModelBisimulationDecomposition<ModelType> bisimulationDecomposition(*model, options);
Expand Down
4 changes: 4 additions & 0 deletions src/storm/storage/bisimulation/BisimulationDecomposition.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ class BisimulationDecomposition : public Decomposition<StateBlock> {
return this->keepRewards;
}

void setKeepRewards(bool keepRewards) {
this->keepRewards = keepRewards;
}

bool isOptimizationDirectionSet() const {
return static_cast<bool>(optimalityType);
}
Expand Down

0 comments on commit 3fae532

Please sign in to comment.