Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some ADD support, improved valuation support, towards access for resu… #154

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ void define_result(py::module& m) {
;
py::class_<storm::modelchecker::SymbolicQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>, std::shared_ptr<storm::modelchecker::SymbolicQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>>>(m, "SymbolicQuantitativeCheckResult", "Symbolic quantitative model checking result", quantitativeCheckResult)
.def("clone", [](storm::modelchecker::SymbolicQuantitativeCheckResult<storm::dd::DdType::Sylvan, double> const& dd) {return dd.clone()->asSymbolicQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>(); })
.def("get_values", &storm::modelchecker::SymbolicQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>::getValueVector);
;
py::class_<storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>, std::shared_ptr<storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>>>(m, "HybridQuantitativeCheckResult", "Hybrid quantitative model checking result", quantitativeCheckResult)
.def("get_values", &storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>::getExplicitValueVector, "Get model checking result values for all states")
Expand Down
9 changes: 9 additions & 0 deletions src/storage/dd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "storm/storage/dd/DdMetaVariable.h"
#include "storm/storage/dd/Dd.h"
#include "storm/storage/dd/Bdd.h"
#include "storm/storage/dd/Add.h"
#include "src/helpers.h"

template<storm::dd::DdType DdType>
Expand All @@ -26,6 +27,14 @@ void define_dd(py::module& m, std::string const& libstring) {

py::class_<storm::dd::Bdd<DdType>> bdd(m, (std::string("Bdd_") + libstring).c_str(), "Bdd", dd);
bdd.def("to_expression", &storm::dd::Bdd<DdType>::toExpression, py::arg("expression_manager"));

py::class_<storm::dd::Add<DdType, double>> add(m, (std::string("Add_") + libstring + "_Double").c_str(), "Add", dd);
add.def("__iter__", [](const storm::dd::Add<DdType, double> &s) { return py::make_iterator(s.begin(), s.end()); },
py::keep_alive<0, 1>() /* Essential: keep object alive while iterator exists */);

py::class_<storm::dd::AddIterator<DdType, double>> addIterator(m, (std::string("AddIterator_") + libstring + "_Double").c_str(), "AddIterator");
addIterator.def("get", [](const storm::dd::AddIterator<DdType, double> &it) { return *it; } );

}


Expand Down
2 changes: 2 additions & 0 deletions src/storage/expressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ void define_expressions(py::module& m) {
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("manager", &storm::expressions::Variable::getManager, "Variable manager")
.def_property_readonly("index", &storm::expressions::Variable::getIndex, "Variable index")
.def_property_readonly("offset", &storm::expressions::Variable::getOffset, "Variable offset (used e.g., in dds)")
.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_rational_type", &storm::expressions::Variable::hasRationalType, "Check if the variable is of rational type")
Expand Down
5 changes: 4 additions & 1 deletion src/storage/valuation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ void define_statevaluation(py::module& m) {
}

void define_simplevaluation(py::module& m) {
py::class_<storm::expressions::SimpleValuation> sval(m, "SimpleValuation");
py::class_<storm::expressions::Valuation> val(m, "Valuation");
val.def_property_readonly("expression_manager", &storm::expressions::Valuation::getManager);
py::class_<storm::expressions::SimpleValuation> sval(m, "SimpleValuation", val);
sval.def("to_json", &storm::expressions::SimpleValuation::toJson, "Convert to JSON");
sval.def("to_string", &storm::expressions::SimpleValuation::toString, py::arg("pretty")=true, "to string");
sval.def("get_boolean_value", &storm::expressions::SimpleValuation::getBooleanValue, py::arg("variable"), "Get Boolean Value for expression variable");
sval.def("get_integer_value", &storm::expressions::SimpleValuation::getIntegerValue, py::arg("variable"), "Get Integer Value for expression variable");

Expand Down
Loading