Changeset 893 for branches/heur


Ignore:
Timestamp:
Mar 11, 2008 1:41:58 PM (11 years ago)
Author:
jpgoncal
Message:

Added function to print info.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/heur/Cbc/src/CbcHeuristic.cpp

    r891 r893  
    2323#include "OsiAuxInfo.hpp"
    2424#include "OsiPresolve.hpp"
    25 
     25#include "CbcBranchActual.hpp"
    2626//==============================================================================
    2727
     
    9696  fractionSmall_(1.0),
    9797  heuristicName_("Unknown"),
    98   howOften_(100),
     98  howOften_(2),
    9999  decayFactor_(0.5),
    100100  shallowDepth_(0),
     
    118118  fractionSmall_(1.0),
    119119  heuristicName_("Unknown"),
    120   howOften_(100),
     120  howOften_(2),
    121121  decayFactor_(0.5),
    122122  shallowDepth_(0),
     
    168168}
    169169
     170void
     171CbcHeuristic::debugNodes()
     172{
     173  CbcNode* node = model_->currentNode();
     174  CbcNodeInfo* nodeInfo = node->nodeInfo();
     175  while (nodeInfo->owner() != NULL) {
     176    const CbcNode* node = nodeInfo->owner();
     177    int depth = node->depth();
     178    int nodeNumber = node->nodeNumber();
     179    bool onTree = node->onTree();
     180    bool active = node->active();
     181    std::cout<<"nodeNumber= "<<nodeNumber
     182             <<", depth= "<<depth
     183             <<", onTree= "<<onTree
     184             <<", active= "<<active<<std::endl;
     185    const OsiBranchingObject* osibr =
     186      nodeInfo->owner()->branchingObject();
     187    const CbcBranchingObject* cbcbr =
     188      dynamic_cast<const CbcBranchingObject*>(osibr);
     189    assert(cbcbr);
     190    const CbcIntegerBranchingObject* brPrint =
     191      dynamic_cast<const CbcIntegerBranchingObject*>(cbcbr);
     192    const double* downBounds = brPrint->downBounds();
     193    const double* upBounds = brPrint->upBounds();
     194    int variable = brPrint->variable();
     195    int way = brPrint->way();
     196    std::cout<<"downBounds= ["<<downBounds[0]<<","<<downBounds[1]<<"]"
     197             <<", upBounds= ["<<upBounds[0]<<","<<upBounds[1]<<"]"
     198             <<", variable= "<<variable
     199             <<", way= "<<way<<std::endl;
     200    nodeInfo = nodeInfo->parent();
     201  }
     202}
     203
    170204bool
    171205CbcHeuristic::shouldHeurRun()
    172206{
     207
    173208  const CbcNode* currentNode = model_->currentNode();
    174209  if (currentNode == NULL) {
    175210    return false;
    176211  }
     212
     213  debugNodes();
    177214
    178215  const int depth = currentNode->depth();
     
    212249    // Get where we are and create the appropriate CbcHeuristicNode object
    213250    CbcHeuristicNode* nodeDesc = new CbcHeuristicNode(*model_);
     251    std::cout<<"minDistance = "<<nodeDesc->minDistance(runNodes_)<<std::endl;
    214252    if (nodeDesc->minDistance(runNodes_) < minDistanceToRun_) {
    215253      delete nodeDesc;
     
    644682  depth = 0;
    645683  while (nodeInfo->owner() != NULL) {
     684#if 0
     685    const OsiBranchingObject* osibr = nodeInfo->parentBranchingObject();
     686#else
    646687    const OsiBranchingObject* osibr =
    647688      nodeInfo->owner()->branchingObject();
     689#endif
    648690    const CbcBranchingObject* cbcbr =
    649691      dynamic_cast<const CbcBranchingObject*>(osibr);
    650692    assert(cbcbr);
     693    const CbcIntegerBranchingObject* brPrint =
     694      dynamic_cast<const CbcIntegerBranchingObject*>(cbcbr);
    651695    brObj_[depth++] = cbcbr->clone();
    652696    nodeInfo = nodeInfo->parent();
Note: See TracChangeset for help on using the changeset viewer.