9 double* eval_weight_matrix,
double* eval_coeff_vector,
10 double* state_min_vector,
double* state_max_vector,
11 double* inequality_matrix,
double* inequality_min_vector,
double* inequality_max_vector,
12 int state_len,
int inequality_len, PrintLevel print_level,
double* ret_status,
14 real_t* H =
new real_t[state_len*state_len];
15 real_t*
A =
new real_t[inequality_len*state_len];
16 real_t* g =
new real_t[state_len];
17 real_t* ub =
new real_t[state_len];
18 real_t* lb =
new real_t[state_len];
19 real_t* ubA =
new real_t[inequality_len];
20 real_t* lbA =
new real_t[inequality_len];
22 for (
int i = 0; i < state_len*state_len; i++) {
23 H[i] = eval_weight_matrix[i];
26 for (
int i = 0; i < state_len*state_len; i++) {
30 for (
int i = 0; i < state_len; i++) {
31 ub[i] = state_max_vector[i];
33 for (
int i = 0; i < state_len; i++) {
34 lb[i] = state_min_vector[i];
36 for (
int i = 0; i < state_len; i++) {
37 g[i] = eval_coeff_vector[i];
39 for (
int i = 0; i < inequality_len; i++) {
40 ubA[i] = inequality_max_vector[i];
42 for (
int i = 0; i < inequality_len; i++) {
43 lbA[i] = inequality_min_vector[i];
45 for (
int i = 0; i < inequality_len*state_len; i++) {
46 A[i] = inequality_matrix[i];
49 QProblem example( state_len,inequality_len, (solve_lp ? HST_ZERO : HST_UNKNOWN));
51 options.printLevel = print_level;
52 example.setOptions( options );
55 returnValue status = example.init( H,g,A,lb,ub,lbA,ubA, nWSR );
57 ret_status[0] = getSimpleStatus(status, (print_level != PL_NONE)? BT_TRUE:BT_FALSE);
59 real_t* xOpt =
new real_t[state_len];
60 example.getPrimalSolution( xOpt );
61 for (
int i = 0; i < state_len; i++) {
80 std::map<std::pair<int, int>, QProblem*>
qp_map;
82 double* eval_weight_matrix,
double* eval_coeff_vector,
83 double* state_min_vector,
double* state_max_vector,
84 double* inequality_matrix,
double* inequality_min_vector,
double* inequality_max_vector,
85 int state_len,
int inequality_len, PrintLevel print_level,
double* ret_status,
87 real_t* H =
new real_t[state_len*state_len];
88 real_t*
A =
new real_t[inequality_len*state_len];
89 real_t* g =
new real_t[state_len];
90 real_t* ub =
new real_t[state_len];
91 real_t* lb =
new real_t[state_len];
92 real_t* ubA =
new real_t[inequality_len];
93 real_t* lbA =
new real_t[inequality_len];
95 for (
int i = 0; i < state_len*state_len; i++) {
96 H[i] = eval_weight_matrix[i];
99 for (
int i = 0; i < state_len*state_len; i++) {
103 for (
int i = 0; i < state_len; i++) {
104 ub[i] = state_max_vector[i];
106 for (
int i = 0; i < state_len; i++) {
107 lb[i] = state_min_vector[i];
109 for (
int i = 0; i < state_len; i++) {
110 g[i] = eval_coeff_vector[i];
112 for (
int i = 0; i < inequality_len; i++) {
113 ubA[i] = inequality_max_vector[i];
115 for (
int i = 0; i < inequality_len; i++) {
116 lbA[i] = inequality_min_vector[i];
118 for (
int i = 0; i < inequality_len*state_len; i++) {
119 A[i] = inequality_matrix[i];
123 std::pair<int, int> tmp_pair(state_len, inequality_len);
124 std::map<std::pair<int, int>, QProblem*>::iterator it =
qp_map.find(tmp_pair);
125 bool is_initial = (it ==
qp_map.end());
127 example =
new QProblem ( state_len,inequality_len, (solve_lp ? HST_ZERO : HST_UNKNOWN));
128 qp_map.insert(std::pair<std::pair<int, int>, QProblem*>(tmp_pair, example));
130 example = it->second;
134 options.printLevel = print_level;
135 example->setOptions( options );
140 status = example->init( H,g,A,lb,ub,lbA,ubA, nWSR );
143 status = example->hotstart( g,lb,ub,lbA,ubA, nWSR );
147 ret_status[0] = getSimpleStatus(status, (print_level != PL_NONE)? BT_TRUE:BT_FALSE);
148 if (example->isSolved() == BT_FALSE && ret_status[0] == 0) ret_status[0] = -100;
150 real_t* xOpt =
new real_t[state_len];
151 example->getPrimalSolution( xOpt );
152 for (
int i = 0; i < state_len; i++) {
156 if ( ret_status[0] != 0 ) {
176 std::map<std::pair<int, int>, SQProblem*>
sqp_map;
178 double* eval_weight_matrix,
double* eval_coeff_vector,
179 double* state_min_vector,
double* state_max_vector,
180 double* inequality_matrix,
double* inequality_min_vector,
double* inequality_max_vector,
181 int state_len,
int inequality_len, PrintLevel print_level,
double* ret_status,
183 real_t* H =
new real_t[state_len*state_len];
184 real_t*
A =
new real_t[inequality_len*state_len];
185 real_t* g =
new real_t[state_len];
186 real_t* ub =
new real_t[state_len];
187 real_t* lb =
new real_t[state_len];
188 real_t* ubA =
new real_t[inequality_len];
189 real_t* lbA =
new real_t[inequality_len];
191 for (
int i = 0; i < state_len*state_len; i++) {
192 H[i] = eval_weight_matrix[i];
195 for (
int i = 0; i < state_len*state_len; i++) {
199 for (
int i = 0; i < state_len; i++) {
200 ub[i] = state_max_vector[i];
202 for (
int i = 0; i < state_len; i++) {
203 lb[i] = state_min_vector[i];
205 for (
int i = 0; i < state_len; i++) {
206 g[i] = eval_coeff_vector[i];
208 for (
int i = 0; i < inequality_len; i++) {
209 ubA[i] = inequality_max_vector[i];
211 for (
int i = 0; i < inequality_len; i++) {
212 lbA[i] = inequality_min_vector[i];
214 for (
int i = 0; i < inequality_len*state_len; i++) {
215 A[i] = inequality_matrix[i];
219 std::pair<int, int> tmp_pair(state_len, inequality_len);
220 std::map<std::pair<int, int>, SQProblem*>::iterator it =
sqp_map.find(tmp_pair);
221 bool is_initial = (it ==
sqp_map.end());
223 example =
new SQProblem ( state_len,inequality_len, (solve_lp ? HST_ZERO : HST_UNKNOWN));
224 sqp_map.insert(std::pair<std::pair<int, int>, SQProblem*>(tmp_pair, example));
226 example = it->second;
230 options.printLevel = print_level;
231 example->setOptions( options );
236 status = example->init( H,g,A,lb,ub,lbA,ubA, nWSR );
239 status = example->hotstart( H,g,A,lb,ub,lbA,ubA, nWSR );
243 ret_status[0] = getSimpleStatus(status, (print_level != PL_NONE)? BT_TRUE:BT_FALSE);
244 if (example->isSolved() == BT_FALSE && ret_status[0] == 0) ret_status[0] = -100;
246 real_t* xOpt =
new real_t[state_len];
247 example->getPrimalSolution( xOpt );
248 for (
int i = 0; i < state_len; i++) {
252 if ( ret_status[0] != 0 ) {
271 double* eval_weight_matrix,
double* eval_coeff_vector,
272 double* state_min_vector,
double* state_max_vector,
273 double* inequality_matrix,
double* inequality_min_vector,
double* inequality_max_vector,
274 int state_len,
int inequality_len, PrintLevel print_level,
double* ret_status) {
276 eval_weight_matrix, eval_coeff_vector,
277 state_min_vector, state_max_vector,
278 inequality_matrix, inequality_min_vector, inequality_max_vector,
279 state_len, inequality_len, print_level, ret_status,
false);
283 double* eval_coeff_vector,
284 double* state_min_vector,
double* state_max_vector,
285 double* inequality_matrix,
double* inequality_min_vector,
double* inequality_max_vector,
286 int state_len,
int inequality_len, PrintLevel print_level,
double* ret_status) {
288 NULL, eval_coeff_vector,
289 state_min_vector, state_max_vector,
290 inequality_matrix, inequality_min_vector, inequality_max_vector,
291 state_len, inequality_len, print_level, ret_status,
true);
295 double* eval_weight_matrix,
double* eval_coeff_vector,
296 double* state_min_vector,
double* state_max_vector,
297 double* inequality_matrix,
double* inequality_min_vector,
double* inequality_max_vector,
298 int state_len,
int inequality_len, PrintLevel print_level,
double* ret_status) {
300 eval_weight_matrix, eval_coeff_vector,
301 state_min_vector, state_max_vector,
302 inequality_matrix, inequality_min_vector, inequality_max_vector,
303 state_len, inequality_len, print_level, ret_status,
false);
307 double* eval_coeff_vector,
308 double* state_min_vector,
double* state_max_vector,
309 double* inequality_matrix,
double* inequality_min_vector,
double* inequality_max_vector,
310 int state_len,
int inequality_len, PrintLevel print_level,
double* ret_status) {
312 NULL, eval_coeff_vector,
313 state_min_vector, state_max_vector,
314 inequality_matrix, inequality_min_vector, inequality_max_vector,
315 state_len, inequality_len, print_level, ret_status,
true);
319 double* eval_weight_matrix,
double* eval_coeff_vector,
320 double* state_min_vector,
double* state_max_vector,
321 double* inequality_matrix,
double* inequality_min_vector,
double* inequality_max_vector,
322 int state_len,
int inequality_len, PrintLevel print_level,
double* ret_status) {
324 eval_weight_matrix, eval_coeff_vector,
325 state_min_vector, state_max_vector,
326 inequality_matrix, inequality_min_vector, inequality_max_vector,
327 state_len, inequality_len, print_level, ret_status,
false);
331 double* eval_coeff_vector,
332 double* state_min_vector,
double* state_max_vector,
333 double* inequality_matrix,
double* inequality_min_vector,
double* inequality_max_vector,
334 int state_len,
int inequality_len, PrintLevel print_level,
double* ret_status) {
336 NULL, eval_coeff_vector,
337 state_min_vector, state_max_vector,
338 inequality_matrix, inequality_min_vector, inequality_max_vector,
339 state_len, inequality_len, print_level, ret_status,
true);
double * solve_qpoases_slp_with_hotstart(double *ret, double *eval_coeff_vector, double *state_min_vector, double *state_max_vector, double *inequality_matrix, double *inequality_min_vector, double *inequality_max_vector, int state_len, int inequality_len, PrintLevel print_level, double *ret_status)
double * solve_qpoases_qp_common(double *ret, double *eval_weight_matrix, double *eval_coeff_vector, double *state_min_vector, double *state_max_vector, double *inequality_matrix, double *inequality_min_vector, double *inequality_max_vector, int state_len, int inequality_len, PrintLevel print_level, double *ret_status, bool solve_lp)
double * solve_qpoases_sqp_with_hotstart_common(double *ret, double *eval_weight_matrix, double *eval_coeff_vector, double *state_min_vector, double *state_max_vector, double *inequality_matrix, double *inequality_min_vector, double *inequality_max_vector, int state_len, int inequality_len, PrintLevel print_level, double *ret_status, bool solve_lp)
std::map< std::pair< int, int >, SQProblem * > sqp_map
double * solve_qpoases_qp_with_hotstart_common(double *ret, double *eval_weight_matrix, double *eval_coeff_vector, double *state_min_vector, double *state_max_vector, double *inequality_matrix, double *inequality_min_vector, double *inequality_max_vector, int state_len, int inequality_len, PrintLevel print_level, double *ret_status, bool solve_lp)
double * solve_qpoases_qp_with_hotstart(double *ret, double *eval_weight_matrix, double *eval_coeff_vector, double *state_min_vector, double *state_max_vector, double *inequality_matrix, double *inequality_min_vector, double *inequality_max_vector, int state_len, int inequality_len, PrintLevel print_level, double *ret_status)
double * solve_qpoases_lp_with_hotstart(double *ret, double *eval_coeff_vector, double *state_min_vector, double *state_max_vector, double *inequality_matrix, double *inequality_min_vector, double *inequality_max_vector, int state_len, int inequality_len, PrintLevel print_level, double *ret_status)
std::map< std::pair< int, int >, QProblem * > qp_map
double * solve_qpoases_qp(double *ret, double *eval_weight_matrix, double *eval_coeff_vector, double *state_min_vector, double *state_max_vector, double *inequality_matrix, double *inequality_min_vector, double *inequality_max_vector, int state_len, int inequality_len, PrintLevel print_level, double *ret_status)
double * solve_qpoases_lp(double *ret, double *eval_coeff_vector, double *state_min_vector, double *state_max_vector, double *inequality_matrix, double *inequality_min_vector, double *inequality_max_vector, int state_len, int inequality_len, PrintLevel print_level, double *ret_status)
double * solve_qpoases_sqp_with_hotstart(double *ret, double *eval_weight_matrix, double *eval_coeff_vector, double *state_min_vector, double *state_max_vector, double *inequality_matrix, double *inequality_min_vector, double *inequality_max_vector, int state_len, int inequality_len, PrintLevel print_level, double *ret_status)