Skip to content

Commit 243d078

Browse files
committed
Unit tests OSQP: eps_abs = 1e-5 (high precision), except for dense_qp_wrapper (1e-3, low precision)
1 parent a8bc5b1 commit 243d078

File tree

7 files changed

+41
-41
lines changed

7 files changed

+41
-41
lines changed

test/src/osqp/cvxpy.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ DOCTEST_TEST_CASE("OSQP: 3 dim test case from cvxpy, check feasibility")
2424

2525
std::cout << "---OSQP: 3 dim test case from cvxpy, check feasibility "
2626
<< std::endl;
27-
T eps_abs = T(1e-3); // OSQP unit test
27+
T eps_abs = T(1e-5); // OSQP unit test
2828
isize dim = 3;
2929

3030
Mat<T, colmajor> H = Mat<T, colmajor>(dim, dim);
@@ -65,7 +65,7 @@ DOCTEST_TEST_CASE("OSQP: simple test case from cvxpy, check feasibility")
6565

6666
std::cout << "---OSQP: simple test case from cvxpy, check feasibility "
6767
<< std::endl;
68-
T eps_abs = T(1e-3); // OSQP unit test
68+
T eps_abs = T(1e-5); // OSQP unit test
6969
isize dim = 1;
7070

7171
Mat<T, colmajor> H = Mat<T, colmajor>(dim, dim);

test/src/osqp/dense_maros_meszaros.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ using namespace proxsuite::common;
1212
#define MAROS_MESZAROS_DIR PROBLEM_PATH "/data/maros_meszaros_data/"
1313

1414
// Pass or fail with the settings:
15-
// eps_abs = 1e-3, eps_rel = 0.
15+
// eps_abs = 1e-5, eps_rel = 0.
1616
// adaptive_mu_update = true, adaptive_mu_interval = 50
1717
// polish = false
1818

@@ -124,13 +124,13 @@ char const* files[] = {
124124
// MAROS_MESZAROS_DIR "QSCAGR25.mat", // ------------- Fail
125125
// MAROS_MESZAROS_DIR "QSCAGR7.mat", // ------------- Fail
126126
// MAROS_MESZAROS_DIR "QSCFXM1.mat", // ------------- Fail
127-
MAROS_MESZAROS_DIR "QSCFXM2.mat", // Skip
128-
MAROS_MESZAROS_DIR "QSCFXM3.mat", // Skip
129-
MAROS_MESZAROS_DIR "QSCORPIO.mat", // ----- Pass
130-
MAROS_MESZAROS_DIR "QSCRS8.mat", // Skip
131-
MAROS_MESZAROS_DIR "QSCSD1.mat", // ----- Pass
132-
MAROS_MESZAROS_DIR "QSCSD6.mat", // Skip
133-
MAROS_MESZAROS_DIR "QSCSD8.mat", // Skip
127+
MAROS_MESZAROS_DIR "QSCFXM2.mat", // Skip
128+
MAROS_MESZAROS_DIR "QSCFXM3.mat", // Skip
129+
// MAROS_MESZAROS_DIR "QSCORPIO.mat", // --------------Fail
130+
MAROS_MESZAROS_DIR "QSCRS8.mat", // Skip
131+
MAROS_MESZAROS_DIR "QSCSD1.mat", // ----- Pass
132+
MAROS_MESZAROS_DIR "QSCSD6.mat", // Skip
133+
MAROS_MESZAROS_DIR "QSCSD8.mat", // Skip
134134
// MAROS_MESZAROS_DIR "QSCTAP1.mat", // ------------- Fail
135135
MAROS_MESZAROS_DIR "QSCTAP2.mat", // Skip
136136
MAROS_MESZAROS_DIR "QSCTAP3.mat", // Skip
@@ -206,7 +206,7 @@ TEST_CASE("OSQP: dense maros meszaros using the api")
206206
qp.init(H, g, A, b, C, l, u);
207207
qp.settings.verbose = false;
208208

209-
qp.settings.eps_abs = 1e-3; // OSQP unit test
209+
qp.settings.eps_abs = 1e-5; // OSQP unit test
210210
qp.settings.eps_rel = 0;
211211
qp.settings.eps_primal_inf = 1e-12;
212212
qp.settings.eps_dual_inf = 1e-12;

test/src/osqp/dense_qp_eq.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ DOCTEST_TEST_CASE("OSQP: qp: start from solution using the wrapper framework")
4141
Eigen::Matrix<T, Eigen::Dynamic, 1> u(0);
4242
Eigen::Matrix<T, Eigen::Dynamic, 1> l(0);
4343
dual_init_in.setZero();
44-
T eps_abs = T(1e-3); // OSQP unit test
44+
T eps_abs = T(1e-5); // OSQP unit test
4545
T eps_rel = T(0);
4646

4747
osqp::dense::QP<T> qp{ dim, n_eq, n_in }; // creating QP object
@@ -65,7 +65,7 @@ DOCTEST_TEST_CASE(
6565
"constraints and increasing dimension with the wrapper API---"
6666
<< std::endl;
6767
T sparsity_factor = 0.15;
68-
T eps_abs = T(1e-3); // OSQP unit test
68+
T eps_abs = T(1e-5); // OSQP unit test
6969
T eps_rel = T(0);
7070
common::utils::rand::set_seed(1);
7171
for (isize dim = 10; dim < 1000; dim += 100) {
@@ -115,7 +115,7 @@ DOCTEST_TEST_CASE(
115115
"increasing dimension using wrapper API---"
116116
<< std::endl;
117117
T sparsity_factor = 0.15;
118-
T eps_abs = T(1e-3); // OSQP unit test
118+
T eps_abs = T(1e-5); // OSQP unit test
119119
T eps_rel = T(0);
120120
common::utils::rand::set_seed(1);
121121
for (isize dim = 10; dim < 1000; dim += 100) {
@@ -174,7 +174,7 @@ DOCTEST_TEST_CASE(
174174
"equality constraints and increasing dimension using wrapper API---"
175175
<< std::endl;
176176
T sparsity_factor = 0.15;
177-
T eps_abs = T(1e-3); // OSQP unit test
177+
T eps_abs = T(1e-5); // OSQP unit test
178178
T eps_rel = T(0);
179179
common::utils::rand::set_seed(1);
180180
for (isize dim = 10; dim < 1000; dim += 100) {
@@ -257,7 +257,7 @@ DOCTEST_TEST_CASE("OSQP: infeasible qp")
257257
proxsuite::osqp::dense::QP<T> qp(n, n_eq, n_in);
258258
qp.init(H, g, nullopt, nullopt, C, l, u);
259259
qp.settings.eps_rel = 0.;
260-
qp.settings.eps_abs = 1e-3; // OSQP unit test
260+
qp.settings.eps_abs = 1e-5; // OSQP unit test
261261

262262
qp.solve();
263263

test/src/osqp/dense_qp_solve.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ using namespace proxsuite::common;
1616
DOCTEST_TEST_CASE("OSQP: osqp::dense: test init with fixed sizes matrices")
1717
{
1818
double sparsity_factor = 0.15;
19-
T eps_abs = T(1e-3); // OSQP unit test
19+
T eps_abs = T(1e-5); // OSQP unit test
2020
T eps_rel = T(0);
2121
common::utils::rand::set_seed(1);
2222
isize dim = 10;
@@ -93,7 +93,7 @@ DOCTEST_TEST_CASE("OSQP: sparse random strongly convex qp with equality and "
9393
"inequality constraints: test solve function---"
9494
<< std::endl;
9595
double sparsity_factor = 0.15;
96-
T eps_abs = T(1e-3); // OSQP unit test
96+
T eps_abs = T(1e-5); // OSQP unit test
9797
common::utils::rand::set_seed(1);
9898
isize dim = 10;
9999

@@ -144,7 +144,7 @@ DOCTEST_TEST_CASE("OSQP: sparse random strongly convex qp with equality and "
144144
"inequality constraints: test solve with different rho value---"
145145
<< std::endl;
146146
double sparsity_factor = 0.15;
147-
T eps_abs = T(1e-3); // OSQP unit test
147+
T eps_abs = T(1e-5); // OSQP unit test
148148
common::utils::rand::set_seed(1);
149149
isize dim = 10;
150150

@@ -198,7 +198,7 @@ DOCTEST_TEST_CASE(
198198
"mu_in values---"
199199
<< std::endl;
200200
double sparsity_factor = 0.15;
201-
T eps_abs = T(1e-3); // OSQP unit test
201+
T eps_abs = T(1e-5); // OSQP unit test
202202
common::utils::rand::set_seed(1);
203203
isize dim = 10;
204204

@@ -251,7 +251,7 @@ DOCTEST_TEST_CASE("OSQP: sparse random strongly convex qp with equality and "
251251
"inequality constraints: test warm starting---"
252252
<< std::endl;
253253
double sparsity_factor = 0.15;
254-
T eps_abs = T(1e-3); // OSQP unit test
254+
T eps_abs = T(1e-5); // OSQP unit test
255255
common::utils::rand::set_seed(1);
256256
isize dim = 10;
257257

@@ -294,7 +294,7 @@ DOCTEST_TEST_CASE("OSQP: sparse random strongly convex qp with equality and "
294294
"inequality constraints: test verbose = true ---"
295295
<< std::endl;
296296
double sparsity_factor = 0.15;
297-
T eps_abs = T(1e-3); // OSQP unit test
297+
T eps_abs = T(1e-5); // OSQP unit test
298298
common::utils::rand::set_seed(1);
299299
isize dim = 10;
300300

@@ -349,7 +349,7 @@ DOCTEST_TEST_CASE("OSQP: sparse random strongly convex qp with equality and "
349349
"inequality constraints: test no initial guess ---"
350350
<< std::endl;
351351
double sparsity_factor = 0.15;
352-
T eps_abs = T(1e-3); // OSQP unit test
352+
T eps_abs = T(1e-5); // OSQP unit test
353353
common::utils::rand::set_seed(1);
354354
isize dim = 10;
355355

test/src/osqp/dense_qp_solve.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_case_basic_solve(self):
5858
H, g, A, b, C, u, l = generate_mixed_qp(n)
5959
n_eq = A.shape[0]
6060
n_in = C.shape[0]
61-
eps_abs = 1e-3 # OSQP unit test
61+
eps_abs = 1e-5 # OSQP unit test
6262

6363
results = proxsuite.osqp.dense.solve(
6464
H=H,
@@ -99,7 +99,7 @@ def test_case_different_rho_value(self):
9999
H, g, A, b, C, u, l = generate_mixed_qp(n)
100100
n_eq = A.shape[0]
101101
n_in = C.shape[0]
102-
eps_abs = 1e-3 # OSQP unit test
102+
eps_abs = 1e-5 # OSQP unit test
103103

104104
results = proxsuite.osqp.dense.solve(
105105
H=H,
@@ -142,7 +142,7 @@ def test_case_different_mu_values(self):
142142
H, g, A, b, C, u, l = generate_mixed_qp(n)
143143
n_eq = A.shape[0]
144144
n_in = C.shape[0]
145-
eps_abs = 1e-3 # OSQP unit test
145+
eps_abs = 1e-5 # OSQP unit test
146146

147147
results = proxsuite.osqp.dense.solve(
148148
H=H,
@@ -185,7 +185,7 @@ def test_case_different_warm_starting(self):
185185
H, g, A, b, C, u, l = generate_mixed_qp(n)
186186
n_eq = A.shape[0]
187187
n_in = C.shape[0]
188-
eps_abs = 1e-3 # OSQP unit test
188+
eps_abs = 1e-5 # OSQP unit test
189189
x_wm = np.random.randn(n)
190190
y_wm = np.random.randn(n_eq)
191191
z_wm = np.random.randn(n_in)
@@ -231,7 +231,7 @@ def test_case_different_verbose_true(self):
231231
H, g, A, b, C, u, l = generate_mixed_qp(n)
232232
n_eq = A.shape[0]
233233
n_in = C.shape[0]
234-
eps_abs = 1e-3 # OSQP unit test
234+
eps_abs = 1e-5 # OSQP unit test
235235
results = proxsuite.osqp.dense.solve(
236236
H=H,
237237
g=np.asfortranarray(g),
@@ -272,7 +272,7 @@ def test_case_different_no_initial_guess(self):
272272
H, g, A, b, C, u, l = generate_mixed_qp(n)
273273
n_eq = A.shape[0]
274274
n_in = C.shape[0]
275-
eps_abs = 1e-3 # OSQP unit test
275+
eps_abs = 1e-5 # OSQP unit test
276276
results = proxsuite.osqp.dense.solve(
277277
H=H,
278278
g=np.asfortranarray(g),
@@ -399,7 +399,7 @@ def test_solve_qpsolvers_problem(self):
399399
l = m["l"].astype(float)
400400
u = m["u"].astype(float)
401401

402-
eps_abs = 1e-3 # OSQP unit test
402+
eps_abs = 1e-5 # OSQP unit test
403403

404404
results = proxsuite.osqp.dense.solve(
405405
P, q, A, b, C, l, u, verbose=False, eps_abs=eps_abs, eps_rel=0

test/src/osqp/dense_qp_with_eq_and_in.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ DOCTEST_TEST_CASE("OSQP: sparse random strongly convex qp with equality and "
2323
"inequality constraints and increasing dimension using wrapper API---"
2424
<< std::endl;
2525
T sparsity_factor = 0.15;
26-
T eps_abs = T(1e-3); // OSQP unit test
26+
T eps_abs = T(1e-5); // OSQP unit test
2727
T eps_rel = T(0);
2828
common::utils::rand::set_seed(1);
2929
for (isize dim = 10; dim < 1000; dim += 100) {
@@ -76,7 +76,7 @@ DOCTEST_TEST_CASE("OSQP: sparse random strongly convex qp with box inequality "
7676
"constraints and increasing dimension using the API---"
7777
<< std::endl;
7878
T sparsity_factor = 0.15;
79-
T eps_abs = T(1e-3); // OSQP unit test
79+
T eps_abs = T(1e-5); // OSQP unit test
8080
T eps_rel = T(0);
8181
common::utils::rand::set_seed(1);
8282
for (isize dim = 10; dim < 1000; dim += 100) {
@@ -127,7 +127,7 @@ DOCTEST_TEST_CASE("OSQP: sparse random not strongly convex qp with inequality "
127127
"constraints and increasing dimension using the API---"
128128
<< std::endl;
129129
T sparsity_factor = 0.15;
130-
T eps_abs = T(1e-3); // OSQP unit test
130+
T eps_abs = T(1e-5); // OSQP unit test
131131
T eps_rel = T(0);
132132
common::utils::rand::set_seed(1);
133133
for (isize dim = 10; dim < 1000; dim += 100) {
@@ -178,7 +178,7 @@ DOCTEST_TEST_CASE(
178178
<< "---OSQP: testing sparse random strongly convex qp with degenerate "
179179
"inequality constraints and increasing dimension using the API---"
180180
<< std::endl;
181-
T eps_abs = T(1e-3); // OSQP unit test
181+
T eps_abs = T(1e-5); // OSQP unit test
182182
T eps_rel = T(0);
183183
T eps_primal_inf = T(1e-15);
184184
T eps_dual_inf = T(1e-15);
@@ -245,7 +245,7 @@ DOCTEST_TEST_CASE(
245245
"increasing dimension using the API---"
246246
<< std::endl;
247247
T sparsity_factor = 0.15;
248-
T eps_abs = T(1e-3); // OSQP unit test
248+
T eps_abs = T(1e-5); // OSQP unit test
249249
T eps_rel = T(0);
250250
common::utils::rand::set_seed(1);
251251
for (isize dim = 10; dim < 1000; dim += 100) {
@@ -306,7 +306,7 @@ DOCTEST_TEST_CASE(
306306
"to test different settings on solution polishing---"
307307
<< std::endl;
308308
T sparsity_factor = 0.15;
309-
T eps_abs = T(1e-3); // OSQP unit test
309+
T eps_abs = T(1e-5); // OSQP unit test
310310
T eps_rel = T(0);
311311
common::utils::rand::set_seed(1);
312312
for (isize dim = 10; dim < 1000; dim += 100) {

test/src/osqp/dense_unconstrained_qp.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ DOCTEST_TEST_CASE("OSQP: sparse random strongly convex unconstrained qp and "
2121
"dimension---"
2222
<< std::endl;
2323
double sparsity_factor = 0.15;
24-
T eps_abs = T(1e-3); // OSQP unit test
24+
T eps_abs = T(1e-5); // OSQP unit test
2525
T eps_rel = 0;
2626
for (int dim = 10; dim < 1000; dim += 100) {
2727

@@ -73,7 +73,7 @@ DOCTEST_TEST_CASE(
7373
"with increasing dimension---"
7474
<< std::endl;
7575
double sparsity_factor = 0.15;
76-
T eps_abs = T(1e-3); // OSQP unit test
76+
T eps_abs = T(1e-5); // OSQP unit test
7777
T eps_rel = 0;
7878
for (int dim = 10; dim < 1000; dim += 100) {
7979

@@ -126,7 +126,7 @@ DOCTEST_TEST_CASE("OSQP: unconstrained qp with H = Id and g random")
126126
std::cout << "---OSQP: unconstrained qp with H = Id and g random---"
127127
<< std::endl;
128128
double sparsity_factor = 0.15;
129-
T eps_abs = T(1e-3); // OSQP unit test
129+
T eps_abs = T(1e-5); // OSQP unit test
130130
T eps_rel = 0;
131131

132132
int dim(100);
@@ -176,7 +176,7 @@ DOCTEST_TEST_CASE("OSQP: unconstrained qp with H = Id and g = 0")
176176
std::cout << "---OSQP: unconstrained qp with H = Id and g = 0---"
177177
<< std::endl;
178178
double sparsity_factor = 0.15;
179-
T eps_abs = T(1e-3); // OSQP unit test
179+
T eps_abs = T(1e-5); // OSQP unit test
180180
T eps_rel = 0;
181181

182182
int dim(100);
@@ -232,7 +232,7 @@ DOCTEST_TEST_CASE("OSQP: sparse random strongly convex unconstrained qp and "
232232
"is found---"
233233
<< std::endl;
234234
double sparsity_factor = 0.15;
235-
T eps_abs = T(1e-3); // OSQP unit test
235+
T eps_abs = T(1e-5); // OSQP unit test
236236
T eps_rel = 0;
237237
for (int dim = 10; dim < 1000; dim += 100) {
238238

0 commit comments

Comments
 (0)