From c29871b1b2da6da430f20b7509e4a2ddc5448b3a Mon Sep 17 00:00:00 2001 From: Sebastian Junges Date: Fri, 24 Apr 2020 16:12:26 -0700 Subject: [PATCH] build reward models and get them by name --- src/core/core.cpp | 3 ++- src/storage/model.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/core.cpp b/src/core/core.cpp index acf2898..a4aba93 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -120,7 +120,8 @@ void define_build(py::module& m) { .def("set_add_out_of_bounds_state", &storm::builder::BuilderOptions::setAddOutOfBoundsState, "Build with out of bounds state", py::arg("new_value")=true) .def("set_add_overlapping_guards_label", &storm::builder::BuilderOptions::setAddOverlappingGuardsLabel, "Build with overlapping guards state labeled", py::arg("new_value")=true) .def("set_build_choice_labels", &storm::builder::BuilderOptions::setBuildChoiceLabels, "Build with choice labels", py::arg("new_value")=true) - .def("set_build_all_labels" , &storm::builder::BuilderOptions::setBuildAllLabels, "Build with all state labels", py::arg("new_value")=true); + .def("set_build_all_labels" , &storm::builder::BuilderOptions::setBuildAllLabels, "Build with all state labels", py::arg("new_value")=true) + .def("set_build_all_reward_models", &storm::builder::BuilderOptions::setBuildAllRewardModels, "Build with all reward models", py::arg("new_value")=true); } void define_optimality_type(py::module& m) { diff --git a/src/storage/model.cpp b/src/storage/model.cpp index 7c7fe09..d470ba5 100644 --- a/src/storage/model.cpp +++ b/src/storage/model.cpp @@ -181,6 +181,7 @@ void define_sparse_model(py::module& m) { .def_property_readonly("reward_models", [](SparseModel& model) {return model.getRewardModels(); }, "Reward models") .def_property_readonly("transition_matrix", &getTransitionMatrix, py::return_value_policy::reference, py::keep_alive<1, 0>(), "Transition matrix") .def_property_readonly("backward_transition_matrix", &SparseModel::getBackwardTransitions, py::return_value_policy::reference, py::keep_alive<1, 0>(), "Backward transition matrix") + .def("get_reward_model", [](SparseModel& model, std::string const& name) {return model.getRewardModel(name);}, py::return_value_policy::reference, py::keep_alive<1, 0>(), "Reward model") .def("has_state_valuations", [](SparseModel const& model) {return model.hasStateValuations();}, "has state valuation?") .def_property_readonly("state_valuations", [](SparseModel const& model) {return model.getStateValuations();}, "state valuations") .def("reduce_to_state_based_rewards", &SparseModel::reduceToStateBasedRewards)