40 const std::vector<std::pair<double, double>>& ref_points) {
41 ref_points_ = ref_points;
45 bounds_around_refs_ = bounds_around_refs;
49 weight_fem_pos_deviation_ = weight_fem_pos_deviation;
53 weight_path_length_ = weight_path_length;
57 weight_ref_deviation_ = weight_ref_deviation;
61 const double weight_curvature_constraint_slack_var) {
62 weight_curvature_constraint_slack_var_ =
63 weight_curvature_constraint_slack_var;
67 curvature_constraint_ = curvature_constraint;
77 scaled_termination_ = scaled_termination;
83 sqp_pen_max_iter_ = sqp_pen_max_iter;
89 sqp_sub_max_iter_ = sqp_sub_max_iter;
96 const std::vector<std::pair<double, double>>&
opt_xy()
const {
101 void CalculateKernel(std::vector<c_float>* P_data,
102 std::vector<c_int>* P_indices,
103 std::vector<c_int>* P_indptr);
105 void CalculateOffset(std::vector<c_float>* q);
107 std::vector<double> CalculateLinearizedFemPosParams(
108 const std::vector<std::pair<double, double>>& points,
const size_t index);
110 void CalculateAffineConstraint(
111 const std::vector<std::pair<double, double>>& points,
112 std::vector<c_float>* A_data, std::vector<c_int>* A_indices,
113 std::vector<c_int>* A_indptr, std::vector<c_float>* lower_bounds,
114 std::vector<c_float>* upper_bounds);
116 void SetPrimalWarmStart(
const std::vector<std::pair<double, double>>& points,
117 std::vector<c_float>* primal_warm_start);
119 bool OptimizeWithOsqp(
const std::vector<c_float>& primal_warm_start,
120 OSQPWorkspace** work);
122 double CalculateConstraintViolation(
123 const std::vector<std::pair<double, double>>& points);
127 std::vector<std::pair<double, double>> ref_points_;
128 std::vector<double> bounds_around_refs_;
129 double curvature_constraint_ = 0.2;
132 double weight_fem_pos_deviation_ = 1.0e5;
133 double weight_path_length_ = 1.0;
134 double weight_ref_deviation_ = 1.0;
135 double weight_curvature_constraint_slack_var_ = 1.0e5;
138 int max_iter_ = 4000;
139 double time_limit_ = 0.0;
140 bool verbose_ =
false;
141 bool scaled_termination_ =
true;
142 bool warm_start_ =
true;
145 int sqp_pen_max_iter_ = 100;
146 double sqp_ftol_ = 1e-2;
147 int sqp_sub_max_iter_ = 100;
148 double sqp_ctol_ = 1e-2;
151 int num_of_points_ = 0;
152 int num_of_pos_variables_ = 0;
153 int num_of_slack_variables_ = 0;
154 int num_of_variables_ = 0;
155 int num_of_variable_constraints_ = 0;
156 int num_of_curvature_constraints_ = 0;
157 int num_of_constraints_ = 0;
160 std::vector<std::pair<double, double>> opt_xy_;
161 std::vector<double> slack_;
162 double average_interval_length_ = 0.0;
166 void set_point_box(std::vector<std::vector<common::math::Vec2d>> point_box) {
167 point_box_ = point_box;
171 void CalculateOffset(std::vector<std::pair<double, double>> points,
172 std::vector<c_float>* q);
174 std::vector<std::vector<common::math::Vec2d>> point_box_;