Ignore:
Timestamp:
Jul 15, 2008 11:57:59 AM (12 years ago)
Author:
forrest
Message:

for threads and hotstart

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/src/CbcModel.cpp

    r983 r1003  
    20332033      threadId[i].status=0;
    20342034      threadInfo[i].baseModel=this;
    2035       threadModel[i]=new CbcModel(*this);
     2035      threadModel[i]=new CbcModel(*this,true);
    20362036#ifdef COIN_HAS_CLP
    20372037      // Solver may need to know about model
     
    33963396    // delete models (here in case some point to others)
    33973397    for (i=0;i<numberThreads_;i++) {
     3398      // make sure handler will be deleted
     3399      threadModel[i]->defaultHandler_=true;
    33983400      delete threadModel[i];
    33993401    }
     
    43064308// Copy constructor.
    43074309
    4308 CbcModel::CbcModel(const CbcModel & rhs, bool noTree)
     4310CbcModel::CbcModel(const CbcModel & rhs, bool cloneHandler)
    43094311:
    43104312  continuousSolver_(NULL),
     
    43904392  solverCharacteristics_ = NULL;
    43914393  if (rhs.emptyWarmStart_) emptyWarmStart_ = rhs.emptyWarmStart_->clone() ;
    4392   if (defaultHandler_) {
     4394  if (defaultHandler_||cloneHandler) {
    43934395    handler_ = new CoinMessageHandler();
    43944396    handler_->setLogLevel(2);
     
    44104412    virginGenerator_=NULL;
    44114413  }
    4412   if (!noTree)
    4413     globalCuts_ = rhs.globalCuts_;
     4414  globalCuts_ = rhs.globalCuts_;
    44144415  numberHeuristics_ = rhs.numberHeuristics_;
    44154416  if (numberHeuristics_) {
     
    44524453  else
    44534454    referenceSolver_=NULL;
    4454   if (!noTree||!rhs.continuousSolver_)
    4455     solver_ = rhs.solver_->clone();
    4456   else
    4457     solver_ = rhs.continuousSolver_->clone();
     4455  solver_ = rhs.solver_->clone();
    44584456  if (rhs.originalColumns_) {
    44594457    int numberColumns = solver_->getNumCols();
     
    45184516    hotstartPriorities_ =NULL;
    45194517  }
    4520   if (rhs.bestSolution_&&!noTree) {
     4518  if (rhs.bestSolution_) {
    45214519    int numberColumns = solver_->getNumCols();
    45224520    bestSolution_ = new double[numberColumns];
     
    45254523    bestSolution_=NULL;
    45264524  }
    4527   if (!noTree) {
    4528     int numberColumns = solver_->getNumCols();
    4529     // Space for current solution
    4530     currentSolution_ = new double[numberColumns];
    4531     continuousSolution_ = new double[numberColumns];
    4532     usedInSolution_ = new int[numberColumns];
    4533     CoinZeroN(usedInSolution_,numberColumns);
    4534   } else {
    4535     currentSolution_=NULL;
    4536     continuousSolution_=NULL;
    4537     usedInSolution_=NULL;
    4538   }
     4525  int numberColumns = solver_->getNumCols();
     4526  // Space for current solution
     4527  currentSolution_ = new double[numberColumns];
     4528  continuousSolution_ = new double[numberColumns];
     4529  usedInSolution_ = new int[numberColumns];
     4530  CoinZeroN(usedInSolution_,numberColumns);
    45394531  testSolution_=currentSolution_;
    45404532  numberRowsAtContinuous_ = rhs.numberRowsAtContinuous_;
     
    45434535  currentNumberCuts_=rhs.currentNumberCuts_;
    45444536  maximumDepth_= rhs.maximumDepth_;
    4545   if (noTree) {
    4546     bestObjective_ = COIN_DBL_MAX;
    4547     numberSolutions_ =0;
    4548     stateOfSearch_= 0;
    4549     numberHeuristicSolutions_=0;
    4550     numberNodes_=0;
    4551     numberNodes2_=0;
    4552     numberIterations_=0;
    4553     status_=0;
    4554     subTreeModel_=NULL;
    4555     numberStoppedSubTrees_=0;
    4556     continuousObjective_=COIN_DBL_MAX;
    4557     originalContinuousObjective_=COIN_DBL_MAX;
    4558     continuousInfeasibilities_=COIN_INT_MAX;
    4559     maximumNumberCuts_=0;
    4560     tree_->cleanTree(this,-COIN_DBL_MAX,bestPossibleObjective_);
    4561     bestPossibleObjective_ = COIN_DBL_MAX;
    4562   }
    45634537  // These are only used as temporary arrays so need not be filled
    45644538  if (maximumNumberCuts_) {
     
    45754549    walkback_ = NULL;
    45764550  synchronizeModel();
     4551  if (cloneHandler) {
     4552    delete handler_;
     4553    CoinMessageHandler * handler = rhs.handler_->clone();
     4554    passInMessageHandler(handler);
     4555  }
    45774556}
    45784557 
     
    1070110680  defaultHandler_=false;
    1070210681  handler_=handler;
     10682  if (solver_)
     10683    solver_->passInMessageHandler(handler);
     10684  if (continuousSolver_)
     10685    continuousSolver_->passInMessageHandler(handler);
     10686  if (referenceSolver_)
     10687    referenceSolver_->passInMessageHandler(handler);
    1070310688}
    1070410689void
     
    1194811933                          double objectiveValue, bool checkSolution)
    1194911934{
    11950   // May be odd discontinuities - so only chaeck if asked
     11935  // May be odd discontinuities - so only check if asked
    1195111936  if (checkSolution) {
    1195211937    assert (numberColumns==solver_->getNumCols());
Note: See TracChangeset for help on using the changeset viewer.