GCC Code Coverage Report


Directory: ./
File: tests/eiquadprog-rt.cpp
Date: 2024-08-26 22:54:11
Exec Total Coverage
Lines: 251 251 100.0%
Branches: 666 1332 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 "eiquadprog/eiquadprog-rt.hpp"
20
21 #include <Eigen/Core>
22 #include <boost/test/unit_test.hpp>
23 #include <iostream>
24
25 using namespace eiquadprog::solvers;
26
27 /**
28 * solves the problem
29 * min. 0.5 * x' Hess x + g0' x
30 * s.t. CE x + ce0 = 0
31 * CI x + ci0 >= 0
32 */
33
34 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
35
36 // min ||x||^2
37
38
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) {
39
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtEiquadprog<2, 0, 0> qp;
40
41
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<2, 2>::d Q;
42
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q.setZero();
43
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q(0, 0) = 1.0;
44
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q(1, 1) = 1.0;
45
46
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d C;
47
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 C.setZero();
48
49
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<0, 2>::d Aeq;
50
51
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<0>::d Beq;
52
53
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<0, 2>::d Aineq;
54
55
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<0>::d Bineq;
56
57
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d x;
58
59
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d solution;
60
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 solution.setZero();
61
62 2 double val = 0.0;
63
64 2 RtEiquadprog_status expected = RT_EIQUADPROG_OPTIMAL;
65
66 RtEiquadprog_status status =
67
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x);
68
69
5/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
2 BOOST_CHECK_EQUAL(status, expected);
70
71
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 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 1 times.
2 BOOST_CHECK_CLOSE(qp.getObjValue(), val, 1e-6);
72
73
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));
74 2 }
75
76 // min ||x-x_0||^2, x_0 = (1 1)^T
77
78
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) {
79
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtEiquadprog<2, 0, 0> qp;
80
81
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<2, 2>::d Q;
82
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q.setZero();
83
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q(0, 0) = 1.0;
84
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q(1, 1) = 1.0;
85
86
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d C;
87
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 C(0) = -1.;
88
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 C(1) = -1.;
89
90
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<0, 2>::d Aeq;
91
92
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<0>::d Beq;
93
94
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<0, 2>::d Aineq;
95
96
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<0>::d Bineq;
97
98
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d x;
99
100
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d solution;
101
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 solution(0) = 1.;
102
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 solution(1) = 1.;
103
104 2 double val = -1.;
105
106 2 RtEiquadprog_status expected = RT_EIQUADPROG_OPTIMAL;
107
108 RtEiquadprog_status status =
109
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x);
110
111
5/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
2 BOOST_CHECK_EQUAL(status, expected);
112
113
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 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 1 times.
2 BOOST_CHECK_CLOSE(qp.getObjValue(), val, 1e-6);
114
115
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));
116 2 }
117
118 // min ||x||^2
119 // s.t.
120 // x[1] = 1 - x[0]
121
122
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) {
123
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtEiquadprog<2, 1, 0> qp;
124
125
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<2, 2>::d Q;
126
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q.setZero();
127
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q(0, 0) = 1.0;
128
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q(1, 1) = 1.0;
129
130
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d C;
131
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 C.setZero();
132
133
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<1, 2>::d Aeq;
134
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aeq(0, 0) = 1.;
135
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aeq(0, 1) = 1.;
136
137
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<1>::d Beq;
138
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Beq(0) = -1.;
139
140
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<0, 2>::d Aineq;
141
142
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<0>::d Bineq;
143
144
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d x;
145
146
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d solution;
147
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 solution(0) = 0.5;
148
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 solution(1) = 0.5;
149
150 2 double val = 0.25;
151
152 2 RtEiquadprog_status expected = RT_EIQUADPROG_OPTIMAL;
153
154 RtEiquadprog_status status =
155
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x);
156
157
5/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
2 BOOST_CHECK_EQUAL(status, expected);
158
159
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 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 1 times.
2 BOOST_CHECK_CLOSE(qp.getObjValue(), val, 1e-6);
160
161
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));
162 2 }
163
164 // min ||x||^2
165 // s.t.
166 // x[i] >= 1
167
168
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) {
169
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtEiquadprog<2, 0, 2> qp;
170
171
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<2, 2>::d Q;
172
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q.setZero();
173
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q(0, 0) = 1.0;
174
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q(1, 1) = 1.0;
175
176
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d C;
177
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 C.setZero();
178
179
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<0, 2>::d Aeq;
180
181
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<0>::d Beq(0);
182
183
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<2, 2>::d Aineq;
184
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aineq.setZero();
185
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aineq(0, 0) = 1.;
186
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aineq(1, 1) = 1.;
187
188
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d Bineq;
189
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Bineq(0) = -1.;
190
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Bineq(1) = -1.;
191
192
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d x;
193
194
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d solution;
195
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 solution(0) = 1.;
196
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 solution(1) = 1.;
197
198 2 double val = 1.;
199
200 2 RtEiquadprog_status expected = RT_EIQUADPROG_OPTIMAL;
201
202 RtEiquadprog_status status =
203
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x);
204
205
5/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
2 BOOST_CHECK_EQUAL(status, expected);
206
207
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 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 1 times.
2 BOOST_CHECK_CLOSE(qp.getObjValue(), val, 1e-6);
208
209
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));
210 2 }
211
212 // min ||x-x_0||^2, x_0 = (1 1)^T
213 // s.t.
214 // x[1] = 5 - x[0]
215 // x[1] >= 3
216
217
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) {
218
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtEiquadprog<2, 1, 1> qp;
219
220
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<2, 2>::d Q;
221
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q.setZero();
222
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q(0, 0) = 1.0;
223
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q(1, 1) = 1.0;
224
225
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d C;
226
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 C(0) = -1.;
227
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 C(1) = -1.;
228
229
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<1, 2>::d Aeq;
230
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aeq(0, 0) = 1.;
231
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aeq(0, 1) = 1.;
232
233
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<1>::d Beq;
234
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Beq(0) = -5.;
235
236
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<1, 2>::d Aineq;
237
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aineq.setZero();
238
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aineq(0, 1) = 1.;
239
240
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<1>::d Bineq;
241
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Bineq(0) = -3.;
242
243
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d x;
244
245
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d solution;
246
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 solution(0) = 2.;
247
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 solution(1) = 3.;
248
249 2 double val = 1.5;
250
251 2 RtEiquadprog_status expected = RT_EIQUADPROG_OPTIMAL;
252
253 RtEiquadprog_status status =
254
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x);
255
256
5/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
2 BOOST_CHECK_EQUAL(status, expected);
257
258
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 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 1 times.
2 BOOST_CHECK_CLOSE(qp.getObjValue(), val, 1e-6);
259
260
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));
261 2 }
262
263 // min ||x||^2
264 // s.t.
265 // x[0] = 1
266 // x[0] = -1
267
268
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) {
269
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtEiquadprog<2, 2, 0> qp;
270
271
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<2, 2>::d Q;
272
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q.setZero();
273
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q(0, 0) = 1.0;
274
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q(1, 1) = 1.0;
275
276
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d C;
277
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 C.setZero();
278
279
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<2, 2>::d Aeq;
280
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aeq.setZero();
281
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aeq(0, 0) = 1.;
282
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aeq(1, 0) = 1.;
283
284
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d Beq;
285
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Beq(0) = -1.;
286
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Beq(1) = 1.;
287
288
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<0, 2>::d Aineq;
289
290
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<0>::d Bineq;
291
292
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d x;
293
294 2 RtEiquadprog_status expected = RT_EIQUADPROG_REDUNDANT_EQUALITIES;
295
296 RtEiquadprog_status status =
297
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x);
298
299
5/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
2 BOOST_CHECK_EQUAL(status, expected);
300 2 }
301
302 // min ||x||^2
303 // s.t.
304 // x[0] >= 1
305 // x[0] <= -1
306 //
307 // correctly fails, but returns wrong error code
308
309
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) {
310
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtEiquadprog<2, 0, 2> qp;
311
312
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<2, 2>::d Q;
313
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q.setZero();
314
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q(0, 0) = 1.0;
315
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q(1, 1) = 1.0;
316
317
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d C;
318
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 C.setZero();
319
320
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<0, 2>::d Aeq;
321
322
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<0>::d Beq;
323
324
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<2, 2>::d Aineq;
325
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aineq.setZero();
326
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aineq(0, 0) = 1.;
327
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aineq(1, 0) = -1.;
328
329
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d Bineq;
330
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Bineq(0) = -1;
331
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Bineq(1) = -1;
332
333
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d x;
334
335 2 RtEiquadprog_status expected = RT_EIQUADPROG_INFEASIBLE;
336
337 RtEiquadprog_status status =
338
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x);
339
340
5/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
2 BOOST_WARN_EQUAL(status, expected);
341
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 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 1 times.
2 BOOST_CHECK(status != RT_EIQUADPROG_OPTIMAL);
342 2 }
343
344 // min ||x-x_0||^2, x_0 = (1 1)^T
345 // s.t.
346 // x[1] = 1 - x[0]
347 // x[0] <= 0
348 // x[1] <= 0
349 //
350 // correctly fails, but returns wrong error code
351
352
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) {
353
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtEiquadprog<2, 1, 2> qp;
354
355
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<2, 2>::d Q;
356
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q.setZero();
357
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q(0, 0) = 1.0;
358
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q(1, 1) = 1.0;
359
360
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d C;
361
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 C(0) = -1.;
362
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 C(1) = -1.;
363
364
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<1, 2>::d Aeq;
365
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aeq(0, 0) = 1.;
366
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aeq(0, 1) = 1.;
367
368
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<1>::d Beq;
369
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Beq(0) = -1.;
370
371
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<2, 2>::d Aineq;
372
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aineq.setZero();
373
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aineq(0, 0) = -1.;
374
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aineq(1, 1) = -1.;
375
376
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d Bineq;
377
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Bineq.setZero();
378
379
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d x;
380
381 2 RtEiquadprog_status expected = RT_EIQUADPROG_INFEASIBLE;
382
383 RtEiquadprog_status status =
384
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x);
385
386
5/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
2 BOOST_WARN_EQUAL(status, expected);
387
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 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 1 times.
2 BOOST_CHECK(status != RT_EIQUADPROG_OPTIMAL);
388 2 }
389
390 // min -||x||^2
391 // DOES NOT WORK!
392
393
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) {
394
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtEiquadprog<2, 0, 0> qp;
395
396
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<2, 2>::d Q;
397
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q.setZero();
398
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q(0, 0) = -1.0;
399
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q(1, 1) = -1.0;
400
401
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d C;
402
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 C.setZero();
403
404
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<0, 2>::d Aeq;
405
406
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<0>::d Beq;
407
408
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<0, 2>::d Aineq;
409
410
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<0>::d Bineq;
411
412
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d x;
413
414 2 RtEiquadprog_status expected = RT_EIQUADPROG_UNBOUNDED;
415
416 RtEiquadprog_status status =
417
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x);
418
419
5/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
2 BOOST_WARN_EQUAL(status, expected);
420
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 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 1 times.
2 BOOST_WARN(status != RT_EIQUADPROG_OPTIMAL); // SHOULD pass!
421 2 }
422
423 // min -||x||^2
424 // s.t.
425 // 0<= x[0] <= 1
426 // 0<= x[1] <= 1
427 // DOES NOT WORK!
428
429
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) {
430
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtEiquadprog<2, 0, 4> qp;
431
432
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<2, 2>::d Q;
433
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q.setZero();
434
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q(0, 0) = -1.0;
435
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Q(1, 1) = -1.0;
436
437
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d C;
438
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 C.setZero();
439
440
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<0, 2>::d Aeq;
441
442
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<0>::d Beq;
443
444
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtMatrixX<4, 2>::d Aineq(4, 2);
445
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aineq.setZero();
446
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aineq(0, 0) = 1.;
447
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aineq(1, 0) = -1.;
448
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aineq(2, 1) = 1.;
449
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Aineq(3, 1) = -1.;
450
451
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<4>::d Bineq;
452
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Bineq(0) = 0.;
453
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Bineq(1) = 1.;
454
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Bineq(2) = 0.;
455
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Bineq(3) = 1.;
456
457
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d x;
458
459
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 RtVectorX<2>::d solution;
460
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 solution(0) = 1.;
461
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 solution(1) = 1.;
462
463 2 double val = -1.;
464
465 2 RtEiquadprog_status expected = RT_EIQUADPROG_OPTIMAL;
466
467 RtEiquadprog_status status =
468
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x);
469
470
5/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
2 BOOST_CHECK_EQUAL(status, expected);
471
472
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 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 1 times.
2 BOOST_WARN_CLOSE(qp.getObjValue(), val, 1e-6);
473
474
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));
475 2 }
476
477 BOOST_AUTO_TEST_SUITE_END()
478