Browse Source

Merge branch 'master' of https://sselab.de/lab9/private/git/storm

Former-commit-id: 0f0e18abad
tempestpy_adaptions
dehnert 10 years ago
parent
commit
0d2440d4a9
  1. 4
      src/adapters/ExplicitModelAdapter.h
  2. 6
      src/storage/prism/RewardModel.cpp
  3. 2
      src/utility/cli.h

4
src/adapters/ExplicitModelAdapter.h

@ -98,7 +98,7 @@ namespace storm {
* @param rewardModel The reward model that is to be built.
* @return The explicit model that was given by the probabilistic program.
*/
static std::unique_ptr<storm::models::AbstractModel<ValueType>> translateProgram(storm::prism::Program program, storm::prism::RewardModel const& rewardModel = storm::prism::RewardModel(), std::string const& constantDefinitionString = "") {
static std::unique_ptr<storm::models::AbstractModel<ValueType>> translateProgram(storm::prism::Program program, std::string const& rewardModelName = "", std::string const& constantDefinitionString = "") {
// Start by defining the undefined constants in the model.
// First, we need to parse the constant definition string.
std::map<std::string, storm::expressions::Expression> constantDefinitions = storm::utility::prism::parseConstantDefinitionString(program, constantDefinitionString);
@ -110,6 +110,7 @@ namespace storm {
// all expressions in the program so we can then evaluate them without having to store the values of the
// constants in the state (i.e., valuation).
preparedProgram = preparedProgram.substituteConstants();
storm::prism::RewardModel const& rewardModel = rewardModelName != "" ? preparedProgram.getRewardModel(rewardModelName) : storm::prism::RewardModel();
ModelComponents modelComponents = buildModelComponents(preparedProgram, rewardModel);
@ -525,6 +526,7 @@ namespace storm {
// Now add all rewards that match this choice.
for (auto const& transitionReward : transitionRewards) {
std::cout << transitionReward.getStatePredicateExpression() << std::endl;
if (transitionReward.getActionName() == "" && transitionReward.getStatePredicateExpression().evaluateAsBool(stateInformation.reachableStates.at(currentState))) {
stateToRewardMap[stateProbabilityPair.first] += ValueType(transitionReward.getRewardValueExpression().evaluateAsDouble(stateInformation.reachableStates.at(currentState)));
}

6
src/storage/prism/RewardModel.cpp

@ -46,7 +46,11 @@ namespace storm {
}
std::ostream& operator<<(std::ostream& stream, RewardModel const& rewardModel) {
stream << "rewards \"" << rewardModel.getName() << "\"" << std::endl;
stream << "rewards";
if (rewardModel.getName() != "") {
std::cout << " \"" << rewardModel.getName() << "\"";
}
std::cout << std::endl;
for (auto const& reward : rewardModel.getStateRewards()) {
stream << reward << std::endl;
}

2
src/utility/cli.h

@ -258,7 +258,7 @@ namespace storm {
storm::prism::Program program = storm::parser::PrismParser::parse(programFile);
// Then, build the model from the symbolic description.
result = storm::adapters::ExplicitModelAdapter<double>::translateProgram(program, settings.isSymbolicRewardModelNameSet() ? program.getRewardModel(settings.getSymbolicRewardModelName()) : storm::prism::RewardModel(), constants);
result = storm::adapters::ExplicitModelAdapter<double>::translateProgram(program, settings.isSymbolicRewardModelNameSet() ? settings.getSymbolicRewardModelName() : "", constants);
} else {
STORM_LOG_THROW(false, storm::exceptions::InvalidSettingsException, "No input model.");
}

Loading…
Cancel
Save