Browse Source

minor extension to expressions/prism program

refactoring
Tobias Winkler 4 years ago
committed by Matthias Volk
parent
commit
1a39ef8380
No known key found for this signature in database GPG Key ID: 83A57678F739FCD3
  1. 1
      src/storage/expressions.cpp
  2. 7
      src/storage/prism.cpp

1
src/storage/expressions.cpp

@ -32,6 +32,7 @@ void define_expressions(py::module& m) {
// Variable // Variable
py::class_<storm::expressions::Variable, std::shared_ptr<storm::expressions::Variable>>(m, "Variable", "Represents a variable") py::class_<storm::expressions::Variable, std::shared_ptr<storm::expressions::Variable>>(m, "Variable", "Represents a variable")
.def_property_readonly("name", &storm::expressions::Variable::getName, "Variable name") .def_property_readonly("name", &storm::expressions::Variable::getName, "Variable name")
.def_property_readonly("manager", &storm::expressions::Variable::getManager, "Variable manager")
.def("has_boolean_type", &storm::expressions::Variable::hasBooleanType, "Check if the variable is of boolean type") .def("has_boolean_type", &storm::expressions::Variable::hasBooleanType, "Check if the variable is of boolean type")
.def("has_integer_type", &storm::expressions::Variable::hasIntegerType, "Check if the variable is of integer type") .def("has_integer_type", &storm::expressions::Variable::hasIntegerType, "Check if the variable is of integer type")
.def("has_rational_type", &storm::expressions::Variable::hasRationalType, "Check if the variable is of rational type") .def("has_rational_type", &storm::expressions::Variable::hasRationalType, "Check if the variable is of rational type")

7
src/storage/prism.cpp

@ -87,10 +87,12 @@ void define_prism(py::module& m) {
; ;
py::class_<Update> update(m, "PrismUpdate", "An update in a Prism command"); py::class_<Update> update(m, "PrismUpdate", "An update in a Prism command");
update.def_property_readonly("assignments", [](Update const& update) {
update.def(py::init<uint_fast64_t, storm::expressions::Expression const&, std::vector<storm::prism::Assignment> const&>())
.def_property_readonly("assignments", [](Update const& update) {
return update.getAssignments(); return update.getAssignments();
}, "Assignments in the update") }, "Assignments in the update")
.def_property_readonly("probability_expression", &Update::getLikelihoodExpression, "The probability expression for this update") .def_property_readonly("probability_expression", &Update::getLikelihoodExpression, "The probability expression for this update")
.def_property_readonly("global_index", &Update::getGlobalIndex, "Retrieves the global index of the update, that is, a unique index over all modules")
.def("substitute", &Update::substitute, "Substitutes all identifiers in the update according to the given map") .def("substitute", &Update::substitute, "Substitutes all identifiers in the update according to the given map")
.def("simplify", &Update::simplify, "Simplifies the update in various ways (also removes identity assignments)") .def("simplify", &Update::simplify, "Simplifies the update in various ways (also removes identity assignments)")
.def("get_assignment", &Update::getAssignment, py::arg("variable_name"), "Retrieves a reference to the assignment for the variable with the given name") .def("get_assignment", &Update::getAssignment, py::arg("variable_name"), "Retrieves a reference to the assignment for the variable with the given name")
@ -99,7 +101,8 @@ void define_prism(py::module& m) {
; ;
py::class_<Assignment> assignment(m, "PrismAssignment", "An assignment in prism"); py::class_<Assignment> assignment(m, "PrismAssignment", "An assignment in prism");
assignment.def_property_readonly("variable", &Assignment::getVariable, "Variable that is updated")
assignment.def(py::init<storm::expressions::Variable const&, storm::expressions::Expression const&>())
.def_property_readonly("variable", &Assignment::getVariable, "Variable that is updated")
.def_property_readonly("expression", &Assignment::getExpression, "Expression for the update") .def_property_readonly("expression", &Assignment::getExpression, "Expression for the update")
.def("__str__", &streamToString<Assignment>) .def("__str__", &streamToString<Assignment>)
; ;

Loading…
Cancel
Save