Apollo 11.0
自动驾驶开放平台
distance_approach_interface.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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 */
20
21#pragma once
22
23#include <omp.h>
24
25#include <adolc/adolc.h>
26#include <adolc/adolc_openmp.h>
27#include <adolc/adolc_sparse.h>
28#include <adolc/adouble.h>
29#include <coin/IpTNLP.hpp>
30#include <coin/IpTypes.hpp>
31
32#include "Eigen/Dense"
33
34#include "modules/common_msgs/config_msgs/vehicle_config.pb.h"
35#include "modules/planning/planning_open_space/proto/planner_open_space_config.pb.h"
36
37#include "cyber/common/log.h"
38#include "cyber/common/macros.h"
43
44#define tag_f 1
45#define tag_g 2
46#define tag_L 3
47#define HPOFF 30
48
49namespace apollo {
50namespace planning {
51
52class DistanceApproachInterface : public Ipopt::TNLP {
53public:
54 virtual ~DistanceApproachInterface() = default;
55
57 virtual bool get_nlp_info(
58 int& n,
59 int& m,
60 int& nnz_jac_g, // NOLINT
61 int& nnz_h_lag, // NOLINT
62 IndexStyleEnum& index_style)
63 = 0; // NOLINT
64
66 virtual bool get_bounds_info(int n, double* x_l, double* x_u, int m, double* g_l, double* g_u) = 0;
67
69 virtual bool get_starting_point(
70 int n,
71 bool init_x,
72 double* x,
73 bool init_z,
74 double* z_L,
75 double* z_U,
76 int m,
77 bool init_lambda,
78 double* lambda)
79 = 0;
80
82 virtual bool eval_f(
83 int n,
84 const double* x,
85 bool new_x, // NOLINT
86 double& obj_value)
87 = 0; // NOLINT
88
90 virtual bool eval_grad_f(int n, const double* x, bool new_x, double* grad_f) = 0;
91
93 virtual bool eval_g(int n, const double* x, bool new_x, int m, double* g) = 0;
94
96 virtual bool check_g(int n, const double* x, int m, const double* g) = 0;
97
102 virtual bool
103 eval_jac_g(int n, const double* x, bool new_x, int m, int nele_jac, int* iRow, int* jCol, double* values)
104 = 0;
105 // sequential implementation to jac_g
106 virtual bool
107 eval_jac_g_ser(int n, const double* x, bool new_x, int m, int nele_jac, int* iRow, int* jCol, double* values)
108 = 0;
109
115 virtual bool eval_h(
116 int n,
117 const double* x,
118 bool new_x,
119 double obj_factor,
120 int m,
121 const double* lambda,
122 bool new_lambda,
123 int nele_hess,
124 int* iRow,
125 int* jCol,
126 double* values)
127 = 0;
128
132 virtual void finalize_solution(
133 Ipopt::SolverReturn status,
134 int n,
135 const double* x,
136 const double* z_L,
137 const double* z_U,
138 int m,
139 const double* g,
140 const double* lambda,
141 double obj_value,
142 const Ipopt::IpoptData* ip_data,
143 Ipopt::IpoptCalculatedQuantities* ip_cq)
144 = 0;
145
147 Eigen::MatrixXd* state_result,
148 Eigen::MatrixXd* control_result,
149 Eigen::MatrixXd* time_result,
150 Eigen::MatrixXd* dual_l_result,
151 Eigen::MatrixXd* dual_n_result) const
152 = 0;
153};
154
155} // namespace planning
156} // namespace apollo
virtual bool eval_grad_f(int n, const double *x, bool new_x, double *grad_f)=0
Method to return the gradient of the objective
virtual bool eval_jac_g(int n, const double *x, bool new_x, int m, int nele_jac, int *iRow, int *jCol, double *values)=0
Method to return: 1) The structure of the jacobian (if "values" is nullptr) 2) The values of the jaco...
virtual 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)=0
Method to return: 1) The structure of the hessian of the lagrangian (if "values" is nullptr) 2) The v...
virtual bool check_g(int n, const double *x, int m, const double *g)=0
Check unfeasible constraints for further study
virtual bool eval_jac_g_ser(int n, const double *x, bool new_x, int m, int nele_jac, int *iRow, int *jCol, double *values)=0
virtual 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)=0
Method to return the starting point for the algorithm
virtual 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 =0
virtual 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)=0
This method is called when the algorithm is complete so the TNLP can store/write the solution
virtual bool get_bounds_info(int n, double *x_l, double *x_u, int m, double *g_l, double *g_u)=0
Method to return the bounds for my problem
virtual bool eval_f(int n, const double *x, bool new_x, double &obj_value)=0
Method to return the objective value
virtual bool eval_g(int n, const double *x, bool new_x, int m, double *g)=0
Method to return the constraint residuals
virtual bool get_nlp_info(int &n, int &m, int &nnz_jac_g, int &nnz_h_lag, IndexStyleEnum &index_style)=0
Method to return some info about the nlp
Planning module main class.
Math-related util functions.
Some util functions.
class register implement
Definition arena_queue.h:37