- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# /home/coin/SVN-release/Blis-0.91.0/Bcps/src/BcpsObject.h

Go to the documentation of this file.

    00001 /*===========================================================================*
    00002  * This file is part of the Branch, Constrain and Price Software (BiCePS)    *
    00003  *                                                                           *
    00004  * BiCePS is distributed under the Common Public License as part of the      *
    00005  * COIN-OR repository (http://www.coin-or.org).                              *
    00006  *                                                                           *
    00007  * Authors:                                                                  *
    00008  *                                                                           *
    00009  *          Yan Xu, Lehigh University                                        *
    00010  *          Ted Ralphs, Lehigh University                                    *
    00011  *                                                                           *
    00012  * Conceptual Design:                                                        *
    00013  *                                                                           *
    00014  *          Yan Xu, Lehigh University                                        *
    00015  *          Ted Ralphs, Lehigh University                                    *
    00016  *          Laszlo Ladanyi, IBM T.J. Watson Research Center                  *
    00017  *          Matthew Saltzman, Clemson University                             *
    00018  *                                                                           *
    00019  * Copyright (C) 2001-2009, Lehigh University, Yan Xu, and Ted Ralphs.       *
    00020  * All Rights Reserved.                                                      *
    00021  *===========================================================================*/
    00022
    00023 #ifndef BcpsObject_h_
    00024 #define BcpsObject_h_
    00025
    00026 #include "Alps.h"
    00027 #include "AlpsKnowledge.h"
    00028
    00029 #include "Bcps.h"
    00030
    00031 class BcpsModel;
    00032 class BcpsBranchObject;
    00033
    00034 //#############################################################################
    00035
    00036 #define    BCPS_NONREMOVALBE 0x0001
    00037 #define    BCPS_BRACNEDON    0x0010
    00038 #define    BCPS_SENDABLE     0x0100
    00039
    00040 //#############################################################################
    00041
    00045 typedef char BcpsIntegral_t;
    00048 //#############################################################################
    00051 //#############################################################################
    00052
    00053 enum BcpsObject_t {
    00054     BCPS_PRIMAL_OBJECT = 0,
    00055     BCPS_VAR_OBJECT = 0,
    00056     BCPS_DUAL_OBJECT = 1,
    00057     BCPS_CON_OBJECT = 1
    00058 };
    00059
    00060 //#############################################################################
    00062 //#############################################################################
    00063
    00064 enum BcpsObjRep_t {
    00065     BCPS_CORE = 0,
    00066     BCPS_INDEXED = 1,
    00067     BCPS_ALGO = 2
    00068 };
    00069
    00070 //#############################################################################
    00074 //#############################################################################
    00075
    00076 class BcpsObject : public AlpsKnowledge {
    00077
    00078  protected:
    00079
    00081     int objectIndex_;
    00082
    00084     BcpsObjRep_t repType_;
    00085
    00090     BcpsIntegral_t intType_;
    00091
    00094     BcpsValidRegion validRegion_;
    00095
    00097     // branched on? non-removable ? can it be sent to the pool?
    00098     // do we need it at all?
    00099     int status_;
    00100
    00102     double lbHard_;
    00103
    00105     double ubHard_;
    00106
    00108     double lbSoft_;
    00109
    00111     double ubSoft_;
    00112
    00114     double hashValue_;
    00115
    00117     int numInactive_;
    00118
    00120     double effectiveness_;
    00121
    00122  public:
    00123
    00124     BcpsObject()
    00125         :
    00126         objectIndex_(-1),
    00127         repType_(BCPS_CORE),
    00128         intType_('C'),
    00129         validRegion_(BcpsValidLocal),
    00130         status_(0),
    00131         lbHard_(0.0),
    00132         ubHard_(0.0),
    00133         lbSoft_(0.0),
    00134         ubSoft_(0.0),
    00135         hashValue_(0.0),
    00136         numInactive_(0),
    00137         effectiveness_(-ALPS_DBL_MAX)
    00138         {}
    00139
    00140     BcpsObject(double lbh, double ubh, double lbs, double ubs)
    00141         :
    00142         objectIndex_(-1),
    00143         repType_(BCPS_CORE),
    00144         intType_('C'),
    00145         validRegion_(BcpsValidLocal),
    00146         status_(0),
    00147         lbHard_(lbh),
    00148         ubHard_(ubh),
    00149         lbSoft_(lbs),
    00150         ubSoft_(ubs),
    00151         hashValue_(0.0),
    00152         numInactive_(0),
    00153         effectiveness_(-ALPS_DBL_MAX)
    00154         {}
    00155
    00156     virtual ~BcpsObject() {}
    00157
    00159     BcpsObject (const BcpsObject & rhs) {
    00160         objectIndex_ = rhs.objectIndex_;
    00161         repType_ = rhs.repType_;
    00162         intType_ = rhs.intType_;
    00163         validRegion_ = rhs.validRegion_,
    00164         status_ = rhs.status_;
    00165         lbHard_ = rhs.lbHard_;
    00166         ubHard_ = rhs.ubHard_;
    00167         lbSoft_ = rhs.lbSoft_;
    00168         ubSoft_ = rhs.ubSoft_;
    00169         hashValue_ = rhs.hashValue_;
    00170         numInactive_ = rhs.numInactive_;
    00171         effectiveness_ = rhs.effectiveness_;
    00172     }
    00173
    00175     BcpsObject & operator = ( const BcpsObject& rhs);
    00176
    00178     virtual BcpsObject * clone() const {
    00179         BcpsObject * be = NULL;
    00180         return be;
    00181     }
    00182
    00185     inline int getObjectIndex() const         { return objectIndex_; }
    00186     inline BcpsObjRep_t getRepType() const    { return repType_; }
    00187     inline BcpsIntegral_t getIntType() const  { return intType_; }
    00188     inline BcpsValidRegion getValidRegion() const  { return validRegion_; }
    00189     inline int getStatus() const              { return status_; }
    00190     inline double getLbHard() const           { return lbHard_; }
    00191     inline double getUbHard() const           { return ubHard_; }
    00192     inline double getLbSoft() const           { return lbSoft_; }
    00193     inline double getUbSoft() const           { return ubSoft_; }
    00194     inline int getNumInactive() const         { return numInactive_; }
    00195     inline double getEffectiveness() const    { return effectiveness_; }
    00200     inline void setObjectIndex(int ind)       { objectIndex_ = ind; }
    00201     inline void setRepType(BcpsObjRep_t rt)   { repType_ = rt; }
    00202     inline void setIntType(BcpsIntegral_t it) { intType_ = it; }
    00203     inline void setValidRegion(BcpsValidRegion val) { validRegion_ = val;}
    00204     inline void setStatus(int st)             { status_ |= st; }
    00205     inline void setLbHard(double lb)          { lbHard_ = lb; }
    00206     inline void setUbHard(double ub)          { ubHard_ = ub; }
    00207     inline void setLbSoft(double lb)          { lbSoft_ = lb; }
    00208     inline void setUbSoft(double ub)          { ubSoft_ = ub; }
    00209     inline void setNumInactive(int num)       { numInactive_ = num; }
    00210     inline void setEffectiveness(double eff)  { effectiveness_= eff; }
    00215     virtual void hashing(BcpsModel *model=NULL)    { hashValue_ = 0.0; }
    00216     double hashValue() const  {  return hashValue_; }
    00231     virtual double infeasibility(BcpsModel *m, int &preferredWay) const {
    00232         return 0.0;
    00233     }
    00234
    00236     virtual void feasibleRegion(BcpsModel *m) {}
    00237
    00241     virtual BcpsBranchObject * createBranchObject(BcpsModel *m, int way) const{
    00242         BcpsBranchObject *be = NULL;
    00243         return be;
    00244     }
    00245
    00252     virtual BcpsBranchObject * preferredNewFeasible(BcpsModel *m) const {
    00253         BcpsBranchObject * temp = NULL;
    00254         return temp;
    00255     }
    00256
    00263     virtual BcpsBranchObject * notPreferredNewFeasible(BcpsModel *m) const {
    00264         BcpsBranchObject * temp = NULL;
    00265         return temp;
    00266     }
    00267
    00271     virtual void resetBounds(BcpsModel *m) {}
    00272
    00275     virtual bool boundBranch(BcpsModel *m) const { return true; }
    00276
    00278     virtual void floorCeiling(double &floorValue,
    00279                               double &ceilingValue,
    00280                               double value,
    00281                               double tolerance) const;
    00282
    00284     virtual double upEstimate() const { return 1.0e-5; }
    00285
    00287     virtual double downEstimate() const { return 1.0e-5; }
    00288
    00289  protected:
    00290
    00292     AlpsReturnStatus encodeBcpsObject(AlpsEncoded *encoded) const {
    00293         AlpsReturnStatus status = AlpsReturnStatusOk;
    00294         encoded->writeRep(objectIndex_);
    00295         encoded->writeRep(repType_);
    00296         encoded->writeRep(intType_);
    00297         encoded->writeRep(validRegion_);
    00298         encoded->writeRep(status_);
    00299         encoded->writeRep(lbHard_);
    00300         encoded->writeRep(ubHard_);
    00301         encoded->writeRep(lbSoft_);
    00302         encoded->writeRep(ubSoft_);
    00303         encoded->writeRep(hashValue_);
    00304         return status;
    00305     }
    00306
    00308     AlpsReturnStatus decodeBcpsObject(AlpsEncoded &encoded){
    00309         AlpsReturnStatus status = AlpsReturnStatusOk;
    00310         encoded.readRep(objectIndex_);
    00311         encoded.readRep(repType_);
    00312         encoded.readRep(intType_);
    00313         encoded.readRep(validRegion_);
    00314         encoded.readRep(status_);
    00315         encoded.readRep(lbHard_);
    00316         encoded.readRep(ubHard_);
    00317         encoded.readRep(lbSoft_);
    00318         encoded.readRep(ubSoft_);
    00319         encoded.readRep(hashValue_);
    00320         return status;
    00321     }
    00322
    00323 protected:
    00324
    00325  public:
    00326
    00327     using AlpsKnowledge::encode ;
    00329     virtual AlpsReturnStatus encode(AlpsEncoded *encoded) {
    00330         AlpsReturnStatus status = AlpsReturnStatusOk;
    00331         assert(0);
    00332         return status;
    00333     }
    00334
    00336     virtual AlpsKnowledge* decode(AlpsEncoded& encoded) const {
    00337         AlpsKnowledge* know = NULL;
    00338         assert(0);
    00339         return know;
    00340     }
    00341 };
    00342
    00343
    00344 //#############################################################################
    00345
    00346
    00347 typedef BcpsObject*  BcpsObject_p;
    00348
    00349
    00350 //#############################################################################
    00351
    00352
    00353 class BcpsConstraint : public BcpsObject {
    00354
    00355  public:
    00357     BcpsConstraint() : BcpsObject() { setType(BcpsKnowledgeTypeConstraint); }
    00358
    00360     BcpsConstraint(double lbh, double ubh, double lbs, double ubs)
    00361         :
    00362         BcpsObject(lbh, ubh, lbs, ubs)
    00363         { setType(BcpsKnowledgeTypeConstraint); }
    00364
    00366     virtual ~BcpsConstraint() {}
    00367
    00369     BcpsConstraint(const BcpsConstraint & rhs)
    00370         :
    00371         BcpsObject(rhs)
    00372         {}
    00373
    00374     inline virtual BcpsObject_t getObjType() const { return BCPS_CON_OBJECT; }
    00375 };
    00376
    00377
    00378 //#############################################################################
    00379
    00380
    00381 class BcpsVariable : public BcpsObject {
    00382  public:
    00384     BcpsVariable() : BcpsObject() { setType(BcpsKnowledgeTypeVariable); }
    00385
    00387     BcpsVariable(double lbh, double ubh, double lbs, double ubs)
    00388         :
    00389         BcpsObject(lbh, ubh, lbs, ubs)
    00390         { setType(BcpsKnowledgeTypeVariable); }
    00391
    00393     virtual ~BcpsVariable() {}
    00394
    00396     BcpsVariable(const BcpsVariable & rhs)
    00397         :
    00398         BcpsObject(rhs)
    00399         {}
    00400
    00401     inline virtual BcpsObject_t getObjType() const { return BCPS_VAR_OBJECT; }
    00402 };
    00403
    00404
    00405 //#############################################################################
    00406
    00407 #endif