From 79798e2cb14dba323a3cefa78c17d0258316fed2 Mon Sep 17 00:00:00 2001 From: dehnert Date: Thu, 27 Nov 2014 18:35:09 +0100 Subject: [PATCH] Fixed the reward-issue even harder. Former-commit-id: 2ca1c229e1732824aca34f32cad8248cfeade28a --- src/adapters/ExplicitModelAdapter.h | 17 ++++++++++++++--- src/utility/cli.h | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/adapters/ExplicitModelAdapter.h b/src/adapters/ExplicitModelAdapter.h index 33d855af7..f6526ff11 100644 --- a/src/adapters/ExplicitModelAdapter.h +++ b/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> translateProgram(storm::prism::Program program, std::string const& rewardModelName = "", std::string const& constantDefinitionString = "") { + static std::unique_ptr> 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 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> result; diff --git a/src/utility/cli.h b/src/utility/cli.h index e0736efbc..30366caa9 100644 --- a/src/utility/cli.h +++ b/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::translateProgram(program, settings.isSymbolicRewardModelNameSet() ? settings.getSymbolicRewardModelName() : "", constants); + result = storm::adapters::ExplicitModelAdapter::translateProgram(program, true, settings.isSymbolicRewardModelNameSet() ? settings.getSymbolicRewardModelName() : "", constants); } else { STORM_LOG_THROW(false, storm::exceptions::InvalidSettingsException, "No input model."); }