Directory: | ./ |
---|---|
File: | tests/eiquadprog-basic.cpp |
Date: | 2024-08-26 22:54:11 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 238 | 238 | 100.0% |
Branches: | 622 | 1244 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2019 CNRS | ||
3 | // | ||
4 | // This file is part of eiquadprog. | ||
5 | // | ||
6 | // eiquadprog is free software: you can redistribute it and/or modify | ||
7 | // it under the terms of the GNU Lesser General Public License as published by | ||
8 | // the Free Software Foundation, either version 3 of the License, or | ||
9 | //(at your option) any later version. | ||
10 | |||
11 | // eiquadprog is distributed in the hope that it will be useful, | ||
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | // GNU Lesser General Public License for more details. | ||
15 | |||
16 | // You should have received a copy of the GNU Lesser General Public License | ||
17 | // along with eiquadprog. If not, see <https://www.gnu.org/licenses/>. | ||
18 | |||
19 | #include <Eigen/Core> | ||
20 | #include <boost/test/unit_test.hpp> | ||
21 | #include <iostream> | ||
22 | |||
23 | #include "eiquadprog/eiquadprog.hpp" | ||
24 | |||
25 | // The problem is in the form: | ||
26 | // min 0.5 * x G x + g0 x | ||
27 | // s.t. | ||
28 | // CE^T x + ce0 = 0 | ||
29 | // CI^T x + ci0 >= 0 | ||
30 | // The matrix and vectors dimensions are as follows: | ||
31 | // G: n * n | ||
32 | // g0: n | ||
33 | // CE: n * p | ||
34 | // ce0: p | ||
35 | // CI: n * m | ||
36 | // ci0: m | ||
37 | // x: n | ||
38 | |||
39 | BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE) | ||
40 | |||
41 | // min ||x||^2 | ||
42 | |||
43 |
33/66✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 23 taken 1 times.
✗ Branch 24 not taken.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 1 times.
✗ Branch 37 not taken.
✓ Branch 41 taken 1 times.
✗ Branch 42 not taken.
✓ Branch 45 taken 1 times.
✗ Branch 46 not taken.
✓ Branch 48 taken 1 times.
✗ Branch 49 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 66 taken 1 times.
✗ Branch 67 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 77 taken 1 times.
✗ Branch 78 not taken.
✓ Branch 80 taken 1 times.
✗ Branch 81 not taken.
✓ Branch 83 taken 1 times.
✗ Branch 84 not taken.
✓ Branch 86 taken 1 times.
✗ Branch 87 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✓ Branch 95 taken 1 times.
✗ Branch 96 not taken.
✓ Branch 98 taken 1 times.
✗ Branch 99 not taken.
✓ Branch 102 taken 1 times.
✗ Branch 103 not taken.
✓ Branch 105 taken 1 times.
✗ Branch 106 not taken.
✓ Branch 108 taken 1 times.
✗ Branch 109 not taken.
✓ Branch 111 taken 1 times.
✗ Branch 112 not taken.
✓ Branch 116 taken 1 times.
✗ Branch 117 not taken.
|
4 | BOOST_AUTO_TEST_CASE(test_unbiased) { |
44 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Q(2, 2); |
45 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q.setZero(); |
46 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q(0, 0) = 1.0; |
47 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q(1, 1) = 1.0; |
48 | |||
49 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd C(2); |
50 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | C.setZero(); |
51 | |||
52 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Aeq(2, 0); |
53 | |||
54 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd Beq(0); |
55 | |||
56 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Aineq(2, 0); |
57 | |||
58 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd Bineq(0); |
59 | |||
60 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd x(2); |
61 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXi activeSet(0); |
62 | size_t activeSetSize; | ||
63 | |||
64 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd solution(2); |
65 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | solution.setZero(); |
66 | |||
67 | 2 | double val = 0.0; | |
68 | |||
69 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | double out = eiquadprog::solvers::solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, |
70 | 2 | x, activeSet, activeSetSize); | |
71 | |||
72 |
6/12✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
|
2 | BOOST_CHECK_CLOSE(out, val, 1e-6); |
73 | |||
74 |
7/14✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 1 times.
|
2 | BOOST_CHECK(x.isApprox(solution)); |
75 | 2 | } | |
76 | |||
77 | // min ||x-x_0||^2, x_0 = (1 1)^T | ||
78 | |||
79 |
33/66✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 23 taken 1 times.
✗ Branch 24 not taken.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 1 times.
✗ Branch 37 not taken.
✓ Branch 41 taken 1 times.
✗ Branch 42 not taken.
✓ Branch 45 taken 1 times.
✗ Branch 46 not taken.
✓ Branch 48 taken 1 times.
✗ Branch 49 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 66 taken 1 times.
✗ Branch 67 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 77 taken 1 times.
✗ Branch 78 not taken.
✓ Branch 80 taken 1 times.
✗ Branch 81 not taken.
✓ Branch 83 taken 1 times.
✗ Branch 84 not taken.
✓ Branch 86 taken 1 times.
✗ Branch 87 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✓ Branch 95 taken 1 times.
✗ Branch 96 not taken.
✓ Branch 98 taken 1 times.
✗ Branch 99 not taken.
✓ Branch 102 taken 1 times.
✗ Branch 103 not taken.
✓ Branch 105 taken 1 times.
✗ Branch 106 not taken.
✓ Branch 108 taken 1 times.
✗ Branch 109 not taken.
✓ Branch 111 taken 1 times.
✗ Branch 112 not taken.
✓ Branch 116 taken 1 times.
✗ Branch 117 not taken.
|
4 | BOOST_AUTO_TEST_CASE(test_biased) { |
80 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Q(2, 2); |
81 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q.setZero(); |
82 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q(0, 0) = 1.0; |
83 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q(1, 1) = 1.0; |
84 | |||
85 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd C(2); |
86 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | C(0) = -1.; |
87 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | C(1) = -1.; |
88 | |||
89 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Aeq(2, 0); |
90 | |||
91 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd Beq(0); |
92 | |||
93 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Aineq(2, 0); |
94 | |||
95 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd Bineq(0); |
96 | |||
97 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd x(2); |
98 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXi activeSet(0); |
99 | size_t activeSetSize; | ||
100 | |||
101 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd solution(2); |
102 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | solution(0) = 1.; |
103 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | solution(1) = 1.; |
104 | |||
105 | 2 | double val = -1.; | |
106 | |||
107 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | double out = eiquadprog::solvers::solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, |
108 | 2 | x, activeSet, activeSetSize); | |
109 | |||
110 |
6/12✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
|
2 | BOOST_CHECK_CLOSE(out, val, 1e-6); |
111 | |||
112 |
7/14✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 1 times.
|
2 | BOOST_CHECK(x.isApprox(solution)); |
113 | 2 | } | |
114 | |||
115 | // min ||x||^2 | ||
116 | // s.t. | ||
117 | // x[1] = 1 - x[0] | ||
118 | |||
119 |
33/66✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 23 taken 1 times.
✗ Branch 24 not taken.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 1 times.
✗ Branch 37 not taken.
✓ Branch 41 taken 1 times.
✗ Branch 42 not taken.
✓ Branch 45 taken 1 times.
✗ Branch 46 not taken.
✓ Branch 48 taken 1 times.
✗ Branch 49 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 66 taken 1 times.
✗ Branch 67 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 77 taken 1 times.
✗ Branch 78 not taken.
✓ Branch 80 taken 1 times.
✗ Branch 81 not taken.
✓ Branch 83 taken 1 times.
✗ Branch 84 not taken.
✓ Branch 86 taken 1 times.
✗ Branch 87 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✓ Branch 95 taken 1 times.
✗ Branch 96 not taken.
✓ Branch 98 taken 1 times.
✗ Branch 99 not taken.
✓ Branch 102 taken 1 times.
✗ Branch 103 not taken.
✓ Branch 105 taken 1 times.
✗ Branch 106 not taken.
✓ Branch 108 taken 1 times.
✗ Branch 109 not taken.
✓ Branch 111 taken 1 times.
✗ Branch 112 not taken.
✓ Branch 116 taken 1 times.
✗ Branch 117 not taken.
|
4 | BOOST_AUTO_TEST_CASE(test_equality_constraints) { |
120 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Q(2, 2); |
121 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q.setZero(); |
122 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q(0, 0) = 1.0; |
123 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q(1, 1) = 1.0; |
124 | |||
125 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd C(2); |
126 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | C.setZero(); |
127 | |||
128 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Aeq(2, 1); |
129 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aeq(0, 0) = 1.; |
130 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aeq(1, 0) = 1.; |
131 | |||
132 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd Beq(1); |
133 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Beq(0) = -1.; |
134 | |||
135 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Aineq(2, 0); |
136 | |||
137 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd Bineq(0); |
138 | |||
139 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd x(2); |
140 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXi activeSet(1); |
141 | size_t activeSetSize; | ||
142 | |||
143 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd solution(2); |
144 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | solution(0) = 0.5; |
145 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | solution(1) = 0.5; |
146 | |||
147 | 2 | double val = 0.25; | |
148 | |||
149 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | double out = eiquadprog::solvers::solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, |
150 | 2 | x, activeSet, activeSetSize); | |
151 | |||
152 |
6/12✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
|
2 | BOOST_CHECK_CLOSE(out, val, 1e-6); |
153 | |||
154 |
7/14✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 1 times.
|
2 | BOOST_CHECK(x.isApprox(solution)); |
155 | 2 | } | |
156 | |||
157 | // min ||x||^2 | ||
158 | // s.t. | ||
159 | // x[i] >= 1 | ||
160 | |||
161 |
33/66✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 23 taken 1 times.
✗ Branch 24 not taken.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 1 times.
✗ Branch 37 not taken.
✓ Branch 41 taken 1 times.
✗ Branch 42 not taken.
✓ Branch 45 taken 1 times.
✗ Branch 46 not taken.
✓ Branch 48 taken 1 times.
✗ Branch 49 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 66 taken 1 times.
✗ Branch 67 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 77 taken 1 times.
✗ Branch 78 not taken.
✓ Branch 80 taken 1 times.
✗ Branch 81 not taken.
✓ Branch 83 taken 1 times.
✗ Branch 84 not taken.
✓ Branch 86 taken 1 times.
✗ Branch 87 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✓ Branch 95 taken 1 times.
✗ Branch 96 not taken.
✓ Branch 98 taken 1 times.
✗ Branch 99 not taken.
✓ Branch 102 taken 1 times.
✗ Branch 103 not taken.
✓ Branch 105 taken 1 times.
✗ Branch 106 not taken.
✓ Branch 108 taken 1 times.
✗ Branch 109 not taken.
✓ Branch 111 taken 1 times.
✗ Branch 112 not taken.
✓ Branch 116 taken 1 times.
✗ Branch 117 not taken.
|
4 | BOOST_AUTO_TEST_CASE(test_inequality_constraints) { |
162 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Q(2, 2); |
163 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q.setZero(); |
164 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q(0, 0) = 1.0; |
165 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q(1, 1) = 1.0; |
166 | |||
167 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd C(2); |
168 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | C.setZero(); |
169 | |||
170 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Aeq(2, 0); |
171 | |||
172 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd Beq(0); |
173 | |||
174 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Aineq(2, 2); |
175 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aineq.setZero(); |
176 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aineq(0, 0) = 1.; |
177 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aineq(1, 1) = 1.; |
178 | |||
179 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd Bineq(2); |
180 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Bineq(0) = -1.; |
181 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Bineq(1) = -1.; |
182 | |||
183 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd x(2); |
184 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXi activeSet(2); |
185 | size_t activeSetSize; | ||
186 | |||
187 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd solution(2); |
188 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | solution(0) = 1.; |
189 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | solution(1) = 1.; |
190 | |||
191 | 2 | double val = 1.; | |
192 | |||
193 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | double out = eiquadprog::solvers::solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, |
194 | 2 | x, activeSet, activeSetSize); | |
195 | |||
196 |
6/12✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
|
2 | BOOST_CHECK_CLOSE(out, val, 1e-6); |
197 | |||
198 |
7/14✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 1 times.
|
2 | BOOST_CHECK(x.isApprox(solution)); |
199 | 2 | } | |
200 | |||
201 | // min ||x-x_0||^2, x_0 = (1 1)^T | ||
202 | // s.t. | ||
203 | // x[1] = 5 - x[0] | ||
204 | // x[1] >= 3 | ||
205 | |||
206 |
33/66✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 23 taken 1 times.
✗ Branch 24 not taken.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 1 times.
✗ Branch 37 not taken.
✓ Branch 41 taken 1 times.
✗ Branch 42 not taken.
✓ Branch 45 taken 1 times.
✗ Branch 46 not taken.
✓ Branch 48 taken 1 times.
✗ Branch 49 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 66 taken 1 times.
✗ Branch 67 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 77 taken 1 times.
✗ Branch 78 not taken.
✓ Branch 80 taken 1 times.
✗ Branch 81 not taken.
✓ Branch 83 taken 1 times.
✗ Branch 84 not taken.
✓ Branch 86 taken 1 times.
✗ Branch 87 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✓ Branch 95 taken 1 times.
✗ Branch 96 not taken.
✓ Branch 98 taken 1 times.
✗ Branch 99 not taken.
✓ Branch 102 taken 1 times.
✗ Branch 103 not taken.
✓ Branch 105 taken 1 times.
✗ Branch 106 not taken.
✓ Branch 108 taken 1 times.
✗ Branch 109 not taken.
✓ Branch 111 taken 1 times.
✗ Branch 112 not taken.
✓ Branch 116 taken 1 times.
✗ Branch 117 not taken.
|
4 | BOOST_AUTO_TEST_CASE(test_full) { |
207 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Q(2, 2); |
208 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q.setZero(); |
209 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q(0, 0) = 1.0; |
210 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q(1, 1) = 1.0; |
211 | |||
212 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd C(2); |
213 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | C(0) = -1.; |
214 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | C(1) = -1.; |
215 | |||
216 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Aeq(2, 1); |
217 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aeq(0, 0) = 1.; |
218 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aeq(1, 0) = 1.; |
219 | |||
220 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd Beq(1); |
221 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Beq(0) = -5.; |
222 | |||
223 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Aineq(2, 1); |
224 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aineq.setZero(); |
225 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aineq(1, 0) = 1.; |
226 | |||
227 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd Bineq(1); |
228 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Bineq(0) = -3.; |
229 | |||
230 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd x(2); |
231 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXi activeSet(2); |
232 | size_t activeSetSize; | ||
233 | |||
234 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd solution(2); |
235 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | solution(0) = 2.; |
236 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | solution(1) = 3.; |
237 | |||
238 | 2 | double val = 1.5; | |
239 | |||
240 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | double out = eiquadprog::solvers::solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, |
241 | 2 | x, activeSet, activeSetSize); | |
242 | |||
243 |
6/12✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
|
2 | BOOST_CHECK_CLOSE(out, val, 1e-6); |
244 | |||
245 |
7/14✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 1 times.
|
2 | BOOST_CHECK(x.isApprox(solution)); |
246 | 2 | } | |
247 | |||
248 | // min ||x||^2 | ||
249 | // s.t. | ||
250 | // x[0] = 1 | ||
251 | // x[0] = -1 | ||
252 | // DOES NOT WORK! | ||
253 | |||
254 |
33/66✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 23 taken 1 times.
✗ Branch 24 not taken.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 1 times.
✗ Branch 37 not taken.
✓ Branch 41 taken 1 times.
✗ Branch 42 not taken.
✓ Branch 45 taken 1 times.
✗ Branch 46 not taken.
✓ Branch 48 taken 1 times.
✗ Branch 49 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 66 taken 1 times.
✗ Branch 67 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 77 taken 1 times.
✗ Branch 78 not taken.
✓ Branch 80 taken 1 times.
✗ Branch 81 not taken.
✓ Branch 83 taken 1 times.
✗ Branch 84 not taken.
✓ Branch 86 taken 1 times.
✗ Branch 87 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✓ Branch 95 taken 1 times.
✗ Branch 96 not taken.
✓ Branch 98 taken 1 times.
✗ Branch 99 not taken.
✓ Branch 102 taken 1 times.
✗ Branch 103 not taken.
✓ Branch 105 taken 1 times.
✗ Branch 106 not taken.
✓ Branch 108 taken 1 times.
✗ Branch 109 not taken.
✓ Branch 111 taken 1 times.
✗ Branch 112 not taken.
✓ Branch 116 taken 1 times.
✗ Branch 117 not taken.
|
4 | BOOST_AUTO_TEST_CASE(test_unfeasible_equalities) { |
255 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Q(2, 2); |
256 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q.setZero(); |
257 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q(0, 0) = 1.0; |
258 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q(1, 1) = 1.0; |
259 | |||
260 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd C(2); |
261 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | C.setZero(); |
262 | |||
263 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Aeq(2, 2); |
264 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aeq.setZero(); |
265 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aeq(0, 0) = 1.; |
266 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aeq(0, 1) = 1.; |
267 | |||
268 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd Beq(2); |
269 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Beq(0) = -1.; |
270 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Beq(1) = 1.; |
271 | |||
272 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Aineq(2, 0); |
273 | |||
274 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd Bineq(0); |
275 | |||
276 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd x(2); |
277 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXi activeSet(2); |
278 | size_t activeSetSize; | ||
279 | |||
280 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | double out = eiquadprog::solvers::solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, |
281 | x, activeSet, activeSetSize); | ||
282 | |||
283 | // DOES NOT WORK!? | ||
284 |
6/12✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 1 times.
|
2 | BOOST_WARN(std::isinf(out)); |
285 | 2 | } | |
286 | |||
287 | // min ||x||^2 | ||
288 | // s.t. | ||
289 | // x[0] >= 1 | ||
290 | // x[0] <= -1 | ||
291 | |||
292 |
33/66✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 23 taken 1 times.
✗ Branch 24 not taken.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 1 times.
✗ Branch 37 not taken.
✓ Branch 41 taken 1 times.
✗ Branch 42 not taken.
✓ Branch 45 taken 1 times.
✗ Branch 46 not taken.
✓ Branch 48 taken 1 times.
✗ Branch 49 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 66 taken 1 times.
✗ Branch 67 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 77 taken 1 times.
✗ Branch 78 not taken.
✓ Branch 80 taken 1 times.
✗ Branch 81 not taken.
✓ Branch 83 taken 1 times.
✗ Branch 84 not taken.
✓ Branch 86 taken 1 times.
✗ Branch 87 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✓ Branch 95 taken 1 times.
✗ Branch 96 not taken.
✓ Branch 98 taken 1 times.
✗ Branch 99 not taken.
✓ Branch 102 taken 1 times.
✗ Branch 103 not taken.
✓ Branch 105 taken 1 times.
✗ Branch 106 not taken.
✓ Branch 108 taken 1 times.
✗ Branch 109 not taken.
✓ Branch 111 taken 1 times.
✗ Branch 112 not taken.
✓ Branch 116 taken 1 times.
✗ Branch 117 not taken.
|
4 | BOOST_AUTO_TEST_CASE(test_unfeasible_inequalities) { |
293 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Q(2, 2); |
294 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q.setZero(); |
295 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q(0, 0) = 1.0; |
296 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q(1, 1) = 1.0; |
297 | |||
298 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd C(2); |
299 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | C.setZero(); |
300 | |||
301 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Aeq(2, 0); |
302 | |||
303 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd Beq(0); |
304 | |||
305 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Aineq(2, 2); |
306 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aineq.setZero(); |
307 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aineq(0, 0) = 1.; |
308 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aineq(0, 1) = -1.; |
309 | |||
310 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd Bineq(2); |
311 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Bineq(0) = -1; |
312 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Bineq(1) = -1; |
313 | |||
314 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd x(2); |
315 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXi activeSet(2); |
316 | size_t activeSetSize; | ||
317 | |||
318 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | double out = eiquadprog::solvers::solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, |
319 | x, activeSet, activeSetSize); | ||
320 | |||
321 |
6/12✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 1 times.
|
2 | BOOST_CHECK(std::isinf(out)); |
322 | 2 | } | |
323 | |||
324 | // min ||x-x_0||^2, x_0 = (1 1)^T | ||
325 | // s.t. | ||
326 | // x[1] = 1 - x[0] | ||
327 | // x[0] <= 0 | ||
328 | // x[1] <= 0 | ||
329 | |||
330 |
33/66✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 23 taken 1 times.
✗ Branch 24 not taken.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 1 times.
✗ Branch 37 not taken.
✓ Branch 41 taken 1 times.
✗ Branch 42 not taken.
✓ Branch 45 taken 1 times.
✗ Branch 46 not taken.
✓ Branch 48 taken 1 times.
✗ Branch 49 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 66 taken 1 times.
✗ Branch 67 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 77 taken 1 times.
✗ Branch 78 not taken.
✓ Branch 80 taken 1 times.
✗ Branch 81 not taken.
✓ Branch 83 taken 1 times.
✗ Branch 84 not taken.
✓ Branch 86 taken 1 times.
✗ Branch 87 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✓ Branch 95 taken 1 times.
✗ Branch 96 not taken.
✓ Branch 98 taken 1 times.
✗ Branch 99 not taken.
✓ Branch 102 taken 1 times.
✗ Branch 103 not taken.
✓ Branch 105 taken 1 times.
✗ Branch 106 not taken.
✓ Branch 108 taken 1 times.
✗ Branch 109 not taken.
✓ Branch 111 taken 1 times.
✗ Branch 112 not taken.
✓ Branch 116 taken 1 times.
✗ Branch 117 not taken.
|
4 | BOOST_AUTO_TEST_CASE(test_unfeasible_constraints) { |
331 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Q(2, 2); |
332 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q.setZero(); |
333 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q(0, 0) = 1.0; |
334 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q(1, 1) = 1.0; |
335 | |||
336 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd C(2); |
337 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | C(0) = -1.; |
338 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | C(1) = -1.; |
339 | |||
340 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Aeq(2, 1); |
341 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aeq(0, 0) = 1.; |
342 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aeq(1, 0) = 1.; |
343 | |||
344 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd Beq(1); |
345 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Beq(0) = -1.; |
346 | |||
347 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Aineq(2, 2); |
348 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aineq.setZero(); |
349 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aineq(0, 0) = -1.; |
350 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aineq(1, 1) = -1.; |
351 | |||
352 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd Bineq(2); |
353 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Bineq.setZero(); |
354 | |||
355 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd x(2); |
356 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXi activeSet(3); |
357 | size_t activeSetSize; | ||
358 | |||
359 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | double out = eiquadprog::solvers::solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, |
360 | x, activeSet, activeSetSize); | ||
361 | |||
362 |
6/12✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 1 times.
|
2 | BOOST_CHECK(std::isinf(out)); |
363 | 2 | } | |
364 | |||
365 | // min -||x||^2 | ||
366 | // DOES NOT WORK! | ||
367 | |||
368 |
33/66✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 23 taken 1 times.
✗ Branch 24 not taken.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 1 times.
✗ Branch 37 not taken.
✓ Branch 41 taken 1 times.
✗ Branch 42 not taken.
✓ Branch 45 taken 1 times.
✗ Branch 46 not taken.
✓ Branch 48 taken 1 times.
✗ Branch 49 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 66 taken 1 times.
✗ Branch 67 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 77 taken 1 times.
✗ Branch 78 not taken.
✓ Branch 80 taken 1 times.
✗ Branch 81 not taken.
✓ Branch 83 taken 1 times.
✗ Branch 84 not taken.
✓ Branch 86 taken 1 times.
✗ Branch 87 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✓ Branch 95 taken 1 times.
✗ Branch 96 not taken.
✓ Branch 98 taken 1 times.
✗ Branch 99 not taken.
✓ Branch 102 taken 1 times.
✗ Branch 103 not taken.
✓ Branch 105 taken 1 times.
✗ Branch 106 not taken.
✓ Branch 108 taken 1 times.
✗ Branch 109 not taken.
✓ Branch 111 taken 1 times.
✗ Branch 112 not taken.
✓ Branch 116 taken 1 times.
✗ Branch 117 not taken.
|
4 | BOOST_AUTO_TEST_CASE(test_unbounded) { |
369 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Q(2, 2); |
370 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q.setZero(); |
371 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q(0, 0) = -1.0; |
372 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q(1, 1) = -1.0; |
373 | |||
374 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd C(2); |
375 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | C.setZero(); |
376 | |||
377 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Aeq(2, 0); |
378 | |||
379 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd Beq(0); |
380 | |||
381 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Aineq(2, 0); |
382 | |||
383 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd Bineq(0); |
384 | |||
385 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd x(2); |
386 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXi activeSet(0); |
387 | size_t activeSetSize; | ||
388 | |||
389 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | double out = eiquadprog::solvers::solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, |
390 | x, activeSet, activeSetSize); | ||
391 | |||
392 | // DOES NOT WORK!? | ||
393 |
6/12✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 1 times.
|
2 | BOOST_WARN(std::isinf(out)); |
394 | 2 | } | |
395 | |||
396 | // min -||x||^2 | ||
397 | // s.t. | ||
398 | // 0<= x[0] <= 1 | ||
399 | // 0<= x[1] <= 1 | ||
400 | // DOES NOT WORK! | ||
401 | |||
402 |
33/66✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 23 taken 1 times.
✗ Branch 24 not taken.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 1 times.
✗ Branch 37 not taken.
✓ Branch 41 taken 1 times.
✗ Branch 42 not taken.
✓ Branch 45 taken 1 times.
✗ Branch 46 not taken.
✓ Branch 48 taken 1 times.
✗ Branch 49 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 66 taken 1 times.
✗ Branch 67 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 77 taken 1 times.
✗ Branch 78 not taken.
✓ Branch 80 taken 1 times.
✗ Branch 81 not taken.
✓ Branch 83 taken 1 times.
✗ Branch 84 not taken.
✓ Branch 86 taken 1 times.
✗ Branch 87 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✓ Branch 95 taken 1 times.
✗ Branch 96 not taken.
✓ Branch 98 taken 1 times.
✗ Branch 99 not taken.
✓ Branch 102 taken 1 times.
✗ Branch 103 not taken.
✓ Branch 105 taken 1 times.
✗ Branch 106 not taken.
✓ Branch 108 taken 1 times.
✗ Branch 109 not taken.
✓ Branch 111 taken 1 times.
✗ Branch 112 not taken.
✓ Branch 116 taken 1 times.
✗ Branch 117 not taken.
|
4 | BOOST_AUTO_TEST_CASE(test_nonconvex) { |
403 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Q(2, 2); |
404 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q.setZero(); |
405 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q(0, 0) = -1.0; |
406 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Q(1, 1) = -1.0; |
407 | |||
408 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd C(2); |
409 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | C.setZero(); |
410 | |||
411 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Aeq(2, 0); |
412 | |||
413 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd Beq(0); |
414 | |||
415 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::MatrixXd Aineq(2, 4); |
416 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aineq.setZero(); |
417 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aineq(0, 0) = 1.; |
418 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aineq(0, 1) = -1.; |
419 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aineq(1, 2) = 1.; |
420 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Aineq(1, 3) = -1.; |
421 | |||
422 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd Bineq(4); |
423 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Bineq(0) = 0.; |
424 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Bineq(1) = 1.; |
425 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Bineq(2) = 0.; |
426 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Bineq(3) = 1.; |
427 | |||
428 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd x(2); |
429 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXi activeSet(4); |
430 | size_t activeSetSize; | ||
431 | |||
432 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Eigen::VectorXd solution(2); |
433 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | solution(0) = 1.; |
434 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | solution(1) = 1.; |
435 | |||
436 | 2 | double val = -1.; | |
437 | |||
438 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | double out = eiquadprog::solvers::solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, |
439 | 2 | x, activeSet, activeSetSize); | |
440 | |||
441 | // DOES NOT WORK!? | ||
442 |
6/12✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
|
2 | BOOST_WARN_CLOSE(out, val, 1e-6); |
443 | |||
444 |
7/14✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 1 times.
|
2 | BOOST_WARN(x.isApprox(solution)); |
445 | 2 | } | |
446 | |||
447 | BOOST_AUTO_TEST_SUITE_END() | ||
448 |