46 const Eigen::MatrixXd& ego,
48 const Eigen::MatrixXi& obstacles_edges_num,
49 const Eigen::MatrixXd& obstacles_A,
50 const Eigen::MatrixXd& obstacles_b,
51 const Eigen::MatrixXd& xWS,
52 Eigen::MatrixXd* l_warm_up,
53 Eigen::MatrixXd* n_warm_up,
54 Eigen::MatrixXd* s_warm_up) {
56 bool solver_flag =
false;
68 dual_variable_warm_start_config_);
71 ADEBUG <<
"dual warm up done.";
77 AWARN <<
"dual warm up fail.";
91 dual_variable_warm_start_config_);
94 ADEBUG <<
"dual warm up done.";
100 AWARN <<
"dual warm up fail.";
114 dual_variable_warm_start_config_);
116 Ipopt::SmartPtr<Ipopt::TNLP> problem = ptop;
118 Ipopt::SmartPtr<Ipopt::IpoptApplication> app = IpoptApplicationFactory();
120 app->Options()->SetIntegerValue(
122 app->Options()->SetIntegerValue(
127 app->Options()->SetNumericValue(
128 "acceptable_constr_viol_tol",
130 app->Options()->SetNumericValue(
131 "min_hessian_perturbation",
133 app->Options()->SetNumericValue(
134 "jacobian_regularization_value",
136 app->Options()->SetStringValue(
137 "print_timing_statistics",
139 app->Options()->SetStringValue(
143 app->Options()->SetStringValue(
"mehrotra_algorithm",
"yes");
145 Ipopt::ApplicationReturnStatus status = app->Initialize();
146 if (status != Ipopt::Solve_Succeeded) {
147 AERROR <<
"*** Dual variable wart start problem error during "
152 status = app->OptimizeTNLP(problem);
154 if (status == Ipopt::Solve_Succeeded || status == Ipopt::Solved_To_Acceptable_Level) {
156 Ipopt::Index iter_count = app->Statistics()->IterationCount();
157 ADEBUG <<
"*** The problem solved in " << iter_count <<
" iterations!";
159 Ipopt::Number final_obj = app->Statistics()->FinalObjective();
160 ADEBUG <<
"*** The final value of the objective function is " << final_obj <<
'.';
163 ADEBUG <<
"Solve not succeeding, return status: " << int(status);
168 solver_flag = (status == Ipopt::Solve_Succeeded || status == Ipopt::Solved_To_Acceptable_Level);
169 }
else if (dual_variable_warm_start_config_.
qp_format() ==
IPOPT) {
179 dual_variable_warm_start_config_);
181 Ipopt::SmartPtr<Ipopt::TNLP> problem = ptop;
183 Ipopt::SmartPtr<Ipopt::IpoptApplication> app = IpoptApplicationFactory();
185 app->Options()->SetIntegerValue(
187 app->Options()->SetIntegerValue(
192 app->Options()->SetNumericValue(
193 "acceptable_constr_viol_tol",
195 app->Options()->SetNumericValue(
196 "min_hessian_perturbation",
198 app->Options()->SetNumericValue(
199 "jacobian_regularization_value",
201 app->Options()->SetStringValue(
202 "print_timing_statistics",
204 app->Options()->SetStringValue(
208 Ipopt::ApplicationReturnStatus status = app->Initialize();
209 if (status != Ipopt::Solve_Succeeded) {
210 AERROR <<
"*** Dual variable wart start problem error during "
215 status = app->OptimizeTNLP(problem);
216 if (status == Ipopt::Solve_Succeeded || status == Ipopt::Solved_To_Acceptable_Level) {
218 Ipopt::Index iter_count = app->Statistics()->IterationCount();
219 ADEBUG <<
"*** The problem solved in " << iter_count <<
" iterations!";
221 Ipopt::Number final_obj = app->Statistics()->FinalObjective();
222 ADEBUG <<
"*** The final value of the objective function is " << final_obj <<
'.';
225 ADEBUG <<
"Solve not succeeding, return status: " << int(status);
230 solver_flag = (status == Ipopt::Solve_Succeeded || status == Ipopt::Solved_To_Acceptable_Level);
241 dual_variable_warm_start_config_);
245 AERROR <<
"dual warm up fail.";
249 ADEBUG <<
"dual warm up done.";
255 Eigen::MatrixXd l_warm_up_ipoptqp(l_warm_up->rows(), l_warm_up->cols());
256 Eigen::MatrixXd n_warm_up_ipoptqp(n_warm_up->rows(), n_warm_up->cols());
267 dual_variable_warm_start_config_);
269 Ipopt::SmartPtr<Ipopt::TNLP> problem = ptop_ipoptqp;
271 Ipopt::SmartPtr<Ipopt::IpoptApplication> app = IpoptApplicationFactory();
273 app->Options()->SetIntegerValue(
275 app->Options()->SetIntegerValue(
280 app->Options()->SetNumericValue(
281 "acceptable_constr_viol_tol",
283 app->Options()->SetNumericValue(
284 "min_hessian_perturbation",
286 app->Options()->SetNumericValue(
287 "jacobian_regularization_value",
289 app->Options()->SetStringValue(
290 "print_timing_statistics",
292 app->Options()->SetStringValue(
296 app->Options()->SetStringValue(
"mehrotra_algorithm",
"yes");
298 Ipopt::ApplicationReturnStatus status = app->Initialize();
299 if (status != Ipopt::Solve_Succeeded) {
300 AERROR <<
"*** Dual variable wart start problem error during "
305 status = app->OptimizeTNLP(problem);
307 if (status == Ipopt::Solve_Succeeded || status == Ipopt::Solved_To_Acceptable_Level) {
309 Ipopt::Index iter_count = app->Statistics()->IterationCount();
310 ADEBUG <<
"*** IPOPTQP: The problem solved in " << iter_count <<
" iterations!";
311 Ipopt::Number final_obj = app->Statistics()->FinalObjective();
312 ADEBUG <<
"*** IPOPTQP: The final value of the objective function is " << final_obj <<
'.';
314 ADEBUG <<
"Solve not succeeding, return status: " << int(status);
320 Eigen::MatrixXd l_warm_up_ipopt(l_warm_up->rows(), l_warm_up->cols());
321 Eigen::MatrixXd n_warm_up_ipopt(n_warm_up->rows(), n_warm_up->cols());
332 dual_variable_warm_start_config_);
334 problem = ptop_ipopt;
337 status = app->Initialize();
338 if (status != Ipopt::Solve_Succeeded) {
339 AERROR <<
"*** Dual variable wart start problem error during "
344 status = app->OptimizeTNLP(problem);
345 if (status == Ipopt::Solve_Succeeded || status == Ipopt::Solved_To_Acceptable_Level) {
347 Ipopt::Index iter_count = app->Statistics()->IterationCount();
348 ADEBUG <<
"*** IPOPT: The problem solved in " << iter_count <<
" iterations!";
349 Ipopt::Number final_obj = app->Statistics()->FinalObjective();
350 ADEBUG <<
"*** IPOPT: The final value of the objective function is " << final_obj <<
'.';
352 ADEBUG <<
"Solve not succeeding, return status: " << int(status);
358 double l_max_diff1 = 0.0;
359 double l_max_diff2 = 0.0;
360 double l_max_diff3 = 0.0;
361 for (
int c = 0; c < l_warm_up->cols(); ++c) {
362 for (
int r = 0; r < l_warm_up->rows(); ++r) {
363 l_max_diff1 = std::max(l_max_diff1, std::abs(l_warm_up->coeff(r, c) - l_warm_up_ipopt(r, c)));
364 l_max_diff2 = std::max(l_max_diff2, std::abs(l_warm_up->coeff(r, c) - l_warm_up_ipoptqp(r, c)));
365 l_max_diff3 = std::max(l_max_diff3, std::abs(l_warm_up_ipoptqp(r, c) - l_warm_up_ipopt(r, c)));
368 ADEBUG <<
"max l warm up diff between osqp & ipopt: " << l_max_diff1;
369 ADEBUG <<
"max l warm up diff between osqp & ipoptqp: " << l_max_diff2;
370 ADEBUG <<
"max l warm up diff between ipopt & ipoptqp: " << l_max_diff3;
372 double n_max_diff1 = 0.0;
373 double n_max_diff2 = 0.0;
374 double n_max_diff3 = 0.0;
375 for (
int c = 0; c < n_warm_up->cols(); ++c) {
376 for (
int r = 0; r < n_warm_up->rows(); ++r) {
377 n_max_diff1 = std::max(n_max_diff1, std::abs(n_warm_up->coeff(r, c) - n_warm_up_ipopt(r, c)));
378 n_max_diff2 = std::max(n_max_diff2, std::abs(n_warm_up->coeff(r, c) - n_warm_up_ipoptqp(r, c)));
379 n_max_diff3 = std::max(n_max_diff3, std::abs(n_warm_up_ipoptqp(r, c) - n_warm_up_ipopt(r, c)));
382 ADEBUG <<
"max n warm up diff between osqp & ipopt: " << n_max_diff1;
383 ADEBUG <<
"max n warm up diff between osqp & ipoptqp: " << n_max_diff2;
384 ADEBUG <<
"max n warm up diff between ipopt & ipoptqp: " << n_max_diff3;
389 if (solver_flag ==
false) {
391 for (
int r = 0; r < l_warm_up->rows(); ++r) {
392 for (
int c = 0; c < l_warm_up->cols(); ++c) {
393 (*l_warm_up)(r, c) = 0.0;
397 for (
int r = 0; r < n_warm_up->rows(); ++r) {
398 for (
int c = 0; c < n_warm_up->cols(); ++c) {
399 (*n_warm_up)(r, c) = 0.0;