Bcps  0.94.5
BcpsBranchStrategy.h
Go to the documentation of this file.
1 /*===========================================================================*
2  * This file is part of the Branch, Constrain and Price Software (BiCePS) *
3  * *
4  * BiCePS is distributed under the Eclipse Public License as part of the *
5  * COIN-OR repository (http://www.coin-or.org). *
6  * *
7  * Authors: *
8  * *
9  * Yan Xu, Lehigh University *
10  * Ted Ralphs, Lehigh University *
11  * *
12  * Conceptual Design: *
13  * *
14  * Yan Xu, Lehigh University *
15  * Ted Ralphs, Lehigh University *
16  * Laszlo Ladanyi, IBM T.J. Watson Research Center *
17  * Matthew Saltzman, Clemson University *
18  * *
19  * Copyright (C) 2001-2017, Lehigh University, Yan Xu, and Ted Ralphs. *
20  * All Rights Reserved. *
21  *===========================================================================*/
22 
23 #ifndef BcpsBranchStrategy_h_
24 #define BcpsBranchStrategy_h_
25 
26 #include "BcpsBranchObject.h"
27 
28 class BcpsModel;
29 
30 //#############################################################################
31 // NOTE: Borrow ideas from COIN/Cbc.
32 //#############################################################################
33 
34 
40 
41  private:
43  BcpsBranchStrategy & operator=(const BcpsBranchStrategy& rhs);
44 
45  protected:
46 
48  int type_;
49 
52 
62 
71  double bestChangeUp_;
79 
80  public:
81 
84  :
85  model_(NULL),
87  branchObjects_(NULL),
88  bestChangeUp_(0.0),
89  bestNumberUp_(0),
90  bestChangeDown_(0.0),
92  {}
93 
96  :
97  model_(m),
99  branchObjects_(NULL),
100  bestChangeUp_(0.0),
101  bestNumberUp_(0),
102  bestChangeDown_(0.0),
103  bestNumberDown_(0)
104  {}
105 
108  for (int k = 0; k < numBranchObjects_; ++k) {
109  delete branchObjects_[k];
110  }
111  delete [] branchObjects_;
112  }
113 
115  virtual BcpsBranchStrategy * clone() const = 0;
116 
118  int getType() const { return type_; }
119 
121  void setType(int t) { type_ = t; }
122 
124  void setModel(BcpsModel *m) { model_ = m; }
125 
128  int getNumBranchObjects() const { return numBranchObjects_; }
129  void setNumBranchObjects(int num) { numBranchObjects_ = num; }
135 
138  virtual void clearBest(BcpsModel * model) {
139  bestBranchObject_ = NULL;
140  bestChangeUp_ = 0.0;
141  bestNumberUp_ = 0;
142  bestChangeDown_ = 0.0;
143  bestNumberDown_ = 0;
144  }
145 
147  virtual int createCandBranchObjects(int numPassesLeft, double ub){
148  return 0;
149  }
150 
156  virtual int betterBranchObject(BcpsBranchObject * b,
157  BcpsBranchObject * bestSoFar) = 0;
158 
163 };
164 
165 #endif
BcpsModel
Definition: BcpsModel.h:40
BcpsBranchStrategy::type_
int type_
Type of branching strategy.
Definition: BcpsBranchStrategy.h:48
BcpsBranchStrategy::setBranchObjects
void setBranchObjects(BcpsBranchObject **obj)
Definition: BcpsBranchStrategy.h:131
BcpsBranchStrategy::getBranchObjects
BcpsBranchObject ** getBranchObjects()
Definition: BcpsBranchStrategy.h:130
BcpsBranchStrategy::~BcpsBranchStrategy
virtual ~BcpsBranchStrategy()
Destructor.
Definition: BcpsBranchStrategy.h:107
BcpsBranchStrategy::bestBranchObject
virtual BcpsBranchObject * bestBranchObject()
Compare branching objects in branchObjects_.
BcpsBranchStrategy::setNumBranchObjects
void setNumBranchObjects(int num)
Definition: BcpsBranchStrategy.h:129
BcpsBranchStrategy::createCandBranchObjects
virtual int createCandBranchObjects(int numPassesLeft, double ub)
Create a set of candidate branching objects.
Definition: BcpsBranchStrategy.h:147
BcpsBranchStrategy::BcpsBranchStrategy
BcpsBranchStrategy()
Default Constructor.
Definition: BcpsBranchStrategy.h:83
BcpsBranchStrategy::branchObjects_
BcpsBranchObject ** branchObjects_
The set of candiate branching objects.
Definition: BcpsBranchStrategy.h:60
BcpsBranchStrategy::setBestBranchObject
void setBestBranchObject(BcpsBranchObject *ob)
Definition: BcpsBranchStrategy.h:133
BcpsBranchObject
BcpsBranchObject contains the member data required when choosing branching entities and excuting actu...
Definition: BcpsBranchObject.h:47
BcpsBranchStrategy::setType
void setType(int t)
Set type.
Definition: BcpsBranchStrategy.h:121
BcpsBranchStrategy::getBestBranchObject
BcpsBranchObject * getBestBranchObject()
Definition: BcpsBranchStrategy.h:132
BcpsBranchStrategy::bestChangeDown_
double bestChangeDown_
Change down for best.
Definition: BcpsBranchStrategy.h:75
BcpsBranchStrategy::setModel
void setModel(BcpsModel *m)
Set model.
Definition: BcpsBranchStrategy.h:124
BcpsBranchStrategy::bestNumberUp_
int bestNumberUp_
Number of infeasibilities for up.
Definition: BcpsBranchStrategy.h:73
BcpsBranchStrategy::betterBranchObject
virtual int betterBranchObject(BcpsBranchObject *b, BcpsBranchObject *bestSoFar)=0
Compare branching object thisOne to bestSoFar.
BcpsBranchStrategy::clearBest
virtual void clearBest(BcpsModel *model)
Clear branching strategy environment before starting a new round of selecting the best branch object.
Definition: BcpsBranchStrategy.h:138
BcpsBranchStrategy::clone
virtual BcpsBranchStrategy * clone() const =0
Clone a branch strategy.
BcpsBranchStrategy::BcpsBranchStrategy
BcpsBranchStrategy(BcpsModel *m)
Useful Constructor.
Definition: BcpsBranchStrategy.h:95
BcpsBranchStrategy::bestNumberDown_
int bestNumberDown_
Number of infeasibilities for down.
Definition: BcpsBranchStrategy.h:77
BcpsBranchStrategy::model_
BcpsModel * model_
Pointer to model.
Definition: BcpsBranchStrategy.h:51
BcpsBranchStrategy::getType
int getType() const
Get type.
Definition: BcpsBranchStrategy.h:118
BcpsBranchStrategy::bestChangeUp_
double bestChangeUp_
Change up for best.
Definition: BcpsBranchStrategy.h:71
BcpsBranchObject.h
BcpsBranchStrategy
Branching strategy specifies: (1) how to select a candidate set of branching objects (2) how to compa...
Definition: BcpsBranchStrategy.h:39
BcpsBranchStrategy::bestBranchObject_
BcpsBranchObject * bestBranchObject_
Following members are used to store information about best branching object found so far.
Definition: BcpsBranchStrategy.h:69
BcpsBranchStrategy::numBranchObjects_
int numBranchObjects_
Following members are used to store candidate branching objects.
Definition: BcpsBranchStrategy.h:58
BcpsBranchStrategy::getNumBranchObjects
int getNumBranchObjects() const
Set/get branching objects.
Definition: BcpsBranchStrategy.h:128