Ignore:
Timestamp:
May 12, 2005 9:33:59 AM (16 years ago)
Author:
forrest
Message:

make createBranch non const

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CbcBranchActual.cpp

    r122 r129  
    214214// Creates a branching object
    215215CbcBranchingObject *
    216 CbcClique::createBranch(int way) const
     216CbcClique::createBranch(int way)
    217217{
    218218  int numberUnsatis=0;
     
    492492// Creates a branching object
    493493CbcBranchingObject *
    494 CbcSOS::createBranch(int way) const
     494CbcSOS::createBranch(int way)
    495495{
    496496  int j;
     
    686686// Creates a branching object
    687687CbcBranchingObject *
    688 CbcSimpleInteger::createBranch(int way) const
     688CbcSimpleInteger::createBranch(int way)
    689689{
    690690  OsiSolverInterface * solver = model_->solver();
     
    918918    olb = model_->solver()->getColLower()[iColumn] ;
    919919    oub = model_->solver()->getColUpper()[iColumn] ;
    920     printf("CbcInteger would branch down on var %d: [%g,%g] => [%g,%g]\n",
    921            iColumn,olb,oub,down_[0],down_[1]) ; }
     920    printf("CbcInteger would branch down on var %d (int var %d): [%g,%g] => [%g,%g]\n",
     921           iColumn,variable_,olb,oub,down_[0],down_[1]) ; }
    922922  } else {
    923923  { double olb,oub ;
    924924    olb = model_->solver()->getColLower()[iColumn] ;
    925925    oub = model_->solver()->getColUpper()[iColumn] ;
    926     printf("CbcInteger would branch up on var %d: [%g,%g] => [%g,%g]\n",
    927            iColumn,olb,oub,up_[0],up_[1]) ; }
     926    printf("CbcInteger would branch up on var %d (int var %d): [%g,%g] => [%g,%g]\n",
     927           iColumn,variable_,olb,oub,up_[0],up_[1]) ; }
    928928  }
    929929}
     
    10101010// Creates a branching object
    10111011CbcBranchingObject *
    1012 CbcSimpleIntegerPseudoCost::createBranch(int way) const
     1012CbcSimpleIntegerPseudoCost::createBranch(int way)
    10131013{
    10141014  OsiSolverInterface * solver = model_->solver();
     
    17321732  :CbcBranchDecision()
    17331733{
     1734  bestCriterion_ = 0.0;
     1735  bestChangeUp_ = 0.0;
     1736  bestNumberUp_ = 0;
     1737  bestChangeDown_ = 0.0;
     1738  bestNumberDown_ = 0;
     1739  bestObject_ = NULL;
    17341740}
    17351741
     
    17391745  :CbcBranchDecision()
    17401746{
     1747  bestCriterion_ = rhs.bestCriterion_;
     1748  bestChangeUp_ = rhs.bestChangeUp_;
     1749  bestNumberUp_ = rhs.bestNumberUp_;
     1750  bestChangeDown_ = rhs.bestChangeDown_;
     1751  bestNumberDown_ = rhs.bestNumberDown_;
     1752  bestObject_ = rhs.bestObject_;
    17411753}
    17421754
     
    17561768CbcBranchDefaultDecision::initialize(CbcModel * model)
    17571769{
     1770  bestCriterion_ = 0.0;
     1771  bestChangeUp_ = 0.0;
     1772  bestNumberUp_ = 0;
     1773  bestChangeDown_ = 0.0;
     1774  bestNumberDown_ = 0;
     1775  bestObject_ = NULL;
    17581776}
    17591777
     
    17721790                            double changeDn, int numInfDn)
    17731791{
    1774   printf("Now obsolete CbcBranchDefaultDecision::betterBranch\n");
    1775   abort();
    1776   return 0;
     1792  bool beforeSolution = thisOne->model()->getSolutionCount()==
     1793    thisOne->model()->getNumberHeuristicSolutions();;
     1794  int betterWay=0;
     1795  if (beforeSolution) {
     1796    if (!bestObject_) {
     1797      bestNumberUp_=INT_MAX;
     1798      bestNumberDown_=INT_MAX;
     1799    }
     1800    // before solution - choose smallest number
     1801    // could add in depth as well
     1802    int bestNumber = CoinMin(bestNumberUp_,bestNumberDown_);
     1803    if (numInfUp<numInfDn) {
     1804      if (numInfUp<bestNumber) {
     1805        betterWay = 1;
     1806      } else if (numInfUp==bestNumber) {
     1807        if (changeUp<bestCriterion_)
     1808          betterWay=1;
     1809      }
     1810    } else if (numInfUp>numInfDn) {
     1811      if (numInfDn<bestNumber) {
     1812        betterWay = -1;
     1813      } else if (numInfDn==bestNumber) {
     1814        if (changeDn<bestCriterion_)
     1815          betterWay=-1;
     1816      }
     1817    } else {
     1818      // up and down have same number
     1819      bool better=false;
     1820      if (numInfUp<bestNumber) {
     1821        better=true;
     1822      } else if (numInfUp==bestNumber) {
     1823        if (min(changeUp,changeDn)<bestCriterion_)
     1824          better=true;;
     1825      }
     1826      if (better) {
     1827        // see which way
     1828        if (changeUp<=changeDn)
     1829          betterWay=1;
     1830        else
     1831          betterWay=-1;
     1832      }
     1833    }
     1834  } else {
     1835    if (!bestObject_) {
     1836      bestCriterion_=-1.0;
     1837    }
     1838    // got a solution
     1839    if (changeUp<=changeDn) {
     1840      if (changeUp>bestCriterion_)
     1841        betterWay=1;
     1842    } else {
     1843      if (changeDn>bestCriterion_)
     1844        betterWay=-1;
     1845    }
     1846  }
     1847  if (betterWay) {
     1848    bestCriterion_ = CoinMin(changeUp,changeDn);
     1849    bestChangeUp_ = changeUp;
     1850    bestNumberUp_ = numInfUp;
     1851    bestChangeDown_ = changeDn;
     1852    bestNumberDown_ = numInfDn;
     1853    bestObject_=thisOne;
     1854  }
     1855  return betterWay;
    17771856}
    17781857
     
    17811860   
    17821861   This routine is used only after strong branching.
    1783    This is reccommended version as it can be more sophisticated
    17841862*/
    17851863
     
    23212399// Creates a branching object
    23222400CbcBranchingObject *
    2323 CbcFollowOn::createBranch(int way) const
     2401CbcFollowOn::createBranch(int way)
    23242402{
    23252403  int otherRow=0;
Note: See TracChangeset for help on using the changeset viewer.