diff --git a/.gitignore b/.gitignore index 509cbb6..5dc4499 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.so __pycache__ +build/ diff --git a/src/storage/model.cpp b/src/storage/model.cpp index 02f32a5..370ceb5 100644 --- a/src/storage/model.cpp +++ b/src/storage/model.cpp @@ -33,8 +33,8 @@ void define_model(py::module& m) { ; // ModelBase - py::class_>(m, "ModelBase", "Base class for all models") - .def_property_readonly("nr_states", &storm::models::ModelBase::getNumberOfStates, "Number of states") + py::class_> modelBase(m, "ModelBase", "Base class for all models"); + modelBase.def_property_readonly("nr_states", &storm::models::ModelBase::getNumberOfStates, "Number of states") .def_property_readonly("nr_transitions", &storm::models::ModelBase::getNumberOfTransitions, "Number of transitions") .def_property_readonly("model_type", &storm::models::ModelBase::getType, "Model type") .def_property_readonly("supports_parameters", &storm::models::ModelBase::supportsParameters, "Flag whether model supports parameters") @@ -47,21 +47,23 @@ void define_model(py::module& m) { ; // Models - py::class_, std::shared_ptr>>(m, "SparseModel", "A probabilistic model where transitions are represented by doubles and saved in a sparse matrix", py::base()) - .def_property_readonly("labels", [](storm::models::sparse::Model& model) { - return model.getStateLabeling().getLabels(); - }, "Labels") +//storm::models::sparse::Model > + + py::class_, std::shared_ptr>> model(m, "SparseModel", "A probabilistic model where transitions are represented by doubles and saved in a sparse matrix", modelBase); + model.def_property_readonly("labels", [](storm::models::sparse::Model& model) { + return model.getStateLabeling().getLabels(); + }, "Labels") .def("labels_state", &storm::models::sparse::Model::getLabelsOfState, py::arg("state"), "Get labels of state") .def_property_readonly("initial_states", &getInitialStates, "Initial states") .def_property_readonly("transition_matrix", &getTransitionMatrix, py::return_value_policy::reference, py::keep_alive<1, 0>(), "Transition matrix") - ; - py::class_, std::shared_ptr>>(m, "SparseDtmc", "DTMC in sparse representation", py::base>()) ; - py::class_, std::shared_ptr>>(m, "SparseMdp", "MDP in sparse representation", py::base>()) + py::class_, std::shared_ptr>>(m, "SparseDtmc", "DTMC in sparse representation", model) + ; + py::class_, std::shared_ptr>>(m, "SparseMdp", "MDP in sparse representation", model) ; - py::class_, std::shared_ptr>>(m, "SparseParametricModel", "A probabilistic model where transitions are represented by rational functions and saved in a sparse matrix", py::base()) - .def("collect_probability_parameters", &storm::models::sparse::getProbabilityParameters, "Collect parameters") + py::class_, std::shared_ptr>> modelRatFunc(m, "SparseParametricModel", "A probabilistic model where transitions are represented by rational functions and saved in a sparse matrix", modelBase); + modelRatFunc.def("collect_probability_parameters", &storm::models::sparse::getProbabilityParameters, "Collect parameters") .def_property_readonly("labels", [](storm::models::sparse::Model& model) { return model.getStateLabeling().getLabels(); }, "Labels") @@ -69,9 +71,9 @@ void define_model(py::module& m) { .def_property_readonly("initial_states", &getInitialStates, "Initial states") .def_property_readonly("transition_matrix", &getTransitionMatrix, py::return_value_policy::reference, py::keep_alive<1, 0>(), "Transition matrix") ; - py::class_, std::shared_ptr>>(m, "SparseParametricDtmc", "pDTMC in sparse representation", py::base>()) + py::class_, std::shared_ptr>>(m, "SparseParametricDtmc", "pDTMC in sparse representation", modelRatFunc) ; - py::class_, std::shared_ptr>>(m, "SparseParametricMdp", "pMDP in sparse representation", py::base>()) + py::class_, std::shared_ptr>>(m, "SparseParametricMdp", "pMDP in sparse representation", modelRatFunc) ; }