You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
2.1 KiB

  1. #include "smtsolver.h"
  2. #include <storm/solver/Z3SmtSolver.h>
  3. #include "storm/storage/expressions/ExpressionManager.h"
  4. #include <storm/solver/SmtSolver.h>
  5. #include <storm/utility/solver.h>
  6. void define_smt(py::module& m) {
  7. using SmtSolver = storm::solver::SmtSolver;
  8. using Z3SmtSolver = storm::solver::Z3SmtSolver;
  9. using ModelReference = storm::solver::SmtSolver::ModelReference;
  10. py::enum_<SmtSolver::CheckResult>(m, "SmtCheckResult", "Result type")
  11. .value("Sat", SmtSolver::CheckResult::Sat)
  12. .value("Unsat", SmtSolver::CheckResult::Unsat)
  13. .value("Unknown", SmtSolver::CheckResult::Unknown)
  14. ;
  15. py::class_<ModelReference, std::shared_ptr<ModelReference >> modelref(m, "ModelReference", "Lightweight Wrapper around results");
  16. modelref.def("get_boolean_value", &ModelReference::getBooleanValue, "get a value for a boolean variable", py::arg("variable"))
  17. .def("get_integer_value", &ModelReference::getIntegerValue, "get a value for an integer variable", py::arg("variable"))
  18. .def("get_rational_value", &ModelReference::getRationalValue, "get a value (as double) for an rational variable", py::arg("variable"));
  19. py::class_<SmtSolver> smtsolver(m, "SmtSolver", "Generic Storm SmtSolver Wrapper");
  20. smtsolver.def("push", &SmtSolver::push, "push")
  21. .def("pop", [](SmtSolver& solver, uint64_t n) {solver.pop(n);}, "pop", py::arg("levels"))
  22. .def("reset", &SmtSolver::reset, "reset")
  23. .def("add", [](SmtSolver& solver, storm::expressions::Expression const& expr) {solver.add(expr);}, "addconstraint")
  24. .def("check", &SmtSolver::check, "check")
  25. .def_property_readonly("model", &SmtSolver::getModel, "get the model");
  26. py::class_<Z3SmtSolver> z3solver(m, "Z3SmtSolver", "z3 API for storm smtsolver wrapper", smtsolver);
  27. z3solver.def(pybind11::init<storm::expressions::ExpressionManager&>());
  28. py::class_<storm::utility::solver::SmtSolverFactory, std::shared_ptr<storm::utility::solver::SmtSolverFactory>> (m, "SmtSolverFactory", "Factory for creating SMT Solvers");
  29. }