From 6faf074fc53c1addd2efc2fbbfdbfe4a3fb21d7f Mon Sep 17 00:00:00 2001 From: Tim Quatmann Date: Mon, 18 Mar 2019 15:34:27 +0100 Subject: [PATCH] Made sure that model::getAllParameters also returns the parameters occurring at rates. --- src/storm/models/sparse/Model.cpp | 16 ++++++++++++++++ src/storm/models/sparse/Model.h | 9 ++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/storm/models/sparse/Model.cpp b/src/storm/models/sparse/Model.cpp index 66da51770..a5b0e6002 100644 --- a/src/storm/models/sparse/Model.cpp +++ b/src/storm/models/sparse/Model.cpp @@ -10,6 +10,8 @@ #include "storm/exceptions/IllegalArgumentException.h" #include "storm/exceptions/IllegalFunctionCallException.h" +#include "storm/models/sparse/Ctmc.h" +#include "storm/models/sparse/MarkovAutomaton.h" namespace storm { namespace models { @@ -474,10 +476,24 @@ namespace storm { return result; } + std::set getRateParameters(Model const& model) { + if (model.isOfType(storm::models::ModelType::Ctmc)) { + auto const& ctmc = model.template as>(); + return storm::utility::vector::getVariables(ctmc->getExitRateVector()); + } else if (model.isOfType(storm::models::ModelType::MarkovAutomaton)) { + auto const& ma = model.template as>(); + return storm::utility::vector::getVariables(ma->getExitRates()); + } else { + return {}; + } + } + std::set getAllParameters(Model const& model) { std::set parameters = getProbabilityParameters(model); std::set rewardParameters = getRewardParameters(model); parameters.insert(rewardParameters.begin(), rewardParameters.end()); + std::set rateParameters = getRewardParameters(model); + parameters.insert(rateParameters.begin(), rateParameters.end()); return parameters; } #endif diff --git a/src/storm/models/sparse/Model.h b/src/storm/models/sparse/Model.h index 4e1d91b0a..885374ab6 100644 --- a/src/storm/models/sparse/Model.h +++ b/src/storm/models/sparse/Model.h @@ -436,7 +436,14 @@ namespace storm { std::set getRewardParameters(Model const& model); /*! - * Get all parameters (probability and rewards) occurring in the model. + * Get all parameters occurring in rates. + * @param model Model. + * @return Set of parameters. If model is not a continuous time model, the returned set is empty. + */ + std::set getRateParameters(Model const& model); + + /*! + * Get all parameters (probability, rewards, and rates) occurring in the model. * @param model Model. * @return Set of parameters. */