26 #ifndef CASADI_BONMIN_NLP_HPP
27 #define CASADI_BONMIN_NLP_HPP
29 #include <BonTMINLP.hpp>
30 #include <IpIpoptCalculatedQuantities.hpp>
31 #include <IpIpoptData.hpp>
32 #include <CoinError.hpp>
35 #include <casadi/interfaces/bonmin/casadi_nlpsol_bonmin_export.h>
38 using namespace Ipopt;
39 using namespace Bonmin;
43 class BonminInterface;
46 class BonminUserClass :
public TMINLP {
49 BonminUserClass(
const BonminInterface& bonminInterface, BonminMemory* mem);
50 ~BonminUserClass()
override;
53 bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
54 Index& nnz_h_lag, TNLP::IndexStyleEnum& index_style)
override;
57 bool get_bounds_info(Index n, Number* x_l, Number* x_u,
58 Index m, Number* g_l, Number* g_u)
override;
61 bool get_starting_point(Index n,
bool init_x, Number* x,
62 bool init_z, Number* z_L, Number* z_U,
63 Index m,
bool init_lambda,
64 Number* lambda)
override;
67 bool eval_f(Index n,
const Number* x,
bool new_x, Number& obj_value)
override;
70 bool eval_grad_f(Index n,
const Number* x,
bool new_x, Number* grad_f)
override;
73 bool eval_g(Index n,
const Number* x,
bool new_x, Index m, Number* g)
override;
79 bool eval_jac_g(Index n,
const Number* x,
bool new_x,
80 Index m, Index nele_jac, Index* iRow, Index *jCol,
81 Number* values)
override;
87 bool eval_h(Index n,
const Number* x,
bool new_x,
88 Number obj_factor, Index m,
const Number* lambda,
89 bool new_lambda, Index nele_hess, Index* iRow,
90 Index* jCol, Number* values)
override;
94 void finalize_solution(TMINLP::SolverReturn status,
95 Index n,
const Number* x,
96 Number obj_value)
override;
99 virtual Index get_number_of_nonlinear_variables();
102 virtual bool get_list_of_nonlinear_variables(Index num_nonlin_vars, Index* pos_nonlin_vars);
106 virtual bool intermediate_callback(AlgorithmMode mode, Index iter, Number obj_value,
107 Number inf_pr, Number inf_du,
108 Number mu, Number d_norm,
109 Number regularization_size,
110 Number alpha_du, Number alpha_pr,
112 const IpoptData* ip_data,
113 IpoptCalculatedQuantities* ip_cq);
115 bool get_variables_types(Index n, VariableType* var_types)
override;
116 bool get_variables_linearity(Index n, Ipopt::TNLP::LinearityType* var_types)
override;
117 bool get_constraints_linearity(Index m, Ipopt::TNLP::LinearityType* const_types)
override;
118 const SosInfo * sosConstraints()
const override;
119 const BranchingInfo* branchingInfo()
const override {
return nullptr;}
122 BonminUserClass(
const BonminUserClass&);
123 BonminUserClass& operator=(
const BonminUserClass&);
124 const BonminInterface& solver_;