proxsuite 0.6.6
The Advanced Proximal Optimization Toolbox
Loading...
Searching...
No Matches
backward_data.hpp
Go to the documentation of this file.
1//
2// Copyright (c) 2022 INRIA
3//
7#ifndef PROXSUITE_PROXQP_DENSE_BACKWARD_DATA_HPP
8#define PROXSUITE_PROXQP_DENSE_BACKWARD_DATA_HPP
9
11#include <Eigen/Core>
14
15namespace proxsuite {
16namespace proxqp {
17namespace dense {
18
23
26template<typename T>
28{
30 using Mat = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
31
32 // dL_dH
34 // dL_dg
36 // dL_dA
38 // dL_db
40 // dL_dC
42 // dL_du
44 // dL_dl
46
47 bool is_valid(isize dim, isize n_eq, isize n_in)
48 {
49#define PROXSUITE_CHECK_SIZE(size, expected_size) \
50 if (size != 0) { \
51 if (!(size == expected_size)) \
52 return false; \
53 }
54
55 // check that all matrices and vectors of qpmodel have the correct size
56 // and that H and C have expected properties
57
58 // dx_dg
59 if (dL_dH.size()) {
60 PROXSUITE_CHECK_SIZE(dL_dH.rows(), dim);
61 PROXSUITE_CHECK_SIZE(dL_dH.cols(), dim);
62 } else {
63 return false;
64 }
65 // dL_dg
66 if (dL_dg.size()) {
67 PROXSUITE_CHECK_SIZE(dL_dg.rows(), dim);
68 } else {
69 return false;
70 }
71 // dL_dA
72 if (dL_dA.size()) {
73 PROXSUITE_CHECK_SIZE(dL_dA.rows(), n_eq);
74 PROXSUITE_CHECK_SIZE(dL_dA.cols(), dim);
75 } else {
76 return false;
77 }
78 // dL_db
79 if (dL_db.size()) {
80 PROXSUITE_CHECK_SIZE(dL_db.rows(), n_eq);
81 } else {
82 return false;
83 }
84 // dL_dC
85 if (dL_dC.size()) {
86 PROXSUITE_CHECK_SIZE(dL_dC.rows(), n_in);
87 PROXSUITE_CHECK_SIZE(dL_dC.cols(), dim);
88 } else {
89 return false;
90 }
91 // dL_du
92 if (dL_du.size()) {
93 PROXSUITE_CHECK_SIZE(dL_du.rows(), n_in);
94 } else {
95 return false;
96 }
97 // dL_dl
98 if (dL_dl.size()) {
99 PROXSUITE_CHECK_SIZE(dL_dl.rows(), n_in);
100 } else {
101 return false;
102 }
103 return true;
104#undef PROXSUITE_CHECK_SIZE
105 }
106
107 void initialize(isize dim, isize n_eq, isize n_in)
108 {
109 bool valid_dimensions = is_valid(dim, n_eq, n_in);
110 if (valid_dimensions == false) {
111
112 dL_dH.resize(dim, dim);
113 dL_dg.resize(dim);
114 dL_dA.resize(n_eq, dim);
115 dL_db.resize(n_eq);
116 dL_dC.resize(n_in, dim);
117 dL_du.resize(n_in);
118 dL_dl.resize(n_in);
119 }
120 dL_dH.setZero();
121 dL_dg.setZero();
122 dL_dA.setZero();
123 dL_db.setZero();
124 dL_dC.setZero();
125 dL_du.setZero();
126 dL_dl.setZero();
127 }
128};
129
130} // namespace dense
131} // namespace proxqp
132} // namespace proxsuite
133
134#endif /* end of include guard PROXSUITE_PROXQP_DENSE_BACKWARD_DATA_HPP */
#define PROXSUITE_CHECK_SIZE(size, expected_size)
This class stores the jacobians of PROXQP solvers with dense backends at a solutions wrt model parame...
bool is_valid(isize dim, isize n_eq, isize n_in)
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > Mat
void initialize(isize dim, isize n_eq, isize n_in)