Skip to content

Commit 92d55bb

Browse files
committed
proxqp: fix lower/upper limits
1 parent 533a8bf commit 92d55bb

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

include/proxsuite/proxqp/dense/fwd.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define PROXSUITE_PROXQP_DENSE_FWD_HPP
77

88
#include <Eigen/Sparse>
9+
#include "proxsuite/helpers/common.hpp"
910

1011
namespace proxsuite {
1112
namespace proxqp {

include/proxsuite/proxqp/dense/model.hpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#define PROXSUITE_PROXQP_DENSE_MODEL_HPP
77

88
#include <Eigen/Core>
9-
#include <proxsuite/linalg/veg/type_traits/core.hpp>
9+
#include "proxsuite/linalg/veg/type_traits/core.hpp"
1010
#include "proxsuite/proxqp/dense/fwd.hpp"
11-
#include <proxsuite/proxqp/sparse/model.hpp>
11+
#include "proxsuite/proxqp/sparse/model.hpp"
1212

1313
namespace proxsuite {
1414
namespace proxqp {
@@ -61,17 +61,18 @@ struct Model
6161
std::invalid_argument,
6262
"wrong argument size: the dimension wrt the primal "
6363
"variable x should be strictly positive.");
64+
65+
const T infinite_bound_value = helpers::infinite_bound<T>::value();
66+
6467
H.setZero();
6568
g.setZero();
6669
A.setZero();
6770
C.setZero();
6871
b.setZero();
69-
u.setZero();
70-
u.array() += 1.E10; // in case it appears u is nullopt (i.e., the problem is
71-
// only lower bounded)
72-
l.setZero();
73-
l.array() -= 1.E10; // in case it appears l is nullopt (i.e., the problem is
74-
// only upper bounded)
72+
u.fill(+infinite_bound_value); // in case it appears u is nullopt (i.e., the
73+
// problem is only lower bounded)
74+
l.fill(-infinite_bound_value); // in case it appears l is nullopt (i.e., the
75+
// problem is only upper bounded)
7576
}
7677

7778
proxsuite::proxqp::sparse::SparseModel<T> to_sparse()

include/proxsuite/proxqp/sparse/fwd.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
#define PROXSUITE_PROXQP_SPARSE_FWD_HPP
77

88
#include <Eigen/Sparse>
9-
#include <proxsuite/linalg/veg/vec.hpp>
10-
#include <proxsuite/proxqp/dense/views.hpp>
9+
#include "proxsuite/linalg/veg/vec.hpp"
10+
#include "proxsuite/proxqp/dense/views.hpp"
11+
#include "proxsuite/helpers/common.hpp"
1112

1213
namespace proxsuite {
1314
namespace proxqp {

include/proxsuite/proxqp/sparse/model.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,16 @@ struct Model
6060
std::invalid_argument,
6161
"wrong argument size: the dimension wrt primal "
6262
"variable x should be strictly positive.");
63+
64+
const T infinite_bound_value = helpers::infinite_bound<T>::value();
65+
6366
g.setZero();
6467
b.setZero();
6568
u.setZero();
66-
u.array() += 1.E10; // in case it appears u is nullopt (i.e., the problem is
67-
// only lower bounded)
68-
l.setZero();
69-
l.array() -= 1.E10; // in case it appears l is nullopt (i.e., the problem is
70-
// only upper bounded)
69+
u.fill(+infinite_bound_value); // in case it appears u is nullopt (i.e., the
70+
// problem is only lower bounded)
71+
l.fill(-infinite_bound_value); // in case it appears l is nullopt (i.e., the
72+
// problem is only upper bounded)
7173
}
7274
/*!
7375
* Returns the current (scaled) KKT matrix of the problem.

0 commit comments

Comments
 (0)