18 Index& nnz_h_lag, IndexStyleEnum& index_style)
34 index_style = TNLP::C_STYLE;
41 Index m, Number* g_l, Number* g_u)
49 for (Index i=0; i<4; i++) {
54 for (Index i=0; i<4; i++) {
68 g_l[1] = g_u[1] = 40.0;
75 bool init_z, Number* z_L, Number* z_U,
76 Index m,
bool init_lambda,
82 assert(init_x ==
true);
83 assert(init_z ==
false);
84 assert(init_lambda ==
false);
100 obj_value = x[0] * x[3] * (x[0] + x[1] + x[2]) + x[2];
110 grad_f[0] = x[0] * x[3] + x[3] * (x[0] + x[1] + x[2]);
111 grad_f[1] = x[0] * x[3];
112 grad_f[2] = x[0] * x[3] + 1;
113 grad_f[3] = x[0] * (x[0] + x[1] + x[2]);
124 g[0] = x[0] * x[1] * x[2] * x[3];
125 g[1] = x[0]*x[0] + x[1]*x[1] + x[2]*x[2] + x[3]*x[3];
132 Index m, Index nele_jac, Index* iRow, Index *jCol,
135 if (values == NULL) {
159 values[0] = x[1]*x[2]*x[3];
160 values[1] = x[0]*x[2]*x[3];
161 values[2] = x[0]*x[1]*x[3];
162 values[3] = x[0]*x[1]*x[2];
176 Number obj_factor, Index m,
const Number* lambda,
177 bool new_lambda, Index nele_hess, Index* iRow,
178 Index* jCol, Number* values)
180 if (values == NULL) {
186 for (Index row = 0; row < 4; row++) {
187 for (Index col = 0; col <= row; col++) {
194 assert(idx == nele_hess);
201 values[0] = obj_factor * (2*x[3]);
203 values[1] = obj_factor * (x[3]);
206 values[3] = obj_factor * (x[3]);
210 values[6] = obj_factor * (2*x[0] + x[1] + x[2]);
211 values[7] = obj_factor * (x[0]);
212 values[8] = obj_factor * (x[0]);
217 values[1] += lambda[0] * (x[2] * x[3]);
219 values[3] += lambda[0] * (x[1] * x[3]);
220 values[4] += lambda[0] * (x[0] * x[3]);
222 values[6] += lambda[0] * (x[1] * x[2]);
223 values[7] += lambda[0] * (x[0] * x[2]);
224 values[8] += lambda[0] * (x[0] * x[1]);
227 values[0] += lambda[1] * 2;
229 values[2] += lambda[1] * 2;
231 values[5] += lambda[1] * 2;
233 values[9] += lambda[1] * 2;
242 Index n,
const Number* x,
const Number* z_L,
const Number* z_U,
243 Index m,
const Number* g,
const Number* lambda,
245 const IpoptData* ip_data,
246 IpoptCalculatedQuantities* ip_cq)
252 std::cout << std::endl << std::endl <<
"Solution of the primal variables, x" << std::endl;
253 for (Index i=0; i<n; i++) {
254 std::cout <<
"x[" << i <<
"] = " << x[i] << std::endl;
257 std::cout << std::endl << std::endl <<
"Solution of the bound multipliers, z_L and z_U" << std::endl;
258 for (Index i=0; i<n; i++) {
259 std::cout <<
"z_L[" << i <<
"] = " << z_L[i] << std::endl;
261 for (Index i=0; i<n; i++) {
262 std::cout <<
"z_U[" << i <<
"] = " << z_U[i] << std::endl;
265 std::cout << std::endl << std::endl <<
"Objective value" << std::endl;
266 std::cout <<
"f(x*) = " << obj_value << std::endl;
268 std::cout << std::endl <<
"Final value of the constraints:" << std::endl;
269 for (Index i=0; i<m ;i++) {
270 std::cout <<
"g(" << i <<
") = " << g[i] << std::endl;
Ipopt_nlp_problem_debugtest()
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)
virtual ~Ipopt_nlp_problem_debugtest()
virtual bool eval_f(Index n, const Number *x, bool new_x, Number &obj_value)
virtual bool get_bounds_info(Index n, Number *x_l, Number *x_u, Index m, Number *g_l, Number *g_u)
virtual bool get_nlp_info(Index &n, Index &m, Index &nnz_jac_g, Index &nnz_h_lag, IndexStyleEnum &index_style)
virtual void finalize_solution(SolverReturn status, Index n, const Number *x, const Number *z_L, const Number *z_U, Index m, const Number *g, const Number *lambda, Number obj_value, const IpoptData *ip_data, IpoptCalculatedQuantities *ip_cq)
virtual bool eval_jac_g(Index n, const Number *x, bool new_x, Index m, Index nele_jac, Index *iRow, Index *jCol, Number *values)
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)
virtual bool eval_grad_f(Index n, const Number *x, bool new_x, Number *grad_f)
virtual bool eval_g(Index n, const Number *x, bool new_x, Index m, Number *g)