Changeset 154


Ignore:
Timestamp:
Jul 9, 2005 12:13:51 PM (15 years ago)
Author:
forrest
Message:

back to old node count

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/CbcModel.cpp

    r152 r154  
    584584  numberIterations_ = 0 ;
    585585  numberNodes_ = 0 ;
    586   // For printing in case node at n000 cutoff
    587   int lastPrinted=0;
    588   int lastRedoTree=0;
     586  numberNodes2_ = 0 ;
    589587  int maximumStatistics=0;
    590588  CbcStatistics ** statistics = NULL;
     
    754752      tree_->push(newNode) ;
    755753      if (statistics) {
    756         if (numberNodes_==maximumStatistics) {
     754        if (numberNodes2_==maximumStatistics) {
    757755          maximumStatistics = 2*maximumStatistics;
    758756          CbcStatistics ** temp = new CbcStatistics * [maximumStatistics];
    759757          memset(temp,0,maximumStatistics*sizeof(CbcStatistics *));
    760           memcpy(temp,statistics,numberNodes_*sizeof(CbcStatistics *));
     758          memcpy(temp,statistics,numberNodes2_*sizeof(CbcStatistics *));
    761759          delete [] statistics;
    762760          statistics=temp;
    763761        }
    764         assert (!statistics[numberNodes_]);
    765         statistics[numberNodes_]=new CbcStatistics(newNode);
     762        assert (!statistics[numberNodes2_]);
     763        statistics[numberNodes2_]=new CbcStatistics(newNode);
    766764      }
    767       numberNodes_++;
     765      numberNodes2_++;
    768766#     ifdef CHECK_NODE
    769767      printf("Node %x on tree\n",newNode) ;
     
    825823    + print a summary line to let the user know we're working
    826824*/
    827     if (numberNodes_==lastRedoTree+1000||numberNodes_==lastRedoTree+1001) {
    828       lastRedoTree=numberNodes_&(~1);
    829       bool redoTree=nodeCompare_->every1000Nodes(this, lastRedoTree) ;
     825    if ((numberNodes_%1000) == 0) {
     826      bool redoTree=nodeCompare_->every1000Nodes(this, numberNodes_) ;
    830827      // redo tree if wanted
    831828      if (redoTree)
    832829        tree_->setComparison(*nodeCompare_) ;
    833830    }
    834     if (numberNodes_==lastPrinted+printFrequency_||
    835          numberNodes_==lastPrinted+printFrequency_+1) {
    836       lastPrinted=numberNodes_&(~1);
     831    if ((numberNodes_%printFrequency_) == 0) {
    837832      int j ;
    838833      int nNodes = tree_->size() ;
     
    844839      }
    845840      messageHandler()->message(CBC_STATUS,messages())
    846         << lastPrinted<< nNodes<< bestObjective_<< bestPossibleObjective_
     841        << numberNodes_<< nNodes<< bestObjective_<< bestPossibleObjective_
    847842        << CoinMessageEol ;
    848843      if (eventHandler) {
     
    931926      {
    932927        // set nodenumber correctly
    933         node->nodeInfo()->setNodeNumber(numberNodes_);
     928        node->nodeInfo()->setNodeNumber(numberNodes2_);
    934929        tree_->push(node) ;
    935930        if (statistics) {
    936           if (numberNodes_==maximumStatistics) {
     931          if (numberNodes2_==maximumStatistics) {
    937932            maximumStatistics = 2*maximumStatistics;
    938933            CbcStatistics ** temp = new CbcStatistics * [maximumStatistics];
    939934            memset(temp,0,maximumStatistics*sizeof(CbcStatistics *));
    940             memcpy(temp,statistics,numberNodes_*sizeof(CbcStatistics *));
     935            memcpy(temp,statistics,numberNodes2_*sizeof(CbcStatistics *));
    941936            delete [] statistics;
    942937            statistics=temp;
    943938          }
    944           assert (!statistics[numberNodes_]);
    945           statistics[numberNodes_]=new CbcStatistics(node);
     939          assert (!statistics[numberNodes2_]);
     940          statistics[numberNodes2_]=new CbcStatistics(node);
    946941        }
    947         numberNodes_++;
     942        numberNodes2_++;
    948943        nodeOnTree=true; // back on tree
    949944        deleteNode = false ;
     
    986981                               maximumWhich,whichGenerator) ;
    987982      if (statistics) {
    988         assert (numberNodes_);
    989         assert (statistics[numberNodes_-1]);
    990         assert (statistics[numberNodes_-1]->node()==numberNodes_-1);
    991         statistics[numberNodes_-1]->endOfBranch(numberIterations_-saveNumber,
     983        assert (numberNodes2_);
     984        assert (statistics[numberNodes2_-1]);
     985        assert (statistics[numberNodes2_-1]->node()==numberNodes2_-1);
     986        statistics[numberNodes2_-1]->endOfBranch(numberIterations_-saveNumber,
    992987                                               feasible ? solver_->getObjValue()
    993988                                               : COIN_DBL_MAX);
     
    11311126        assert (!newNode || newNode->objectiveValue() <= getCutoff()) ;
    11321127        if (statistics) {
    1133           assert (numberNodes_);
    1134           assert (statistics[numberNodes_-1]);
    1135           assert (statistics[numberNodes_-1]->node()==numberNodes_-1);
     1128          assert (numberNodes2_);
     1129          assert (statistics[numberNodes2_-1]);
     1130          assert (statistics[numberNodes2_-1]->node()==numberNodes2_-1);
    11361131          if (newNode)
    1137             statistics[numberNodes_-1]->updateInfeasibility(newNode->numberUnsatisfied());
     1132            statistics[numberNodes2_-1]->updateInfeasibility(newNode->numberUnsatisfied());
    11381133          else
    1139             statistics[numberNodes_-1]->sayInfeasible();
     1134            statistics[numberNodes2_-1]->sayInfeasible();
    11401135        }
    11411136        if (newNode)
     
    11811176            tree_->push(newNode) ;
    11821177            if (statistics) {
    1183               if (numberNodes_==maximumStatistics) {
     1178              if (numberNodes2_==maximumStatistics) {
    11841179                maximumStatistics = 2*maximumStatistics;
    11851180                CbcStatistics ** temp = new CbcStatistics * [maximumStatistics];
    11861181                memset(temp,0,maximumStatistics*sizeof(CbcStatistics *));
    1187                 memcpy(temp,statistics,numberNodes_*sizeof(CbcStatistics *));
     1182                memcpy(temp,statistics,numberNodes2_*sizeof(CbcStatistics *));
    11881183                delete [] statistics;
    11891184                statistics=temp;
    11901185              }
    1191               assert (!statistics[numberNodes_]);
    1192               statistics[numberNodes_]=new CbcStatistics(newNode);
     1186              assert (!statistics[numberNodes2_]);
     1187              statistics[numberNodes2_]=new CbcStatistics(newNode);
    11931188            }
    1194             numberNodes_++;
     1189            numberNodes2_++;
    11951190#           ifdef CHECK_NODE
    11961191            printf("Node %x pushed on tree c\n",newNode) ;
     
    13241319    if (doStatistics==3) {
    13251320      printf("  node parent depth column   value                    obj      inf\n");
    1326       for ( i=0;i<numberNodes_;i++) {
     1321      for ( i=0;i<numberNodes2_;i++) {
    13271322        statistics[i]->print(lookup);
    13281323      }
     
    13311326      // Find last solution
    13321327      int k;
    1333       for (k=numberNodes_-1;k>=0;k--) {
     1328      for (k=numberNodes2_-1;k>=0;k--) {
    13341329        if (statistics[k]->endingObjective()!=COIN_DBL_MAX&&
    13351330            !statistics[k]->endingInfeasibility())
     
    13691364    double averageNumberIterations1=0.0;
    13701365    double averageValue=0.0;
    1371     for ( i=0;i<numberNodes_;i++) {
     1366    for ( i=0;i<numberNodes2_;i++) {
    13721367      int depth =  statistics[i]->depth();
    13731368      int way =  statistics[i]->way();
     
    14191414    if (numberSolutions)
    14201415      averageSolutionDepth /= (double) numberSolutions;
    1421     int numberSolved = numberNodes_-numberCutoff;
     1416    int numberSolved = numberNodes2_-numberCutoff;
    14221417    double averageNumberIterations2=numberIterations_-averageNumberIterations1;
    14231418    if(numberCutoff) {
     
    14251420      averageNumberIterations2 /= (double) numberCutoff;
    14261421    }
    1427     if (numberNodes_)
    1428       averageValue /= (double) numberNodes_;
     1422    if (numberNodes2_)
     1423      averageValue /= (double) numberNodes2_;
    14291424    if (numberSolved) {
    14301425      averageNumberIterations1 /= (double) numberSolved;
     
    14531448           numberUp,numberFirstUp,numberUp-numberFirstUp,numberCutoffUp,
    14541449           averageInfUp,averageObjUp);
    1455     for ( i=0;i<numberNodes_;i++)
     1450    for ( i=0;i<numberNodes2_;i++)
    14561451      delete statistics[i];
    14571452    delete [] statistics;
     
    15781573  numberHeuristicSolutions_(0),
    15791574  numberNodes_(0),
     1575  numberNodes2_(0),
    15801576  numberIterations_(0),
    15811577  status_(0),
     
    16641660  numberHeuristicSolutions_(0),
    16651661  numberNodes_(0),
     1662  numberNodes2_(0),
    16661663  numberIterations_(0),
    16671664  status_(0),
     
    18421839  numberHeuristicSolutions_(rhs.numberHeuristicSolutions_),
    18431840  numberNodes_(rhs.numberNodes_),
     1841  numberNodes2_(rhs.numberNodes2_),
    18441842  numberIterations_(rhs.numberIterations_),
    18451843  status_(rhs.status_),
     
    19771975    numberHeuristicSolutions_=0;
    19781976    numberNodes_=0;
     1977    numberNodes2_=0;
    19791978    numberIterations_=0;
    19801979    status_=0;
     
    20672066    numberHeuristicSolutions_=rhs.numberHeuristicSolutions_;
    20682067    numberNodes_ = rhs.numberNodes_;
     2068    numberNodes2_ = rhs.numberNodes2_;
    20692069    numberIterations_ = rhs.numberIterations_;
    20702070    status_ = rhs.status_;
     
    25812581      delete addCuts[i];
    25822582    delete [] addCuts;
    2583     //numberNodes_++;
     2583    numberNodes_++;
    25842584    return 0;
    25852585  }
  • trunk/CbcNode.cpp

    r150 r154  
    821821  }
    822822  // Set node number
    823   nodeInfo_->setNodeNumber(model->getNodeCount());
     823  nodeInfo_->setNodeNumber(model->getNodeCount2());
    824824}
    825825
  • trunk/CbcStatistics.cpp

    r150 r154  
    7474    assert (branch);
    7575    CbcModel * model = branch->model();
    76     id_=model->getNodeCount();
    77   }
     76    id_=model->getNodeCount2();
     77  } 
    7878}
    7979
  • trunk/include/CbcModel.hpp

    r150 r154  
    12271227  //@}
    12281228
     1229  ///@semi-private i.e. users should not use
     1230  //@{
     1231    /// Get how many Nodes it took to solve the problem.
     1232    int getNodeCount2() const
     1233    { return numberNodes2_;};
     1234  //@}
     1235
    12291236//---------------------------------------------------------------------------
    12301237
     
    13201327  /// Cumulative number of nodes
    13211328  int numberNodes_;
     1329  /** Cumulative number of nodes for statistics.
     1330      Must fix to match up
     1331  */
     1332  int numberNodes2_;
    13221333  /// Cumulative number of iterations
    13231334  int numberIterations_;
Note: See TracChangeset for help on using the changeset viewer.