<commit_before>#include "ColaConfig.h"
#include "ColaModel.hpp"
#include "Cone.hpp"
#include "LorentzCone.hpp"
#include "ScaledCone.hpp"

#include "Separate.hpp"

#include "CoinMpsIO.hpp"

#include <OsiClpSolverInterface.hpp>
#include <CoinPackedMatrix.hpp>
#include <CoinPackedVector.hpp>

#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <string>
#include <iostream>

#ifndef ipfint
//typedef ipfint FORTRAN_INTEGER_TYPE ;
typedef int ipfint;
typedef const int cipfint;
#endif

// using simple lapack interface
extern "C"
{
  /** LAPACK Fortran subroutine DPOSV. */
  void F77_FUNC(dposv, DPOSV)(char * uplo, ipfint * n, ipfint * nrhs,
                              double * A, ipfint * lda, double * B,
                              ipfint * ldb, ipfint * info);
}

ColaModel::ColaModel() : OsiClpSolverInterface() {
  options_ = new Options();
  total_num_supports_ = 0;
  total_num_cuts_ = 0;
  num_supports_ = 0;
  num_cuts_ = 0;
  num_lp_solved_ = 0;
  imp_solution_ = 0;
  cones_.clear();
  // this is the default beavior, user can change this using options
  setHintParam(OsiDoReducePrint,true,OsiHintTry);
  // for unboundedness directions set option
  OsiClpSolverInterface::getModelPtr()->setMoreSpecialOptions(0);
}

ColaModel::ColaModel(char * data_file) : OsiClpSolverInterface() {
  options_ = new Options();
  total_num_supports_ = 0;
  total_num_cuts_ = 0;
  num_supports_ = 0;
  num_cuts_ = 0;
  num_lp_solved_ = 0;
  imp_solution_ = 0;
  // this is the default beavior, user can change this using options
  setHintParam(OsiDoReducePrint,true,OsiHintTry);
  cones_.clear();
  OsiConicSolverInterface::readMps(data_file);
  OsiClpSolverInterface::getModelPtr()->setMoreSpecialOptions(0);
}

// copy constructor
ColaModel::ColaModel(ColaModel const & other): OsiClpSolverInterface(other) {
  // copy conic constraints
  std::vector<Cone*> other_cones = other.get_conic_constraints();
  std::vector<Cone*>::const_iterator it;
  for (it=other_cones.begin(); it!=other_cones.end(); ++it) {
    cones_.push_back((*it)->clone());
  }
  // copy options
  options_ = other.options()->clone();
  // copy problem status
  soco_status_ = other.problem_status();
  // copy number of lp solved
  num_lp_solved_ = other.num_lp_solved();
  // copy number of cuts generated
  int numCones = other.getNumCones();
  num_cuts_ = new int[numCones]();
  std::copy(other.num_cuts(), other.num_cuts()+numCones, num_cuts_);
  total_num_cuts_ = other.total_num_cuts();
  // copy number of supports
  num_supports_ = new int[numCones]();
  std::copy(other.num_supports(), other.num_supports() + numCones,
	    num_supports_);
  total_num_supports_ = other.total_num_supports();
  imp_solution_ = 0;
}

// copy assignment operator
ColaModel & ColaModel::operator=(ColaModel const & rhs) {
  // copy conic constraints
  std::vector<Cone*> rhs_cones = rhs.get_conic_constraints();
  std::vector<Cone*>::const_iterator it;
  for (it=rhs_cones.begin(); it!=rhs_cones.end(); ++it) {
    cones_.push_back((*it)->clone());
  }
  // copy options
  if (options_)
    delete options_;
  options_ = rhs.options()->clone();
  // copy problem status
  soco_status_ = rhs.problem_status();
  // copy number of lp solved
  num_lp_solved_ = rhs.num_lp_solved();
  int numCones = rhs.getNumCones();
  // copy number of cuts generated
  if (num_cuts_)
    delete num_cuts_;
  num_cuts_ = new int[numCones]();
  std::copy(rhs.num_cuts(), rhs.num_cuts()+numCones, num_cuts_);
  total_num_cuts_ = rhs.total_num_cuts();
  // copy number of supports
  if (num_supports_)
    delete num_supports_;
  num_supports_ = new int[numCones]();
  std::copy(rhs.num_supports(), rhs.num_supports() + numCones,
	    num_supports_);
  total_num_supports_ = rhs.total_num_supports();
  imp_solution_ = 0;
  return *this;
}

// overrite clone function of OsiConicSolverInterface
OsiConicSolverInterface * ColaModel::clone (bool copyData) const {
  ColaModel * new_solver;
  if (copyData) {
    new_solver = new ColaModel(*this);
  }
  else {
    new_solver = new ColaModel();
  }
  return new_solver;
}

ColaModel::~ColaModel() {
  // free conic constraints
  // std::vector<Cone*>::iterator it;
  // for (it=cones_.begin(); it!=cones_.end(); it++) {
  //   delete *it;
  // }
  cones_.clear();
  // free rest
  if(num_cuts_) {
    delete[] num_cuts_;
  }
  if (num_supports_) {
    delete[] num_supports_;
  }
  if (imp_solution_) {
    delete[] imp_solution_;<commit_msg>fix Cola destructor.<commit_after>#include "ColaConfig.h"
#include "ColaModel.hpp"
#include "Cone.hpp"
#include "LorentzCone.hpp"
#include "ScaledCone.hpp"

#include "Separate.hpp"

#include "CoinMpsIO.hpp"

#include <OsiClpSolverInterface.hpp>
#include <CoinPackedMatrix.hpp>
#include <CoinPackedVector.hpp>

#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <string>
#include <iostream>

#ifndef ipfint
//typedef ipfint FORTRAN_INTEGER_TYPE ;
typedef int ipfint;
typedef const int cipfint;
#endif

// using simple lapack interface
extern "C"
{
  /** LAPACK Fortran subroutine DPOSV. */
  void F77_FUNC(dposv, DPOSV)(char * uplo, ipfint * n, ipfint * nrhs,
                              double * A, ipfint * lda, double * B,
                              ipfint * ldb, ipfint * info);
}

ColaModel::ColaModel() : OsiClpSolverInterface() {
  options_ = new Options();
  total_num_supports_ = 0;
  total_num_cuts_ = 0;
  num_supports_ = 0;
  num_cuts_ = 0;
  num_lp_solved_ = 0;
  imp_solution_ = 0;
  cones_.clear();
  // this is the default beavior, user can change this using options
  setHintParam(OsiDoReducePrint,true,OsiHintTry);
  // for unboundedness directions set option
  OsiClpSolverInterface::getModelPtr()->setMoreSpecialOptions(0);
}

ColaModel::ColaModel(char * data_file) : OsiClpSolverInterface() {
  options_ = new Options();
  total_num_supports_ = 0;
  total_num_cuts_ = 0;
  num_supports_ = 0;
  num_cuts_ = 0;
  num_lp_solved_ = 0;
  imp_solution_ = 0;
  // this is the default beavior, user can change this using options
  setHintParam(OsiDoReducePrint,true,OsiHintTry);
  cones_.clear();
  OsiConicSolverInterface::readMps(data_file);
  OsiClpSolverInterface::getModelPtr()->setMoreSpecialOptions(0);
}

// copy constructor
ColaModel::ColaModel(ColaModel const & other): OsiClpSolverInterface(other) {
  // copy conic constraints
  std::vector<Cone*> other_cones = other.get_conic_constraints();
  std::vector<Cone*>::const_iterator it;
  for (it=other_cones.begin(); it!=other_cones.end(); ++it) {
    cones_.push_back((*it)->clone());
  }
  // copy options
  options_ = other.options()->clone();
  // copy problem status
  soco_status_ = other.problem_status();
  // copy number of lp solved
  num_lp_solved_ = other.num_lp_solved();
  // copy number of cuts generated
  int numCones = other.getNumCones();
  num_cuts_ = new int[numCones]();
  std::copy(other.num_cuts(), other.num_cuts()+numCones, num_cuts_);
  total_num_cuts_ = other.total_num_cuts();
  // copy number of supports
  num_supports_ = new int[numCones]();
  std::copy(other.num_supports(), other.num_supports() + numCones,
	    num_supports_);
  total_num_supports_ = other.total_num_supports();
  imp_solution_ = 0;
}

// copy assignment operator
ColaModel & ColaModel::operator=(ColaModel const & rhs) {
  // copy conic constraints
  std::vector<Cone*> rhs_cones = rhs.get_conic_constraints();
  std::vector<Cone*>::const_iterator it;
  for (it=rhs_cones.begin(); it!=rhs_cones.end(); ++it) {
    cones_.push_back((*it)->clone());
  }
  // copy options
  if (options_)
    delete options_;
  options_ = rhs.options()->clone();
  // copy problem status
  soco_status_ = rhs.problem_status();
  // copy number of lp solved
  num_lp_solved_ = rhs.num_lp_solved();
  int numCones = rhs.getNumCones();
  // copy number of cuts generated
  if (num_cuts_)
    delete num_cuts_;
  num_cuts_ = new int[numCones]();
  std::copy(rhs.num_cuts(), rhs.num_cuts()+numCones, num_cuts_);
  total_num_cuts_ = rhs.total_num_cuts();
  // copy number of supports
  if (num_supports_)
    delete num_supports_;
  num_supports_ = new int[numCones]();
  std::copy(rhs.num_supports(), rhs.num_supports() + numCones,
	    num_supports_);
  total_num_supports_ = rhs.total_num_supports();
  imp_solution_ = 0;
  return *this;
}

// overrite clone function of OsiConicSolverInterface
OsiConicSolverInterface * ColaModel::clone (bool copyData) const {
  ColaModel * new_solver;
  if (copyData) {
    new_solver = new ColaModel(*this);
  }
  else {
    new_solver = new ColaModel();
  }
  return new_solver;
}

ColaModel::~ColaModel() {
  // free conic constraints
  for (int i=0; i<cones_.size(); ++i) {
    delete cones_[i];
  }
  cones_.clear();
  // free rest
  if(num_cuts_) {
    delete[] num_cuts_;
  }
  if (num_supports_) {
    delete[] num_supports_;
  }
  if (imp_solution_) {
    delete[] imp_solution_;
{'fraction_non_alphanumeric': 0.1329727293216137, 'fraction_numerical': 0.0041694838855082265, 'mean_word_length': 4.226737338044758, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3780408', 'n_tokens_mistral': 3364, 'n_tokens_neox': 3260, 'n_words': 676}