Ignore:
Timestamp:
Nov 9, 2009 6:33:07 PM (10 years ago)
Author:
EdwinStraver
Message:

Changed formatting using AStyle -A4 -p

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/sandbox/Cbc/src/CbcStatistics.cpp

    r1271 r1286  
    66#  pragma warning(disable:4786)
    77#endif
    8  
     8
    99#include <cassert>
    1010#include <cstdio>
     
    1414CbcStatistics::operator=(const CbcStatistics & rhs)
    1515{
    16   if (this != &rhs) {
    17     value_ = rhs.value_;
    18     startingObjective_=rhs.startingObjective_;
    19     endingObjective_=rhs.endingObjective_;
    20     id_=rhs.id_;
    21     parentId_=rhs.parentId_;
    22     way_ = rhs.way_;
    23     sequence_=rhs.sequence_;
    24     depth_=rhs.depth_;
    25     startingInfeasibility_=rhs.startingInfeasibility_;
    26     endingInfeasibility_=rhs.endingInfeasibility_;
    27     numberIterations_=rhs.numberIterations_;
    28   }
    29   return *this;
     16    if (this != &rhs) {
     17        value_ = rhs.value_;
     18        startingObjective_ = rhs.startingObjective_;
     19        endingObjective_ = rhs.endingObjective_;
     20        id_ = rhs.id_;
     21        parentId_ = rhs.parentId_;
     22        way_ = rhs.way_;
     23        sequence_ = rhs.sequence_;
     24        depth_ = rhs.depth_;
     25        startingInfeasibility_ = rhs.startingInfeasibility_;
     26        endingInfeasibility_ = rhs.endingInfeasibility_;
     27        numberIterations_ = rhs.numberIterations_;
     28    }
     29    return *this;
    3030}
    3131
    3232CbcStatistics::CbcStatistics () :
    33   value_ ( 0.0),
    34   startingObjective_(0.0),
    35   endingObjective_(COIN_DBL_MAX),
    36   id_(-1),
    37   parentId_(-1),
    38   way_ ( 0),
    39   sequence_(-1),
    40   depth_(0),
    41   startingInfeasibility_(-1),
    42   endingInfeasibility_(0),
    43   numberIterations_(0)
     33        value_ ( 0.0),
     34        startingObjective_(0.0),
     35        endingObjective_(COIN_DBL_MAX),
     36        id_(-1),
     37        parentId_(-1),
     38        way_ ( 0),
     39        sequence_(-1),
     40        depth_(0),
     41        startingInfeasibility_(-1),
     42        endingInfeasibility_(0),
     43        numberIterations_(0)
    4444{
    4545}
    46 // First or second branch 
     46// First or second branch
    4747CbcStatistics::CbcStatistics(CbcNode * node, CbcModel * model)
    48   :  endingObjective_(COIN_DBL_MAX),
    49      endingInfeasibility_(0),
    50      numberIterations_(0)
     48        :  endingObjective_(COIN_DBL_MAX),
     49        endingInfeasibility_(0),
     50        numberIterations_(0)
    5151{
    52   CbcNodeInfo * nodeInfo = node->nodeInfo();
    53   CbcNodeInfo * parent = nodeInfo->parent();
    54   int numberBranches = nodeInfo->numberBranchesLeft();
    55   const CbcBranchingObject * branch = dynamic_cast <const CbcBranchingObject *>(node->branchingObject());
    56   const OsiTwoWayBranchingObject * branch2 = dynamic_cast <const OsiTwoWayBranchingObject *>(node->branchingObject());
    57   startingObjective_=node->objectiveValue();
    58   way_=node->way();
    59   depth_=node->depth();
    60   startingInfeasibility_ = node->numberUnsatisfied();
    61   if (branch) {
    62     sequence_=branch->variable();
    63     value_ = branch->value();
    64   } else {
    65     const OsiSimpleInteger * obj = dynamic_cast<const OsiSimpleInteger *>(branch2->originalObject());
    66     assert (obj);
    67     sequence_=obj->columnNumber();
    68     value_=branch2->value();
    69   }
    70   if (parent)
    71     parentId_=parent->nodeNumber();
    72   else
    73     parentId_=-1;
    74   if (numberBranches==2) {
    75     id_=nodeInfo->nodeNumber();
    76   } else {
    77     way_ *= 10;
    78     id_=model->getNodeCount2();
    79   }
     52    CbcNodeInfo * nodeInfo = node->nodeInfo();
     53    CbcNodeInfo * parent = nodeInfo->parent();
     54    int numberBranches = nodeInfo->numberBranchesLeft();
     55    const CbcBranchingObject * branch = dynamic_cast <const CbcBranchingObject *>(node->branchingObject());
     56    const OsiTwoWayBranchingObject * branch2 = dynamic_cast <const OsiTwoWayBranchingObject *>(node->branchingObject());
     57    startingObjective_ = node->objectiveValue();
     58    way_ = node->way();
     59    depth_ = node->depth();
     60    startingInfeasibility_ = node->numberUnsatisfied();
     61    if (branch) {
     62        sequence_ = branch->variable();
     63        value_ = branch->value();
     64    } else {
     65        const OsiSimpleInteger * obj = dynamic_cast<const OsiSimpleInteger *>(branch2->originalObject());
     66        assert (obj);
     67        sequence_ = obj->columnNumber();
     68        value_ = branch2->value();
     69    }
     70    if (parent)
     71        parentId_ = parent->nodeNumber();
     72    else
     73        parentId_ = -1;
     74    if (numberBranches == 2) {
     75        id_ = nodeInfo->nodeNumber();
     76    } else {
     77        way_ *= 10;
     78        id_ = model->getNodeCount2();
     79    }
    8080}
    8181
    8282CbcStatistics::CbcStatistics(const CbcStatistics & rhs) :
    83   value_ ( rhs.value_),
    84   startingObjective_(rhs.startingObjective_),
    85   endingObjective_(rhs.endingObjective_),
    86   id_(rhs.id_),
    87   parentId_(rhs.parentId_),
    88   way_ ( rhs.way_),
    89   sequence_(rhs.sequence_),
    90   depth_(rhs.depth_),
    91   startingInfeasibility_(rhs.startingInfeasibility_),
    92   endingInfeasibility_(rhs.endingInfeasibility_),
    93   numberIterations_(rhs.numberIterations_)
     83        value_ ( rhs.value_),
     84        startingObjective_(rhs.startingObjective_),
     85        endingObjective_(rhs.endingObjective_),
     86        id_(rhs.id_),
     87        parentId_(rhs.parentId_),
     88        way_ ( rhs.way_),
     89        sequence_(rhs.sequence_),
     90        depth_(rhs.depth_),
     91        startingInfeasibility_(rhs.startingInfeasibility_),
     92        endingInfeasibility_(rhs.endingInfeasibility_),
     93        numberIterations_(rhs.numberIterations_)
    9494{
    9595}
     
    9999}
    100100// Update at end of branch
    101 void 
     101void
    102102CbcStatistics::endOfBranch(int numberIterations, double objectiveValue)
    103103{
    104   numberIterations_ = numberIterations;
    105   endingObjective_=objectiveValue;
     104    numberIterations_ = numberIterations;
     105    endingObjective_ = objectiveValue;
    106106}
    107107// Update number of infeasibilities
    108 void 
     108void
    109109CbcStatistics::updateInfeasibility(int numberInfeasibilities)
    110110{
    111   endingInfeasibility_=numberInfeasibilities;
     111    endingInfeasibility_ = numberInfeasibilities;
    112112}
    113113// Branch found to be infeasible by chooseBranch
    114 void 
     114void
    115115CbcStatistics::sayInfeasible()
    116116{
    117   endingObjective_=COIN_DBL_MAX;
     117    endingObjective_ = COIN_DBL_MAX;
    118118}
    119119// Just prints
    120 void 
     120void
    121121CbcStatistics::print(const int * sequenceLookup) const
    122122{
    123   int sequence=-1;
    124   if (sequence_>=0)
    125     sequence = sequenceLookup ? sequenceLookup[sequence_] : sequence_;
    126   printf("%6d %6d %5d %6d %7.3f %s %s %13.7g (%5d) -> ",
    127          id_,parentId_,depth_,sequence,value_,abs(way_)==1 ? " left" : "right",
    128          way_<0 ? "down" : " up ",startingObjective_,startingInfeasibility_);
    129   if (endingObjective_!=COIN_DBL_MAX)
    130     if (endingInfeasibility_)
    131       printf("%13.7g (%5d)\n",endingObjective_,endingInfeasibility_);
     123    int sequence = -1;
     124    if (sequence_ >= 0)
     125        sequence = sequenceLookup ? sequenceLookup[sequence_] : sequence_;
     126    printf("%6d %6d %5d %6d %7.3f %s %s %13.7g (%5d) -> ",
     127           id_, parentId_, depth_, sequence, value_, abs(way_) == 1 ? " left" : "right",
     128           way_ < 0 ? "down" : " up ", startingObjective_, startingInfeasibility_);
     129    if (endingObjective_ != COIN_DBL_MAX)
     130        if (endingInfeasibility_)
     131            printf("%13.7g (%5d)\n", endingObjective_, endingInfeasibility_);
     132        else
     133            printf("%13.7g ** Solution\n", endingObjective_);
    132134    else
    133       printf("%13.7g ** Solution\n",endingObjective_);
    134   else
    135     printf("cutoff\n");
     135        printf("cutoff\n");
    136136}
Note: See TracChangeset for help on using the changeset viewer.