Skip to content

Commit b3aebb6

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

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/storm/api/bisimulation.h

Lines changed: 15 additions & 0 deletions
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,6 +25,13 @@ 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 &&
32+
std::any_of(formulas.begin(), formulas.end(), [](auto const& formula) { return formula->getReferencedRewardModels().size() > 0; })) {
33+
options.setKeepRewards(true);
34+
}
2735
options.setType(type);
2836

2937
storm::storage::DeterministicModelBisimulationDecomposition<ModelType> bisimulationDecomposition(*model, options);
@@ -39,6 +47,13 @@ std::shared_ptr<ModelType> performNondeterministicSparseBisimulationMinimization
3947
if (!formulas.empty() && graphPreserving) {
4048
options = typename storm::storage::NondeterministicModelBisimulationDecomposition<ModelType>::Options(*model, formulas);
4149
}
50+
// If we cannot use formula-based decomposition because of
51+
// non-graph-preserving regions but there are reward models, we need to
52+
// preserve those
53+
if (!graphPreserving &&
54+
std::any_of(formulas.begin(), formulas.end(), [](auto const& formula) { return formula->getReferencedRewardModels().size() > 0; })) {
55+
options.setKeepRewards(true);
56+
}
4257
options.setType(type);
4358

4459
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)