|
1 | 1 | // |
2 | 2 | // Copyright (c) 2022 INRIA |
3 | 3 | // |
4 | | -#include <optional> |
5 | 4 | #include <random> |
| 5 | +#include <iostream> |
6 | 6 | #include <Eigen/Core> |
| 7 | +#include <proxsuite/helpers/optional.hpp> // for c++14 |
7 | 8 | #include <proxsuite/proxqp/sparse/sparse.hpp> |
8 | 9 |
|
9 | 10 | using namespace proxsuite::proxqp; |
| 11 | +using proxsuite::nullopt; // c++17 simply use std::nullopt |
10 | 12 |
|
11 | 13 | int |
12 | 14 | main() |
@@ -44,15 +46,15 @@ main() |
44 | 46 |
|
45 | 47 | // inequality constraints C: other way to define sparse matrix from dense |
46 | 48 | // matrix using sparseView |
47 | | - Eigen::MatrixXd C = Eigen::MatrixXd(n_in, n_in); |
| 49 | + Eigen::MatrixXd C = Eigen::MatrixXd(n_in, dim); |
48 | 50 | C << 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0; |
49 | 51 | Eigen::SparseMatrix<double> C_spa(n_in, dim); |
50 | 52 | C_spa = C.sparseView(); |
51 | 53 |
|
52 | | - Eigen::VectorXd l = Eigen::VectorXd(dim); |
| 54 | + Eigen::VectorXd l = Eigen::VectorXd(n_in); |
53 | 55 | l << -1.0, -1.0, -1.0; |
54 | 56 |
|
55 | | - Eigen::VectorXd u = Eigen::VectorXd(dim); |
| 57 | + Eigen::VectorXd u = Eigen::VectorXd(n_in); |
56 | 58 | u << 1.0, 1.0, 1.0; |
57 | 59 |
|
58 | 60 | std::cout << "H:\n" << H_spa << std::endl; |
|
70 | 72 |
|
71 | 73 | // initialize qp with matrices describing the problem |
72 | 74 | // note: it is also possible to use update here |
73 | | - qp.init(H_spa, g, std::nullopt, std::nullopt, C_spa, l, u); |
| 75 | + qp.init(H_spa, g, nullopt, nullopt, C_spa, l, u); |
74 | 76 |
|
75 | 77 | qp.solve(); |
76 | 78 |
|
|
0 commit comments