Browse Source

added some debug output to JaniNextStateGenerator

Former-commit-id: 2c116cf22b [formerly 98c11d0ce2]
Former-commit-id: bc3a09342a
tempestpy_adaptions
dehnert 8 years ago
parent
commit
ae8a963c33
  1. 2
      src/builder/jit/StateBehaviour.cpp
  2. 14
      src/generator/JaniNextStateGenerator.cpp
  3. 2
      src/generator/NextStateGenerator.cpp
  4. 2
      src/generator/PrismNextStateGenerator.cpp
  5. 31
      src/storage/expressions/SimpleValuation.cpp
  6. 2
      src/utility/storm.h

2
src/builder/jit/StateBehaviour.cpp

@ -133,8 +133,8 @@ namespace storm {
// If there is no previous Markovian choice, just move the Markovian choice to the front. // If there is no previous Markovian choice, just move the Markovian choice to the front.
if (index != 0) { if (index != 0) {
std::swap(choices.front(), choice); std::swap(choices.front(), choice);
foundPreviousMarkovianChoice = true;
} }
foundPreviousMarkovianChoice = true;
++index; ++index;
} }
} else { } else {

14
src/generator/JaniNextStateGenerator.cpp

@ -390,6 +390,9 @@ namespace storm {
// Iterate over all automata. // Iterate over all automata.
uint64_t automatonIndex = 0; uint64_t automatonIndex = 0;
std::cout << "getting silent choices of state" << std::endl;
std::cout << unpackStateIntoValuation(state, this->variableInformation, *this->expressionManager).toString(true) << std::endl;
for (auto const& automaton : model.getAutomata()) { for (auto const& automaton : model.getAutomata()) {
uint64_t location = locations[automatonIndex]; uint64_t location = locations[automatonIndex];
@ -402,8 +405,10 @@ namespace storm {
// Skip the command, if it is not enabled. // Skip the command, if it is not enabled.
if (!this->evaluator->asBool(edge.getGuard())) { if (!this->evaluator->asBool(edge.getGuard())) {
std::cout << "guard " << edge.getGuard() << " evaluates to false" << std::endl;
continue; continue;
} }
std::cout << "guard " << edge.getGuard() << " evaluates to true" << std::endl;
// Determine the exit rate if it's a Markovian edge. // Determine the exit rate if it's a Markovian edge.
boost::optional<ValueType> exitRate = boost::none; boost::optional<ValueType> exitRate = boost::none;
@ -422,6 +427,7 @@ namespace storm {
if (probability != storm::utility::zero<ValueType>()) { if (probability != storm::utility::zero<ValueType>()) {
// Obtain target state index and add it to the list of known states. If it has not yet been // Obtain target state index and add it to the list of known states. If it has not yet been
// seen, we also add it to the set of states that have yet to be explored. // seen, we also add it to the set of states that have yet to be explored.
std::cout << "got new state " << unpackStateIntoValuation(applyUpdate(state, destination, this->variableInformation.locationVariables[automatonIndex]), this->variableInformation, *this->expressionManager).toString(true) << std::endl;
StateType stateIndex = stateToIdCallback(applyUpdate(state, destination, this->variableInformation.locationVariables[automatonIndex])); StateType stateIndex = stateToIdCallback(applyUpdate(state, destination, this->variableInformation.locationVariables[automatonIndex]));
// Update the choice by adding the probability/target state to it. // Update the choice by adding the probability/target state to it.
@ -453,6 +459,9 @@ namespace storm {
std::vector<Choice<ValueType>> JaniNextStateGenerator<ValueType, StateType>::getNonsilentActionChoices(std::vector<uint64_t> const& locations, CompressedState const& state, StateToIdCallback stateToIdCallback) { std::vector<Choice<ValueType>> JaniNextStateGenerator<ValueType, StateType>::getNonsilentActionChoices(std::vector<uint64_t> const& locations, CompressedState const& state, StateToIdCallback stateToIdCallback) {
std::vector<Choice<ValueType>> result; std::vector<Choice<ValueType>> result;
std::cout << "getting nonsilent choices of state" << std::endl;
std::cout << unpackStateIntoValuation(state, this->variableInformation, *this->expressionManager).toString(true) << std::endl;
for (uint64_t actionIndex : model.getNonsilentActionIndices()) { for (uint64_t actionIndex : model.getNonsilentActionIndices()) {
std::vector<std::vector<storm::jani::Edge const*>> enabledEdges = getEnabledEdges(locations, actionIndex); std::vector<std::vector<storm::jani::Edge const*>> enabledEdges = getEnabledEdges(locations, actionIndex);
@ -530,10 +539,15 @@ namespace storm {
// Add the probabilities/rates to the newly created choice. // Add the probabilities/rates to the newly created choice.
ValueType probabilitySum = storm::utility::zero<ValueType>(); ValueType probabilitySum = storm::utility::zero<ValueType>();
for (auto const& stateProbabilityPair : *newTargetStates) { for (auto const& stateProbabilityPair : *newTargetStates) {
std::cout << "got new state (sync)" << std::endl;
std::cout << unpackStateIntoValuation(stateProbabilityPair.first, this->variableInformation, *this->expressionManager).toString(true) << std::endl;
StateType actualIndex = stateToIdCallback(stateProbabilityPair.first); StateType actualIndex = stateToIdCallback(stateProbabilityPair.first);
choice.addProbability(actualIndex, stateProbabilityPair.second); choice.addProbability(actualIndex, stateProbabilityPair.second);
if (this->options.isExplorationChecksSet()) {
probabilitySum += stateProbabilityPair.second; probabilitySum += stateProbabilityPair.second;
} }
}
if (this->options.isExplorationChecksSet()) { if (this->options.isExplorationChecksSet()) {
// Check that the resulting distribution is in fact a distribution. // Check that the resulting distribution is in fact a distribution.

2
src/generator/NextStateGenerator.cpp

@ -127,8 +127,8 @@ namespace storm {
// If there is no previous Markovian choice, just move the Markovian choice to the front. // If there is no previous Markovian choice, just move the Markovian choice to the front.
if (index != 0) { if (index != 0) {
std::swap(result.getChoices().front(), choice); std::swap(result.getChoices().front(), choice);
foundPreviousMarkovianChoice = true;
} }
foundPreviousMarkovianChoice = true;
++index; ++index;
} }
} else { } else {

2
src/generator/PrismNextStateGenerator.cpp

@ -407,9 +407,11 @@ namespace storm {
// Update the choice by adding the probability/target state to it. // Update the choice by adding the probability/target state to it.
choice.addProbability(stateIndex, probability); choice.addProbability(stateIndex, probability);
if (this->options.isExplorationChecksSet()) {
probabilitySum += probability; probabilitySum += probability;
} }
} }
}
// Create the state-action reward for the newly created choice. // Create the state-action reward for the newly created choice.
for (auto const& rewardModel : rewardModels) { for (auto const& rewardModel : rewardModels) {

31
src/storage/expressions/SimpleValuation.cpp

@ -110,27 +110,16 @@ namespace storm {
return "[" + boost::join(assignments, ", ") + "]"; return "[" + boost::join(assignments, ", ") + "]";
} }
std::string SimpleValuation::toString(bool pretty) const { std::string SimpleValuation::toString(bool pretty) const {
std::stringstream sstr;
if(pretty) {
sstr << "valuation {" << std::endl;
for(auto const& e : getManager()) {
sstr << e.first.getName() << "=";
if (e.first.hasBooleanType()) {
sstr << std::boolalpha << this->getBooleanValue(e.first) << std::noboolalpha;
} else if (e.first.hasIntegerType()) {
sstr << this->getIntegerValue(e.first);
} else if (e.first.hasRationalType()) {
sstr << this->getRationalValue(e.first);
} else {
STORM_LOG_THROW(false, storm::exceptions::InvalidTypeException, "Unexpected variable type.");
}
sstr << std::endl;
if (pretty) {
std::set<storm::expressions::Variable> allVariables;
for (auto const& e : getManager()) {
allVariables.insert(e.first);
} }
sstr << "}";
return toPrettyString(allVariables);
} else { } else {
sstr << "valuation {" << std::endl;
std::stringstream sstr;
sstr << "[" << std::endl;
sstr << getManager() << std::endl; sstr << getManager() << std::endl;
if (!booleanValues.empty()) { if (!booleanValues.empty()) {
for (auto const& element : booleanValues) { for (auto const& element : booleanValues) {
@ -150,12 +139,10 @@ namespace storm {
} }
sstr << std::endl; sstr << std::endl;
} }
sstr << "}";
}
sstr << "]";
return sstr.str(); return sstr.str();
} }
}
std::ostream& operator<<(std::ostream& out, SimpleValuation const& valuation) { std::ostream& operator<<(std::ostream& out, SimpleValuation const& valuation) {
out << valuation.toString(false) << std::endl; out << valuation.toString(false) << std::endl;

2
src/utility/storm.h

@ -226,7 +226,7 @@ namespace storm {
if (model->getType() == storm::models::ModelType::MarkovAutomaton && model->isSparseModel()) { if (model->getType() == storm::models::ModelType::MarkovAutomaton && model->isSparseModel()) {
std::shared_ptr<storm::models::sparse::MarkovAutomaton<typename ModelType::ValueType>> ma = model->template as<storm::models::sparse::MarkovAutomaton<typename ModelType::ValueType>>(); std::shared_ptr<storm::models::sparse::MarkovAutomaton<typename ModelType::ValueType>> ma = model->template as<storm::models::sparse::MarkovAutomaton<typename ModelType::ValueType>>();
if (ma->hasOnlyTrivialNondeterminism()) { if (ma->hasOnlyTrivialNondeterminism()) {
// Markov automaton can be converted into CTMC
// Markov automaton can be converted into CTMC.
model = ma->convertToCTMC(); model = ma->convertToCTMC();
} }
} }

Loading…
Cancel
Save