23#include <coin/IpIpoptApplication.hpp>
24#include <coin/IpSolveStatistics.hpp>
38 const std::vector<std::pair<double, double>>& raw_point2d,
39 const std::vector<double>& bounds, std::vector<double>* opt_x,
40 std::vector<double>* opt_y,
41 std::vector<std::vector<common::math::Vec2d>> point_box) {
44 return SqpWithOsqp(raw_point2d, bounds, opt_x, opt_y, point_box);
49 return QpWithOsqp(raw_point2d, bounds, opt_x, opt_y);
55 const std::vector<std::pair<double, double>>& raw_point2d,
56 const std::vector<double>& bounds, std::vector<double>* opt_x,
57 std::vector<double>* opt_y) {
58 if (opt_x ==
nullptr || opt_y ==
nullptr) {
59 AERROR <<
"opt_x or opt_y is nullptr";
78 if (!solver.
Solve()) {
82 *opt_x = solver.
opt_x();
83 *opt_y = solver.
opt_y();
88 const std::vector<std::pair<double, double>>& raw_point2d,
89 const std::vector<double>& bounds, std::vector<double>* opt_x,
90 std::vector<double>* opt_y,
91 std::vector<std::vector<common::math::Vec2d>> point_box) {
92 if (opt_x ==
nullptr || opt_y ==
nullptr) {
93 AERROR <<
"opt_x or opt_y is nullptr";
122 if (!solver.
Solve()) {
126 std::vector<std::pair<double, double>> opt_xy = solver.
opt_xy();
129 opt_x->resize(opt_xy.size());
130 opt_y->resize(opt_xy.size());
131 for (
size_t i = 0; i < opt_xy.size(); ++i) {
132 (*opt_x)[i] = opt_xy[i].first;
133 (*opt_y)[i] = opt_xy[i].second;
139 const std::vector<std::pair<double, double>>& raw_point2d,
140 const std::vector<double>& bounds, std::vector<double>* opt_x,
141 std::vector<double>* opt_y) {
142 if (opt_x ==
nullptr || opt_y ==
nullptr) {
143 AERROR <<
"opt_x or opt_y is nullptr";
157 Ipopt::SmartPtr<Ipopt::TNLP> problem = smoother;
160 Ipopt::SmartPtr<Ipopt::IpoptApplication> app = IpoptApplicationFactory();
162 app->Options()->SetIntegerValue(
"print_level",
164 app->Options()->SetIntegerValue(
166 app->Options()->SetIntegerValue(
169 app->Options()->SetNumericValue(
"tol", config_.
tol());
170 app->Options()->SetNumericValue(
"acceptable_tol", config_.
acceptable_tol());
172 Ipopt::ApplicationReturnStatus status = app->Initialize();
173 if (status != Ipopt::Solve_Succeeded) {
174 AERROR <<
"*** Error during initialization!";
178 status = app->OptimizeTNLP(problem);
180 if (status == Ipopt::Solve_Succeeded ||
181 status == Ipopt::Solved_To_Acceptable_Level) {
183 Ipopt::Index iter_count = app->Statistics()->IterationCount();
184 ADEBUG <<
"*** The problem solved in " << iter_count <<
" iterations!";
186 AERROR <<
"Solver fails with return code: " <<
static_cast<int>(status);
void set_weight_fem_pos_deviation(const double weight_fem_pos_deviation)
void get_optimization_results(std::vector< double > *ptr_x, std::vector< double > *ptr_y) const
void set_weight_ref_deviation(const double weight_ref_deviation)
void set_weight_path_length(const double weight_path_length)
void set_weight_curvature_constraint_slack_var(const double weight_curvature_constraint_slack_var)
void set_curvature_constraint(const double curvature_constraint)
const std::vector< double > & opt_y() const
void set_weight_path_length(const double weight_path_length)
void set_max_iter(const int max_iter)
void set_scaled_termination(const bool scaled_termination)
void set_time_limit(const double time_limit)
void set_verbose(const bool verbose)
void set_ref_points(const std::vector< std::pair< double, double > > &ref_points)
void set_weight_fem_pos_deviation(const double weight_fem_pos_deviation)
void set_bounds_around_refs(const std::vector< double > &bounds_around_refs)
void set_warm_start(const bool warm_start)
void set_weight_ref_deviation(const double weight_ref_deviation)
const std::vector< double > & opt_x() const
bool QpWithOsqp(const std::vector< std::pair< double, double > > &raw_point2d, const std::vector< double > &bounds, std::vector< double > *opt_x, std::vector< double > *opt_y)
bool NlpWithIpopt(const std::vector< std::pair< double, double > > &raw_point2d, const std::vector< double > &bounds, std::vector< double > *opt_x, std::vector< double > *opt_y)
FemPosDeviationSmoother(const FemPosDeviationSmootherConfig &config)
bool SqpWithOsqp(const std::vector< std::pair< double, double > > &raw_point2d, const std::vector< double > &bounds, std::vector< double > *opt_x, std::vector< double > *opt_y)
bool Solve(const std::vector< std::pair< double, double > > &raw_point2d, const std::vector< double > &bounds, std::vector< double > *opt_x, std::vector< double > *opt_y, std::vector< std::vector< common::math::Vec2d > > point_box={})
void set_sqp_ctol(const double sqp_ctol)
void set_weight_curvature_constraint_slack_var(const double weight_curvature_constraint_slack_var)
void set_weight_fem_pos_deviation(const double weight_fem_pos_deviation)
void set_sqp_ftol(const double sqp_ftol)
void set_warm_start(const bool warm_start)
const std::vector< std::pair< double, double > > & opt_xy() const
void set_sqp_pen_max_iter(const int sqp_pen_max_iter)
void set_weight_path_length(const double weight_path_length)
void set_scaled_termination(const bool scaled_termination)
void set_verbose(const bool verbose)
void set_ref_points(const std::vector< std::pair< double, double > > &ref_points)
void set_time_limit(const double time_limit)
void set_max_iter(const int max_iter)
void set_sqp_sub_max_iter(const int sqp_sub_max_iter)
void set_point_box(std::vector< std::vector< common::math::Vec2d > > point_box)
void set_bounds_around_refs(const std::vector< double > &bounds_around_refs)
void set_curvature_constraint(const double curvature_constraint)
void set_weight_ref_deviation(const double weight_ref_deviation)
Planning module main class.
optional int32 sqp_sub_max_iter
optional bool scaled_termination
optional int32 print_level
optional double weight_curvature_constraint_slack_var
optional double weight_fem_pos_deviation
optional double weight_path_length
optional double acceptable_tol
optional int32 sqp_pen_max_iter
optional double time_limit
optional int32 acceptable_num_of_iterations
optional int32 max_num_of_iterations
optional double curvature_constraint
optional bool apply_curvature_constraint
optional double weight_ref_deviation