26 var_types[0] = Ipopt::TNLP::LINEAR;
27 var_types[1] = Ipopt::TNLP::NON_LINEAR;
28 var_types[2] = Ipopt::TNLP::NON_LINEAR;
29 var_types[3] = Ipopt::TNLP::LINEAR;
38 const_types[0] = Ipopt::TNLP::NON_LINEAR;
39 const_types[1] = Ipopt::TNLP::LINEAR;
40 const_types[2] = Ipopt::TNLP::LINEAR;
45 Index& nnz_h_lag, TNLP::IndexStyleEnum& index_style)
51 index_style = TNLP::FORTRAN_STYLE;
57 Index m, Number* g_l, Number* g_u)
86 bool init_z, Number* z_L, Number* z_U,
87 Index m,
bool init_lambda,
106 obj_value = - x[0] - x[1] - x[2];
127 g[0] = (x[1] - 1./2.)*(x[1] - 1./2.) + (x[2] - 1./2.)*(x[2] - 1./2.);
129 g[2] = x[0] + x[2] + x[3];
136 Index m, Index nnz_jac, Index* iRow, Index *jCol,
140 assert(nnz_jac == 7);
168 values[2] = 2*x[1] - 1;
171 values[4] = 2*x[2] - 1;
182 Number obj_factor, Index m,
const Number* lambda,
183 bool new_lambda, Index nele_hess, Index* iRow,
184 Index* jCol, Number* values)
188 assert(nele_hess==2);
198 values[0] = 2*lambda[0];
199 values[1] = 2*lambda[0];
206 Index n,
const Number* x, Number obj_value)
208 std::cout<<
"Problem status: "<<status<<std::endl;
209 std::cout<<
"Objective value: "<<obj_value<<std::endl;
211 std::cout<<
"Solution:"<<std::endl;
212 for(
int i = 0 ; i < n ; i++){
213 std::cout<<
"x["<<i<<
"] = "<<x[i];
214 if(i < n-1) std::cout<<
", ";}
215 std::cout<<std::endl;
virtual bool eval_g(Index n, const Number *x, bool new_x, Index m, Number *g)
Method which compute the value of the functions defining the constraints at a point x...
virtual void finalize_solution(TMINLP::SolverReturn status, Index n, const Number *x, Number obj_value)
Method called by Ipopt at the end of optimization.
virtual bool get_bounds_info(Index n, Number *x_l, Number *x_u, Index m, Number *g_l, Number *g_u)
Method to pass the bounds on variables and constraints to Ipopt.
virtual bool eval_grad_f(Index n, const Number *x, bool new_x, Number *grad_f)
Method which compute the gradient of the objective at a point x.
virtual bool get_variables_linearity(Index n, Ipopt::TNLP::LinearityType *var_types)
Pass info about linear and nonlinear variables.
virtual bool get_nlp_info(Index &n, Index &m, Index &nnz_jac_g, Index &nnz_h_lag, TNLP::IndexStyleEnum &index_style)
Method to pass the main dimensions of the problem to Ipopt.
virtual bool eval_jac_g(Index n, const Number *x, bool new_x, Index m, Index nele_jac, Index *iRow, Index *jCol, Number *values)
Method to compute the Jacobian of the functions defining the constraints.
virtual bool get_variables_types(Index n, VariableType *var_types)
Pass the type of the variables (INTEGER, BINARY, CONTINUOUS) to the optimizer.
virtual bool get_starting_point(Index n, bool init_x, Number *x, bool init_z, Number *z_L, Number *z_U, Index m, bool init_lambda, Number *lambda)
Method to to pass the starting point for optimization to Ipopt.
SolverReturn
Return statuses of algorithm.
virtual bool get_constraints_linearity(Index m, Ipopt::TNLP::LinearityType *const_types)
Pass the type of the constraints (LINEAR, NON_LINEAR) to the optimizer.
virtual bool eval_f(Index n, const Number *x, bool new_x, Number &obj_value)
Method which compute the value of the objective function at point x.
virtual bool eval_h(Index n, const Number *x, bool new_x, Number obj_factor, Index m, const Number *lambda, bool new_lambda, Index nele_hess, Index *iRow, Index *jCol, Number *values)
Method to compute the Jacobian of the functions defining the constraints.
VariableType
Type of the variables.