Changeset 981 for branches


Ignore:
Timestamp:
Jun 16, 2008 11:20:49 AM (11 years ago)
Author:
jpgoncal
Message:

Added print statements for debugging.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/dynamicbranching/dynamicbranching.cpp

    r980 r981  
    4343#include "OsiClpSolverInterface.hpp"
    4444
     45//#define DEBUG_DYNAMIC_BRANCHING
    4546
    4647// below needed for pathetic branch and bound code
     
    955956  const bool parent_is_down_child = parent_id == grandparent.child_down_;
    956957
     958#if defined(DEBUG_DYNAMIC_BRANCHING)
     959  printf("entered moveNodeUp\n");
     960  printf("parent_id %d grandparent_id %d greatgrandparent_id %d\n",
     961         parent_id, grandparent_id, greatgrandparent_id);
     962  printf("parent.way_ %d\n", parent.way_);
     963#endif
     964
     965
    957966  // First hang the nodes where they belong.
    958967  parent.parent_ = greatgrandparent_id;
     
    961970  int& child_to_move =
    962971    down_child_stays_with_parent ? parent.child_up_ : parent.child_down_;
     972
     973#if defined(DEBUG_DYNAMIC_BRANCHING)
     974  printf("parent_is_down_child %d down_child_stays_with_parent %d child_to_move %d\n", parent_is_down_child, down_child_stays_with_parent, child_to_move);
     975#endif
     976
    963977  if (parent_is_down_child) {
    964978    grandparent.child_down_ = child_to_move;
     
    978992    }
    979993  }
     994
     995#if defined(DEBUG_DYNAMIC_BRANCHING)
     996  printf("after exchange\n");
     997  printf("parent.parent_ %d parent.child_down_ %d parent.child_up_ %d\n",
     998         parent.parent_, parent.child_down_, parent.child_up_);
     999  printf("grandparent.parent_ %d grandparent.child_down_ %d grandparent.child_up_ %d\n",
     1000         grandparent.parent_, grandparent.child_down_, grandparent.child_up_);
     1001  if (greatgrandparent_id >= 0) {
     1002    DBNodeSimple& greatgrandparent = nodes_[greatgrandparent_id];
     1003    printf("greatgrandparent.parent_ %d greatgrandparent.child_down_ %d greatgrandparent.child_up_ %d\n",
     1004         greatgrandparent.parent_, greatgrandparent.child_down_, greatgrandparent.child_up_);
     1005  }
     1006  printf("exiting moveNodeUp\n");
     1007#endif
     1008
    9801009
    9811010  // Now make sure way_ is set properly
     
    10271056    }
    10281057  }
    1029  
    10301058 
    10311059  // Now modify bounds
     
    11541182    // while until nothing on stack
    11551183    while (branchingTree.size()) {
     1184#if defined(DEBUG_DYNAMIC_BRANCHING)
     1185      printf("branchingTree.size = %d %d\n",branchingTree.size(),branchingTree.size_);
     1186      printf("i node_id parent child_down child_up\n");
     1187      for(int k=0; k<branchingTree.size_; k++) {
     1188        DBNodeSimple& node = branchingTree.nodes_[k];
     1189        printf("%d %d %d %d %d\n",k, node.node_id_, node.parent_,
     1190               node.child_down_, node.child_up_);
     1191      }
     1192#endif
    11561193      // last node
    11571194      DBNodeSimple node = branchingTree.back();
    11581195      int kNode = branchingTree.chosen_;
    11591196      branchingTree.pop_back();
     1197#if defined(DEBUG_DYNAMIC_BRANCHING)
     1198      printf("Deleted current parent %d %d\n",branchingTree.size(),branchingTree.size_);
     1199#endif
    11601200      assert (! node.bothChildDone());
    11611201      numberNodes++;
     
    12131253        // to be done. We want the whole tree all the time.
    12141254        branchingTree.push_back(node);
     1255#if defined(DEBUG_DYNAMIC_BRANCHING)
     1256      printf("Added current parent %d %d\n",branchingTree.size(),branchingTree.size_);
     1257#endif
    12151258       
    12161259        // solve
     
    12691312                                                   branchingTree)) {
    12701313          branchingTree.moveNodeUp(which, model, node);
     1314#if defined(DEBUG_DYNAMIC_BRANCHING)
     1315          printf("It moved a node up. The current state is:\n");
     1316          printf("i node_id parent child_down child_up\n");
     1317          for(int k=0; k<branchingTree.size_; k++) {
     1318            DBNodeSimple& node = branchingTree.nodes_[k];
     1319            printf("%d %d %d %d %d\n",k, node.node_id_, node.parent_,
     1320               node.child_down_, node.child_up_);
     1321          }
     1322#endif
    12711323        }
    12721324        if ((numberNodes%1000)==0)
     
    12901342          // push on stack
    12911343          branchingTree.push_back(newNode);
     1344#if defined(DEBUG_DYNAMIC_BRANCHING)
     1345      printf("Added current child %d %d\n",branchingTree.size(),branchingTree.size_);
     1346#endif
    12921347          if(branchingTree.nodes_[kNode].way_ & DBNodeSimple::WAY_DOWN_CURRENT)
    12931348            branchingTree.nodes_[kNode].child_down_ = branchingTree.last_;
Note: See TracChangeset for help on using the changeset viewer.