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. 16
      src/generator/JaniNextStateGenerator.cpp
  3. 2
      src/generator/NextStateGenerator.cpp
  4. 6
      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 (index != 0) {
std::swap(choices.front(), choice);
foundPreviousMarkovianChoice = true;
}
foundPreviousMarkovianChoice = true;
++index;
}
} else {

16
src/generator/JaniNextStateGenerator.cpp

@ -390,6 +390,9 @@ namespace storm {
// Iterate over all automata.
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()) {
uint64_t location = locations[automatonIndex];
@ -402,8 +405,10 @@ namespace storm {
// Skip the command, if it is not enabled.
if (!this->evaluator->asBool(edge.getGuard())) {
std::cout << "guard " << edge.getGuard() << " evaluates to false" << std::endl;
continue;
}
std::cout << "guard " << edge.getGuard() << " evaluates to true" << std::endl;
// Determine the exit rate if it's a Markovian edge.
boost::optional<ValueType> exitRate = boost::none;
@ -422,6 +427,7 @@ namespace storm {
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
// 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]));
// 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>> 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()) {
std::vector<std::vector<storm::jani::Edge const*>> enabledEdges = getEnabledEdges(locations, actionIndex);
@ -530,9 +539,14 @@ namespace storm {
// Add the probabilities/rates to the newly created choice.
ValueType probabilitySum = storm::utility::zero<ValueType>();
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);
choice.addProbability(actualIndex, stateProbabilityPair.second);
probabilitySum += stateProbabilityPair.second;
if (this->options.isExplorationChecksSet()) {
probabilitySum += stateProbabilityPair.second;
}
}
if (this->options.isExplorationChecksSet()) {

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 (index != 0) {
std::swap(result.getChoices().front(), choice);
foundPreviousMarkovianChoice = true;
}
foundPreviousMarkovianChoice = true;
++index;
}
} else {

6
src/generator/PrismNextStateGenerator.cpp

@ -385,7 +385,7 @@ namespace storm {
if (!this->evaluator->asBool(command.getGuardExpression())) {
continue;
}
result.push_back(Choice<ValueType>(command.getActionIndex(), command.isMarkovian()));
Choice<ValueType>& choice = result.back();
@ -407,7 +407,9 @@ namespace storm {
// Update the choice by adding the probability/target state to it.
choice.addProbability(stateIndex, probability);
probabilitySum += probability;
if (this->options.isExplorationChecksSet()) {
probabilitySum += probability;
}
}
}

31
src/storage/expressions/SimpleValuation.cpp

@ -110,27 +110,16 @@ namespace storm {
return "[" + boost::join(assignments, ", ") + "]";
}
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 {
sstr << "valuation {" << std::endl;
std::stringstream sstr;
sstr << "[" << std::endl;
sstr << getManager() << std::endl;
if (!booleanValues.empty()) {
for (auto const& element : booleanValues) {
@ -150,11 +139,9 @@ namespace storm {
}
sstr << std::endl;
}
sstr << "}";
sstr << "]";
return sstr.str();
}
return sstr.str();
}
std::ostream& operator<<(std::ostream& out, SimpleValuation const& valuation) {

2
src/utility/storm.h

@ -226,7 +226,7 @@ namespace storm {
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>>();
if (ma->hasOnlyTrivialNondeterminism()) {
// Markov automaton can be converted into CTMC
// Markov automaton can be converted into CTMC.
model = ma->convertToCTMC();
}
}

Loading…
Cancel
Save