/* Copyright (C) 2005, International Business Machines and others. * All Rights Reserved. * This code is published under the Common Public License. * * \$Id\$ * * Authors: Carl Laird, Andreas Waechter IBM 2005-08-17 */ #include "IpStdCInterface.h" #include #include #include /* Function Declarations */ Bool eval_f(Index n, Number* x, Bool new_x, Number* obj_value, UserDataPtr user_data); Bool eval_grad_f(Index n, Number* x, Bool new_x, Number* grad_f, UserDataPtr user_data); Bool eval_g(Index n, Number* x, Bool new_x, Index m, Number* g, UserDataPtr user_data); Bool eval_jac_g(Index n, Number *x, Bool new_x, Index m, Index nele_jac, Index *iRow, Index *jCol, Number *values, UserDataPtr user_data); Bool eval_h(Index n, Number *x, Bool new_x, Number obj_factor, Index m, Number *lambda, Bool new_lambda, Index nele_hess, Index *iRow, Index *jCol, Number *values, UserDataPtr user_data); /* Main Program */ int main() { Index n=-1; /* number of variables */ Index m=-1; /* number of constraints */ Number* x_L = NULL; /* lower bounds on x */ Number* x_U = NULL; /* upper bounds on x */ Number* g_L = NULL; /* lower bounds on g */ Number* g_U = NULL; /* upper bounds on g */ IpoptProblem nlp = NULL; /* IpoptProblem */ enum ApplicationReturnStatus status; /* Solve return code */ Number* x = NULL; /* starting point and solution vector */ Number* mult_x_L = NULL; /* lower bound multipliers at the solution */ Number* mult_x_U = NULL; /* upper bound multipliers at the solution */ Number obj; /* objective value */ Index i; /* generic counter */ /* Number of nonzeros in the Jacobian of the constraints */ Index nele_jac = 8; /* Number of nonzeros in the Hessian of the Lagrangian (lower or upper triangual part only) */ Index nele_hess = 10; /* indexing style for matrices */ Index index_style = 0; /* C-style; start counting of rows and column indices at 0 */ /* set the number of variables and allocate space for the bounds */ n=4; x_L = (Number*)malloc(sizeof(Number)*n); x_U = (Number*)malloc(sizeof(Number)*n); /* set the values for the variable bounds */ for (i=0; i