// Copyright (C) 2005, 2006 International Business Machines and others. // All Rights Reserved. // This code is published under the Eclipse Public License. // // $Id: LuksanVlcek1.cpp 2005 2011-06-06 12:55:16Z stefan $ // // Authors: Andreas Waechter IBM 2005-10-127 #include "LuksanVlcek1.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; LuksanVlcek1::LuksanVlcek1(Number g_l, Number g_u) { g_l_ = g_l; g_u_ = g_u; } bool LuksanVlcek1::InitializeProblem(Index N) { N_=N; if (N_<=2) { printf("N needs to be at least 3.\n"); return false; } return true; } // returns the size of the problem bool LuksanVlcek1::get_nlp_info(Index& n, Index& m, Index& nnz_jac_g, Index& nnz_h_lag, IndexStyleEnum& index_style) { // The problem described in LuksanVlcek1.hpp has 4 variables, x[0] through x[3] n = N_; m = N_-2; nnz_jac_g = m*3; nnz_h_lag = n + n-1; // use the C style numbering of matrix indices (starting at 0) index_style = TNLP::C_STYLE; return true; } // returns the variable bounds bool LuksanVlcek1::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=0; i0) { // x[i+1]x[i+1] values[ihes] += obj_factor*200.; if (i1) { // x[i+2]x[i+2] values[ihes] += lambda[i-2]*(- 2.*sin(x[i-1]-x[i])*sin(x[i-1]+x[i]) - 2.*cos(x[i-1]-x[i])*cos(x[i-1]+x[i])); } ihes++; if (i0) { // x[i+1],x[i+2] values[ihes] += lambda[i-1]*( sin(x[i]-x[i+1])*sin(x[i]+x[i+1]) + cos(x[i]-x[i+1])*cos(x[i]+x[i+1]) - cos(x[i]-x[i+1])*cos(x[i]+x[i+1]) - sin(x[i]-x[i+1])*sin(x[i]+x[i+1]) ); } */ ihes++; } } DBG_ASSERT(ihes == nele_hess); } return true; } void LuksanVlcek1::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) {}