From 7a274add6ef41d89ad40fa0e844aa2818f22aced Mon Sep 17 00:00:00 2001 From: hannah Date: Sat, 13 Jun 2020 09:35:40 +0200 Subject: [PATCH] PrismChoiceOrigins bindings --- src/storage/choiceorigins.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/storage/choiceorigins.cpp b/src/storage/choiceorigins.cpp index 01488b6..9973993 100644 --- a/src/storage/choiceorigins.cpp +++ b/src/storage/choiceorigins.cpp @@ -1,15 +1,35 @@ #include "choiceorigins.h" #include "storm/storage/sparse/JaniChoiceOrigins.h" +#include "storm/storage/sparse/PrismChoiceOrigins.h" #include "storm/storage/jani/Model.h" +using ChoiceOrigins = storm::storage::sparse::ChoiceOrigins; +using JaniChoiceOrigins = storm::storage::sparse::JaniChoiceOrigins; +using PrismChoiceOrigins = storm::storage::sparse::PrismChoiceOrigins; + void define_origins(py::module& m) { - using ChoiceOrigins = storm::storage::sparse::ChoiceOrigins; + py::class_> co(m, "ChoiceOrigins", "This class represents the origin of choices of a model in terms of the input model spec."); - co.def("get_identifier_info", &ChoiceOrigins::getIdentifierInfo, "identifier"_a, "human readable string") - .def("get_choice_info", &ChoiceOrigins::getChoiceInfo, "identifier"_a, "human readable string") ; - using JaniChoiceOrigins = storm::storage::sparse::JaniChoiceOrigins; + co.def("is_prism_choice_origins", &ChoiceOrigins::isPrismChoiceOrigins) + .def("is_jani_choice_origins", &ChoiceOrigins::isJaniChoiceOrigins) + .def("as_prism_choice_origins", [](ChoiceOrigins &co) -> PrismChoiceOrigins& { return co.asPrismChoiceOrigins(); }) + .def("as_jani_choice_origins", [](ChoiceOrigins &co) -> JaniChoiceOrigins& { return co.asJaniChoiceOrigins(); }) + .def("get_identifier_info", &ChoiceOrigins::getIdentifierInfo, "identifier"_a, "human readable string") + .def("get_choice_info", &ChoiceOrigins::getChoiceInfo, "identifier"_a, "human readable string") + .def("get_number_of_identifiers", &ChoiceOrigins::getNumberOfIdentifiers, "the number of considered identifier") + ; + + py::class_>(m, "JaniChoiceOrigins", "This class represents for each choice the origin in the jani spec.", co) + .def(py::initconst&, std::vector const&, std::vector const&>(), "jani_model"_a, "index_to_identifier_mapping"_a, "identifier_to_edge_index__set_mapping"_a) .def_property_readonly("model", &JaniChoiceOrigins::getModel, "retrieves the associated JANI model") .def("get_edge_index_set", [](JaniChoiceOrigins const& co, uint64_t choice) -> auto& { return co.getEdgeIndexSet(choice); }, "returns the set of edges that induced the choice", py::arg("choice_index")) - ; + ; + + py::class_>(m, "PrismChoiceOrigins", "This class represents for each choice the set of prism commands that induced the choice.", co) + .def(py::initconst&, std::vector const&, std::vector const&>(), "prism_program"_a, "index_to_identifier_mapping"_a, "identifier_to_command_set_mapping"_a) + .def_property_readonly("program", &PrismChoiceOrigins::getProgram, "retrieves the associated Prism program") + .def("get_command_set", [](PrismChoiceOrigins const& co, uint64_t choice) -> auto& { return co.getCommandSet(choice); }, "Returns the set of prism commands that induced the choice", py::arg("choice_index")) + ; + } \ No newline at end of file