// Copyright (C) 2005, 2006 International Business Machines and others. // All Rights Reserved. // This code is published under the Eclipse Public License. // // $Id: LuksanVlcek5.cpp 2005 2011-06-06 12:55:16Z stefan $ // // Authors: Andreas Waechter IBM 2005-10-127 #include "LuksanVlcek5.hpp" #ifdef HAVE_CONFIG_H #include "config.h" #else #include "configall_system.h" #endif #ifdef HAVE_CMATH # include #else # ifdef HAVE_MATH_H # include # else # error "don't have header file for math" # endif #endif #ifdef HAVE_CSTDIO # include #else # ifdef HAVE_STDIO_H # include # else # error "don't have header file for stdio" # endif #endif using namespace Ipopt; inline static Index Sgn(Number a) { if (a>0.) { return 1; } else { return -1; } } LuksanVlcek5::LuksanVlcek5(Number g_l, Number g_u) { g_l_ = g_l; g_u_ = g_u; } bool LuksanVlcek5::InitializeProblem(Index N) { N_=N; if (N_<=4) { printf("N needs to be at least 5.\n"); return false; } return true; } // returns the size of the problem bool LuksanVlcek5::get_nlp_info(Index& n, Index& m, Index& nnz_jac_g, Index& nnz_h_lag, IndexStyleEnum& index_style) { // The problem described in LuksanVlcek5.hpp has 4 variables, x[0] through x[3] n = N_+2; m = N_-4; nnz_jac_g = 5 * m; nnz_h_lag = n + n-1 + n-2; // use the C style numbering of matrix indices (starting at 0) index_style = TNLP::C_STYLE; return true; } // returns the variable bounds bool LuksanVlcek5::get_bounds_info(Index n, Number* x_l, Number* x_u, Index m, Number* g_l, Number* g_u) { // none of the variables have bounds for (Index i=1; i