33 {
39 const size_t acceptable_num_of_iterations =
41 const double tol = config_.
tol();
43 const bool use_automatic_differentiation =
45
46 CosThetaIpoptInterface* smoother =
47 new CosThetaIpoptInterface(raw_point2d, bounds);
48
49 smoother->set_weight_cos_included_angle(weight_cos_included_angle);
50 smoother->set_weight_anchor_points(weight_anchor_points);
51 smoother->set_weight_length(weight_length);
52 smoother->set_automatic_differentiation_flag(use_automatic_differentiation);
53
54 Ipopt::SmartPtr<Ipopt::TNLP> problem = smoother;
55
56
57 Ipopt::SmartPtr<Ipopt::IpoptApplication> app = IpoptApplicationFactory();
58
59 app->Options()->SetIntegerValue("print_level", static_cast<int>(print_level));
60 app->Options()->SetIntegerValue("max_iter",
61 static_cast<int>(max_num_of_iterations));
62 app->Options()->SetIntegerValue(
63 "acceptable_iter", static_cast<int>(acceptable_num_of_iterations));
64 app->Options()->SetNumericValue("tol", tol);
65 app->Options()->SetNumericValue("acceptable_tol", acceptable_tol);
66
67 Ipopt::ApplicationReturnStatus status = app->Initialize();
68 if (status != Ipopt::Solve_Succeeded) {
69 AERROR <<
"*** Error during initialization!";
70 return false;
71 }
72
73 status = app->OptimizeTNLP(problem);
74
75 if (status == Ipopt::Solve_Succeeded ||
76 status == Ipopt::Solved_To_Acceptable_Level) {
77
78 Ipopt::Index iter_count = app->Statistics()->IterationCount();
79 ADEBUG <<
"*** The problem solved in " << iter_count <<
" iterations!";
80 } else {
81 AERROR <<
"Solver fails with return code: " <<
static_cast<int>(status);
82 return false;
83 }
84 smoother->get_optimization_results(opt_x, opt_y);
85 return true;
86}
optional int32 acceptable_num_of_iterations
optional bool ipopt_use_automatic_differentiation
optional double acceptable_tol
optional double weight_anchor_points
optional int32 print_level
optional int32 max_num_of_iterations
optional double weight_length
optional double weight_cos_included_angle