Browse Source

Binding for exporting into DRN format

refactoring
Matthias Volk 8 years ago
parent
commit
c7b3fae4d0
  1. 16
      src/core/core.cpp
  2. 1
      src/core/core.h
  3. 1
      src/mod_core.cpp

16
src/core/core.cpp

@ -1,4 +1,5 @@
#include "core.h" #include "core.h"
#include "storm/utility/DirectEncodingExporter.h"
void define_core(py::module& m) { void define_core(py::module& m) {
// Init // Init
@ -62,3 +63,18 @@ void define_build(py::module& m) {
m.def("_build_sparse_parametric_model_from_drn", &storm::buildExplicitDRNModel<storm::RationalFunction>, "Build the parametric model from DRN", py::arg("file")); m.def("_build_sparse_parametric_model_from_drn", &storm::buildExplicitDRNModel<storm::RationalFunction>, "Build the parametric model from DRN", py::arg("file"));
} }
// Thin wrapper for exporting model
template<typename ValueType>
void exportDRN(std::shared_ptr<storm::models::sparse::Model<ValueType>> model, std::string const& file) {
std::ofstream stream;
storm::utility::openFile(file, stream);
storm::exporter::explicitExportSparseModel(stream, model, {});
storm::utility::closeFile(stream);
}
void define_export(py::module& m) {
// Export
m.def("export_to_drn", &exportDRN<double>, "Export model in DRN format", py::arg("model"), py::arg("file"));
m.def("export_parametric_to_drn", &exportDRN<storm::RationalFunction>, "Export parametric model in DRN format", py::arg("model"), py::arg("file"));
}

1
src/core/core.h

@ -6,5 +6,6 @@
void define_core(py::module& m); void define_core(py::module& m);
void define_parse(py::module& m); void define_parse(py::module& m);
void define_build(py::module& m); void define_build(py::module& m);
void define_export(py::module& m);
#endif /* PYTHON_CORE_CORE_H_ */ #endif /* PYTHON_CORE_CORE_H_ */

1
src/mod_core.cpp

@ -19,6 +19,7 @@ PYBIND11_PLUGIN(core) {
define_property(m); define_property(m);
define_parse(m); define_parse(m);
define_build(m); define_build(m);
define_export(m);
define_result(m); define_result(m);
define_modelchecking(m); define_modelchecking(m);
define_bisimulation(m); define_bisimulation(m);

Loading…
Cancel
Save