Browse Source

Added conversion from transition-based rewards to state-based rewards to enable proper treatment in bisimulation minimization

Former-commit-id: d0c31094bd
tempestpy_adaptions
dehnert 10 years ago
parent
commit
9cf82bcd98
  1. 13
      src/models/AbstractModel.h
  2. 4
      src/utility/cli.h

13
src/models/AbstractModel.h

@ -11,7 +11,11 @@
#include "src/storage/SparseMatrix.h"
#include "src/storage/Scheduler.h"
#include "src/storage/StronglyConnectedComponentDecomposition.h"
#include "src/utility/macros.h"
#include "src/utility/Hash.h"
#include "src/utility/vector.h"
#include "src/exceptions/InvalidOperationException.h"
namespace storm {
namespace models {
@ -329,6 +333,15 @@ class AbstractModel: public std::enable_shared_from_this<AbstractModel<T>> {
return static_cast<bool>(choiceLabeling);
}
void convertTransitionRewardsToStateRewards() {
STORM_LOG_THROW(this->hasTransitionRewards(), storm::exceptions::InvalidOperationException, "Cannot reduce non-existant transition rewards to state rewards.");
if (this->hasStateRewards()) {
storm::utility::vector::addVectorsInPlace(stateRewardVector.get(), transitionMatrix.getPointwiseProductRowSumVector(transitionRewardMatrix.get()));
} else {
this->stateRewardVector = transitionMatrix.getPointwiseProductRowSumVector(transitionRewardMatrix.get());
}
}
/*!
* Retrieves the size of the internal representation of the model in memory.
* @return the size of the internal representation of the model in memory

4
src/utility/cli.h

@ -288,6 +288,10 @@ namespace storm {
STORM_LOG_THROW(model->getType() == storm::models::DTMC, storm::exceptions::InvalidSettingsException, "Bisimulation minimization is currently only available for DTMCs.");
std::shared_ptr<storm::models::Dtmc<double>> dtmc = model->template as<storm::models::Dtmc<double>>();
if (dtmc->hasTransitionRewards()) {
dtmc->convertTransitionRewardsToStateRewards();
}
std::cout << "Performing bisimulation minimization... ";
storm::storage::DeterministicModelBisimulationDecomposition<double> bisimulationDecomposition(*dtmc, boost::optional<std::set<std::string>>(), true, storm::settings::bisimulationSettings().isWeakBisimulationSet(), true);
model = bisimulationDecomposition.getQuotient();

Loading…
Cancel
Save