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/CbcTree.hpp

    r1271 r1286  
    2121//#define CBC_DUBIOUS_HEAP
    2222#endif
    23 #ifndef CBC_DUBIOUS_HEAP 
     23#ifndef CBC_DUBIOUS_HEAP
    2424class CbcTree {
    2525
    2626public:
    2727
    28   // Default Constructor
    29   CbcTree ();
    30 
    31   // Copy constructor
    32   CbcTree ( const CbcTree & rhs);
    33   // = operator
    34   CbcTree & operator=(const CbcTree & rhs);
    35    
    36   virtual ~CbcTree();
    37 
    38   /// Clone
    39   virtual CbcTree * clone() const;
    40   /// Create C++ lines to get to current state
    41   virtual void generateCpp( FILE * ) {}
    42 
    43 /*! \name Heap access and maintenance methods */
    44 //@{
    45 
    46   /// Set comparison function and resort heap
    47   void setComparison(CbcCompareBase  &compare);
    48 
    49   /// Return the top node of the heap
    50   virtual CbcNode * top() const;
    51 
    52   /// Add a node to the heap
    53   virtual void push(CbcNode * x);
    54 
    55   /// Remove the top node from the heap
    56   virtual void pop() ;
    57   /// Gets best node and takes off heap
    58   virtual CbcNode * bestNode(double cutoff);
    59 
    60 //@}
    61 /*! \name vector methods */
    62 //@{
    63 
    64   /// Test if empty *** note may be overridden
    65   virtual bool empty() ;
    66 
    67   /// Return size
    68   virtual int size() const
    69   {return nodes_.size();}
    70   /// [] operator
    71   inline CbcNode * operator [] (int i) const
    72   { return nodes_[i];}
    73 
    74   /// Return a node pointer
    75   inline CbcNode * nodePointer (int i) const
    76   { return nodes_[i];}
    77 
    78 
    79 //@}
    80 
    81 /*! \name Search tree maintenance */
    82 //@{
    83 
    84 /*! \brief Prune the tree using an objective function cutoff
    85 
    86   This routine removes all nodes with objective worst than the
    87   specified cutoff value.
    88   It also sets bestPossibleObjective to best
    89   of all on tree before deleting.
    90 */
    91 
    92   virtual void cleanTree(CbcModel * model, double cutoff, double & bestPossibleObjective);
    93 
    94   /// Get best on list using alternate method
    95   CbcNode * bestAlternate();
    96 
    97   /// We may have got an intelligent tree so give it one more chance
    98   virtual void endSearch() {}
    99 
    100   /// Get best possible objective function in the tree
    101   virtual double getBestPossibleObjective();
    102   /// Reset maximum node number
    103   inline void resetNodeNumbers()
    104   { maximumNodeNumber_=0;}
    105   /// Set number of branches
    106   inline void setNumberBranching(int value)
    107   { numberBranching_=value;}
    108   /// Get number of branches
    109   inline int getNumberBranching() const
    110   { return numberBranching_;}
    111   /// Set maximum branches
    112   inline void setMaximumBranching(int value)
    113   { maximumBranching_=value;}
    114   /// Get maximum branches
    115   inline int getMaximumBranching() const
    116   { return maximumBranching_;}
    117   /// Get branched variables
    118   inline unsigned int * branched() const
    119   { return branched_;}
    120   /// Get bounds
    121   inline int * newBounds() const
    122   { return newBound_;}
    123   /// Adds branching information to complete state
    124   void addBranchingInformation(const CbcModel * model,const CbcNodeInfo * nodeInfo,
    125                                const double * currentLower,
    126                                const double * currentUpper);
    127   /// Increase space for data
    128   void increaseSpace();
     28    // Default Constructor
     29    CbcTree ();
     30
     31    // Copy constructor
     32    CbcTree ( const CbcTree & rhs);
     33    // = operator
     34    CbcTree & operator=(const CbcTree & rhs);
     35
     36    virtual ~CbcTree();
     37
     38    /// Clone
     39    virtual CbcTree * clone() const;
     40    /// Create C++ lines to get to current state
     41    virtual void generateCpp( FILE * ) {}
     42
     43    /*! \name Heap access and maintenance methods */
     44//@{
     45
     46    /// Set comparison function and resort heap
     47    void setComparison(CbcCompareBase  &compare);
     48
     49    /// Return the top node of the heap
     50    virtual CbcNode * top() const;
     51
     52    /// Add a node to the heap
     53    virtual void push(CbcNode * x);
     54
     55    /// Remove the top node from the heap
     56    virtual void pop() ;
     57    /// Gets best node and takes off heap
     58    virtual CbcNode * bestNode(double cutoff);
     59
     60//@}
     61    /*! \name vector methods */
     62//@{
     63
     64    /// Test if empty *** note may be overridden
     65    virtual bool empty() ;
     66
     67    /// Return size
     68    virtual int size() const {
     69        return nodes_.size();
     70    }
     71    /// [] operator
     72    inline CbcNode * operator [] (int i) const {
     73        return nodes_[i];
     74    }
     75
     76    /// Return a node pointer
     77    inline CbcNode * nodePointer (int i) const {
     78        return nodes_[i];
     79    }
     80
     81
     82//@}
     83
     84    /*! \name Search tree maintenance */
     85//@{
     86
     87    /*! \brief Prune the tree using an objective function cutoff
     88
     89      This routine removes all nodes with objective worst than the
     90      specified cutoff value.
     91      It also sets bestPossibleObjective to best
     92      of all on tree before deleting.
     93    */
     94
     95    virtual void cleanTree(CbcModel * model, double cutoff, double & bestPossibleObjective);
     96
     97    /// Get best on list using alternate method
     98    CbcNode * bestAlternate();
     99
     100    /// We may have got an intelligent tree so give it one more chance
     101    virtual void endSearch() {}
     102
     103    /// Get best possible objective function in the tree
     104    virtual double getBestPossibleObjective();
     105    /// Reset maximum node number
     106    inline void resetNodeNumbers() {
     107        maximumNodeNumber_ = 0;
     108    }
     109    /// Set number of branches
     110    inline void setNumberBranching(int value) {
     111        numberBranching_ = value;
     112    }
     113    /// Get number of branches
     114    inline int getNumberBranching() const {
     115        return numberBranching_;
     116    }
     117    /// Set maximum branches
     118    inline void setMaximumBranching(int value) {
     119        maximumBranching_ = value;
     120    }
     121    /// Get maximum branches
     122    inline int getMaximumBranching() const {
     123        return maximumBranching_;
     124    }
     125    /// Get branched variables
     126    inline unsigned int * branched() const {
     127        return branched_;
     128    }
     129    /// Get bounds
     130    inline int * newBounds() const {
     131        return newBound_;
     132    }
     133    /// Adds branching information to complete state
     134    void addBranchingInformation(const CbcModel * model, const CbcNodeInfo * nodeInfo,
     135                                 const double * currentLower,
     136                                 const double * currentUpper);
     137    /// Increase space for data
     138    void increaseSpace();
    129139//@}
    130140protected:
    131   std::vector <CbcNode *> nodes_;
    132   CbcCompare comparison_;       ///> Sort function for heap ordering.
    133   /// Maximum "node" number so far to split ties
    134   int maximumNodeNumber_;
    135   /// Size of variable list
    136   int numberBranching_;
    137   /// Maximum size of variable list
    138   int maximumBranching_;
    139   /** Integer variables branched or bounded
    140       top bit set if new upper bound
    141       next bit set if a branch
    142   */
    143   unsigned int * branched_;
    144   /// New bound
    145   int * newBound_;
     141    std::vector <CbcNode *> nodes_;
     142    CbcCompare comparison_;     ///> Sort function for heap ordering.
     143    /// Maximum "node" number so far to split ties
     144    int maximumNodeNumber_;
     145    /// Size of variable list
     146    int numberBranching_;
     147    /// Maximum size of variable list
     148    int maximumBranching_;
     149    /** Integer variables branched or bounded
     150        top bit set if new upper bound
     151        next bit set if a branch
     152    */
     153    unsigned int * branched_;
     154    /// New bound
     155    int * newBound_;
    146156};
    147157/*! \class tree
     
    155165public:
    156166
    157   // Default Constructor
    158   CbcTreeArray ();
    159 
    160   // Copy constructor
    161   CbcTreeArray ( const CbcTreeArray & rhs);
    162   // = operator
    163   CbcTreeArray & operator=(const CbcTreeArray & rhs);
    164    
    165   virtual ~CbcTreeArray();
    166 
    167   /// Clone
    168   virtual CbcTree * clone() const;
    169   /// Create C++ lines to get to current state
    170   virtual void generateCpp( FILE * ) {}
    171 
    172 /*! \name Heap access and maintenance methods */
    173 //@{
    174 
    175   /// Set comparison function and resort heap
    176   void setComparison(CbcCompareBase  &compare);
    177 
    178   /// Add a node to the heap
    179   virtual void push(CbcNode * x);
    180 
    181   /// Gets best node and takes off heap
    182   virtual CbcNode * bestNode(double cutoff);
    183 
    184 //@}
    185 /*! \name vector methods */
    186 //@{
    187 
    188   /// Test if empty *** note may be overridden
    189   virtual bool empty() ;
    190 
    191 //@}
    192 
    193 /*! \name Search tree maintenance */
    194 //@{
    195 
    196 /*! \brief Prune the tree using an objective function cutoff
    197 
    198   This routine removes all nodes with objective worst than the
    199   specified cutoff value.
    200   It also sets bestPossibleObjective to best
    201   of all on tree before deleting.
    202 */
    203 
    204   void cleanTree(CbcModel * model, double cutoff, double & bestPossibleObjective);
    205   /// Get best possible objective function in the tree
    206   virtual double getBestPossibleObjective();
     167    // Default Constructor
     168    CbcTreeArray ();
     169
     170    // Copy constructor
     171    CbcTreeArray ( const CbcTreeArray & rhs);
     172    // = operator
     173    CbcTreeArray & operator=(const CbcTreeArray & rhs);
     174
     175    virtual ~CbcTreeArray();
     176
     177    /// Clone
     178    virtual CbcTree * clone() const;
     179    /// Create C++ lines to get to current state
     180    virtual void generateCpp( FILE * ) {}
     181
     182    /*! \name Heap access and maintenance methods */
     183//@{
     184
     185    /// Set comparison function and resort heap
     186    void setComparison(CbcCompareBase  &compare);
     187
     188    /// Add a node to the heap
     189    virtual void push(CbcNode * x);
     190
     191    /// Gets best node and takes off heap
     192    virtual CbcNode * bestNode(double cutoff);
     193
     194//@}
     195    /*! \name vector methods */
     196//@{
     197
     198    /// Test if empty *** note may be overridden
     199    virtual bool empty() ;
     200
     201//@}
     202
     203    /*! \name Search tree maintenance */
     204//@{
     205
     206    /*! \brief Prune the tree using an objective function cutoff
     207
     208      This routine removes all nodes with objective worst than the
     209      specified cutoff value.
     210      It also sets bestPossibleObjective to best
     211      of all on tree before deleting.
     212    */
     213
     214    void cleanTree(CbcModel * model, double cutoff, double & bestPossibleObjective);
     215    /// Get best possible objective function in the tree
     216    virtual double getBestPossibleObjective();
    207217//@}
    208218protected:
    209   /// Returns
    210   /// Last node
    211   CbcNode * lastNode_;
    212   /// Last node popped
    213   CbcNode * lastNodePopped_;
    214   /// Not used yet
    215   int switches_;
     219    /// Returns
     220    /// Last node
     221    CbcNode * lastNode_;
     222    /// Last node popped
     223    CbcNode * lastNodePopped_;
     224    /// Not used yet
     225    int switches_;
    216226
    217227};
     
    229239public:
    230240
    231   // Default Constructor
    232   CbcNewTree ();
    233 
    234   // Copy constructor
    235   CbcNewTree ( const CbcNewTree & rhs);
    236   // = operator
    237   CbcNewTree & operator=(const CbcNewTree & rhs);
    238    
    239   virtual ~CbcNewTree();
    240 
    241   /// Clone
    242   virtual CbcNewTree * clone() const;
    243   /// Create C++ lines to get to current state
    244   virtual void generateCpp( FILE * ) {}
    245 
    246 /*! \name Heap access and maintenance methods */
    247 //@{
    248 
    249   /// Set comparison function and resort heap
    250   void setComparison(CbcCompareBase  &compare);
    251 
    252   /// Return the top node of the heap
    253   virtual CbcNode * top() const;
    254 
    255   /// Add a node to the heap
    256   virtual void push(CbcNode * x);
    257 
    258   /// Remove the top node from the heap
    259   virtual void pop() ;
    260   /// Gets best node and takes off heap
    261   virtual CbcNode * bestNode(double cutoff);
    262 
    263 //@}
    264 /*! \name vector methods */
    265 //@{
    266 
    267   /// Test if empty *** note may be overridden
    268   virtual bool empty() ;
    269 
    270   /// Return size
    271   inline int size() const
    272   { return nodes_.size();}
    273 
    274   /// [] operator
    275   inline CbcNode * operator [] (int i) const
    276   { return nodes_[i];}
    277 
    278   /// Return a node pointer
    279   inline CbcNode * nodePointer (int i) const
    280   { return nodes_[i];}
    281 
    282 //@}
    283 
    284 /*! \name Search tree maintenance */
    285 //@{
    286 
    287 /*! \brief Prune the tree using an objective function cutoff
    288 
    289   This routine removes all nodes with objective worst than the
    290   specified cutoff value.
    291   It also sets bestPossibleObjective to best
    292   of all on tree before deleting.
    293 */
    294 
    295   void cleanTree(CbcModel * model, double cutoff, double & bestPossibleObjective);
    296 
    297   /// Get best on list using alternate method
    298   CbcNode * bestAlternate();
    299 
    300   /// We may have got an intelligent tree so give it one more chance
    301   virtual void endSearch() {}
     241    // Default Constructor
     242    CbcNewTree ();
     243
     244    // Copy constructor
     245    CbcNewTree ( const CbcNewTree & rhs);
     246    // = operator
     247    CbcNewTree & operator=(const CbcNewTree & rhs);
     248
     249    virtual ~CbcNewTree();
     250
     251    /// Clone
     252    virtual CbcNewTree * clone() const;
     253    /// Create C++ lines to get to current state
     254    virtual void generateCpp( FILE * ) {}
     255
     256    /*! \name Heap access and maintenance methods */
     257//@{
     258
     259    /// Set comparison function and resort heap
     260    void setComparison(CbcCompareBase  &compare);
     261
     262    /// Return the top node of the heap
     263    virtual CbcNode * top() const;
     264
     265    /// Add a node to the heap
     266    virtual void push(CbcNode * x);
     267
     268    /// Remove the top node from the heap
     269    virtual void pop() ;
     270    /// Gets best node and takes off heap
     271    virtual CbcNode * bestNode(double cutoff);
     272
     273//@}
     274    /*! \name vector methods */
     275//@{
     276
     277    /// Test if empty *** note may be overridden
     278    virtual bool empty() ;
     279
     280    /// Return size
     281    inline int size() const {
     282        return nodes_.size();
     283    }
     284
     285    /// [] operator
     286    inline CbcNode * operator [] (int i) const {
     287        return nodes_[i];
     288    }
     289
     290    /// Return a node pointer
     291    inline CbcNode * nodePointer (int i) const {
     292        return nodes_[i];
     293    }
     294
     295//@}
     296
     297    /*! \name Search tree maintenance */
     298//@{
     299
     300    /*! \brief Prune the tree using an objective function cutoff
     301
     302      This routine removes all nodes with objective worst than the
     303      specified cutoff value.
     304      It also sets bestPossibleObjective to best
     305      of all on tree before deleting.
     306    */
     307
     308    void cleanTree(CbcModel * model, double cutoff, double & bestPossibleObjective);
     309
     310    /// Get best on list using alternate method
     311    CbcNode * bestAlternate();
     312
     313    /// We may have got an intelligent tree so give it one more chance
     314    virtual void endSearch() {}
    302315//@}
    303316protected:
     
    310323public:
    311324
    312   // Default Constructor
    313   CbcTree ();
    314 
    315   // Copy constructor
    316   CbcTree ( const CbcTree & rhs);
    317   // = operator
    318   CbcTree & operator=(const CbcTree & rhs);
    319    
    320   virtual ~CbcTree();
    321 
    322   /// Clone
    323   virtual CbcTree * clone() const;
    324   /// Create C++ lines to get to current state
    325   virtual void generateCpp( FILE * fp) {}
    326 
    327 /*! \name Heap access and maintenance methods */
    328 //@{
    329 
    330   /// Set comparison function and resort heap
    331   void setComparison(CbcCompareBase  &compare);
    332 
    333   /// Return the top node of the heap
    334   virtual CbcNode * top() const;
    335 
    336   /// Add a node to the heap
    337   virtual void push(CbcNode * x);
    338 
    339   /// Remove the top node from the heap
    340   virtual void pop() ;
    341   /// Gets best node and takes off heap
    342   virtual CbcNode * bestNode(double cutoff);
    343 
    344 //@}
    345 /*! \name vector methods */
    346 //@{
    347 
    348   /// Test if empty *** note may be overridden
    349   //virtual bool empty() ;
    350 
    351   /// Return size
    352   inline int size() const
    353   { return nodes_.size();}
    354 
    355   /// [] operator
    356   inline CbcNode * operator [] (int i) const
    357   { return nodes_[i];}
    358 
    359   /// Return a node pointer
    360   inline CbcNode * nodePointer (int i) const
    361   { return nodes_[i];}
    362  
    363   virtual bool empty();
    364   //inline int size() const { return size_; }
    365   void realpop();
    366   /** After changing data in the top node, fix the heap */
    367   void fixTop();
    368   void realpush(CbcNode * node);
    369 //@}
    370 
    371 /*! \name Search tree maintenance */
    372 //@{
    373 
    374 /*! \brief Prune the tree using an objective function cutoff
    375 
    376   This routine removes all nodes with objective worst than the
    377   specified cutoff value.
    378   It also sets bestPossibleObjective to best
    379   of all on tree before deleting.
    380 */
    381 
    382   void cleanTree(CbcModel * model, double cutoff, double & bestPossibleObjective);
    383 
    384   /// Get best on list using alternate method
    385   CbcNode * bestAlternate();
    386 
    387   /// We may have got an intelligent tree so give it one more chance
    388   virtual void endSearch() {}
    389   /// Reset maximum node number
    390   inline void resetNodeNumbers()
    391   { maximumNodeNumber_=0;}
     325    // Default Constructor
     326    CbcTree ();
     327
     328    // Copy constructor
     329    CbcTree ( const CbcTree & rhs);
     330    // = operator
     331    CbcTree & operator=(const CbcTree & rhs);
     332
     333    virtual ~CbcTree();
     334
     335    /// Clone
     336    virtual CbcTree * clone() const;
     337    /// Create C++ lines to get to current state
     338    virtual void generateCpp( FILE * fp) {}
     339
     340    /*! \name Heap access and maintenance methods */
     341//@{
     342
     343    /// Set comparison function and resort heap
     344    void setComparison(CbcCompareBase  &compare);
     345
     346    /// Return the top node of the heap
     347    virtual CbcNode * top() const;
     348
     349    /// Add a node to the heap
     350    virtual void push(CbcNode * x);
     351
     352    /// Remove the top node from the heap
     353    virtual void pop() ;
     354    /// Gets best node and takes off heap
     355    virtual CbcNode * bestNode(double cutoff);
     356
     357//@}
     358    /*! \name vector methods */
     359//@{
     360
     361    /// Test if empty *** note may be overridden
     362    //virtual bool empty() ;
     363
     364    /// Return size
     365    inline int size() const {
     366        return nodes_.size();
     367    }
     368
     369    /// [] operator
     370    inline CbcNode * operator [] (int i) const {
     371        return nodes_[i];
     372    }
     373
     374    /// Return a node pointer
     375    inline CbcNode * nodePointer (int i) const {
     376        return nodes_[i];
     377    }
     378
     379    virtual bool empty();
     380    //inline int size() const { return size_; }
     381    void realpop();
     382    /** After changing data in the top node, fix the heap */
     383    void fixTop();
     384    void realpush(CbcNode * node);
     385//@}
     386
     387    /*! \name Search tree maintenance */
     388//@{
     389
     390    /*! \brief Prune the tree using an objective function cutoff
     391
     392      This routine removes all nodes with objective worst than the
     393      specified cutoff value.
     394      It also sets bestPossibleObjective to best
     395      of all on tree before deleting.
     396    */
     397
     398    void cleanTree(CbcModel * model, double cutoff, double & bestPossibleObjective);
     399
     400    /// Get best on list using alternate method
     401    CbcNode * bestAlternate();
     402
     403    /// We may have got an intelligent tree so give it one more chance
     404    virtual void endSearch() {}
     405    /// Reset maximum node number
     406    inline void resetNodeNumbers() {
     407        maximumNodeNumber_ = 0;
     408    }
    392409//@}
    393410protected:
    394   std::vector <CbcNode *> nodes_;
    395   CbcCompare comparison_;       ///> Sort function for heap ordering.
    396   /// Maximum "node" number so far to split ties
    397   int maximumNodeNumber_;
     411    std::vector <CbcNode *> nodes_;
     412    CbcCompare comparison_;     ///> Sort function for heap ordering.
     413    /// Maximum "node" number so far to split ties
     414    int maximumNodeNumber_;
    398415
    399416
Note: See TracChangeset for help on using the changeset viewer.