From 44bcad9779804e979037f34bd5cc5c6a425f5de0 Mon Sep 17 00:00:00 2001 From: Matthias Volk Date: Mon, 28 Aug 2017 16:08:49 +0200 Subject: [PATCH] Fixed bindings for ModelBase::as --- src/storage/model.cpp | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/storage/model.cpp b/src/storage/model.cpp index 6bb90cb..48f0da4 100644 --- a/src/storage/model.cpp +++ b/src/storage/model.cpp @@ -98,14 +98,30 @@ void define_model(py::module& m) { .def_property_readonly("supports_parameters", &ModelBase::supportsParameters, "Flag whether model supports parameters") .def_property_readonly("has_parameters", &ModelBase::hasParameters, "Flag whether model has parameters") .def_property_readonly("is_exact", &ModelBase::isExact, "Flag whether model is exact") - .def("_as_dtmc", &ModelBase::as>, "Get model as DTMC") - .def("_as_pdtmc", &ModelBase::as>, "Get model as pDTMC") - .def("_as_mdp", &ModelBase::as>, "Get model as MDP") - .def("_as_pmdp", &ModelBase::as>, "Get model as pMDP") - .def("_as_ctmc", &ModelBase::as>, "Get model as CTMC") - .def("_as_pctmc", &ModelBase::as>, "Get model as pCTMC") - .def("_as_ma", &ModelBase::as>, "Get model as MA") - .def("_as_pma", &ModelBase::as>, "Get model as pMA") + .def("_as_dtmc", [](ModelBase &modelbase) { + return modelbase.as>(); + }, "Get model as DTMC") + .def("_as_pdtmc", [](ModelBase &modelbase) { + return modelbase.as>(); + }, "Get model as pDTMC") + .def("_as_mdp", [](ModelBase &modelbase) { + return modelbase.as>(); + }, "Get model as MDP") + .def("_as_pmdp", [](ModelBase &modelbase) { + return modelbase.as>(); + }, "Get model as pMDP") + .def("_as_ctmc", [](ModelBase &modelbase) { + return modelbase.as>(); + }, "Get model as CTMC") + .def("_as_pctmc", [](ModelBase &modelbase) { + return modelbase.as>(); + }, "Get model as pCTMC") + .def("_as_ma", [](ModelBase &modelbase) { + return modelbase.as>(); + }, "Get model as MA") + .def("_as_pma", [](ModelBase &modelbase) { + return modelbase.as>(); + }, "Get model as pMA") ; // Models @@ -140,7 +156,7 @@ void define_model(py::module& m) { .def_property_readonly("state_rewards", [](RewardModel& rewardModel) {return rewardModel.getStateRewardVector();}) .def_property_readonly("state_action_rewards", [](RewardModel& rewardModel) {return rewardModel.getStateActionRewardVector();}) .def("reduce_to_state_based_rewards", [](RewardModel& rewardModel, SparseMatrix const& transitions, bool onlyStateRewards){return rewardModel.reduceToStateBasedRewards(transitions, onlyStateRewards);}, py::arg("transition_matrix"), py::arg("only_state_rewards"), "Reduce to state-based rewards") - ; + ; @@ -183,8 +199,7 @@ void define_model(py::module& m) { .def_property_readonly("state_rewards", [](RewardModel& rewardModel) {return rewardModel.getStateRewardVector();}) .def_property_readonly("state_action_rewards", [](RewardModel& rewardModel) {return rewardModel.getStateActionRewardVector();}) .def("reduce_to_state_based_rewards", [](RewardModel& rewardModel, SparseMatrix const& transitions, bool onlyStateRewards){return rewardModel.reduceToStateBasedRewards(transitions, onlyStateRewards);}, py::arg("transition_matrix"), py::arg("only_state_rewards"), "Reduce to state-based rewards") - - ; + ; }