|
1 | 1 | // |
2 | 2 | // Copyright (c) 2022 INRIA |
3 | 3 | // |
4 | | -#include <proxsuite/proxqp/dense/model.hpp> |
5 | | -#include <proxsuite/proxqp/sparse/model.hpp> |
| 4 | + |
6 | 5 | #include <pybind11/pybind11.h> |
7 | 6 | #include <pybind11/eigen.h> |
| 7 | +#include <pybind11/operators.h> |
| 8 | + |
| 9 | +#include <proxsuite/proxqp/dense/model.hpp> |
| 10 | +#include <proxsuite/proxqp/sparse/model.hpp> |
8 | 11 | #include <proxsuite/proxqp/dense/utils.hpp> |
| 12 | +#include <proxsuite/serialization/archive.hpp> |
| 13 | +#include <proxsuite/serialization/eigen.hpp> |
| 14 | +#include <proxsuite/serialization/model.hpp> |
9 | 15 |
|
10 | 16 | namespace proxsuite { |
11 | 17 | namespace proxqp { |
@@ -34,7 +40,21 @@ exposeDenseModel(pybind11::module_ m) |
34 | 40 | .def_readonly("n_total", &Model<T>::n_total) |
35 | 41 | .def("is_valid", |
36 | 42 | &Model<T>::is_valid, |
37 | | - "Check if model is containing valid data."); |
| 43 | + "Check if model is containing valid data.") |
| 44 | + .def(pybind11::self == pybind11::self) |
| 45 | + .def(pybind11::self != pybind11::self) |
| 46 | + .def(pybind11::pickle( |
| 47 | + |
| 48 | + [](const proxsuite::proxqp::dense::Model<T>& model) { |
| 49 | + return pybind11::bytes(proxsuite::serialization::saveToString(model)); |
| 50 | + }, |
| 51 | + [](pybind11::bytes& s) { |
| 52 | + // create qp model which will be updated by loaded data |
| 53 | + proxsuite::proxqp::dense::Model<T> model(1, 1, 1); |
| 54 | + proxsuite::serialization::loadFromString(model, s); |
| 55 | + |
| 56 | + return model; |
| 57 | + })); |
38 | 58 | } |
39 | 59 | } // namespace python |
40 | 60 | } // namespace dense |
|
0 commit comments