Skip to content

Commit 3483e73

Browse files
authored
Merge pull request #66 from Bambade/devel
Change default model upper and lower bounds
2 parents ee67d2e + 60cf93d commit 3483e73

31 files changed

+328
-247
lines changed

examples/cpp/benchmark_dense_qp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ main()
5858
double setup_time = 0.0;
5959

6060
dense::isize dim = 100;
61-
dense::isize n_eq(dim * 0.5);
62-
dense::isize n_in(dim * 0.5);
61+
dense::isize n_eq(dim / 2);
62+
dense::isize n_in(dim / 2);
6363

6464
for (T sparsity_factor = 0.1; sparsity_factor < 0.5; sparsity_factor += 0.1) {
6565
T strong_convexity_factor(1.e-2);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// Copyright (c) 2022 INRIA
3+
//
4+
/**
5+
* @file common.hpp
6+
*/
7+
8+
#ifndef PROXSUITE_HELPERS_COMMON_HPP
9+
#define PROXSUITE_HELPERS_COMMON_HPP
10+
11+
#include "proxsuite/config.hpp"
12+
#include <limits>
13+
14+
namespace proxsuite {
15+
namespace helpers {
16+
17+
template<typename Scalar>
18+
struct infinite_bound
19+
{
20+
static Scalar value()
21+
{
22+
using namespace std;
23+
return sqrt(std::numeric_limits<Scalar>::max());
24+
}
25+
};
26+
27+
} // helpers
28+
} // proxsuite
29+
30+
#endif // ifndef PROXSUITE_HELPERS_COMMON_HPP

include/proxsuite/proxqp/dense/dense.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// Copyright (c) 2022 INRIA
33
//
44
/** \file */
5-
#ifndef PROXSUITE_QP_DENSE_DENSE_HPP
6-
#define PROXSUITE_QP_DENSE_DENSE_HPP
5+
#ifndef PROXSUITE_PROXQP_DENSE_DENSE_HPP
6+
#define PROXSUITE_PROXQP_DENSE_DENSE_HPP
77

88
#include "proxsuite/proxqp/dense/wrapper.hpp" // includes everything
99

10-
#endif /* end of include guard PROXSUITE_QP_DENSE_DENSE_HPP */
10+
#endif /* end of include guard PROXSUITE_PROXQP_DENSE_DENSE_HPP */

include/proxsuite/proxqp/dense/fwd.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
// Copyright (c) 2022 INRIA
33
//
44
/** \file */
5-
#ifndef PROXSUITE_QP_DENSE_FWD_HPP
6-
#define PROXSUITE_QP_DENSE_FWD_HPP
5+
#ifndef PROXSUITE_PROXQP_DENSE_FWD_HPP
6+
#define PROXSUITE_PROXQP_DENSE_FWD_HPP
77

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

1011
namespace proxsuite {
1112
namespace proxqp {
@@ -49,4 +50,4 @@ using VecBool = Eigen::Matrix<bool, DYN, 1>;
4950
} // namespace proxqp
5051
} // namespace proxsuite
5152

52-
#endif /* end of include guard PROXSUITE_QP_DENSE_FWD_HPP */
53+
#endif /* end of include guard PROXSUITE_PROXQP_DENSE_FWD_HPP */

include/proxsuite/proxqp/dense/helpers.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* @file helpers.hpp
66
*/
77

8-
#ifndef PROXSUITE_QP_DENSE_HELPERS_HPP
9-
#define PROXSUITE_QP_DENSE_HELPERS_HPP
8+
#ifndef PROXSUITE_PROXQP_DENSE_HELPERS_HPP
9+
#define PROXSUITE_PROXQP_DENSE_HELPERS_HPP
1010

1111
#include <proxsuite/proxqp/results.hpp>
1212
#include <proxsuite/proxqp/settings.hpp>
@@ -579,4 +579,4 @@ warm_start(std::optional<VecRef<T>> x_wm,
579579
} // namespace proxqp
580580
} // namespace proxsuite
581581

582-
#endif /* end of include guard PROXSUITE_QP_DENSE_HELPERS_HPP */
582+
#endif /* end of include guard PROXSUITE_PROXQP_DENSE_HELPERS_HPP */

include/proxsuite/proxqp/dense/linesearch.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Copyright (c) 2022 INRIA
33
//
44
/** \file */
5-
#ifndef PROXSUITE_QP_DENSE_LINESEARCH_HPP
6-
#define PROXSUITE_QP_DENSE_LINESEARCH_HPP
5+
#ifndef PROXSUITE_PROXQP_DENSE_LINESEARCH_HPP
6+
#define PROXSUITE_PROXQP_DENSE_LINESEARCH_HPP
77

88
#include "proxsuite/proxqp/dense/views.hpp"
99
#include "proxsuite/proxqp/dense/model.hpp"
@@ -514,4 +514,4 @@ active_set_change(const Model<T>& qpmodel,
514514
} // namespace proxqp
515515
} // namespace proxsuite
516516

517-
#endif /* end of include guard PROXSUITE_QP_DENSE_LINESEARCH_HPP */
517+
#endif /* end of include guard PROXSUITE_PROXQP_DENSE_LINESEARCH_HPP */

include/proxsuite/proxqp/dense/model.hpp

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
// Copyright (c) 2022 INRIA
33
//
44
/** \file */
5-
#ifndef PROXSUITE_QP_DENSE_MODEL_HPP
6-
#define PROXSUITE_QP_DENSE_MODEL_HPP
5+
#ifndef PROXSUITE_PROXQP_DENSE_MODEL_HPP
6+
#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 {
@@ -32,41 +32,47 @@ struct Model
3232
Vec<T> u;
3333
Vec<T> l;
3434

35-
///// model size
35+
///// model sizes
3636
isize dim;
3737
isize n_eq;
3838
isize n_in;
3939
isize n_total;
40+
4041
/*!
4142
* Default constructor.
42-
* @param _dim primal variable dimension.
43-
* @param _n_eq number of equality constraints.
44-
* @param _n_in number of inequality constraints.
43+
* @param dim primal variable dimension.
44+
* @param n_eq number of equality constraints.
45+
* @param n_in number of inequality constraints.
4546
*/
46-
Model(isize _dim, isize _n_eq, isize _n_in)
47-
: H(_dim, _dim)
48-
, g(_dim)
49-
, A(_n_eq, _dim)
50-
, C(_n_in, _dim)
51-
, b(_n_eq)
52-
, u(_n_in)
53-
, l(_n_in)
54-
, dim(_dim)
55-
, n_eq(_n_eq)
56-
, n_in(_n_in)
57-
, n_total(_dim + _n_eq + _n_in)
47+
Model(isize dim, isize n_eq, isize n_in)
48+
: H(dim, dim)
49+
, g(dim)
50+
, A(n_eq, dim)
51+
, C(n_in, dim)
52+
, b(n_eq)
53+
, u(n_in)
54+
, l(n_in)
55+
, dim(dim)
56+
, n_eq(n_eq)
57+
, n_in(n_in)
58+
, n_total(dim + n_eq + n_in)
5859
{
59-
PROXSUITE_THROW_PRETTY(_dim == 0,
60+
PROXSUITE_THROW_PRETTY(dim == 0,
6061
std::invalid_argument,
61-
"wrong argument size: the dimension wrt primal "
62+
"wrong argument size: the dimension wrt the primal "
6263
"variable x should be strictly positive.");
64+
65+
const T infinite_bound_value = helpers::infinite_bound<T>::value();
66+
6367
H.setZero();
6468
g.setZero();
6569
A.setZero();
6670
C.setZero();
6771
b.setZero();
68-
u.setZero();
69-
l.setZero();
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)
7076
}
7177

7278
proxsuite::proxqp::sparse::SparseModel<T> to_sparse()
@@ -83,4 +89,4 @@ struct Model
8389
} // namespace proxqp
8490
} // namespace proxsuite
8591

86-
#endif /* end of include guard PROXSUITE_QP_DENSE_MODEL_HPP */
92+
#endif /* end of include guard PROXSUITE_PROXQP_DENSE_MODEL_HPP */

include/proxsuite/proxqp/dense/preconditioner/identity.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
/**
55
* @file identity.hpp
66
*/
7-
#ifndef PROXSUITE_QP_DENSE_PRECOND_IDENTITY_HPP
8-
#define PROXSUITE_QP_DENSE_PRECOND_IDENTITY_HPP
7+
#ifndef PROXSUITE_PROXQP_DENSE_PRECOND_IDENTITY_HPP
8+
#define PROXSUITE_PROXQP_DENSE_PRECOND_IDENTITY_HPP
99

1010
#include "proxsuite/proxqp/dense/views.hpp"
1111

@@ -109,5 +109,5 @@ struct IdentityPrecond
109109
} // namespace proxqp
110110
} // namespace proxsuite
111111

112-
#endif /* end of include guard PROXSUITE_QP_DENSE_PRECOND_IDENTITY_HPP \
112+
#endif /* end of include guard PROXSUITE_PROXQP_DENSE_PRECOND_IDENTITY_HPP \
113113
*/

include/proxsuite/proxqp/dense/preconditioner/ruiz.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
/**
55
* @file ruiz.hpp
66
*/
7-
#ifndef PROXSUITE_QP_DENSE_PRECOND_RUIZ_HPP
8-
#define PROXSUITE_QP_DENSE_PRECOND_RUIZ_HPP
7+
#ifndef PROXSUITE_PROXQP_DENSE_PRECOND_RUIZ_HPP
8+
#define PROXSUITE_PROXQP_DENSE_PRECOND_RUIZ_HPP
99

1010
#include "proxsuite/proxqp/dense/views.hpp"
1111
#include "proxsuite/proxqp/dense/fwd.hpp"
@@ -569,4 +569,4 @@ struct RuizEquilibration
569569
} // namespace proxqp
570570
} // namespace proxsuite
571571

572-
#endif /* end of include guard PROXSUITE_QP_DENSE_PRECOND_RUIZ_HPP */
572+
#endif /* end of include guard PROXSUITE_PROXQP_DENSE_PRECOND_RUIZ_HPP */

include/proxsuite/proxqp/dense/solver.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* @file solver.hpp
66
*/
77

8-
#ifndef PROXSUITE_QP_DENSE_SOLVER_HPP
9-
#define PROXSUITE_QP_DENSE_SOLVER_HPP
8+
#ifndef PROXSUITE_PROXQP_DENSE_SOLVER_HPP
9+
#define PROXSUITE_PROXQP_DENSE_SOLVER_HPP
1010

1111
#include "proxsuite/proxqp/dense/views.hpp"
1212
#include "proxsuite/proxqp/dense/linesearch.hpp"
@@ -1325,4 +1325,4 @@ qp_solve( //
13251325
} // namespace proxqp
13261326
} // namespace proxsuite
13271327

1328-
#endif /* end of include guard PROXSUITE_QP_DENSE_SOLVER_HPP */
1328+
#endif /* end of include guard PROXSUITE_PROXQP_DENSE_SOLVER_HPP */

0 commit comments

Comments
 (0)