diff --git a/src/gspn/gspn.cpp b/src/gspn/gspn.cpp index b1c00b4..acef32f 100644 --- a/src/gspn/gspn.cpp +++ b/src/gspn/gspn.cpp @@ -13,26 +13,39 @@ void define_gspn(py::module& m) { // GSPN class py::class_>(m, "GSPN", "Generalized Stochastic Petri Net") .def("name", &GSPN::getName, "Name of GSPN") - // todo getter + .def("set_name", &GSPN::setName, "Set name of GSPN") + + //todo constructor + // .def(py::init, ... >()) + + // todo write tests: + .def_static("timed_transition_id_to_transition_id", &GSPN::timedTransitionIdToTransitionId) + .def_static("immediate_transition_id_to_transition_id", &GSPN::immediateTransitionIdToTransitionId) + .def_static("transition_id_to_timed_transition_id", &GSPN::transitionIdToTimedTransitionId) + .def_static("transition_id_to_immediate_transition_id", &GSPN::transitionIdToImmediateTransitionId) + + // getNumberOfPlaces, getNumberOfImmediateTransitions, getNumberOfTimedTransitions, ... + + //todo private? ; -//} -// todo ? void define_gspn_builder(py::module& m) { + // GSPN_Builder class py::class_>(m, "GSPNBuilder", "Generalized Stochastic Petri Net Builder") .def(py::init(), "Constructor") .def("set_name", &GSPNBuilder::setGspnName, "Set name of GSPN", py::arg("name")) - // todo: boost::optional - //.def("add_place", &GSPNBuilder::addPlace, "Add a place to the GSPN", py::arg("capacity") = 1, py::arg("initialTokens") = 0, py::arg("name") = std::string("")) + // todo: boost::optional capacity + //.def("add_place", &GSPNBuilder::addPlace, "Add a place to the GSPN", py::arg("capacity") = boost::optional(1), py::arg("initialTokens") = uint_fast64_t(0), py::arg("name") = std::string("")) //.def("set_place_layout_info", &GSPNBuilder::setPlaceLayoutInfo, "Set place layout information", py::arg("placeId"), py::arg("layoutInfo")) + // todo GSPNBuilder::RateType(0) ? .def("add_immediate_transition", &GSPNBuilder::addImmediateTransition, "Adds an immediate transition to the GSPN", py::arg("priority") = uint_fast64_t(0), py::arg("weight") = double(0), py::arg("name") = std::string("")) // todo: boost::optional .def("add_timed_transition", py::overload_cast(&GSPNBuilder::addTimedTransition), "Adds an timed transition to the GSPN", py::arg("priority"), py::arg("rate"), py::arg("name") = std::string("")) .def("add_timed_transition", py::overload_cast, std::string const&>(&GSPNBuilder::addTimedTransition), "Adds an timed transition to the GSPN", py::arg("priority"), py::arg("rate"), py::arg("numServers"), py::arg("name") = "") - // todo descriptions + // todo add descriptions .def("add_input_arc", py::overload_cast(&GSPNBuilder::addInputArc), py::arg("from"), py::arg("to"), py::arg("multiplicity")) .def("add_input_arc", py::overload_cast(&GSPNBuilder::addInputArc), py::arg("from"), py::arg("to"), py::arg("multiplicity")) .def("add_inhibition_arc", py::overload_cast(&GSPNBuilder::addInhibitionArc), py::arg("from"), py::arg("to"), py::arg("multiplicity")) @@ -47,7 +60,7 @@ void define_gspn(py::module& m) { .def("build_gspn", &GSPNBuilder::buildGspn, "Construct GSPN", py::arg("exprManager") = nullptr, py::arg("constantsSubstitution") = std::map()) - // todo prvate? + // todo private fcts and attributes? // .def("is_timed_transition_id", &GSPNBuilder::isTimedTransitionId, py::arg("tid")) // .def("is_immediate_transition_id", &GSPNBuilder::isImmediateTransitionId, py::arg("tid")) // getTransition diff --git a/src/gspn/gspn.h b/src/gspn/gspn.h index ff36197..cc43acd 100644 --- a/src/gspn/gspn.h +++ b/src/gspn/gspn.h @@ -3,5 +3,5 @@ #include "common.h" void define_gspn(py::module& m); -// todo ? void define_gspn_builder(py::module& m); + diff --git a/tests/gspn/test_gspn.py b/tests/gspn/test_gspn.py index d7a3b33..ab379d3 100644 --- a/tests/gspn/test_gspn.py +++ b/tests/gspn/test_gspn.py @@ -1,7 +1,6 @@ import os import stormpy -from helpers.helper import get_example_path from configurations import gspn @@ -9,13 +8,13 @@ from configurations import gspn @gspn class TestGSPNBuilder: def test_build_gspn(self): - # assert True - # builder: ~/storm/src/storm-dft/transformations/DFTToGSPNTransformator.cpp + gspn_name = "gspn_test" builder = stormpy.gspn.GSPNBuilder() builder.set_name(gspn_name) # todo place tests, set_place_layout_info (boost) # p_id_0 = builder.add_place(capacity = 1, initialTokens=0, name="place_test") + # p_id_0 = builder.add_place(1, 0, "place_test") ti_id_0 = builder.add_immediate_transition() ti_id_1 = builder.add_immediate_transition(priority=0, weight=0.5, name="ti_1") @@ -33,6 +32,10 @@ class TestGSPNBuilder: gspn = builder.build_gspn() assert gspn.name() == gspn_name + gspn_new_name = "new_name" + gspn.set_name(gspn_new_name) + assert gspn.name() == gspn_new_name +