00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef BcpsBranchStrategy_h_
00024 #define BcpsBranchStrategy_h_
00025
00026 #include "BcpsBranchObject.h"
00027
00028 class BcpsModel;
00029
00030
00031
00032
00033
00034
00039 class BcpsBranchStrategy {
00040
00041 private:
00043 BcpsBranchStrategy & operator=(const BcpsBranchStrategy& rhs);
00044
00045 protected:
00046
00048 BcpsModel *model_;
00049
00055 int numBranchObjects_;
00057 BcpsBranchObject ** branchObjects_;
00059
00066 BcpsBranchObject * bestBranchObject_;
00068 double bestChangeUp_;
00070 int bestNumberUp_;
00072 double bestChangeDown_;
00074 int bestNumberDown_;
00076
00077 public:
00078
00080 BcpsBranchStrategy()
00081 :
00082 model_(NULL),
00083 numBranchObjects_(0),
00084 branchObjects_(NULL),
00085 bestChangeUp_(0.0),
00086 bestNumberUp_(0),
00087 bestChangeDown_(0.0),
00088 bestNumberDown_(0)
00089 {}
00090
00092 BcpsBranchStrategy(BcpsModel *m)
00093 :
00094 model_(m),
00095 numBranchObjects_(0),
00096 branchObjects_(NULL),
00097 bestChangeUp_(0.0),
00098 bestNumberUp_(0),
00099 bestChangeDown_(0.0),
00100 bestNumberDown_(0)
00101 {}
00102
00104 virtual ~BcpsBranchStrategy() {
00105 for (int k = 0; k < numBranchObjects_; ++k) {
00106 delete branchObjects_[k];
00107 }
00108 delete [] branchObjects_;
00109 }
00110
00112 virtual BcpsBranchStrategy * clone() const = 0;
00113
00115 void setModel(BcpsModel *m) { model_ = m; }
00116
00119 int getNumBranchObjects() { return numBranchObjects_; }
00120 void getNumBranchObjects(int num) { numBranchObjects_ = num; }
00121 BcpsBranchObject ** getBranchObjects() { return branchObjects_; }
00122 void setBranchObjects(BcpsBranchObject **obj) { branchObjects_ = obj; }
00123 BcpsBranchObject *getBestBranchObject() { return bestBranchObject_; }
00124 void setBestBranchObject(BcpsBranchObject *ob) { bestBranchObject_ = ob; }
00126
00129 virtual void clearBest(BcpsModel * model) {
00130 bestBranchObject_ = NULL;
00131 bestChangeUp_ = 0.0;
00132 bestNumberUp_ = 0;
00133 bestChangeDown_ = 0.0;
00134 bestNumberDown_ = 0;
00135 }
00136
00138 virtual int createCandBranchObjects(int numPassesLeft) { return 0; }
00139
00145 virtual int betterBranchObject(BcpsBranchObject * b,
00146 BcpsBranchObject * bestSoFar) = 0;
00147
00151 virtual int bestBranchObject();
00152 };
00153
00154 #endif