From a0d9443af147e949c1e6a01ac24749d12593ec5b Mon Sep 17 00:00:00 2001 From: Harpreet Date: Sat, 3 Sep 2016 00:36:51 +0530 Subject: cbcintlinprog added --- sci_gateway/cpp/sci_minuncTMINLP.cpp | 236 +++++++++++++++++++++++++++++++++++ 1 file changed, 236 insertions(+) create mode 100644 sci_gateway/cpp/sci_minuncTMINLP.cpp (limited to 'sci_gateway/cpp/sci_minuncTMINLP.cpp') diff --git a/sci_gateway/cpp/sci_minuncTMINLP.cpp b/sci_gateway/cpp/sci_minuncTMINLP.cpp new file mode 100644 index 0000000..a3212aa --- /dev/null +++ b/sci_gateway/cpp/sci_minuncTMINLP.cpp @@ -0,0 +1,236 @@ +// Copyright (C) 2015 - IIT Bombay - FOSSEE +// +// Author: Harpreet Singh, Pranav Deshpande and Akshay Miterani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in +// 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 "minuncTMINLP.hpp" +#include "sci_iofunc.hpp" + +extern "C" +{ +#include "call_scilab.h" +#include +#include +#include +#include +#include +#include +#include +} + +using namespace Ipopt; +using namespace Bonmin; + +minuncTMINLP::~minuncTMINLP() +{ + if(finalX_) delete[] finalX_; +} + +// Set the type of every variable - CONTINUOUS or INTEGER +bool minuncTMINLP::get_variables_types(Index n, VariableType* var_types) +{ + n = numVars_; + for(int i=0; i < n; i++) + var_types[i] = CONTINUOUS; + for(int i=0 ; i < intconSize_ ; ++i) + var_types[(int)(intcon_[i]-1)] = INTEGER; + return true; +} + +// The linearity of the variables - LINEAR or NON_LINEAR +bool minuncTMINLP::get_variables_linearity(Index n, Ipopt::TNLP::LinearityType* var_types) +{ + /* + n = numVars_; + for(int i = 0; i < n; i++) + var_types[i] = Ipopt::TNLP::LINEAR; + */ + return true; +} + +// The linearity of the constraints - LINEAR or NON_LINEAR +bool minuncTMINLP::get_constraints_linearity(Index m, Ipopt::TNLP::LinearityType* const_types) +{ + /* m = numConstr_; + for(int i = 0; i < m; i++) + const_types[i] = Ipopt::TNLP::LINEAR; + */ + return true; +} + +//get NLP info such as number of variables,constraints,no.of elements in jacobian and hessian to allocate memory +bool minuncTMINLP::get_nlp_info(Index& n, Index& m, Index& nnz_jac_g, Index& nnz_h_lag, TNLP::IndexStyleEnum& index_style) +{ + n=numVars_; // Number of variables + m=0; // Number of constraints + nnz_jac_g = 0; // 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=TNLP::C_STYLE; // Index style of matrices + return true; +} + +//get variable and constraint bound info +bool minuncTMINLP::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;i