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

- File List
- File Members

# /home/coin/svn-release/Bcps-0.93.10/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 Eclipse 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-2013, 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     virtual void printDesc() {}
    00290
    00291  protected:
    00292
    00294     AlpsReturnStatus encodeBcpsObject(AlpsEncoded *encoded) const {
    00295         AlpsReturnStatus status = AlpsReturnStatusOk;
    00296         encoded->writeRep(objectIndex_);
    00297         encoded->writeRep(repType_);
    00298         encoded->writeRep(intType_);
    00299         encoded->writeRep(validRegion_);
    00300         encoded->writeRep(status_);
    00301         encoded->writeRep(lbHard_);
    00302         encoded->writeRep(ubHard_);
    00303         encoded->writeRep(lbSoft_);
    00304         encoded->writeRep(ubSoft_);
    00305         encoded->writeRep(hashValue_);
    00306         return status;
    00307     }
    00308
    00310     AlpsReturnStatus decodeBcpsObject(AlpsEncoded &encoded){
    00311         AlpsReturnStatus status = AlpsReturnStatusOk;
    00312         encoded.readRep(objectIndex_);
    00313         encoded.readRep(repType_);
    00314         encoded.readRep(intType_);
    00315         encoded.readRep(validRegion_);
    00316         encoded.readRep(status_);
    00317         encoded.readRep(lbHard_);
    00318         encoded.readRep(ubHard_);
    00319         encoded.readRep(lbSoft_);
    00320         encoded.readRep(ubSoft_);
    00321         encoded.readRep(hashValue_);
    00322         return status;
    00323     }
    00324
    00325 protected:
    00326
    00327  public:
    00328
    00329     using AlpsKnowledge::encode ;
    00331     virtual AlpsReturnStatus encode(AlpsEncoded *encoded) {
    00332         AlpsReturnStatus status = AlpsReturnStatusOk;
    00333         assert(0);
    00334         return status;
    00335     }
    00336
    00338     virtual AlpsKnowledge* decode(AlpsEncoded& encoded) const {
    00339         AlpsKnowledge* know = NULL;
    00340         assert(0);
    00341         return know;
    00342     }
    00343 };
    00344
    00345
    00346 //#############################################################################
    00347
    00348
    00349 typedef BcpsObject*  BcpsObject_p;
    00350
    00351
    00352 //#############################################################################
    00353
    00354
    00355 class BcpsConstraint : public BcpsObject {
    00356
    00357  public:
    00359     BcpsConstraint() : BcpsObject() { setType(BcpsKnowledgeTypeConstraint); }
    00360
    00362     BcpsConstraint(double lbh, double ubh, double lbs, double ubs)
    00363         :
    00364         BcpsObject(lbh, ubh, lbs, ubs)
    00365         { setType(BcpsKnowledgeTypeConstraint); }
    00366
    00368     virtual ~BcpsConstraint() {}
    00369
    00371     BcpsConstraint(const BcpsConstraint & rhs)
    00372         :
    00373         BcpsObject(rhs)
    00374         {}
    00375
    00376     inline virtual BcpsObject_t getObjType() const { return BCPS_CON_OBJECT; }
    00377 };
    00378
    00379
    00380 //#############################################################################
    00381
    00382
    00383 class BcpsVariable : public BcpsObject {
    00384  public:
    00386     BcpsVariable() : BcpsObject() { setType(BcpsKnowledgeTypeVariable); }
    00387
    00389     BcpsVariable(double lbh, double ubh, double lbs, double ubs)
    00390         :
    00391         BcpsObject(lbh, ubh, lbs, ubs)
    00392         { setType(BcpsKnowledgeTypeVariable); }
    00393
    00395     virtual ~BcpsVariable() {}
    00396
    00398     BcpsVariable(const BcpsVariable & rhs)
    00399         :
    00400         BcpsObject(rhs)
    00401         {}
    00402
    00403     inline virtual BcpsObject_t getObjType() const { return BCPS_VAR_OBJECT; }
    00404 };
    00405
    00406
    00407 //#############################################################################
    00408
    00409 #endif