diff options
Diffstat (limited to 'sci_gateway/cpp/sci_minbndNLP.cpp')
-rw-r--r-- | sci_gateway/cpp/sci_minbndNLP.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/sci_gateway/cpp/sci_minbndNLP.cpp b/sci_gateway/cpp/sci_minbndNLP.cpp index 481a796..0fa7ef2 100644 --- a/sci_gateway/cpp/sci_minbndNLP.cpp +++ b/sci_gateway/cpp/sci_minbndNLP.cpp @@ -1,14 +1,13 @@ // Copyright (C) 2015 - 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 - +// Author: R.Vidyadhar & Vignesh Kannan +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in #include "minbndNLP.hpp" #include "sci_iofunc.hpp" @@ -28,9 +27,9 @@ using namespace Ipopt; minbndNLP::~minbndNLP() { - free(finalX_); - free(finalZu_); - free(finalZl_); + if(finalX_) delete[] finalX_; + if(finalZl_) delete[] finalZl_; + if(finalZu_) delete[] finalZu_; } //get NLP info such as number of variables,constraints,no.of elements in jacobian and hessian to allocate memory @@ -290,19 +289,19 @@ bool minbndNLP::eval_h(Index n, const Number* x, bool new_x,Number obj_factor, I void minbndNLP::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) { - finalX_ = (double*)malloc(sizeof(double) * numVars_ * 1); - for (Index i=0; i<numVars_; i++) + finalX_ = new double[n]; + for (Index i=0; i<n; i++) { finalX_[i] = x[i]; } - - finalZl_ = (double*)malloc(sizeof(double) * numVars_ * 1); + + finalZl_ = new double[n]; for (Index i=0; i<n; i++) { finalZl_[i] = z_L[i]; } - finalZu_ = (double*)malloc(sizeof(double) * numVars_ * 1); + finalZu_ = new double[n]; for (Index i=0; i<n; i++) { finalZu_[i] = z_U[i]; |