diff --git a/src/mod_utility.cpp b/src/mod_utility.cpp new file mode 100644 index 0000000..f222c8f --- /dev/null +++ b/src/mod_utility.cpp @@ -0,0 +1,9 @@ +#include "common.h" + +#include "utility/shortestPaths.h" + +PYBIND11_PLUGIN(utility) { + py::module m("utility", "Dumping ground of stuff that really should be somewhere more reasonable"); + define_ksp(m); + return m.ptr(); +} diff --git a/src/utility/shortestPaths.cpp b/src/utility/shortestPaths.cpp new file mode 100644 index 0000000..13b8c34 --- /dev/null +++ b/src/utility/shortestPaths.cpp @@ -0,0 +1,61 @@ +#include "shortestPaths.h" +#include "storm/utility/shortestPaths.h" + +#include + +using namespace pybind11::literals; + +void define_ksp(py::module& m) { + + using Path = storm::utility::ksp::Path; + using state_t = storm::utility::ksp::state_t; + + // (k-shortest) Path + py::class_(m, "Path") + // Fuck all this. FIXME + + //.def(py::init, unsigned long, double>()) // does not work (because it's an aggregate initialized struct?) + + // this may or may not be working (i.e., initializing with the values as expected) + // https://pybind11.readthedocs.io/en/latest/advanced/classes.html#custom-constructors + .def("__init__", [](Path &instance, state_t preNode, unsigned long preK, double distance) { + new (&instance) Path { boost::optional(preNode), preK, distance }; + }, "predecessorNode"_a, "predecessorK"_a, "distance"_a) + + .def("__init__", [](Path &instance, unsigned long preK, double distance) { + new (&instance) Path { boost::none, preK, distance }; + }, "predecessorK"_a, "distance"_a) + + // this actually seemed to work, once!, but not anymore + .def(py::self == py::self) + + .def("__repr__", + [](Path const& a) { + // shit this is ugly. but it's a proof of concept -- at least it works + std::string str = ">(m, "ShortestPathsGenerator") + ; + */ +} \ No newline at end of file diff --git a/src/utility/shortestPaths.h b/src/utility/shortestPaths.h new file mode 100644 index 0000000..5cc0a97 --- /dev/null +++ b/src/utility/shortestPaths.h @@ -0,0 +1,8 @@ +#ifndef PYTHON_UTILITY_SHORTESTPATHS_H_ +#define PYTHON_UTILITY_SHORTESTPATHS_H_ + +#include "src/common.h" + +void define_ksp(py::module& m); + +#endif /* PYTHON_UTILITY_SHORTESTPATHS_H_ */