diff --git a/src/adapters/ExplicitModelAdapter.h b/src/adapters/ExplicitModelAdapter.h index e341507a2..1fafc1066 100644 --- a/src/adapters/ExplicitModelAdapter.h +++ b/src/adapters/ExplicitModelAdapter.h @@ -100,7 +100,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); @@ -116,8 +116,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/stormParametric.cpp b/src/stormParametric.cpp index 143120667..1e550e6ad 100644 --- a/src/stormParametric.cpp +++ b/src/stormParametric.cpp @@ -143,7 +143,7 @@ int main(const int argc, const char** argv) { std::string const& programFile = storm::settings::generalSettings().getSymbolicModelFilename(); std::string const& constants = storm::settings::generalSettings().getConstantDefinitionString(); storm::prism::Program program = storm::parser::PrismParser::parse(programFile); - std::shared_ptr> model = storm::adapters::ExplicitModelAdapter::translateProgram(program, storm::settings::generalSettings().isSymbolicRewardModelNameSet() ? program.getRewardModel(storm::settings::generalSettings().getSymbolicRewardModelName()) : storm::prism::RewardModel(), constants); + std::shared_ptr> model = storm::adapters::ExplicitModelAdapter::translateProgram(program, true, storm::settings::generalSettings().isSymbolicRewardModelNameSet() ? storm::settings::generalSettings().getSymbolicRewardModelName() : "", constants); model->printModelInformationToStream(std::cout); diff --git a/src/utility/cli.h b/src/utility/cli.h index ebe93b672..919e221c5 100644 --- a/src/utility/cli.h +++ b/src/utility/cli.h @@ -262,7 +262,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."); }