22#include <adolc/adolc.h>
23#include <adolc/adolc_sparse.h>
24#include <adolc/adouble.h>
25#include <coin/IpIpoptApplication.hpp>
26#include <coin/IpIpoptCalculatedQuantities.hpp>
27#include <coin/IpIpoptData.hpp>
28#include <coin/IpOrigIpoptNLP.hpp>
29#include <coin/IpSolveStatistics.hpp>
30#include <coin/IpTNLP.hpp>
31#include <coin/IpTNLPAdapter.hpp>
32#include <coin/IpTypes.hpp>
45 std::vector<double> bounds);
50 weight_fem_pos_deviation_ = weight_fem_pos_deviation;
54 weight_path_length_ = weight_path_length;
58 weight_ref_deviation_ = weight_ref_deviation;
62 const double weight_curvature_constraint_slack_var) {
63 weight_curvature_constraint_slack_var_ =
64 weight_curvature_constraint_slack_var;
68 curvature_constraint_ = curvature_constraint;
72 std::vector<double>* ptr_y)
const;
75 bool get_nlp_info(
int& n,
int& m,
int& nnz_jac_g,
int& nnz_h_lag,
76 IndexStyleEnum& index_style)
override;
79 bool get_bounds_info(
int n,
double* x_l,
double* x_u,
int m,
double* g_l,
80 double* g_u)
override;
84 double* z_L,
double* z_U,
int m,
bool init_lambda,
85 double* lambda)
override;
88 bool eval_f(
int n,
const double* x,
bool new_x,
double& obj_value)
override;
91 bool eval_grad_f(
int n,
const double* x,
bool new_x,
double* grad_f)
override;
94 bool eval_g(
int n,
const double* x,
bool new_x,
int m,
double* g)
override;
100 bool eval_jac_g(
int n,
const double* x,
bool new_x,
int m,
int nele_jac,
101 int* iRow,
int* jCol,
double* values)
override;
108 bool eval_h(
int n,
const double* x,
bool new_x,
double obj_factor,
int m,
109 const double* lambda,
bool new_lambda,
int nele_hess,
int* iRow,
110 int* jCol,
double* values)
override;
116 const double* z_L,
const double* z_U,
int m,
117 const double* g,
const double* lambda,
118 double obj_value,
const Ipopt::IpoptData* ip_data,
119 Ipopt::IpoptCalculatedQuantities* ip_cq)
override;
125 bool eval_obj(
int n,
const T* x, T* obj_value);
132 virtual void generate_tapes(
int n,
int m,
int* nnz_jac_g,
int* nnz_h_lag);
138 std::vector<std::pair<double, double>> ref_points_;
139 std::vector<double> bounds_around_refs_;
142 double weight_fem_pos_deviation_ = 1.0e8;
143 double weight_path_length_ = 1.0;
144 double weight_ref_deviation_ = 1.0;
145 double weight_curvature_constraint_slack_var_ = 1.0e2;
147 double curvature_constraint_ = 0.2;
149 size_t num_of_variables_ = 0;
150 size_t num_of_constraints_ = 0;
151 size_t nnz_jac_g_ = 0;
152 size_t nnz_h_lag_ = 0;
153 size_t num_of_points_ = 0;
154 size_t num_of_slack_var_ = 0;
155 size_t num_of_curvature_constr_ = 0;
156 size_t num_of_slack_constr_ = 0;
158 size_t slack_var_start_index_ = 0;
159 size_t slack_var_end_index_ = 0;
160 size_t curvature_constr_start_index_ = 0;
161 size_t curvature_constr_end_index_ = 0;
162 size_t slack_constr_start_index_ = 0;
163 size_t slack_constr_end_index_ = 0;
165 std::vector<double> opt_x_;
166 std::vector<double> opt_y_;
176 std::vector<double> obj_lam_;
179 unsigned int* rind_g_;
180 unsigned int* cind_g_;
182 unsigned int* rind_L_;
183 unsigned int* cind_L_;
virtual ~FemPosDeviationIpoptInterface()=default
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
bool get_bounds_info(int n, double *x_l, double *x_u, int m, double *g_l, double *g_u) override
Method to return the bounds for my problem
void set_weight_ref_deviation(const double weight_ref_deviation)
bool eval_g(int n, const double *x, bool new_x, int m, double *g) override
Method to return the constraint residuals
void set_weight_path_length(const double weight_path_length)
bool eval_grad_f(int n, const double *x, bool new_x, double *grad_f) override
Method to return the gradient of the objective
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) override
Method to return the starting point for the algorithm
bool eval_obj(int n, const T *x, T *obj_value)
Template to return the objective value
bool get_nlp_info(int &n, int &m, int &nnz_jac_g, int &nnz_h_lag, IndexStyleEnum &index_style) override
Method to return some info about the nlp
void set_weight_curvature_constraint_slack_var(const double weight_curvature_constraint_slack_var)
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) override
This method is called when the algorithm is complete so the TNLP can store/write the solution
bool eval_constraints(int n, const T *x, int m, T *g)
Template to compute contraints
bool eval_jac_g(int n, const double *x, bool new_x, int m, int nele_jac, int *iRow, int *jCol, double *values) override
Method to return: 1) The structure of the jacobian (if "values" is nullptr) 2) The values of the jaco...
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) override
Method to return: 1) The structure of the hessian of the lagrangian (if "values" is nullptr) 2) The v...
void set_curvature_constraint(const double curvature_constraint)
virtual void generate_tapes(int n, int m, int *nnz_jac_g, int *nnz_h_lag)
Method to generate the required tapes
bool eval_f(int n, const double *x, bool new_x, double &obj_value) override
Method to return the objective value
Planning module main class.