diff --git a/src/mod_storage.cpp b/src/mod_storage.cpp index e85dd03..997d037 100644 --- a/src/mod_storage.cpp +++ b/src/mod_storage.cpp @@ -8,6 +8,7 @@ #include "storage/prism.h" #include "storage/jani.h" #include "storage/state.h" +#include "storage/choiceorigins.h" #include "storage/labeling.h" #include "storage/expressions.h" @@ -30,6 +31,7 @@ PYBIND11_MODULE(storage, m) { define_prism(m); define_jani(m); define_labeling(m); + define_origins(m); define_expressions(m); define_scheduler(m, "Double"); define_distribution(m, "Double"); diff --git a/src/storage/choiceorigins.cpp b/src/storage/choiceorigins.cpp new file mode 100644 index 0000000..c41cfe2 --- /dev/null +++ b/src/storage/choiceorigins.cpp @@ -0,0 +1,13 @@ +#include "choiceorigins.h" +#include "storm/storage/sparse/JaniChoiceOrigins.h" +#include "storm/storage/jani/Model.h" + +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."); + using JaniChoiceOrigins = storm::storage::sparse::JaniChoiceOrigins; + py::class_>(m, "JaniChoiceOrigins", "This class represents for each choice the origin in the jani spec.") + .def_property_readonly("model", &JaniChoiceOrigins::getModel, "retrieves the associated JANI model") + .def("get_edge_index_set", [](JaniChoiceOrigins const& co, uint64_t choice) { return co.getEdgeIndexSet(choice); }, "returns the set of edges that induced the choice", py::arg("choice_index")) + ; +} \ No newline at end of file diff --git a/src/storage/choiceorigins.h b/src/storage/choiceorigins.h new file mode 100644 index 0000000..5082bb9 --- /dev/null +++ b/src/storage/choiceorigins.h @@ -0,0 +1,6 @@ +#pragma once + +#include "common.h" + + +void define_origins(py::module& m); \ No newline at end of file diff --git a/src/storage/model.cpp b/src/storage/model.cpp index 99995bb..7844dce 100644 --- a/src/storage/model.cpp +++ b/src/storage/model.cpp @@ -165,6 +165,8 @@ void define_sparse_model(py::module& m) { py::class_, std::shared_ptr>, ModelBase> model(m, "_SparseModel", "A probabilistic model where transitions are represented by doubles and saved in a sparse matrix"); model.def_property_readonly("labeling", &getLabeling, "Labels") .def_property_readonly("choice_labeling", [](SparseModel const& model) {return model.getChoiceLabeling();}, "get choice labelling") + .def("has_choice_origins", [](SparseModel const& model) {return model.hasChoiceOrigins();}, "has choice origins?") + .def_property_readonly("choice_origins", [](SparseModel const& model) {return model.getChoiceOrigins();}) .def("labels_state", &SparseModel::getLabelsOfState, py::arg("state"), "Get labels of state") .def_property_readonly("initial_states", &getSparseInitialStates, "Initial states") .def_property_readonly("states", [](SparseModel& model) {