Changeset 1681 for stable


Ignore:
Timestamp:
Jun 29, 2011 3:43:11 AM (8 years ago)
Author:
forrest
Message:

change from ifdef COIN_HAS_BONMIB to runtime test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • stable/2.7/Cbc/src/CbcModel.cpp

    r1675 r1681  
    23962396    if (numberObjects_)
    23972397        doHeuristicsAtRoot();
    2398 #ifdef COIN_HAS_BONMIN // With some heuristics solver needs a resolve here (don't know if this is bug in heuristics)
    2399     solver_->resolve();
    2400     if(!isProvenOptimal()){
    2401       solver_->initialSolve();
    2402     }
    2403 #endif
     2398    if (solverCharacteristics_->solutionAddsCuts()) {
     2399      // With some heuristics solver needs a resolve here (don't know if this is bug in heuristics)
     2400      solver_->resolve();
     2401      if(!isProvenOptimal()){
     2402        solver_->initialSolve();
     2403      }
     2404    }
    24042405    /*
    24052406      Grepping through the code, it would appear that this is a command line
     
    24132414    stoppedOnGap_ = false ;
    24142415    // See if can stop on gap
    2415 #ifdef COIN_HAS_BONMIN // With some heuristics solver needs a resolve here (don't know if this is bug in heuristics)
    2416     solver_->resolve();
    2417     if(!isProvenOptimal()){
    2418       solver_->initialSolve();
    2419     }
    2420 #endif
     2416    if (solverCharacteristics_->solutionAddsCuts()) {
     2417      // With some heuristics solver needs a resolve here (don't know if this is bug in heuristics)
     2418      solver_->resolve();
     2419      if(!isProvenOptimal()){
     2420        solver_->initialSolve();
     2421      }
     2422    }
    24212423    bestPossibleObjective_ = solver_->getObjValue() * solver_->getObjSense();
    24222424    double testGap = CoinMax(dblParam_[CbcAllowableGap],
     
    71057107            << CoinMessageEol ;
    71067108        }
    7107 #ifdef COIN_HAS_BONMIN  //Is Necessary for Bonmin? Always keepGoing if cuts have been generated in last iteration (taken from similar code in Cbc-2.4)
    7108         if (solverCharacteristics_->solutionAddsCuts()&&numberViolated) {
    7109           for (i = 0;i<numberCutGenerators_;i++) {
    7110             if (generator_[i]->mustCallAgain()) {
    7111               keepGoing=true; // say must go round
    7112               break;
    7113             }
    7114           }
    7115         }
     7109        //Is Necessary for Bonmin? Always keepGoing if cuts have been generated in last iteration (taken from similar code in Cbc-2.4)
     7110        if (solverCharacteristics_->solutionAddsCuts()&&numberViolated) {
     7111          for (i = 0;i<numberCutGenerators_;i++) {
     7112            if (generator_[i]->mustCallAgain()) {
     7113              keepGoing=true; // say must go round
     7114              break;
     7115            }
     7116          }
     7117        }
    71167118        if(!keepGoing){
    7117 #endif
    7118         // Status for single pass of cut generation
    7119         int status = 0;
    7120         /*
    7121           threadMode with bit 2^1 set indicates we should use threads for root cut
    7122           generation.
    7123         */
    7124         if ((threadMode_&2) == 0 || numberNodes_) {
     7119          // Status for single pass of cut generation
     7120          int status = 0;
     7121          /*
     7122            threadMode with bit 2^1 set indicates we should use threads for root cut
     7123            generation.
     7124          */
     7125          if ((threadMode_&2) == 0 || numberNodes_) {
    71257126            status = serialCuts(theseCuts, node, slackCuts, lastNumberCuts);
    7126         } else {
     7127          } else {
    71277128            // do cuts independently
    71287129#ifdef CBC_THREAD
    71297130            status = parallelCuts(master, theseCuts, node, slackCuts, lastNumberCuts);
    71307131#endif
    7131         }
    7132         // Do we need feasible and violated?
    7133         feasible = (status >= 0);
    7134         if (status == 1)
     7132          }
     7133          // Do we need feasible and violated?
     7134          feasible = (status >= 0);
     7135          if (status == 1)
    71357136            keepGoing = true;
    7136         else if (status == 2)
     7137          else if (status == 2)
    71377138            numberTries = 0;
    7138         if (!feasible)
     7139          if (!feasible)
    71397140            violated = -2;
    7140 #ifdef COIN_HAS_BONMIN  //Is Necessary for Bonmin? Always keepGoing if cuts have been generated in last iteration (taken from similar code in Cbc-2.4)
    7141         }
    7142 #endif
     7141        }
    71437142        //if (!feasible)
    71447143        //break;
     
    1259512594#endif
    1259612595    currentNode_ = newNode; // so can be used elsewhere
    12597 #ifdef COIN_HAS_BONMIN // Remember number of rows to restore at the end of the loop
    12598     int saveNumberRows=solver_->getNumRows();
    12599 #endif
    1260012596    /*
    1260112597      Enough preparation. Get down to the business of choosing a branching
    1260212598      variable.
    1260312599    */
    12604 #ifdef COIN_HAS_BONMIN // Remember number of rows to restore at the end of the loop
    1260512600    int saveNumberRows=solver_->getNumRows();
    12606 #endif
    1260712601    while (anyAction == -1) {
    1260812602        // Set objective value (not so obvious if NLP etc)
     
    1269412688            resolve(solver_);
    1269512689            double objval = solver_->getObjValue();
    12696 #ifndef COIN_HAS_BONMIN
    12697             int saveNumberRows = solver_->getNumRows();
    12698 #endif
    1269912690            lastHeuristic_ = NULL;
    1270012691            setBestSolution(CBC_SOLUTION, objval,
     
    1271412705                feasible = false; // pretend infeasible
    1271512706            }
    12716 #ifndef COIN_HAS_BONMIN
    12717             if( saveNumberRows<solver_->getNumRows()) {
    12718                 // delete rows - but leave solution
    12719                 int n = solver_->getNumRows();
    12720                 int * del = new int [n-saveNumberRows];
    12721                 for (int i=saveNumberRows;i<n;i++)
    12722                     del[i-saveNumberRows]=i;
    12723                 solver_->deleteRows(n-saveNumberRows,del);
    12724                 delete [] del;
    12725             }
    12726 #endif
    1272712707            if (feasible)
    1272812708                anyAction = -1;
     
    1276512745        }
    1276612746    }
    12767 #ifdef COIN_HAS_BONMIN //A candidate has been found; restore the subproblem.
    1276812747    if( saveNumberRows<solver_->getNumRows()) {
    1276912748        // delete rows - but leave solution
     
    1277512754        delete [] del;
    1277612755    }
    12777 #endif
    1277812756    /*
    1277912757      End main loop to choose a branching variable.
Note: See TracChangeset for help on using the changeset viewer.