Skip to content

Commit 3fae532

Browse files
committed
Preserve reward models in graph-preserving bisim
1 parent f739523 commit 3fae532

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/storm/api/bisimulation.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
#include <any>
34
#include "storm/models/sparse/Ctmc.h"
45
#include "storm/models/sparse/Dtmc.h"
56
#include "storm/models/sparse/Mdp.h"
@@ -24,8 +25,16 @@ std::shared_ptr<ModelType> performDeterministicSparseBisimulationMinimization(st
2425
if (!formulas.empty() && graphPreserving) {
2526
options = typename storm::storage::DeterministicModelBisimulationDecomposition<ModelType>::Options(*model, formulas);
2627
}
28+
// If we cannot use formula-based decomposition because of
29+
// non-graph-preserving regions but there are reward models, we need to
30+
// preserve those
31+
if (!graphPreserving && std::any_of(formulas.begin(), formulas.end(), [](auto const& formula) {
32+
return formula->getReferencedRewardModels().size() > 0;
33+
})) {
34+
options.setKeepRewards(true);
35+
}
2736
options.setType(type);
28-
37+
2938
storm::storage::DeterministicModelBisimulationDecomposition<ModelType> bisimulationDecomposition(*model, options);
3039
bisimulationDecomposition.computeBisimulationDecomposition();
3140
return bisimulationDecomposition.getQuotient();
@@ -39,6 +48,14 @@ std::shared_ptr<ModelType> performNondeterministicSparseBisimulationMinimization
3948
if (!formulas.empty() && graphPreserving) {
4049
options = typename storm::storage::NondeterministicModelBisimulationDecomposition<ModelType>::Options(*model, formulas);
4150
}
51+
// If we cannot use formula-based decomposition because of
52+
// non-graph-preserving regions but there are reward models, we need to
53+
// preserve those
54+
if (!graphPreserving && std::any_of(formulas.begin(), formulas.end(), [](auto const& formula) {
55+
return formula->getReferencedRewardModels().size() > 0;
56+
})) {
57+
options.setKeepRewards(true);
58+
}
4259
options.setType(type);
4360

4461
storm::storage::NondeterministicModelBisimulationDecomposition<ModelType> bisimulationDecomposition(*model, options);

src/storm/storage/bisimulation/BisimulationDecomposition.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ class BisimulationDecomposition : public Decomposition<StateBlock> {
103103
return this->keepRewards;
104104
}
105105

106+
void setKeepRewards(bool keepRewards) {
107+
this->keepRewards = keepRewards;
108+
}
109+
106110
bool isOptimizationDirectionSet() const {
107111
return static_cast<bool>(optimalityType);
108112
}

0 commit comments

Comments
 (0)