Browse Source

Fixed the reward-issue even harder.

Former-commit-id: 2ca1c229e1
tempestpy_adaptions
dehnert 10 years ago
parent
commit
79798e2cb1
  1. 17
      src/adapters/ExplicitModelAdapter.h
  2. 2
      src/utility/cli.h

17
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, std::string const& rewardModelName = "", std::string const& constantDefinitionString = "") {
static std::unique_ptr<storm::models::AbstractModel<ValueType>> translateProgram(storm::prism::Program program, bool rewards = true, 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,8 +110,19 @@ 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.hasRewardModel(rewardModelName) ? preparedProgram.getRewardModel(rewardModelName) : storm::prism::RewardModel();
storm::prism::RewardModel rewardModel = storm::prism::RewardModel();
// Select the appropriate reward model.
if (rewards) {
// If a specific reward model was selected or one with the empty name exists, select it.
if (rewardModelName != "" || preparedProgram.hasRewardModel(rewardModelName)) {
rewardModel = preparedProgram.getRewardModel(rewardModelName);
} else if (preparedProgram.hasRewardModel()) {
// Otherwise, we select the first one.
rewardModel = preparedProgram.getRewardModel(0);
}
}
ModelComponents modelComponents = buildModelComponents(preparedProgram, rewardModel);
std::unique_ptr<storm::models::AbstractModel<ValueType>> result;

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() ? settings.getSymbolicRewardModelName() : "", constants);
result = storm::adapters::ExplicitModelAdapter<double>::translateProgram(program, true, settings.isSymbolicRewardModelNameSet() ? settings.getSymbolicRewardModelName() : "", constants);
} else {
STORM_LOG_THROW(false, storm::exceptions::InvalidSettingsException, "No input model.");
}

Loading…
Cancel
Save