// (C) Copyright Francois Margot and Carnegie Mellon University 2011 // All Rights Reserved. // This code is published under the Eclipse Public License (EPL). // // Authors : // Francois Margot, Tepper School of Business, Carnegie Mellon University, // // Date : 3/31/2011 #include #include #include #include #include "CoinHelperFunctions.hpp" #include "CouenneProblem.hpp" #include "CouenneRecordBestSol.hpp" using namespace Couenne; //#define TRACE /*************************************************************/ /** Default constructor. */ CouenneRecordBestSol::CouenneRecordBestSol() { cardInitDom = -1; initIsInt = NULL; initDomLb = NULL; initDomUb = NULL; hasSol = false; cardSol = -1; sol = NULL; val = -1; maxViol = -1; cardModSol = -1; modSol = NULL; modSolVal = -1; modSolMaxViol = -1; } /*************************************************************/ // copy constructor CouenneRecordBestSol::CouenneRecordBestSol(const CouenneRecordBestSol &other) { cardInitDom = other.cardInitDom; if(cardInitDom > -1) { initIsInt = new bool[other.cardInitDom]; initDomLb = new CouNumber[other.cardInitDom]; initDomUb = new CouNumber[other.cardInitDom]; CoinCopyN(other.initIsInt, cardInitDom, initIsInt); CoinCopyN(other.initDomLb, cardInitDom, initDomLb); CoinCopyN(other.initDomUb, cardInitDom, initDomUb); } else { initIsInt = NULL; initDomLb = NULL; initDomUb = NULL; } for(unsigned int i=0; i -1) { delete[] initIsInt; delete[] initDomLb; delete[] initDomUb; } if(sol != NULL) { delete[] sol; } if(modSol != NULL) { delete[] modSol; } } /*****************************************************************************/ void CouenneRecordBestSol::setInitIsInt(const bool *givenIsInt, const int givenCard) { if(initIsInt == NULL) { if(cardInitDom == -1) { cardInitDom = givenCard; } if(givenCard != cardInitDom) { printf("### ERROR: CouenneRecordBestSol::setInitIsInt(): cardInitDom: %d givenCard: %d\n", cardInitDom, givenCard); exit(1); } initIsInt = new bool[givenCard]; } else { if(givenCard != cardInitDom) { printf("### ERROR: CouenneRecordBestSol::setInitIsInt(): cardInitDom: %d givenCard: %d\n", cardInitDom, givenCard); exit(1); } } CoinCopyN(givenIsInt, givenCard, initIsInt); listInt.empty(); for(int i=0; i