/* * Quadratic Programming Toolbox for Scilab using IPOPT library * Authors : Sai Kiran Keyur Joshi Iswarya */ #include "QuadNLP.hpp" #include "IpIpoptData.hpp" extern "C"{ #include #include #include #include #include double x_static,i, *op_obj_x = NULL,*op_obj_value = NULL; using namespace Ipopt; QuadNLP::~QuadNLP() { free(finalX_); free(finalZl_); free(finalZu_);} //get NLP info such as number of variables,constraints,no.of elements in jacobian and hessian to allocate memory bool QuadNLP::get_nlp_info(Index& n, Index& m, Index& nnz_jac_g, Index& nnz_h_lag, IndexStyleEnum& index_style){ 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+1)/2; // 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 QuadNLP::get_bounds_info(Index n, Number* x_l, Number* x_u, Index m, Number* g_l, Number* g_u){ unsigned int i; for(i=0;iiter_count(); } } const double * QuadNLP::getX() { return finalX_; } const double * QuadNLP::getZl() { return finalZl_; } const double * QuadNLP::getZu() { return finalZu_; } const double * QuadNLP::getLambda() { return finalLambda_; } double QuadNLP::getObjVal() { return finalObjVal_; } double QuadNLP::iterCount() { return (double)iter_; } int QuadNLP::returnStatus() { return status_; } }