// Copyright (C) 1815 - IIT Bombay - FOSSEE // // Author: R.Vidyadhar & Vignesh Kannan // Organization: FOSSEE, IIT Bombay // Email: rvidhyadar@gmail.com & vignesh2496@gmail.com // This file must be used under the terms of the CeCILL. // This source file is licensed as described in the file COPYING, which // you should have received as part of this distribution. The terms // are also available at // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt #include "minconNLP.hpp" #include "sci_iofunc.hpp" extern "C" { #include #include #include #include #include #include #include using namespace std; using namespace Ipopt; minconNLP::~minconNLP() { free(finalX_); free(finalGradient_); free(finalHessian_); free(finalZu_); free(finalZl_); free(finalLambda_); } //get NLP info such as number of variables,constraints,no.of elements in jacobian and hessian to allocate memory bool minconNLP::get_nlp_info(Index& n, Index& m, Index& nnz_jac_g, Index& nnz_h_lag, IndexStyleEnum& index_style) { finalGradient_ = (double*)malloc(sizeof(double) * numVars_ * 1); finalHessian_ = (double*)malloc(sizeof(double) * numVars_ * numVars_); n=numVars_; // Number of variables m=numConstr_; // Number of constraints nnz_jac_g = n*m; // No. of elements in Jacobian of constraints nnz_h_lag = n*n; // No. of elements in lower traingle of Hessian of the Lagrangian. index_style=C_STYLE; // Index style of matrices return true; } //get variable and constraint bound info bool minconNLP::get_bounds_info(Index n, Number* x_l, Number* x_u, Index m, Number* g_l, Number* g_u) { unsigned int i; //assigning bounds for the variables for(i=0;i