qpOASES-3.0beta/examples/qrecipe.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of qpOASES.
3  *
4  * qpOASES -- An Implementation of the Online Active Set Strategy.
5  * Copyright (C) 2007-2011 by Hans Joachim Ferreau, Andreas Potschka,
6  * Christian Kirches et al. All rights reserved.
7  *
8  * qpOASES is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * qpOASES is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with qpOASES; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23 
24 
36 #include <qpOASES.hpp>
37 
39 
40 const real_t Inf = INFTY;
41 
42 long H_jc[] = {0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64,
43  68, 72, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
44  76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
45  76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
46  76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
47  76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
48  76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
49  76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
50  76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
51  76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76};
52 
53 long H_ir[] = {0, 10, 20, 34, 1, 11, 21, 35, 2, 12, 22, 36, 3, 13, 23, 37, 4, 14,
54  24, 38, 0, 10, 20, 34, 1, 11, 21, 35, 2, 12, 22, 36, 3, 13, 23, 37, 4, 14,
55  24, 38, 0, 10, 20, 34, 1, 11, 21, 35, 2, 12, 22, 36, 3, 13, 23, 37, 4, 14,
56  24, 38, 0, 10, 20, 34, 1, 11, 21, 35, 2, 12, 22, 36, 3, 13, 23, 37, 4, 14,
57  24, 38};
58 
59 real_t H_val[] = {10, 1, 1, 1, 10, 1, 1, 1, 10, 1, 1, 1, 10, 1, 1, 1, 10, 1, 1,
60  1, 1, 10, 1, 1, 1, 10, 1, 1, 1, 10, 1, 1, 1, 10, 1, 1, 1, 10, 1, 1, 1, 1,
61  10, 1, 1, 1, 10, 1, 1, 1, 10, 1, 1, 1, 10, 1, 1, 1, 10, 1, 1, 1, 1, 10, 1,
62  1, 1, 10, 1, 1, 1, 10, 1, 1, 1, 10, 1, 1, 1, 10};
63 
64 long A_jc[] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120,
65  130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270,
66  280, 290, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312,
67  313, 314, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 331,
68  333, 335, 337, 339, 341, 343, 345, 347, 349, 351, 353, 355, 357, 359, 361,
69  363, 365, 367, 369, 371, 373, 383, 393, 403, 405, 408, 410, 413, 415, 418,
70  420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 444, 446, 448,
71  450, 452, 454, 456, 458, 460, 462, 472, 482, 492, 494, 497, 499, 502, 504,
72  507, 509, 511, 513, 515, 517, 519, 521, 523, 525, 527, 529, 531, 533, 535,
73  537, 539, 541, 543, 545, 547, 549, 551, 561, 571, 581, 583, 586, 588, 591,
74  593, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609,
75  610, 611, 612, 613, 614, 615, 616, 617, 618, 628, 638, 648, 650, 653, 655,
76  658, 660};
77 
78 long A_ir[] = {0, 14, 35, 36, 71, 72, 85, 86, 87, 88, 1, 14, 35, 36, 71, 72, 85,
79  86, 87, 88, 2, 14, 35, 36, 71, 72, 85, 86, 87, 88, 3, 14, 35, 36, 71, 72,
80  85, 86, 87, 88, 4, 14, 35, 36, 71, 72, 85, 86, 87, 88, 5, 14, 35, 36, 71,
81  72, 85, 86, 87, 88, 6, 14, 35, 36, 71, 72, 85, 86, 87, 88, 7, 14, 35, 36,
82  71, 72, 85, 86, 87, 88, 8, 14, 35, 36, 71, 72, 85, 86, 87, 88, 9, 14, 35,
83  36, 71, 72, 85, 86, 87, 88, 0, 15, 37, 38, 69, 70, 79, 80, 81, 82, 1, 15,
84  37, 38, 69, 70, 79, 80, 81, 82, 2, 15, 37, 38, 69, 70, 79, 80, 81, 82, 3,
85  15, 37, 38, 69, 70, 79, 80, 81, 82, 4, 15, 37, 38, 69, 70, 79, 80, 81, 82,
86  5, 15, 37, 38, 69, 70, 79, 80, 81, 82, 6, 15, 37, 38, 69, 70, 79, 80, 81,
87  82, 7, 15, 37, 38, 69, 70, 79, 80, 81, 82, 8, 15, 37, 38, 69, 70, 79, 80,
88  81, 82, 9, 15, 37, 38, 69, 70, 79, 80, 81, 82, 0, 16, 39, 40, 67, 68, 73,
89  74, 75, 76, 1, 16, 39, 40, 67, 68, 73, 74, 75, 76, 2, 16, 39, 40, 67, 68,
90  73, 74, 75, 76, 3, 16, 39, 40, 67, 68, 73, 74, 75, 76, 4, 16, 39, 40, 67,
91  68, 73, 74, 75, 76, 5, 16, 39, 40, 67, 68, 73, 74, 75, 76, 6, 16, 39, 40,
92  67, 68, 73, 74, 75, 76, 7, 16, 39, 40, 67, 68, 73, 74, 75, 76, 8, 16, 39,
93  40, 67, 68, 73, 74, 75, 76, 9, 16, 39, 40, 67, 68, 73, 74, 75, 76, 10, 11,
94  12, 13, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 47, 48, 49, 50, 51,
95  52, 53, 54, 55, 56, 57, 47, 58, 48, 59, 49, 60, 50, 61, 51, 62, 52, 63, 53,
96  64, 54, 65, 55, 66, 46, 56, 45, 57, 47, 58, 48, 59, 49, 60, 50, 61, 51, 62,
97  52, 63, 53, 64, 54, 65, 55, 66, 46, 56, 45, 57, 10, 14, 71, 72, 85, 86, 87,
98  88, 89, 90, 11, 15, 69, 70, 79, 80, 81, 82, 83, 84, 12, 16, 67, 68, 73, 74,
99  75, 76, 77, 78, 35, 90, 36, 89, 90, 37, 84, 38, 83, 84, 39, 78, 40, 77, 78,
100  44, 58, 43, 59, 42, 60, 41, 61, 34, 62, 33, 63, 32, 64, 31, 65, 30, 66, 29,
101  46, 28, 45, 44, 58, 43, 59, 42, 60, 41, 61, 34, 62, 33, 63, 32, 64, 31, 65,
102  30, 66, 29, 46, 28, 45, 10, 14, 71, 72, 85, 86, 87, 88, 89, 90, 11, 15, 69,
103  70, 79, 80, 81, 82, 83, 84, 12, 16, 67, 68, 73, 74, 75, 76, 77, 78, 35, 90,
104  36, 89, 90, 37, 84, 38, 83, 84, 39, 78, 40, 77, 78, 27, 44, 26, 43, 25, 42,
105  24, 41, 23, 34, 22, 33, 21, 32, 20, 31, 19, 30, 18, 29, 17, 28, 27, 44, 26,
106  43, 25, 42, 24, 41, 23, 34, 22, 33, 21, 32, 20, 31, 19, 30, 18, 29, 17, 28,
107  10, 14, 71, 72, 85, 86, 87, 88, 89, 90, 11, 15, 69, 70, 79, 80, 81, 82, 83,
108  84, 12, 16, 67, 68, 73, 74, 75, 76, 77, 78, 35, 90, 36, 89, 90, 37, 84, 38,
109  83, 84, 39, 78, 40, 77, 78, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 27,
110  26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 10, 14, 71, 72, 85, 86, 87, 88, 89,
111  90, 11, 15, 69, 70, 79, 80, 81, 82, 83, 84, 12, 16, 67, 68, 73, 74, 75, 76,
112  77, 78, 35, 90, 36, 89, 90, 37, 84, 38, 83, 84, 39, 78, 40, 77, 78};
113 
115 -1.0000000000000000e+00, 1.0000000000000000e+00, 8.8678200000000004e+01,
116  9.3617050000000006e+01, 1.6000000000000000e+01, 8.1999999999999993e+00,
117  9.9000000000000000e+01, 8.0000000000000000e+01, 1.2000000000000000e+01,
118  9.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
119  8.0062830000000005e+01, 9.9224010000000007e+01, 1.0000000000000000e+02,
120  2.1100000000000001e+01, 1.0000000000000000e+02, 1.0000000000000000e+02,
121  1.1400000000000000e+02, 1.1680000000000000e+02, -1.0000000000000000e+00,
122  1.0000000000000000e+00, 7.4697360000000003e+01, 8.3801220000000001e+01,
123 -8.1999999999999993e+00, 2.0000000000000000e+00, 9.0000000000000000e+01,
124  2.3999999999999999e+00, -1.2000000000000000e+01, -1.4800000000000001e+01,
125 -1.0000000000000000e+00, 1.0000000000000000e+00, 7.9194209999999998e+01,
126  9.0175110000000004e+01, 4.3000000000000000e+01, 8.0000000000000000e+00,
127  1.0000000000000000e+02, 9.5000000000000000e+01, 9.0000000000000000e+00,
128  2.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
129  7.8568219999999997e+01, 8.5996200000000002e+01, -1.2500000000000000e+01,
130  1.0000000000000000e+00, 9.6500000000000000e+01, 4.0000000000000000e+00,
131 -1.8000000000000000e+01, -2.1899999999999999e+01, -1.0000000000000000e+00,
132  1.0000000000000000e+00, 8.2922240000000002e+01, 8.6963380000000001e+01,
133  6.5000000000000000e+01, 1.2500000000000000e+01, 1.0000000000000000e+02,
134  9.8000000000000000e+01, 4.9000000000000000e+01, 3.7000000000000000e+01,
135 -1.0000000000000000e+00, 1.0000000000000000e+00, 8.2592740000000006e+01,
136  9.3147599999999997e+01, -1.2000000000000000e+01, 1.0000000000000000e+00,
137  9.6500000000000000e+01, 4.0000000000000000e+00, -1.8000000000000000e+01,
138 -2.1899999999999999e+01, -1.0000000000000000e+00, 1.0000000000000000e+00,
139  7.6506460000000004e+01, 7.8210250000000002e+01, 7.9000000000000000e+01,
140  1.2000000000000000e+01, 1.0000000000000000e+02, 9.5000000000000000e+01,
141  6.8000000000000000e+01, 6.1000000000000000e+01, -1.0000000000000000e+00,
142  1.0000000000000000e+00, 8.8357460000000003e+01, 9.4257840000000002e+01,
143  1.2500000000000000e+02, 6.1299999999999997e+01, 1.0000000000000000e+02,
144  1.0000000000000000e+02, 1.4500000000000000e+02, 1.4500000000000000e+02,
145 -1.0000000000000000e+00, 1.0000000000000000e+00, 9.0590469999999996e+01,
146  1.0582863000000000e+02, 6.2000000000000002e+00, 6.0000000000000000e+00,
147  9.7000000000000000e+01, 2.8500000000000000e+01, 4.0000000000000000e+00,
148  3.6000000000000001e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
149  8.8678200000000004e+01, 9.3617050000000006e+01, 1.6000000000000000e+01,
150  8.1999999999999993e+00, 9.9000000000000000e+01, 8.0000000000000000e+01,
151  1.2000000000000000e+01, 9.0000000000000000e+00, -1.0000000000000000e+00,
152  1.0000000000000000e+00, 8.0062830000000005e+01, 9.9224010000000007e+01,
153  1.0000000000000000e+02, 2.1100000000000001e+01, 1.0000000000000000e+02,
154  1.0000000000000000e+02, 1.1400000000000000e+02, 1.1680000000000000e+02,
155 -1.0000000000000000e+00, 1.0000000000000000e+00, 7.4697360000000003e+01,
156  8.3801220000000001e+01, -8.1999999999999993e+00, 2.0000000000000000e+00,
157  9.0000000000000000e+01, 2.3999999999999999e+00, -1.2000000000000000e+01,
158 -1.4800000000000001e+01, -1.0000000000000000e+00, 1.0000000000000000e+00,
159  7.9194209999999998e+01, 9.0175110000000004e+01, 4.3000000000000000e+01,
160  8.0000000000000000e+00, 1.0000000000000000e+02, 9.5000000000000000e+01,
161  9.0000000000000000e+00, 2.0000000000000000e+00, -1.0000000000000000e+00,
162  1.0000000000000000e+00, 7.8568219999999997e+01, 8.5996200000000002e+01,
163 -1.2500000000000000e+01, 1.0000000000000000e+00, 9.6500000000000000e+01,
164  4.0000000000000000e+00, -1.8000000000000000e+01, -2.1899999999999999e+01,
165 -1.0000000000000000e+00, 1.0000000000000000e+00, 8.2922240000000002e+01,
166  8.6963380000000001e+01, 6.5000000000000000e+01, 1.2500000000000000e+01,
167  1.0000000000000000e+02, 9.8000000000000000e+01, 4.9000000000000000e+01,
168  3.7000000000000000e+01, -1.0000000000000000e+00, 1.0000000000000000e+00,
169  8.2592740000000006e+01, 9.3147599999999997e+01, -1.2000000000000000e+01,
170  1.0000000000000000e+00, 9.6500000000000000e+01, 4.0000000000000000e+00,
171 -1.8000000000000000e+01, -2.1899999999999999e+01, -1.0000000000000000e+00,
172  1.0000000000000000e+00, 7.6506460000000004e+01, 7.8210250000000002e+01,
173  7.9000000000000000e+01, 1.2000000000000000e+01, 1.0000000000000000e+02,
174  9.5000000000000000e+01, 6.8000000000000000e+01, 6.1000000000000000e+01,
175 -1.0000000000000000e+00, 1.0000000000000000e+00, 8.8357460000000003e+01,
176  9.4257840000000002e+01, 1.2500000000000000e+02, 6.1299999999999997e+01,
177  1.0000000000000000e+02, 1.0000000000000000e+02, 1.4500000000000000e+02,
178  1.4500000000000000e+02, -1.0000000000000000e+00, 1.0000000000000000e+00,
179  9.0590469999999996e+01, 1.0582863000000000e+02, 6.2000000000000002e+00,
180  6.0000000000000000e+00, 9.7000000000000000e+01, 2.8500000000000000e+01,
181  4.0000000000000000e+00, 3.6000000000000001e+00, -1.0000000000000000e+00,
182  1.0000000000000000e+00, 8.8678200000000004e+01, 9.3617050000000006e+01,
183  1.6000000000000000e+01, 8.1999999999999993e+00, 9.9000000000000000e+01,
184  8.0000000000000000e+01, 1.2000000000000000e+01, 9.0000000000000000e+00,
185 -1.0000000000000000e+00, 1.0000000000000000e+00, 8.0062830000000005e+01,
186  9.9224010000000007e+01, 1.0000000000000000e+02, 2.1100000000000001e+01,
187  1.0000000000000000e+02, 1.0000000000000000e+02, 1.1400000000000000e+02,
188  1.1680000000000000e+02, -1.0000000000000000e+00, 1.0000000000000000e+00,
189  7.4697360000000003e+01, 8.3801220000000001e+01, -8.1999999999999993e+00,
190  2.0000000000000000e+00, 9.0000000000000000e+01, 2.3999999999999999e+00,
191 -1.2000000000000000e+01, -1.4800000000000001e+01, -1.0000000000000000e+00,
192  1.0000000000000000e+00, 7.9194209999999998e+01, 9.0175110000000004e+01,
193  4.3000000000000000e+01, 8.0000000000000000e+00, 1.0000000000000000e+02,
194  9.5000000000000000e+01, 9.0000000000000000e+00, 2.0000000000000000e+00,
195 -1.0000000000000000e+00, 1.0000000000000000e+00, 7.8568219999999997e+01,
196  8.5996200000000002e+01, -1.2500000000000000e+01, 1.0000000000000000e+00,
197  9.6500000000000000e+01, 4.0000000000000000e+00, -1.8000000000000000e+01,
198 -2.1899999999999999e+01, -1.0000000000000000e+00, 1.0000000000000000e+00,
199  8.2922240000000002e+01, 8.6963380000000001e+01, 6.5000000000000000e+01,
200  1.2500000000000000e+01, 1.0000000000000000e+02, 9.8000000000000000e+01,
201  4.9000000000000000e+01, 3.7000000000000000e+01, -1.0000000000000000e+00,
202  1.0000000000000000e+00, 8.2592740000000006e+01, 9.3147599999999997e+01,
203 -1.2000000000000000e+01, 1.0000000000000000e+00, 9.6500000000000000e+01,
204  4.0000000000000000e+00, -1.8000000000000000e+01, -2.1899999999999999e+01,
205 -1.0000000000000000e+00, 1.0000000000000000e+00, 7.6506460000000004e+01,
206  7.8210250000000002e+01, 7.9000000000000000e+01, 1.2000000000000000e+01,
207  1.0000000000000000e+02, 9.5000000000000000e+01, 6.8000000000000000e+01,
208  6.1000000000000000e+01, -1.0000000000000000e+00, 1.0000000000000000e+00,
209  8.8357460000000003e+01, 9.4257840000000002e+01, 1.2500000000000000e+02,
210  6.1299999999999997e+01, 1.0000000000000000e+02, 1.0000000000000000e+02,
211  1.4500000000000000e+02, 1.4500000000000000e+02, -1.0000000000000000e+00,
212  1.0000000000000000e+00, 9.0590469999999996e+01, 1.0582863000000000e+02,
213  6.2000000000000002e+00, 6.0000000000000000e+00, 9.7000000000000000e+01,
214  2.8500000000000000e+01, 4.0000000000000000e+00, 3.6000000000000001e+00,
215 -1.0000000000000000e+00, -1.0000000000000000e+00, -1.0000000000000000e+00,
216 -1.0000000000000000e+00, 1.0000000000000000e+00, 1.0000000000000000e+00,
217  1.0000000000000000e+00, 1.0000000000000000e+00, 1.0000000000000000e+00,
218  1.0000000000000000e+00, 1.0000000000000000e+00, 1.0000000000000000e+00,
219  1.0000000000000000e+00, 1.0000000000000000e+00, -1.2000000000000000e-01,
220 -3.8000000000000000e-01, -5.0000000000000000e-01, 1.0000000000000000e+00,
221  1.0000000000000000e+00, 1.0000000000000000e+00, 1.0000000000000000e+00,
222  1.0000000000000000e+00, 1.0000000000000000e+00, 1.0000000000000000e+00,
223  1.0000000000000000e+00, 1.0000000000000000e+00, 1.0000000000000000e+00,
224  1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
225  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
226 -1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
227  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
228 -1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
229  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
230 -1.0000000000000000e+00, 1.0000000000000000e+00, 1.0000000000000000e+00,
231 -1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
232 -1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
233  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
234 -1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
235  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
236 -1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
237  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
238  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
239 -1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
240 -4.7000000000000000e+01, -8.6999999999999993e+00, -9.0000000000000000e+01,
241 -5.0000000000000000e+01, -1.0000000000000000e+01, -1.0000000000000000e+01,
242 -9.3000000000000000e+01, -8.9000000000000000e+01, 1.0000000000000000e+00,
243 -1.0000000000000000e+00, -4.7000000000000000e+01, -8.6999999999999993e+00,
244 -9.0000000000000000e+01, -5.0000000000000000e+01, -1.0000000000000000e+01,
245 -1.0000000000000000e+01, -8.9000000000000000e+01, -8.5000000000000000e+01,
246  1.0000000000000000e+00, -1.0000000000000000e+00, -4.7000000000000000e+01,
247 -8.6999999999999993e+00, -9.0000000000000000e+01, -5.0000000000000000e+01,
248 -1.0000000000000000e+01, -1.0000000000000000e+01, -9.1000000000000000e+01,
249 -8.8000000000000000e+01, -1.0000000000000000e+00, 5.0000000000000000e-01,
250 -1.0000000000000000e+00, 1.0000000000000000e+00, 5.0000000000000000e-01,
251 -1.0000000000000000e+00, 5.0000000000000000e-01, -1.0000000000000000e+00,
252  1.0000000000000000e+00, 5.0000000000000000e-01, -1.0000000000000000e+00,
253  5.0000000000000000e-01, -1.0000000000000000e+00, 1.0000000000000000e+00,
254  5.0000000000000000e-01, 1.0000000000000000e+00, -1.0000000000000000e+00,
255  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
256 -1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
257  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
258 -1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
259  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
260 -1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
261  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
262 -1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
263  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
264 -1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
265  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
266 -1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
267  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
268 -1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
269  1.0000000000000000e+00, -1.0000000000000000e+00, -4.7000000000000000e+01,
270 -8.6999999999999993e+00, -9.0000000000000000e+01, -5.0000000000000000e+01,
271 -1.0000000000000000e+01, -1.0000000000000000e+01, -9.3000000000000000e+01,
272 -8.9000000000000000e+01, 1.0000000000000000e+00, -1.0000000000000000e+00,
273 -4.7000000000000000e+01, -8.6999999999999993e+00, -9.0000000000000000e+01,
274 -5.0000000000000000e+01, -1.0000000000000000e+01, -1.0000000000000000e+01,
275 -8.9000000000000000e+01, -8.5000000000000000e+01, 1.0000000000000000e+00,
276 -1.0000000000000000e+00, -4.7000000000000000e+01, -8.6999999999999993e+00,
277 -9.0000000000000000e+01, -5.0000000000000000e+01, -1.0000000000000000e+01,
278 -1.0000000000000000e+01, -9.1000000000000000e+01, -8.8000000000000000e+01,
279 -1.0000000000000000e+00, 5.0000000000000000e-01, -1.0000000000000000e+00,
280  1.0000000000000000e+00, 5.0000000000000000e-01, -1.0000000000000000e+00,
281  5.0000000000000000e-01, -1.0000000000000000e+00, 1.0000000000000000e+00,
282  5.0000000000000000e-01, -1.0000000000000000e+00, 5.0000000000000000e-01,
283 -1.0000000000000000e+00, 1.0000000000000000e+00, 5.0000000000000000e-01,
284  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
285 -1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
286  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
287 -1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
288  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
289 -1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
290  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
291 -1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
292  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
293 -1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
294  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
295 -1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
296  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
297 -1.0000000000000000e+00, 1.0000000000000000e+00, -1.0000000000000000e+00,
298  1.0000000000000000e+00, -1.0000000000000000e+00, 1.0000000000000000e+00,
299 -1.0000000000000000e+00, -4.7000000000000000e+01, -8.6999999999999993e+00,
300 -9.0000000000000000e+01, -5.0000000000000000e+01, -1.0000000000000000e+01,
301 -1.0000000000000000e+01, -9.3000000000000000e+01, -8.9000000000000000e+01,
302  1.0000000000000000e+00, -1.0000000000000000e+00, -4.7000000000000000e+01,
303 -8.6999999999999993e+00, -9.0000000000000000e+01, -5.0000000000000000e+01,
304 -1.0000000000000000e+01, -1.0000000000000000e+01, -8.9000000000000000e+01,
305 -8.5000000000000000e+01, 1.0000000000000000e+00, -1.0000000000000000e+00,
306 -4.7000000000000000e+01, -8.6999999999999993e+00, -9.0000000000000000e+01,
307 -5.0000000000000000e+01, -1.0000000000000000e+01, -1.0000000000000000e+01,
308 -9.1000000000000000e+01, -8.8000000000000000e+01, -1.0000000000000000e+00,
309  5.0000000000000000e-01, -1.0000000000000000e+00, 1.0000000000000000e+00,
310  5.0000000000000000e-01, -1.0000000000000000e+00, 5.0000000000000000e-01,
311 -1.0000000000000000e+00, 1.0000000000000000e+00, 5.0000000000000000e-01,
312 -1.0000000000000000e+00, 5.0000000000000000e-01, -1.0000000000000000e+00,
313  1.0000000000000000e+00, 5.0000000000000000e-01, -1.0000000000000000e+00,
314 -1.0000000000000000e+00, -1.0000000000000000e+00, -1.0000000000000000e+00,
315 -1.0000000000000000e+00, -1.0000000000000000e+00, -1.0000000000000000e+00,
316 -1.0000000000000000e+00, -1.0000000000000000e+00, -1.0000000000000000e+00,
317 -1.0000000000000000e+00, -1.0000000000000000e+00, -1.0000000000000000e+00,
318 -1.0000000000000000e+00, -1.0000000000000000e+00, -1.0000000000000000e+00,
319 -1.0000000000000000e+00, -1.0000000000000000e+00, -1.0000000000000000e+00,
320 -1.0000000000000000e+00, -1.0000000000000000e+00, -1.0000000000000000e+00,
321  1.0000000000000000e+00, -1.0000000000000000e+00, -4.7000000000000000e+01,
322 -8.6999999999999993e+00, -9.0000000000000000e+01, -5.0000000000000000e+01,
323 -1.0000000000000000e+01, -1.0000000000000000e+01, -9.3000000000000000e+01,
324 -8.9000000000000000e+01, 1.0000000000000000e+00, -1.0000000000000000e+00,
325 -4.7000000000000000e+01, -8.6999999999999993e+00, -9.0000000000000000e+01,
326 -5.0000000000000000e+01, -1.0000000000000000e+01, -1.0000000000000000e+01,
327 -8.9000000000000000e+01, -8.5000000000000000e+01, 1.0000000000000000e+00,
328 -1.0000000000000000e+00, -4.7000000000000000e+01, -8.6999999999999993e+00,
329 -9.0000000000000000e+01, -5.0000000000000000e+01, -1.0000000000000000e+01,
330 -1.0000000000000000e+01, -9.1000000000000000e+01, -8.8000000000000000e+01,
331 -1.0000000000000000e+00, 5.0000000000000000e-01, -1.0000000000000000e+00,
332  1.0000000000000000e+00, 5.0000000000000000e-01, -1.0000000000000000e+00,
333  5.0000000000000000e-01, -1.0000000000000000e+00, 1.0000000000000000e+00,
334  5.0000000000000000e-01, -1.0000000000000000e+00, 5.0000000000000000e-01,
335 -1.0000000000000000e+00, 1.0000000000000000e+00, 5.0000000000000000e-01};
336 
337 real_t g[] = {+0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00,
338  +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00,
339  +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00,
340  +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00,
341  +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00,
342  +0e+00, +0e+00, -2e+00, -2e+00, -2e+00, -2e+00, -2e+00, -2e+00, -2e+00,
343  -2e+00, +0e+00, -2e+00, +0e+00, +2e-03, +2e-03, +2e-03, +2e-03, +2e-03,
344  +2e-03, +1e-03, +2e-03, +2e-03, +2e-03, +0e+00, -2e-03, -2e-03, -2e-03,
345  -2e-03, -2e-03, -2e-03, -1e-03, -2e-03, -2e-03, -2e-03, +0e+00, +0e+00,
346  +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +2e-03,
347  +2e-03, +2e-03, +2e-03, +2e-03, +2e-03, +1e-03, +2e-03, +2e-03, +2e-03,
348  +0e+00, -2e-03, -2e-03, -2e-03, -2e-03, -2e-03, -2e-03, -1e-03, -2e-03,
349  -2e-03, -2e-03, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00,
350  +0e+00, +0e+00, +0e+00, +2e-03, +2e-03, +2e-03, +2e-03, +2e-03, +2e-03,
351  +1e-03, +2e-03, +2e-03, +2e-03, +0e+00, -2e-03, -2e-03, -2e-03, -2e-03,
352  -2e-03, -2e-03, -1e-03, -2e-03, -2e-03, -2e-03, +0e+00, +0e+00, +0e+00,
353  +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +1e-01, +1e-01,
354  +1e-01, +1e-01, +1e-01, +1e-01, +1e-01, +1e-01, +1e-01, +1e-01, +0e+00,
355  -1e-01, -1e-01, -1e-01, -1e-01, -1e-01, -1e-01, -1e-01, -1e-01, -1e-01,
356  -1e-01, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00, +0e+00,
357  +0e+00};
358 
359 real_t lb[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
360  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
361  0, 0, 0, -Inf, 0, -Inf, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 5,
362  10, 5, 0, 10, 0, 2, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
363  0, 0, 0, 0, 0, 10, 5, 10, 5, 0, 10, 0, 5, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0,
364  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 5, 10, 5, 0, 10, 0, 5, 0, 10, 0, 0,
365  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
366  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
367 
368 real_t ub[] = {Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf,
369  Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf,
370  Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf,
371  Inf, Inf, 0, 92, 39, 87, 29, 0, 20, 0, 28, 20, 71, Inf, 130, 45, 53, 55, 75,
372  112, 0, 73, 480, 154, 121, 50, 30, 77, 20, 0, 18, 0, 5, 20, 71, Inf, Inf,
373  Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, 130, 55, 93, 60, 75, 115, 0, 67,
374  480, 154, 121, 50, 20, 37, 15, 0, 15, 0, 8, 20, 71, Inf, Inf, Inf, Inf, Inf,
375  Inf, Inf, Inf, Inf, Inf, 130, 55, 93, 60, 75, 105, 0, 67, 4980, 154, 110,
376  50, 20, 37, 15, 0, 25, 0, 8, 20, 71, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf,
377  Inf, Inf, 20, 20, 20, 20, 0, 20, 0, 20, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
378  0, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf};
379 
380 real_t lbA[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
381  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
382  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -Inf, -Inf,
383  -Inf, -Inf, -Inf, -Inf, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
384  0};
385 
386 real_t ubA[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
387  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
388  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
389  0, 0, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf, Inf,
390  Inf, Inf, Inf, Inf};
391 
392 long H_nnz = sizeof(H_val) / sizeof(real_t);
393 long A_nnz = sizeof(A_val) / sizeof(real_t);
394 
395 int main( )
396 {
397  long i;
398  int nWSR;
399  long *H_jd;
400  real_t err, tic, toc;
401  real_t *x1 = new real_t[180];
402  real_t *y1 = new real_t[271];
403  real_t *x2 = new real_t[180];
404  real_t *y2 = new real_t[271];
405 
406  /* create sparse matrices */
407  SymSparseMat *H = new SymSparseMat(180, 180, H_ir, H_jc, H_val);
408  SparseMatrix *A = new SparseMatrix(91, 180, A_ir, A_jc, A_val);
409 
410  H_jd = H->createDiagInfo();
411 
412  real_t* H_full = H->full();
413  real_t* A_full = A->full();
414 
415  SymDenseMat *Hd = new SymDenseMat(180,180,180,H_full);
416  DenseMatrix *Ad = new DenseMatrix(91,180,180,A_full);
417 
418  /* solve with dense matrices */
419  nWSR = 1000;
420  QProblem qrecipeD(180, 91);
421  tic = getCPUtime();
422  qrecipeD.init(Hd, g, Ad, lb, ub, lbA, ubA, nWSR, 0);
423  toc = getCPUtime();
424  qrecipeD.getPrimalSolution(x1);
425  qrecipeD.getDualSolution(y1);
426 
427  fprintf(stdout, "Solved dense problem in %d iterations, %.3f seconds.\n", nWSR, toc-tic);
428 
429  /* solve with sparse matrices */
430  nWSR = 1000;
431  QProblem qrecipeS(180, 91);
432  tic = getCPUtime();
433  qrecipeS.init(H, g, A, lb, ub, lbA, ubA, nWSR, 0);
434  toc = getCPUtime();
435  qrecipeS.getPrimalSolution(x2);
436  qrecipeS.getDualSolution(y2);
437 
438  fprintf(stdout, "Solved sparse problem in %d iterations, %.3f seconds.\n", nWSR, toc-tic);
439 
440  /* check distance of solutions */
441  err = 0.0;
442  for (i = 0; i < 180; i++)
443  if (fabs(x1[i] - x2[i]) > err)
444  err = fabs(x1[i] - x2[i]);
445  fprintf(stdout, "Primal error: %9.2e\n", err);
446  err = 0.0;
447  for (i = 0; i < 271; i++)
448  if (fabs(y1[i] - y2[i]) > err)
449  err = fabs(y1[i] - y2[i]);
450  fprintf(stdout, "Dual error: %9.2e\n", err);
451 
452  delete H;
453  delete A;
454  delete[] H_full;
455  delete[] A_full;
456  delete Hd;
457  delete Ad;
458  delete[] H_jd;
459 
460  delete[] y2;
461  delete[] x2;
462  delete[] y1;
463  delete[] x1;
464 
465  return 0;
466 }
467 
468 
469 /*
470  * end of file
471  */
Interfaces matrix-vector operations tailored to symmetric sparse matrices.
returnValue init(const real_t *const _H, const real_t *const _g, const real_t *const _A, const real_t *const _lb, const real_t *const _ub, const real_t *const _lbA, const real_t *const _ubA, int &nWSR, const real_t *const yOpt=0, real_t *const cputime=0)
const double INFTY
real_t toc(timer *t)
Definition: AD_test.c:25
Interfaces matrix-vector operations tailored to symmetric dense matrices.
void tic(timer *t)
Definition: AD_test.c:19
Interfaces matrix-vector operations tailored to general dense matrices.
Interfaces matrix-vector operations tailored to general sparse matrices.
USING_NAMESPACE_QPOASES const real_t Inf
double real_t
Definition: AD_test.c:10
Implements the online active set strategy for QPs with general constraints.


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:35:02