Apollo 11.0
自动驾驶开放平台
distance_approach_ipopt_fixed_ts_interface.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17/*
18 * @file
19 */
21namespace apollo {
22namespace planning {
23
25 const size_t horizon,
26 const double ts,
27 const Eigen::MatrixXd& ego,
28 const Eigen::MatrixXd& xWS,
29 const Eigen::MatrixXd& uWS,
30 const Eigen::MatrixXd& l_warm_up,
31 const Eigen::MatrixXd& n_warm_up,
32 const Eigen::MatrixXd& x0,
33 const Eigen::MatrixXd& xf,
34 const Eigen::MatrixXd& last_time_u,
35 const std::vector<double>& XYbounds,
36 const Eigen::MatrixXi& obstacles_edges_num,
37 const size_t obstacles_num,
38 const Eigen::MatrixXd& obstacles_A,
39 const Eigen::MatrixXd& obstacles_b,
40 const PlannerOpenSpaceConfig& planner_open_space_config) :
41 ts_(ts),
42 ego_(ego),
43 xWS_(xWS),
44 uWS_(uWS),
45 l_warm_up_(l_warm_up),
46 n_warm_up_(n_warm_up),
47 x0_(x0),
48 xf_(xf),
49 last_time_u_(last_time_u),
50 XYbounds_(XYbounds),
51 obstacles_edges_num_(obstacles_edges_num),
52 obstacles_A_(obstacles_A),
53 obstacles_b_(obstacles_b) {
54 ACHECK(horizon < std::numeric_limits<int>::max()) << "Invalid cast on horizon in open space planner";
55 horizon_ = static_cast<int>(horizon);
56 ACHECK(obstacles_num < std::numeric_limits<int>::max()) << "Invalid cast on obstacles_num in open space planner";
57
58 obstacles_num_ = static_cast<int>(obstacles_num);
59 w_ev_ = ego_(1, 0) + ego_(3, 0);
60 l_ev_ = ego_(0, 0) + ego_(2, 0);
61 g_ = {l_ev_ / 2, w_ev_ / 2, l_ev_ / 2, w_ev_ / 2};
62 offset_ = (ego_(0, 0) + ego_(2, 0)) / 2 - ego_(2, 0);
63 obstacles_edges_sum_ = obstacles_edges_num_.sum();
64 state_result_ = Eigen::MatrixXd::Zero(4, horizon_ + 1);
65 dual_l_result_ = Eigen::MatrixXd::Zero(obstacles_edges_sum_, horizon_ + 1);
66 dual_n_result_ = Eigen::MatrixXd::Zero(4 * obstacles_num_, horizon_ + 1);
67 control_result_ = Eigen::MatrixXd::Zero(2, horizon_ + 1);
68 time_result_ = Eigen::MatrixXd::Zero(1, horizon_ + 1);
69 state_start_index_ = 0;
70 control_start_index_ = 4 * (horizon_ + 1);
71 time_start_index_ = control_start_index_ + 2 * horizon_;
72 l_start_index_ = time_start_index_;
73 n_start_index_ = l_start_index_ + obstacles_edges_sum_ * (horizon_ + 1);
74
75 planner_open_space_config_ = planner_open_space_config;
76 distance_approach_config_ = planner_open_space_config_.distance_approach_config();
77 weight_state_x_ = distance_approach_config_.weight_x();
78 weight_state_y_ = distance_approach_config_.weight_y();
79 weight_state_phi_ = distance_approach_config_.weight_phi();
80 weight_state_v_ = distance_approach_config_.weight_v();
81 weight_input_steer_ = distance_approach_config_.weight_steer();
82 weight_input_a_ = distance_approach_config_.weight_a();
83 weight_rate_steer_ = distance_approach_config_.weight_steer_rate();
84 weight_rate_a_ = distance_approach_config_.weight_a_rate();
85 weight_stitching_steer_ = distance_approach_config_.weight_steer_stitching();
86 weight_stitching_a_ = distance_approach_config_.weight_a_stitching();
87 weight_first_order_time_ = distance_approach_config_.weight_first_order_time();
88 weight_second_order_time_ = distance_approach_config_.weight_second_order_time();
89 min_safety_distance_ = distance_approach_config_.min_safety_distance();
90 max_steer_angle_ = vehicle_param_.max_steer_angle() / vehicle_param_.steer_ratio();
91 max_speed_forward_ = distance_approach_config_.max_speed_forward();
92 max_speed_reverse_ = distance_approach_config_.max_speed_reverse();
93 max_acceleration_forward_ = distance_approach_config_.max_acceleration_forward();
94 max_acceleration_reverse_ = distance_approach_config_.max_acceleration_reverse();
95 min_time_sample_scaling_ = distance_approach_config_.min_time_sample_scaling();
96 max_time_sample_scaling_ = distance_approach_config_.max_time_sample_scaling();
97 max_steer_rate_ = vehicle_param_.max_steer_angle_rate() / vehicle_param_.steer_ratio();
98 use_fix_time_ = distance_approach_config_.use_fix_time();
99 wheelbase_ = vehicle_param_.wheel_base();
100 enable_constraint_check_ = distance_approach_config_.enable_constraint_check();
101}
102
104 const size_t horizon,
105 const double ts,
106 const Eigen::MatrixXd& ego,
107 const Eigen::MatrixXd& xWS,
108 const Eigen::MatrixXd& uWS,
109 const Eigen::MatrixXd& l_warm_up,
110 const Eigen::MatrixXd& n_warm_up,
111 const Eigen::MatrixXd& x0,
112 const Eigen::MatrixXd& xf,
113 const Eigen::MatrixXd& last_time_u,
114 const std::vector<double>& XYbounds,
115 const Eigen::MatrixXi& obstacles_edges_num,
116 const size_t obstacles_num,
117 const Eigen::MatrixXd& obstacles_A,
118 const Eigen::MatrixXd& obstacles_b,
119 const DistanceApproachConfig& distance_approach_config) :
120 ts_(ts),
121 ego_(ego),
122 xWS_(xWS),
123 uWS_(uWS),
124 l_warm_up_(l_warm_up),
125 n_warm_up_(n_warm_up),
126 x0_(x0),
127 xf_(xf),
128 last_time_u_(last_time_u),
129 XYbounds_(XYbounds),
130 obstacles_edges_num_(obstacles_edges_num),
131 obstacles_A_(obstacles_A),
132 obstacles_b_(obstacles_b),
133 distance_approach_config_(distance_approach_config) {
134 ACHECK(horizon < std::numeric_limits<int>::max()) << "Invalid cast on horizon in open space planner";
135 horizon_ = static_cast<int>(horizon);
136 ACHECK(obstacles_num < std::numeric_limits<int>::max()) << "Invalid cast on obstacles_num in open space planner";
137
138 obstacles_num_ = static_cast<int>(obstacles_num);
139 w_ev_ = ego_(1, 0) + ego_(3, 0);
140 l_ev_ = ego_(0, 0) + ego_(2, 0);
141 g_ = {l_ev_ / 2, w_ev_ / 2, l_ev_ / 2, w_ev_ / 2};
142 offset_ = (ego_(0, 0) + ego_(2, 0)) / 2 - ego_(2, 0);
143 obstacles_edges_sum_ = obstacles_edges_num_.sum();
144 state_result_ = Eigen::MatrixXd::Zero(4, horizon_ + 1);
145 dual_l_result_ = Eigen::MatrixXd::Zero(obstacles_edges_sum_, horizon_ + 1);
146 dual_n_result_ = Eigen::MatrixXd::Zero(4 * obstacles_num_, horizon_ + 1);
147 control_result_ = Eigen::MatrixXd::Zero(2, horizon_ + 1);
148 time_result_ = Eigen::MatrixXd::Zero(1, horizon_ + 1);
149 state_start_index_ = 0;
150 control_start_index_ = 4 * (horizon_ + 1);
151 time_start_index_ = control_start_index_ + 2 * horizon_;
152 l_start_index_ = time_start_index_;
153 n_start_index_ = l_start_index_ + obstacles_edges_sum_ * (horizon_ + 1);
154
155 weight_state_x_ = distance_approach_config_.weight_x();
156 weight_state_y_ = distance_approach_config_.weight_y();
157 weight_state_phi_ = distance_approach_config_.weight_phi();
158 weight_state_v_ = distance_approach_config_.weight_v();
159 weight_input_steer_ = distance_approach_config_.weight_steer();
160 weight_input_a_ = distance_approach_config_.weight_a();
161 weight_rate_steer_ = distance_approach_config_.weight_steer_rate();
162 weight_rate_a_ = distance_approach_config_.weight_a_rate();
163 weight_stitching_steer_ = distance_approach_config_.weight_steer_stitching();
164 weight_stitching_a_ = distance_approach_config_.weight_a_stitching();
165 weight_first_order_time_ = distance_approach_config_.weight_first_order_time();
166 weight_second_order_time_ = distance_approach_config_.weight_second_order_time();
167 min_safety_distance_ = distance_approach_config_.min_safety_distance();
168 max_steer_angle_ = vehicle_param_.max_steer_angle() / vehicle_param_.steer_ratio();
169 max_speed_forward_ = distance_approach_config_.max_speed_forward();
170 max_speed_reverse_ = distance_approach_config_.max_speed_reverse();
171 max_acceleration_forward_ = distance_approach_config_.max_acceleration_forward();
172 max_acceleration_reverse_ = distance_approach_config_.max_acceleration_reverse();
173 min_time_sample_scaling_ = distance_approach_config_.min_time_sample_scaling();
174 max_time_sample_scaling_ = distance_approach_config_.max_time_sample_scaling();
175 max_steer_rate_ = vehicle_param_.max_steer_angle_rate() / vehicle_param_.steer_ratio();
176 use_fix_time_ = distance_approach_config_.use_fix_time();
177 wheelbase_ = vehicle_param_.wheel_base();
178 enable_constraint_check_ = distance_approach_config_.enable_constraint_check();
179}
180
182 int& n,
183 int& m,
184 int& nnz_jac_g,
185 int& nnz_h_lag,
186 IndexStyleEnum& index_style) {
187 ADEBUG << "get_nlp_info";
188 // n1 : states variables, 4 * (N+1)
189 int n1 = 4 * (horizon_ + 1);
190 ADEBUG << "n1: " << n1;
191 // n2 : control inputs variables
192 int n2 = 2 * horizon_;
193 ADEBUG << "n2: " << n2;
194 // n4 : dual multiplier associated with obstacle shape
195 lambda_horizon_ = obstacles_edges_num_.sum() * (horizon_ + 1);
196 ADEBUG << "lambda_horizon_: " << lambda_horizon_;
197 // n5 : dual multipier associated with car shape, obstacles_num*4 * (N+1)
198 miu_horizon_ = obstacles_num_ * 4 * (horizon_ + 1);
199 ADEBUG << "miu_horizon_: " << miu_horizon_;
200
201 // m1 : dynamics constatins
202 int m1 = 4 * horizon_;
203 ADEBUG << "m1: " << m1;
204 // m2 : control rate constraints (only steering)
205 int m2 = horizon_;
206 ADEBUG << "m2: " << m2;
207 // m4 : obstacle constraints
208 int m4 = 4 * obstacles_num_ * (horizon_ + 1);
209 ADEBUG << "m4: " << m4;
210
211 num_of_variables_ = n1 + n2 + lambda_horizon_ + miu_horizon_;
212 num_of_constraints_ = m1 + m2 + m4 + (num_of_variables_ - (horizon_ + 1) + 2);
213
214 // number of variables
215 n = num_of_variables_;
216 ADEBUG << "num_of_variables_ " << num_of_variables_;
217 // number of constraints
218 m = num_of_constraints_;
219 ADEBUG << "num_of_constraints_ " << num_of_constraints_;
220
221 generate_tapes(n, m, &nnz_jac_g, &nnz_h_lag);
222
223 index_style = IndexStyleEnum::C_STYLE;
224 return true;
225}
226
228 int n,
229 double* x_l,
230 double* x_u,
231 int m,
232 double* g_l,
233 double* g_u) {
234 ADEBUG << "get_bounds_info";
235 ACHECK(XYbounds_.size() == 4) << "XYbounds_ size is not 4, but" << XYbounds_.size();
236
237 // Variables: includes state, u, sample time and lagrange multipliers
238 // 1. state variables, 4 * [0, horizon]
239 // start point pose
240 int variable_index = 0;
241 for (int i = 0; i < 4; ++i) {
242 x_l[i] = -2e19;
243 x_u[i] = 2e19;
244 }
245 variable_index += 4;
246
247 // During horizons, 2 ~ N-1
248 for (int i = 1; i < horizon_; ++i) {
249 // x
250 x_l[variable_index] = -2e19;
251 x_u[variable_index] = 2e19;
252
253 // y
254 x_l[variable_index + 1] = -2e19;
255 x_u[variable_index + 1] = 2e19;
256
257 // phi
258 x_l[variable_index + 2] = -2e19;
259 x_u[variable_index + 2] = 2e19;
260
261 // v
262 x_l[variable_index + 3] = -2e19;
263 x_u[variable_index + 3] = 2e19;
264
265 variable_index += 4;
266 }
267
268 // end point pose
269 for (int i = 0; i < 4; ++i) {
270 x_l[variable_index + i] = -2e19;
271 x_u[variable_index + i] = 2e19;
272 }
273 variable_index += 4;
274 ADEBUG << "variable_index after adding state variables : " << variable_index;
275
276 // 2. control variables, 2 * [0, horizon_-1]
277 for (int i = 0; i < horizon_; ++i) {
278 // u1
279 x_l[variable_index] = -2e19;
280 x_u[variable_index] = 2e19;
281
282 // u2
283 x_l[variable_index + 1] = -2e19;
284 x_u[variable_index + 1] = 2e19;
285
286 variable_index += 2;
287 }
288 ADEBUG << "variable_index after adding control variables : " << variable_index;
289
290 // 4. lagrange constraint l, [0, obstacles_edges_sum_ - 1] * [0,
291 // horizon_]
292 for (int i = 0; i < horizon_ + 1; ++i) {
293 for (int j = 0; j < obstacles_edges_sum_; ++j) {
294 x_l[variable_index] = 0.0;
295 x_u[variable_index] = 2e19; // nlp_upper_bound_limit
296 ++variable_index;
297 }
298 }
299 ADEBUG << "variable_index after adding lagrange l : " << variable_index;
300
301 // 5. lagrange constraint n, [0, 4*obstacles_num-1] * [0, horizon_]
302 for (int i = 0; i < horizon_ + 1; ++i) {
303 for (int j = 0; j < 4 * obstacles_num_; ++j) {
304 x_l[variable_index] = 0.0;
305 x_u[variable_index] = 2e19; // nlp_upper_bound_limit
306
307 ++variable_index;
308 }
309 }
310 ADEBUG << "variable_index after adding lagrange n : " << variable_index;
311
312 // Constraints: includes four state Euler forward constraints, three
313 // Obstacle related constraints
314
315 // 1. dynamics constraints 4 * [0, horizons-1]
316 int constraint_index = 0;
317 for (int i = 0; i < 4 * horizon_; ++i) {
318 g_l[i] = 0.0;
319 g_u[i] = 0.0;
320 }
321 constraint_index += 4 * horizon_;
322
323 ADEBUG << "constraint_index after adding Euler forward dynamics constraints: " << constraint_index;
324
325 // 2. Control rate limit constraints, 1 * [0, horizons-1], only apply
326 // steering rate as of now
327 for (int i = 0; i < horizon_; ++i) {
328 g_l[constraint_index] = -max_steer_rate_;
329 g_u[constraint_index] = max_steer_rate_;
330 ++constraint_index;
331 }
332
333 ADEBUG << "constraint_index after adding steering rate constraints: " << constraint_index;
334
335 // 4. Three obstacles related equal constraints, one equality constraints,
336 // [0, horizon_] * [0, obstacles_num_-1] * 4
337 for (int i = 0; i < horizon_ + 1; ++i) {
338 for (int j = 0; j < obstacles_num_; ++j) {
339 // a. norm(A'*lambda) <= 1
340 g_l[constraint_index] = -2e19;
341 g_u[constraint_index] = 1.0;
342
343 // b. G'*mu + R'*A*lambda = 0
344 g_l[constraint_index + 1] = 0.0;
345 g_u[constraint_index + 1] = 0.0;
346 g_l[constraint_index + 2] = 0.0;
347 g_u[constraint_index + 2] = 0.0;
348
349 // c. -g'*mu + (A*t - b)*lambda > min_safety_distance_
350 g_l[constraint_index + 3] = min_safety_distance_;
351 g_u[constraint_index + 3] = 2e19; // nlp_upper_bound_limit
352 constraint_index += 4;
353 }
354 }
355 ADEBUG << "constraints_index after adding obstacles related constraints: " << constraint_index;
356
357 // 5. load variable bounds as constraints
358 // start configuration
359 g_l[constraint_index] = x0_(0, 0);
360 g_u[constraint_index] = x0_(0, 0);
361 g_l[constraint_index + 1] = x0_(1, 0);
362 g_u[constraint_index + 1] = x0_(1, 0);
363 g_l[constraint_index + 2] = x0_(2, 0);
364 g_u[constraint_index + 2] = x0_(2, 0);
365 g_l[constraint_index + 3] = x0_(3, 0);
366 g_u[constraint_index + 3] = x0_(3, 0);
367 constraint_index += 4;
368
369 for (int i = 1; i < horizon_; ++i) {
370 g_l[constraint_index] = XYbounds_[0];
371 g_u[constraint_index] = XYbounds_[1];
372 g_l[constraint_index + 1] = XYbounds_[2];
373 g_u[constraint_index + 1] = XYbounds_[3];
374 g_l[constraint_index + 2] = -max_speed_reverse_;
375 g_u[constraint_index + 2] = max_speed_forward_;
376 constraint_index += 3;
377 }
378
379 // end configuration
380 g_l[constraint_index] = xf_(0, 0);
381 g_u[constraint_index] = xf_(0, 0);
382 g_l[constraint_index + 1] = xf_(1, 0);
383 g_u[constraint_index + 1] = xf_(1, 0);
384 g_l[constraint_index + 2] = xf_(2, 0);
385 g_u[constraint_index + 2] = xf_(2, 0);
386 g_l[constraint_index + 3] = xf_(3, 0);
387 g_u[constraint_index + 3] = xf_(3, 0);
388 constraint_index += 4;
389
390 for (int i = 0; i < horizon_; ++i) {
391 g_l[constraint_index] = -max_steer_angle_;
392 g_u[constraint_index] = max_steer_angle_;
393 g_l[constraint_index + 1] = -max_acceleration_reverse_;
394 g_u[constraint_index + 1] = max_acceleration_forward_;
395 constraint_index += 2;
396 }
397
398 for (int i = 0; i < lambda_horizon_; ++i) {
399 g_l[constraint_index] = 0.0;
400 g_u[constraint_index] = 2e19;
401 constraint_index++;
402 }
403
404 for (int i = 0; i < miu_horizon_; ++i) {
405 g_l[constraint_index] = 0.0;
406 g_u[constraint_index] = 2e19;
407 constraint_index++;
408 }
409
410 ADEBUG << "constraint_index after adding obstacles constraints: " << constraint_index;
411 ADEBUG << "get_bounds_info_ out";
412 return true;
413}
414
416 int n,
417 bool init_x,
418 double* x,
419 bool init_z,
420 double* z_L,
421 double* z_U,
422 int m,
423 bool init_lambda,
424 double* lambda) {
425 ADEBUG << "get_starting_point";
426 ACHECK(init_x) << "Warm start init_x setting failed";
427
428 CHECK_EQ(horizon_, uWS_.cols());
429 CHECK_EQ(horizon_ + 1, xWS_.cols());
430
431 // 1. state variables 4 * (horizon_ + 1)
432 for (int i = 0; i < horizon_ + 1; ++i) {
433 int index = i * 4;
434 for (int j = 0; j < 4; ++j) {
435 x[index + j] = xWS_(j, i);
436 }
437 }
438
439 // 2. control variable initialization, 2 * horizon_
440 for (int i = 0; i < horizon_; ++i) {
441 int index = i * 2;
442 x[control_start_index_ + index] = uWS_(0, i);
443 x[control_start_index_ + index + 1] = uWS_(1, i);
444 }
445
446 // 3. lagrange constraint l, obstacles_edges_sum_ * (horizon_+1)
447 for (int i = 0; i < horizon_ + 1; ++i) {
448 int index = i * obstacles_edges_sum_;
449 for (int j = 0; j < obstacles_edges_sum_; ++j) {
450 x[l_start_index_ + index + j] = l_warm_up_(j, i);
451 }
452 }
453
454 // 4. lagrange constraint m, 4*obstacles_num * (horizon_+1)
455 for (int i = 0; i < horizon_ + 1; ++i) {
456 int index = i * 4 * obstacles_num_;
457 for (int j = 0; j < 4 * obstacles_num_; ++j) {
458 x[n_start_index_ + index + j] = n_warm_up_(j, i);
459 }
460 }
461
462 if (enable_constraint_check_) {
463 int kM = m;
464 double g[kM];
465 ADEBUG << "initial points constraint checking";
466 eval_constraints(n, x, m, g);
467 check_g(n, x, m, g);
468 }
469
470 ADEBUG << "get_starting_point out";
471 return true;
472}
473
474bool DistanceApproachIPOPTFixedTsInterface::eval_f(int n, const double* x, bool new_x, double& obj_value) {
475 eval_obj(n, x, &obj_value);
476 return true;
477}
478
479bool DistanceApproachIPOPTFixedTsInterface::eval_grad_f(int n, const double* x, bool new_x, double* grad_f) {
480 gradient(tag_f, n, x, grad_f);
481 return true;
482}
483
484bool DistanceApproachIPOPTFixedTsInterface::eval_g(int n, const double* x, bool new_x, int m, double* g) {
485 eval_constraints(n, x, m, g);
486 if (enable_constraint_check_) {
487 check_g(n, x, m, g);
488 }
489 return true;
490}
491
493 int n,
494 const double* x,
495 bool new_x,
496 int m,
497 int nele_jac,
498 int* iRow,
499 int* jCol,
500 double* values) {
501 if (values == nullptr) {
502 // return the structure of the jacobian
503 for (int idx = 0; idx < nnz_jac; idx++) {
504 iRow[idx] = rind_g[idx];
505 jCol[idx] = cind_g[idx];
506 }
507 } else {
508 // return the values of the jacobian of the constraints
509 sparse_jac(tag_g, m, n, 1, x, &nnz_jac, &rind_g, &cind_g, &jacval, options_g);
510 for (int idx = 0; idx < nnz_jac; idx++) {
511 values[idx] = jacval[idx];
512 }
513 }
514 return true;
515 // return eval_jac_g_ser(n, x, new_x, m, nele_jac, iRow, jCol, values);
516}
517
519 int n,
520 const double* x,
521 bool new_x,
522 int m,
523 int nele_jac,
524 int* iRow,
525 int* jCol,
526 double* values) {
527 AERROR << "NOT VALID NOW";
528 return false;
529} // NOLINT
530
532 int n,
533 const double* x,
534 bool new_x,
535 double obj_factor,
536 int m,
537 const double* lambda,
538 bool new_lambda,
539 int nele_hess,
540 int* iRow,
541 int* jCol,
542 double* values) {
543 if (values == nullptr) {
544 // return the structure. This is a symmetric matrix, fill the lower left
545 // triangle only.
546
547 for (int idx = 0; idx < nnz_L; idx++) {
548 iRow[idx] = rind_L[idx];
549 jCol[idx] = cind_L[idx];
550 }
551 } else {
552 // return the values. This is a symmetric matrix, fill the lower left
553 // triangle only
554
555 obj_lam[0] = obj_factor;
556
557 for (int idx = 0; idx < m; idx++) {
558 obj_lam[1 + idx] = lambda[idx];
559 }
560
561 set_param_vec(tag_L, m + 1, obj_lam);
562 sparse_hess(tag_L, n, 1, const_cast<double*>(x), &nnz_L, &rind_L, &cind_L, &hessval, options_L);
563
564 for (int idx = 0; idx < nnz_L; idx++) {
565 values[idx] = hessval[idx];
566 }
567 }
568
569 return true;
570}
571
573 Ipopt::SolverReturn status,
574 int n,
575 const double* x,
576 const double* z_L,
577 const double* z_U,
578 int m,
579 const double* g,
580 const double* lambda,
581 double obj_value,
582 const Ipopt::IpoptData* ip_data,
583 Ipopt::IpoptCalculatedQuantities* ip_cq) {
584 int state_index = state_start_index_;
585 int control_index = control_start_index_;
586 // int time_index = time_start_index_;
587 int dual_l_index = l_start_index_;
588 int dual_n_index = n_start_index_;
589
590 // enable_constraint_check_: for debug only
591 if (enable_constraint_check_) {
592 ADEBUG << "final resolution constraint checking";
593 check_g(n, x, m, g);
594 }
595 // 1. state variables, 4 * [0, horizon]
596 // 2. control variables, 2 * [0, horizon_-1]
597 // 3. sampling time variables, 1 * [0, horizon_]
598 // 4. dual_l obstacles_edges_sum_ * [0, horizon]
599 // 5. dual_n obstacles_num * [0, horizon]
600 for (int i = 0; i < horizon_; ++i) {
601 state_result_(0, i) = x[state_index];
602 state_result_(1, i) = x[state_index + 1];
603 state_result_(2, i) = x[state_index + 2];
604 state_result_(3, i) = x[state_index + 3];
605 control_result_(0, i) = x[control_index];
606 control_result_(1, i) = x[control_index + 1];
607 time_result_(0, i) = ts_;
608 for (int j = 0; j < obstacles_edges_sum_; ++j) {
609 dual_l_result_(j, i) = x[dual_l_index + j];
610 }
611 for (int k = 0; k < 4 * obstacles_num_; k++) {
612 dual_n_result_(k, i) = x[dual_n_index + k];
613 }
614 state_index += 4;
615 control_index += 2;
616 // time_index++;
617 dual_l_index += obstacles_edges_sum_;
618 dual_n_index += 4 * obstacles_num_;
619 }
620 state_result_(0, 0) = x0_(0, 0);
621 state_result_(1, 0) = x0_(1, 0);
622 state_result_(2, 0) = x0_(2, 0);
623 state_result_(3, 0) = x0_(3, 0);
624 // push back last horizon for state and time variables
625 state_result_(0, horizon_) = xf_(0, 0);
626 state_result_(1, horizon_) = xf_(1, 0);
627 state_result_(2, horizon_) = xf_(2, 0);
628 state_result_(3, horizon_) = xf_(3, 0);
629 time_result_(0, horizon_) = ts_;
630 // time_result_ = ts_ * time_result_;
631 for (int j = 0; j < obstacles_edges_sum_; ++j) {
632 dual_l_result_(j, horizon_) = x[dual_l_index + j];
633 }
634 for (int k = 0; k < 4 * obstacles_num_; k++) {
635 dual_n_result_(k, horizon_) = x[dual_n_index + k];
636 }
637 // memory deallocation of ADOL-C variables
638 delete[] obj_lam;
639 free(rind_g);
640 free(cind_g);
641 free(rind_L);
642 free(cind_L);
643 free(jacval);
644 free(hessval);
645}
646
648 Eigen::MatrixXd* state_result,
649 Eigen::MatrixXd* control_result,
650 Eigen::MatrixXd* time_result,
651 Eigen::MatrixXd* dual_l_result,
652 Eigen::MatrixXd* dual_n_result) const {
653 ADEBUG << "get_optimization_results";
654 *state_result = state_result_;
655 *control_result = control_result_;
656 *time_result = time_result_;
657 *dual_l_result = dual_l_result_;
658 *dual_n_result = dual_n_result_;
659
660 if (!distance_approach_config_.enable_initial_final_check()) {
661 return;
662 }
663 CHECK_EQ(state_result_.cols(), xWS_.cols());
664 CHECK_EQ(state_result_.rows(), xWS_.rows());
665 double state_diff_max = 0.0;
666 for (int i = 0; i < horizon_ + 1; ++i) {
667 for (int j = 0; j < 4; ++j) {
668 state_diff_max = std::max(std::abs(xWS_(j, i) - state_result_(j, i)), state_diff_max);
669 }
670 }
671
672 // 2. control variable initialization, 2 * horizon_
673 CHECK_EQ(control_result_.rows(), uWS_.rows());
674 double control_diff_max = 0.0;
675 for (int i = 0; i < horizon_; ++i) {
676 control_diff_max = std::max(std::abs(uWS_(0, i) - control_result_(0, i)), control_diff_max);
677 control_diff_max = std::max(std::abs(uWS_(1, i) - control_result_(1, i)), control_diff_max);
678 }
679
680 // 3. lagrange constraint l, obstacles_edges_sum_ * (horizon_+1)
681 CHECK_EQ(dual_l_result_.cols(), l_warm_up_.cols());
682 CHECK_EQ(dual_l_result_.rows(), l_warm_up_.rows());
683 double l_diff_max = 0.0;
684 for (int i = 0; i < horizon_ + 1; ++i) {
685 for (int j = 0; j < obstacles_edges_sum_; ++j) {
686 l_diff_max = std::max(std::abs(l_warm_up_(j, i) - dual_l_result_(j, i)), l_diff_max);
687 }
688 }
689
690 // 4. lagrange constraint m, 4*obstacles_num * (horizon_+1)
691 CHECK_EQ(n_warm_up_.cols(), dual_n_result_.cols());
692 CHECK_EQ(n_warm_up_.rows(), dual_n_result_.rows());
693 double n_diff_max = 0.0;
694 for (int i = 0; i < horizon_ + 1; ++i) {
695 for (int j = 0; j < 4 * obstacles_num_; ++j) {
696 n_diff_max = std::max(std::abs(n_warm_up_(j, i) - dual_n_result_(j, i)), n_diff_max);
697 }
698 }
699
700 ADEBUG << "state_diff_max: " << state_diff_max;
701 ADEBUG << "control_diff_max: " << control_diff_max;
702 ADEBUG << "dual_l_diff_max: " << l_diff_max;
703 ADEBUG << "dual_n_diff_max: " << n_diff_max;
704}
705
706//*************** start ADOL-C part ***********************************
707template <class T>
708void DistanceApproachIPOPTFixedTsInterface::eval_obj(int n, const T* x, T* obj_value) {
709 // Objective is :
710 // min control inputs
711 // min input rate
712 // min time (if the time step is not fixed)
713 // regularization wrt warm start trajectory
714 DCHECK(ts_ != 0) << "ts in distance_approach_ is 0";
715 int control_index = control_start_index_;
716 // int time_index = time_start_index_;
717 int state_index = state_start_index_;
718
719 // TODO(QiL): Initial implementation towards earlier understanding and debug
720 // purpose, later code refine towards improving efficiency
721
722 *obj_value = 0.0;
723 // 1. objective to minimize state diff to warm up
724 for (int i = 0; i < horizon_ + 1; ++i) {
725 T x1_diff = x[state_index] - xWS_(0, i);
726 T x2_diff = x[state_index + 1] - xWS_(1, i);
727 T x3_diff = x[state_index + 2] - xWS_(2, i);
728 T x4_abs = x[state_index + 3];
729 *obj_value += weight_state_x_ * x1_diff * x1_diff + weight_state_y_ * x2_diff * x2_diff
730 + weight_state_phi_ * x3_diff * x3_diff + weight_state_v_ * x4_abs * x4_abs;
731 state_index += 4;
732 }
733
734 // 2. objective to minimize u square
735 for (int i = 0; i < horizon_; ++i) {
736 *obj_value += weight_input_steer_ * x[control_index] * x[control_index]
737 + weight_input_a_ * x[control_index + 1] * x[control_index + 1];
738 control_index += 2;
739 }
740
741 // 3. objective to minimize input change rate for first horizon
742 control_index = control_start_index_;
743 T last_time_steer_rate = (x[control_index] - last_time_u_(0, 0)) / ts_;
744 T last_time_a_rate = (x[control_index + 1] - last_time_u_(1, 0)) / ts_;
745
746 *obj_value += weight_stitching_steer_ * last_time_steer_rate * last_time_steer_rate
747 + weight_stitching_a_ * last_time_a_rate * last_time_a_rate;
748
749 // 4. objective to minimize input change rates, [0- horizon_ -2]
750 for (int i = 0; i < horizon_ - 1; ++i) {
751 T steering_rate = (x[control_index + 2] - x[control_index]) / ts_;
752 T a_rate = (x[control_index + 3] - x[control_index + 1]) / ts_;
753 *obj_value += weight_rate_steer_ * steering_rate * steering_rate + weight_rate_a_ * a_rate * a_rate;
754 control_index += 2;
755 }
756}
757
758template <class T>
760 // state start index
761 int state_index = state_start_index_;
762
763 // control start index.
764 int control_index = control_start_index_;
765
766 // time start index
767 // int time_index = time_start_index_;
768
769 int constraint_index = 0;
770
771 // 1. state constraints 4 * [0, horizons-1]
772 // commented implementation is linearized model with fixed ts
773 for (int i = 0; i < horizon_; ++i) {
774 // x1
775 /*
776 g[constraint_index] =
777 x[state_index + 4] -
778 ((xWS_(0, i) + ts_ * xWS_(3, i) * cos(xWS_(2, i))) +
779 (x[state_index] - xWS_(0, i)) +
780 (ts_ * cos(xWS_(2, i))) * (x[state_index + 3] - xWS_(3, i)) +
781 (-ts_ * xWS_(3, i) * sin(xWS_(2, i))) *
782 (x[state_index + 2] - xWS_(2, i)));
783 */
784
785 g[constraint_index]
786 = x[state_index + 4] - (x[state_index] + ts_ * x[state_index + 3] * cos(x[state_index + 2]));
787
788 // x2
789 /*
790 g[constraint_index + 1] =
791 x[state_index + 5] -
792 ((xWS_(1, i) + ts_ * xWS_(3, i) * sin(xWS_(2, i))) +
793 (x[state_index + 1] - xWS_(1, i)) +
794 (ts_ * sin(xWS_(2, i))) * (x[state_index + 3] - xWS_(3, i)) +
795 (ts_ * xWS_(3, i) * cos(xWS_(2, i))) *
796 (x[state_index + 2] - xWS_(2, i)));
797 */
798
799 g[constraint_index + 1]
800 = x[state_index + 5] - (x[state_index + 1] + ts_ * x[state_index + 3] * sin(x[state_index + 2]));
801
802 // x3
803 /*
804 g[constraint_index + 2] =
805 x[state_index + 6] -
806 ((xWS_(2, i) + ts_ * xWS_(3, i) * tan(uWS_(0, i)) / wheelbase_) +
807 (x[state_index + 2] - xWS_(2, i)) +
808 (ts_ * tan(uWS_(0, i)) / wheelbase_) *
809 (x[state_index + 3] - xWS_(3, i)) +
810 (ts_ * xWS_(3, i) / cos(uWS_(0, i)) / cos(uWS_(0, i)) / wheelbase_)
811 *
812 (x[control_index] - uWS_(0, i)));
813 */
814
815 g[constraint_index + 2] = x[state_index + 6]
816 - (x[state_index + 2] + ts_ * x[state_index + 3] * tan(x[control_index]) / wheelbase_);
817
818 // x4
819 /*
820 g[constraint_index + 3] =
821 x[state_index + 7] - ((x[state_index + 3] + ts_ * uWS_(1, i)) +
822 (ts_ * (x[control_index + 1] - uWS_(1, i))));
823 */
824 g[constraint_index + 3] = x[state_index + 7] - (x[state_index + 3] + ts_ * x[control_index + 1]);
825
826 control_index += 2;
827 constraint_index += 4;
828 state_index += 4;
829 }
830
831 ADEBUG << "constraint_index after adding Euler forward dynamics constraints "
832 "updated: "
833 << constraint_index;
834
835 // 2. Control rate limit constraints, 1 * [0, horizons-1], only apply
836 // steering rate as of now
837 control_index = control_start_index_;
838
839 // First rate is compare first with stitch point
840 g[constraint_index] = (x[control_index] - last_time_u_(0, 0)) / ts_;
841 control_index += 2;
842 constraint_index++;
843
844 for (int i = 1; i < horizon_; ++i) {
845 g[constraint_index] = (x[control_index] - x[control_index - 2]) / ts_;
846 constraint_index++;
847 control_index += 2;
848 }
849
850 // 4. Three obstacles related equal constraints, one equality constraints,
851 // [0, horizon_] * [0, obstacles_num_-1] * 4
852 state_index = state_start_index_;
853 int l_index = l_start_index_;
854 int n_index = n_start_index_;
855
856 for (int i = 0; i < horizon_ + 1; ++i) {
857 int edges_counter = 0;
858 for (int j = 0; j < obstacles_num_; ++j) {
859 int current_edges_num = obstacles_edges_num_(j, 0);
860 Eigen::MatrixXd Aj = obstacles_A_.block(edges_counter, 0, current_edges_num, 2);
861 Eigen::MatrixXd bj = obstacles_b_.block(edges_counter, 0, current_edges_num, 1);
862
863 // norm(A* lambda) <= 1
864 T tmp1 = 0.0;
865 T tmp2 = 0.0;
866 for (int k = 0; k < current_edges_num; ++k) {
867 // TODO(QiL) : replace this one directly with x
868 tmp1 += Aj(k, 0) * x[l_index + k];
869 tmp2 += Aj(k, 1) * x[l_index + k];
870 }
871 g[constraint_index] = tmp1 * tmp1 + tmp2 * tmp2;
872
873 // G' * mu + R' * lambda == 0
874 g[constraint_index + 1]
875 = x[n_index] - x[n_index + 2] + cos(x[state_index + 2]) * tmp1 + sin(x[state_index + 2]) * tmp2;
876
877 g[constraint_index + 2]
878 = x[n_index + 1] - x[n_index + 3] - sin(x[state_index + 2]) * tmp1 + cos(x[state_index + 2]) * tmp2;
879
880 // -g'*mu + (A*t - b)*lambda > 0
881 T tmp3 = 0.0;
882 for (int k = 0; k < 4; ++k) {
883 tmp3 += -g_[k] * x[n_index + k];
884 }
885
886 T tmp4 = 0.0;
887 for (int k = 0; k < current_edges_num; ++k) {
888 tmp4 += bj(k, 0) * x[l_index + k];
889 }
890
891 g[constraint_index + 3] = tmp3 + (x[state_index] + cos(x[state_index + 2]) * offset_) * tmp1
892 + (x[state_index + 1] + sin(x[state_index + 2]) * offset_) * tmp2 - tmp4;
893
894 // Update index
895 edges_counter += current_edges_num;
896 l_index += current_edges_num;
897 n_index += 4;
898 constraint_index += 4;
899 }
900 state_index += 4;
901 }
902 ADEBUG << "constraint_index after obstacles avoidance constraints "
903 "updated: "
904 << constraint_index;
905
906 // 5. load variable bounds as constraints
907 state_index = state_start_index_;
908 control_index = control_start_index_;
909 // time_index = time_start_index_;
910 l_index = l_start_index_;
911 n_index = n_start_index_;
912
913 // start configuration
914 g[constraint_index] = x[state_index];
915 g[constraint_index + 1] = x[state_index + 1];
916 g[constraint_index + 2] = x[state_index + 2];
917 g[constraint_index + 3] = x[state_index + 3];
918 constraint_index += 4;
919 state_index += 4;
920
921 // constraints on x,y,v
922 for (int i = 1; i < horizon_; ++i) {
923 g[constraint_index] = x[state_index];
924 g[constraint_index + 1] = x[state_index + 1];
925 g[constraint_index + 2] = x[state_index + 3];
926 constraint_index += 3;
927 state_index += 4;
928 }
929
930 // end configuration
931 g[constraint_index] = x[state_index];
932 g[constraint_index + 1] = x[state_index + 1];
933 g[constraint_index + 2] = x[state_index + 2];
934 g[constraint_index + 3] = x[state_index + 3];
935 constraint_index += 4;
936 state_index += 4;
937
938 for (int i = 0; i < horizon_; ++i) {
939 g[constraint_index] = x[control_index];
940 g[constraint_index + 1] = x[control_index + 1];
941 constraint_index += 2;
942 control_index += 2;
943 }
944
945 for (int i = 0; i < lambda_horizon_; ++i) {
946 g[constraint_index] = x[l_index];
947 constraint_index++;
948 l_index++;
949 }
950
951 for (int i = 0; i < miu_horizon_; ++i) {
952 g[constraint_index] = x[n_index];
953 constraint_index++;
954 n_index++;
955 }
956}
957
958bool DistanceApproachIPOPTFixedTsInterface::check_g(int n, const double* x, int m, const double* g) {
959 int kN = n;
960 int kM = m;
961 double x_u_tmp[kN];
962 double x_l_tmp[kN];
963 double g_u_tmp[kM];
964 double g_l_tmp[kM];
965
966 get_bounds_info(n, x_l_tmp, x_u_tmp, m, g_l_tmp, g_u_tmp);
967
968 const double delta_v = 1e-4;
969 for (int idx = 0; idx < n; ++idx) {
970 x_u_tmp[idx] = x_u_tmp[idx] + delta_v;
971 x_l_tmp[idx] = x_l_tmp[idx] - delta_v;
972 if (x[idx] > x_u_tmp[idx] || x[idx] < x_l_tmp[idx]) {
973 AINFO << "x idx unfeasible: " << idx << ", x: " << x[idx] << ", lower: " << x_l_tmp[idx]
974 << ", upper: " << x_u_tmp[idx];
975 }
976 }
977
978 // m1 : dynamics constatins
979 int m1 = 4 * horizon_;
980
981 // m2 : control rate constraints (only steering)
982 int m2 = m1 + horizon_;
983
984 // m3 : sampling time equality constraints
985 int m3 = m2;
986
987 // m4 : obstacle constraints
988 int m4 = m3 + 4 * obstacles_num_ * (horizon_ + 1);
989
990 // 5. load variable bounds as constraints
991 // start configuration
992 int m5 = m4 + 3 + 1;
993
994 // constraints on x,y,v
995 int m6 = m5 + 3 * (horizon_ - 1);
996
997 // end configuration
998 int m7 = m6 + 3 + 1;
999
1000 // control variable bnd
1001 int m8 = m7 + 2 * horizon_;
1002
1003 // time interval variable bnd
1004 int m9 = m8;
1005
1006 // lambda_horizon_
1007 int m10 = m9 + lambda_horizon_;
1008
1009 // miu_horizon_
1010 int m11 = m10 + miu_horizon_;
1011
1012 CHECK_EQ(m11, num_of_constraints_);
1013
1014 AINFO << "dynamics constatins to: " << m1;
1015 AINFO << "control rate constraints (only steering) to: " << m2;
1016 AINFO << "sampling time equality constraints to: " << m3;
1017 AINFO << "obstacle constraints to: " << m4;
1018 AINFO << "start conf constraints to: " << m5;
1019 AINFO << "constraints on x,y,v to: " << m6;
1020 AINFO << "end constraints to: " << m7;
1021 AINFO << "control bnd to: " << m8;
1022 AINFO << "time interval constraints to: " << m9;
1023 AINFO << "lambda constraints to: " << m10;
1024 AINFO << "miu constraints to: " << m11;
1025 AINFO << "total constraints: " << num_of_constraints_;
1026
1027 for (int idx = 0; idx < m; ++idx) {
1028 if (g[idx] > g_u_tmp[idx] + delta_v || g[idx] < g_l_tmp[idx] - delta_v) {
1029 AINFO << "constratins idx unfeasible: " << idx << ", g: " << g[idx] << ", lower: " << g_l_tmp[idx]
1030 << ", upper: " << g_u_tmp[idx];
1031 }
1032 }
1033 return true;
1034}
1035
1036void DistanceApproachIPOPTFixedTsInterface::generate_tapes(int n, int m, int* nnz_jac_g, int* nnz_h_lag) {
1037 std::vector<double> xp(n);
1038 std::vector<double> lamp(m);
1039 std::vector<double> zl(m);
1040 std::vector<double> zu(m);
1041 std::vector<adouble> xa(n);
1042 std::vector<adouble> g(m);
1043 std::vector<double> lam(m);
1044
1045 double sig = 0.0;
1046 adouble obj_value;
1047 double dummy = 0.0;
1048 obj_lam = new double[m + 1];
1049 get_starting_point(n, 1, &xp[0], 0, &zl[0], &zu[0], m, 0, &lamp[0]);
1050
1051 trace_on(tag_f);
1052 for (int idx = 0; idx < n; idx++) {
1053 xa[idx] <<= xp[idx];
1054 }
1055 eval_obj(n, &xa[0], &obj_value);
1056 obj_value >>= dummy;
1057 trace_off();
1058
1059 trace_on(tag_g);
1060 for (int idx = 0; idx < n; idx++) {
1061 xa[idx] <<= xp[idx];
1062 }
1063 eval_constraints(n, &xa[0], m, &g[0]);
1064 for (int idx = 0; idx < m; idx++) {
1065 g[idx] >>= dummy;
1066 }
1067 trace_off();
1068
1069 trace_on(tag_L);
1070 for (int idx = 0; idx < n; idx++) {
1071 xa[idx] <<= xp[idx];
1072 }
1073 for (int idx = 0; idx < m; idx++) {
1074 lam[idx] = 1.0;
1075 }
1076 sig = 1.0;
1077 eval_obj(n, &xa[0], &obj_value);
1078 obj_value *= mkparam(sig);
1079 eval_constraints(n, &xa[0], m, &g[0]);
1080 for (int idx = 0; idx < m; idx++) {
1081 obj_value += g[idx] * mkparam(lam[idx]);
1082 }
1083 obj_value >>= dummy;
1084
1085 trace_off();
1086
1087 rind_g = nullptr;
1088 cind_g = nullptr;
1089 rind_L = nullptr;
1090 cind_L = nullptr;
1091 jacval = nullptr;
1092 hessval = nullptr;
1093
1094 options_g[0] = 0; /* sparsity pattern by index domains (default) */
1095 options_g[1] = 0; /* safe mode (default) */
1096 options_g[2] = 0;
1097 options_g[3] = 0; /* column compression (default) */
1098 sparse_jac(tag_g, m, n, 0, &xp[0], &nnz_jac, &rind_g, &cind_g, &jacval, options_g);
1099 *nnz_jac_g = nnz_jac;
1100
1101 options_L[0] = 0;
1102 options_L[1] = 1;
1103 sparse_hess(tag_L, n, 0, &xp[0], &nnz_L, &rind_L, &cind_L, &hessval, options_L);
1104 *nnz_h_lag = nnz_L;
1105}
1106//*************** end ADOL-C part ***********************************
1107
1108} // namespace planning
1109} // namespace apollo
bool eval_jac_g_ser(int n, const double *x, bool new_x, int m, int nele_jac, int *iRow, int *jCol, double *values) override
DistanceApproachIPOPTFixedTsInterface(const size_t horizon, const double ts, const Eigen::MatrixXd &ego, const Eigen::MatrixXd &xWS, const Eigen::MatrixXd &uWS, const Eigen::MatrixXd &l_warm_up, const Eigen::MatrixXd &n_warm_up, const Eigen::MatrixXd &x0, const Eigen::MatrixXd &xf, const Eigen::MatrixXd &last_time_u, const std::vector< double > &XYbounds, const Eigen::MatrixXi &obstacles_edges_num, const size_t obstacles_num, const Eigen::MatrixXd &obstacles_A, const Eigen::MatrixXd &obstacles_b, const PlannerOpenSpaceConfig &planner_open_space_config)
void eval_obj(int n, const T *x, T *obj_value)
Template to return the objective value
bool get_bounds_info(int n, double *x_l, double *x_u, int m, double *g_l, double *g_u) override
Method to return the bounds for my problem
bool eval_f(int n, const double *x, bool new_x, double &obj_value) override
Method to return the objective value
bool check_g(int n, const double *x, int m, const double *g)
Check unfeasible constraints for further study
bool get_starting_point(int n, bool init_x, double *x, bool init_z, double *z_L, double *z_U, int m, bool init_lambda, double *lambda) override
Method to return the starting point for the algorithm
void eval_constraints(int n, const T *x, int m, T *g)
Template to compute constraints
void generate_tapes(int n, int m, int *nnz_jac_g, int *nnz_h_lag)
Method to generate the required tapes by ADOL-C
void get_optimization_results(Eigen::MatrixXd *state_result, Eigen::MatrixXd *control_result, Eigen::MatrixXd *time_result, Eigen::MatrixXd *dual_l_result, Eigen::MatrixXd *dual_n_result) const override
bool get_nlp_info(int &n, int &m, int &nnz_jac_g, int &nnz_h_lag, IndexStyleEnum &index_style) override
Method to return some info about the nlp
bool eval_g(int n, const double *x, bool new_x, int m, double *g) override
Method to return the constraint residuals
bool eval_h(int n, const double *x, bool new_x, double obj_factor, int m, const double *lambda, bool new_lambda, int nele_hess, int *iRow, int *jCol, double *values) override
Method to return: 1) The structure of the hessian of the lagrangian (if "values" is nullptr) 2) The v...
bool eval_grad_f(int n, const double *x, bool new_x, double *grad_f) override
Method to return the gradient of the objective
bool eval_jac_g(int n, const double *x, bool new_x, int m, int nele_jac, int *iRow, int *jCol, double *values) override
Method to return: 1) The structure of the jacobian (if "values" is nullptr) 2) The values of the jaco...
void finalize_solution(Ipopt::SolverReturn status, int n, const double *x, const double *z_L, const double *z_U, int m, const double *g, const double *lambda, double obj_value, const Ipopt::IpoptData *ip_data, Ipopt::IpoptCalculatedQuantities *ip_cq) override
This method is called when the algorithm is complete so the TNLP can store/write the solution
Planning module main class.
#define tag_f
#define tag_g
#define tag_L
#define ACHECK(cond)
Definition log.h:80
#define ADEBUG
Definition log.h:41
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42
class register implement
Definition arena_queue.h:37