Browse Source

Include choice labels in exported scheduler.

tempestpy_adaptions
Tim Quatmann 5 years ago
parent
commit
b896726c4a
  1. 10
      src/storm/storage/Scheduler.cpp

10
src/storm/storage/Scheduler.cpp

@ -3,6 +3,7 @@
#include "storm/utility/macros.h" #include "storm/utility/macros.h"
#include "storm/exceptions/NotImplementedException.h" #include "storm/exceptions/NotImplementedException.h"
#include <boost/algorithm/string/join.hpp>
namespace storm { namespace storm {
namespace storage { namespace storage {
@ -125,6 +126,7 @@ namespace storm {
STORM_LOG_THROW(model == nullptr || model->getNumberOfStates() == schedulerChoices.front().size(), storm::exceptions::InvalidOperationException, "The given model is not compatible with this scheduler."); STORM_LOG_THROW(model == nullptr || model->getNumberOfStates() == schedulerChoices.front().size(), storm::exceptions::InvalidOperationException, "The given model is not compatible with this scheduler.");
bool const stateValuationsGiven = model != nullptr && model->hasStateValuations(); bool const stateValuationsGiven = model != nullptr && model->hasStateValuations();
bool const choiceLabelsGiven = model != nullptr && model->hasChoiceLabeling();
bool const choiceOriginsGiven = model != nullptr && model->hasChoiceOrigins(); bool const choiceOriginsGiven = model != nullptr && model->hasChoiceOrigins();
uint_fast64_t widthOfStates = std::to_string(schedulerChoices.front().size()).length(); uint_fast64_t widthOfStates = std::to_string(schedulerChoices.front().size()).length();
if (stateValuationsGiven) { if (stateValuationsGiven) {
@ -181,6 +183,10 @@ namespace storm {
} else { } else {
out << choice.getDeterministicChoice(); out << choice.getDeterministicChoice();
} }
if (choiceLabelsGiven) {
auto choiceLabels = model->getChoiceLabeling().getLabelsOfChoice(model->getTransitionMatrix().getRowGroupIndices()[state] + choice.getDeterministicChoice());
out << " {" << boost::join(choiceLabels, ", ") << "}";
}
} else { } else {
bool firstChoice = true; bool firstChoice = true;
for (auto const& choiceProbPair : choice.getChoiceAsDistribution()) { for (auto const& choiceProbPair : choice.getChoiceAsDistribution()) {
@ -195,6 +201,10 @@ namespace storm {
} else { } else {
out << choiceProbPair.first; out << choiceProbPair.first;
} }
if (choiceLabelsGiven) {
auto choiceLabels = model->getChoiceLabeling().getLabelsOfChoice(model->getTransitionMatrix().getRowGroupIndices()[state] + choice.getDeterministicChoice());
out << " {" << boost::join(choiceLabels, ", ") << "}";
}
out << ")"; out << ")";
} }
} }

Loading…
Cancel
Save