Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef BcpsBranchObject_h_
00030 #define BcpsBranchObject_h_
00031
00032 #include "BcpsModel.h"
00033
00034 #include "Alps.h"
00035 #include "AlpsEncoded.h"
00036
00037
00038
00039
00040
00047 class BcpsBranchObject {
00048
00049 protected:
00050
00052 int type_;
00053
00055 BcpsModel *model_;
00056
00060 int objectIndex_;
00061
00069 double upScore_;
00070
00072 double downScore_;
00074
00078 int direction_;
00079
00082 double value_;
00083
00085 int numBranchesLeft_;
00087
00088 public:
00089
00091 BcpsBranchObject()
00092 :
00093 type_(0),
00094 model_(NULL),
00095 objectIndex_(-1),
00096 upScore_(0),
00097 downScore_(0),
00098 direction_(0),
00099 value_(0.0),
00100 numBranchesLeft_(0)
00101 {}
00102
00104 BcpsBranchObject(BcpsModel * model)
00105 :
00106 type_(0),
00107 model_(model),
00108 objectIndex_(-1),
00109 upScore_(0),
00110 downScore_(0),
00111 direction_(0),
00112 value_(0.0),
00113 numBranchesLeft_(2)
00114 {}
00115
00117 BcpsBranchObject(BcpsModel * model,
00118 int objectIndex,
00119 int direction ,
00120 double value)
00121 :
00122 type_(0),
00123 model_(model),
00124 objectIndex_(objectIndex),
00125 upScore_(0),
00126 downScore_(0),
00127 direction_(direction),
00128 value_(value),
00129 numBranchesLeft_(2)
00130 {}
00131
00133 BcpsBranchObject(BcpsModel * model,
00134 int objectIndex,
00135 int upScore,
00136 double downScore,
00137 int direction ,
00138 double value)
00139 :
00140 type_(0),
00141 model_(model),
00142 objectIndex_(objectIndex),
00143 upScore_(upScore),
00144 downScore_(downScore),
00145 direction_(direction),
00146 value_(value),
00147 numBranchesLeft_(2)
00148 {}
00149
00151 BcpsBranchObject (const BcpsBranchObject &);
00152
00154 virtual ~BcpsBranchObject() { }
00155
00157 BcpsBranchObject & operator = ( const BcpsBranchObject& rhs);
00158
00160 virtual BcpsBranchObject * clone() const = 0;
00161
00163 int getType() { return type_; }
00164
00166 void setType(int t) { type_ = t; }
00167
00169 virtual int numBranches() const { return 2; }
00170
00172 virtual int numBranchesLeft() const { return numBranchesLeft_; }
00173
00176
00177 virtual double branch(bool normalBranch = false) = 0;
00178
00180 virtual void print(bool normalBranch) {}
00181
00183 virtual bool boundBranch() const { return true; }
00184
00186 inline int getObjectIndex() const { return objectIndex_; }
00187
00189 inline void setObjectIndex(int ind) { objectIndex_ = ind; }
00190
00192 inline double getUpScore() const { return upScore_; }
00193
00195 inline void setUpScore(double score) { upScore_ = score; }
00196
00198 inline double getDownScore() const { return downScore_; }
00199
00201 inline void setDownScore(double score) { downScore_ = score; }
00202
00204 inline int getDirection() const { return direction_; }
00205
00207 inline void setDirection(int direction) { direction_ = direction; }
00208
00210 inline double getValue() const { return value_; }
00211
00213 inline BcpsModel * model() const { return model_; }
00214
00215 protected:
00216
00218 AlpsReturnStatus encodeBcps(AlpsEncoded *encoded) const {
00219 AlpsReturnStatus status = AlpsReturnStatusOk;
00220 assert(encoded);
00221 encoded->writeRep(objectIndex_);
00222 encoded->writeRep(upScore_);
00223 encoded->writeRep(downScore_);
00224 encoded->writeRep(direction_);
00225 encoded->writeRep(value_);
00226 encoded->writeRep(numBranchesLeft_);
00227
00228 return status;
00229 }
00230
00232 AlpsReturnStatus decodeBcps(AlpsEncoded &encoded) {
00233 AlpsReturnStatus status = AlpsReturnStatusOk;
00234
00235 encoded.readRep(objectIndex_);
00236 encoded.readRep(upScore_);
00237 encoded.readRep(downScore_);
00238 encoded.readRep(direction_);
00239 encoded.readRep(value_);
00240 encoded.readRep(numBranchesLeft_);
00241
00242 return status;
00243 }
00244
00245 public:
00246
00248 virtual AlpsReturnStatus encode(AlpsEncoded *encoded) const {
00249 AlpsReturnStatus status = AlpsReturnStatusOk;
00250
00251 assert(0);
00252 return status;
00253 }
00254
00256 virtual AlpsReturnStatus decode(AlpsEncoded &encoded) {
00257 AlpsReturnStatus status = AlpsReturnStatusOk;
00258
00259 assert(0);
00260 return status;
00261 }
00262
00263 };
00264
00265 #endif