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

- File List
- File Members

BcpsObject.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-2013, Lehigh University, Yan Xu, and Ted Ralphs. *
20 * All Rights Reserved. *
21 *===========================================================================*/
22
23 #ifndef BcpsObject_h_
24 #define BcpsObject_h_
25
26 #include "Alps.h"
27 #include "AlpsKnowledge.h"
28
29 #include "Bcps.h"
30
31 class BcpsModel;
32 class BcpsBranchObject;
33
34 //#############################################################################
35
36 #define BCPS_NONREMOVALBE 0x0001
37 #define BCPS_BRACNEDON 0x0010
38 #define BCPS_SENDABLE 0x0100
39
40 //#############################################################################
41
45 typedef char BcpsIntegral_t;
48 //#############################################################################
51 //#############################################################################
52
53 enum BcpsObject_t {
54 BCPS_PRIMAL_OBJECT = 0,
55 BCPS_VAR_OBJECT = 0,
56 BCPS_DUAL_OBJECT = 1,
57 BCPS_CON_OBJECT = 1
58 };
59
60 //#############################################################################
62 //#############################################################################
63
64 enum BcpsObjRep_t {
65 BCPS_CORE = 0,
66 BCPS_INDEXED = 1,
67 BCPS_ALGO = 2
68 };
69
70 //#############################################################################
74 //#############################################################################
75
76 class BcpsObject : public AlpsKnowledge {
77
78 protected:
79
81 int objectIndex_;
82
84 BcpsObjRep_t repType_;
85
90 BcpsIntegral_t intType_;
91
94 BcpsValidRegion validRegion_;
95
97 // branched on? non-removable ? can it be sent to the pool?
98 // do we need it at all?
99 int status_;
100
102 double lbHard_;
103
105 double ubHard_;
106
108 double lbSoft_;
109
111 double ubSoft_;
112
114 double hashValue_;
115
117 int numInactive_;
118
120 double effectiveness_;
121
122 public:
123
124 BcpsObject()
125 :
126 objectIndex_(-1),
127 repType_(BCPS_CORE),
128 intType_('C'),
129 validRegion_(BcpsValidLocal),
130 status_(0),
131 lbHard_(0.0),
132 ubHard_(0.0),
133 lbSoft_(0.0),
134 ubSoft_(0.0),
135 hashValue_(0.0),
136 numInactive_(0),
137 effectiveness_(-ALPS_DBL_MAX)
138 {}
139
140 BcpsObject(double lbh, double ubh, double lbs, double ubs)
141 :
142 objectIndex_(-1),
143 repType_(BCPS_CORE),
144 intType_('C'),
145 validRegion_(BcpsValidLocal),
146 status_(0),
147 lbHard_(lbh),
148 ubHard_(ubh),
149 lbSoft_(lbs),
150 ubSoft_(ubs),
151 hashValue_(0.0),
152 numInactive_(0),
153 effectiveness_(-ALPS_DBL_MAX)
154 {}
155
156 virtual ~BcpsObject() {}
157
159 BcpsObject (const BcpsObject & rhs) {
160 objectIndex_ = rhs.objectIndex_;
161 repType_ = rhs.repType_;
162 intType_ = rhs.intType_;
163 validRegion_ = rhs.validRegion_,
164 status_ = rhs.status_;
165 lbHard_ = rhs.lbHard_;
166 ubHard_ = rhs.ubHard_;
167 lbSoft_ = rhs.lbSoft_;
168 ubSoft_ = rhs.ubSoft_;
169 hashValue_ = rhs.hashValue_;
170 numInactive_ = rhs.numInactive_;
171 effectiveness_ = rhs.effectiveness_;
172 }
173
175 BcpsObject & operator = ( const BcpsObject& rhs);
176
178 virtual BcpsObject * clone() const {
179 BcpsObject * be = NULL;
180 return be;
181 }
182
185 inline int getObjectIndex() const { return objectIndex_; }
186 inline BcpsObjRep_t getRepType() const { return repType_; }
187 inline BcpsIntegral_t getIntType() const { return intType_; }
188 inline BcpsValidRegion getValidRegion() const { return validRegion_; }
189 inline int getStatus() const { return status_; }
190 inline double getLbHard() const { return lbHard_; }
191 inline double getUbHard() const { return ubHard_; }
192 inline double getLbSoft() const { return lbSoft_; }
193 inline double getUbSoft() const { return ubSoft_; }
194 inline int getNumInactive() const { return numInactive_; }
195 inline double getEffectiveness() const { return effectiveness_; }
200 inline void setObjectIndex(int ind) { objectIndex_ = ind; }
201 inline void setRepType(BcpsObjRep_t rt) { repType_ = rt; }
202 inline void setIntType(BcpsIntegral_t it) { intType_ = it; }
203 inline void setValidRegion(BcpsValidRegion val) { validRegion_ = val;}
204 inline void setStatus(int st) { status_ |= st; }
205 inline void setLbHard(double lb) { lbHard_ = lb; }
206 inline void setUbHard(double ub) { ubHard_ = ub; }
207 inline void setLbSoft(double lb) { lbSoft_ = lb; }
208 inline void setUbSoft(double ub) { ubSoft_ = ub; }
209 inline void setNumInactive(int num) { numInactive_ = num; }
210 inline void setEffectiveness(double eff) { effectiveness_= eff; }
215 virtual void hashing(BcpsModel *model=NULL) { hashValue_ = 0.0; }
216 double hashValue() const { return hashValue_; }
231 virtual double infeasibility(BcpsModel *m, int &preferredWay) const {
232 return 0.0;
233 }
234
236 virtual void feasibleRegion(BcpsModel *m) {}
237
241 virtual BcpsBranchObject * createBranchObject(BcpsModel *m, int way) const{
242 BcpsBranchObject *be = NULL;
243 return be;
244 }
245
252 virtual BcpsBranchObject * preferredNewFeasible(BcpsModel *m) const {
253 BcpsBranchObject * temp = NULL;
254 return temp;
255 }
256
263 virtual BcpsBranchObject * notPreferredNewFeasible(BcpsModel *m) const {
264 BcpsBranchObject * temp = NULL;
265 return temp;
266 }
267
271 virtual void resetBounds(BcpsModel *m) {}
272
275 virtual bool boundBranch(BcpsModel *m) const { return true; }
276
278 virtual void floorCeiling(double &floorValue,
279 double &ceilingValue,
280 double value,
281 double tolerance) const;
282
284 virtual double upEstimate() const { return 1.0e-5; }
285
287 virtual double downEstimate() const { return 1.0e-5; }
288
289 virtual void printDesc() {}
290
291 protected:
292
294 AlpsReturnStatus encodeBcpsObject(AlpsEncoded *encoded) const {
295 AlpsReturnStatus status = AlpsReturnStatusOk;
296 encoded->writeRep(objectIndex_);
297 encoded->writeRep(repType_);
298 encoded->writeRep(intType_);
299 encoded->writeRep(validRegion_);
300 encoded->writeRep(status_);
301 encoded->writeRep(lbHard_);
302 encoded->writeRep(ubHard_);
303 encoded->writeRep(lbSoft_);
304 encoded->writeRep(ubSoft_);
305 encoded->writeRep(hashValue_);
306 return status;
307 }
308
310 AlpsReturnStatus decodeBcpsObject(AlpsEncoded &encoded){
311 AlpsReturnStatus status = AlpsReturnStatusOk;
312 encoded.readRep(objectIndex_);
313 encoded.readRep(repType_);
314 encoded.readRep(intType_);
315 encoded.readRep(validRegion_);
316 encoded.readRep(status_);
317 encoded.readRep(lbHard_);
318 encoded.readRep(ubHard_);
319 encoded.readRep(lbSoft_);
320 encoded.readRep(ubSoft_);
321 encoded.readRep(hashValue_);
322 return status;
323 }
324
325 protected:
326
327 public:
328
329 using AlpsKnowledge::encode ;
331 virtual AlpsReturnStatus encode(AlpsEncoded *encoded) {
332 AlpsReturnStatus status = AlpsReturnStatusOk;
333 assert(0);
334 return status;
335 }
336
338 virtual AlpsKnowledge* decode(AlpsEncoded& encoded) const {
339 AlpsKnowledge* know = NULL;
340 assert(0);
341 return know;
342 }
343 };
344
345
346 //#############################################################################
347
348
349 typedef BcpsObject* BcpsObject_p;
350
351
352 //#############################################################################
353
354
355 class BcpsConstraint : public BcpsObject {
356
357 public:
359 BcpsConstraint() : BcpsObject() { setType(BcpsKnowledgeTypeConstraint); }
360
362 BcpsConstraint(double lbh, double ubh, double lbs, double ubs)
363 :
364 BcpsObject(lbh, ubh, lbs, ubs)
365 { setType(BcpsKnowledgeTypeConstraint); }
366
368 virtual ~BcpsConstraint() {}
369
371 BcpsConstraint(const BcpsConstraint & rhs)
372 :
373 BcpsObject(rhs)
374 {}
375
376 inline virtual BcpsObject_t getObjType() const { return BCPS_CON_OBJECT; }
377 };
378
379
380 //#############################################################################
381
382
383 class BcpsVariable : public BcpsObject {
384 public:
386 BcpsVariable() : BcpsObject() { setType(BcpsKnowledgeTypeVariable); }
387
389 BcpsVariable(double lbh, double ubh, double lbs, double ubs)
390 :
391 BcpsObject(lbh, ubh, lbs, ubs)
392 { setType(BcpsKnowledgeTypeVariable); }
393
395 virtual ~BcpsVariable() {}
396
398 BcpsVariable(const BcpsVariable & rhs)
399 :
400 BcpsObject(rhs)
401 {}
402
403 inline virtual BcpsObject_t getObjType() const { return BCPS_VAR_OBJECT; }
404 };
405
406
407 //#############################################################################
408
409 #endif
BcpsObject::repType_
BcpsObjRep_t repType_
Core, indexed, or algorithmic.
Definition: BcpsObject.h:84
BcpsObject::objectIndex_
int objectIndex_
Global index of this object.
Definition: BcpsObject.h:81
BcpsObject::getIntType
BcpsIntegral_t getIntType() const
Return the value of the appropriate field.
Definition: BcpsObject.h:187
BcpsObject::setUbHard
void setUbHard(double ub)
Set the appropriate property.
Definition: BcpsObject.h:206
BcpsObject::ubHard_
double ubHard_
The upper bound of the object when it was first created.
Definition: BcpsObject.h:105
BcpsVariable::BcpsVariable
BcpsVariable(const BcpsVariable &rhs)
Copy constructor.
Definition: BcpsObject.h:398
BcpsObject::decode
virtual AlpsKnowledge * decode(AlpsEncoded &encoded) const
Decode a constraint from an encoded object.
Definition: BcpsObject.h:338
BcpsObject::BcpsObject
BcpsObject()
Definition: BcpsObject.h:124
BcpsObject::preferredNewFeasible
virtual BcpsBranchObject * preferredNewFeasible(BcpsModel *m) const
Given a valid solution (with reduced costs, etc.), return a branching object which would give a new f...
Definition: BcpsObject.h:252
AlpsEncoded::readRep
AlpsEncoded & readRep(T &value)
Read a single object of type T from repsentation_ .
Definition: AlpsEncoded.h:173
AlpsEncoded::writeRep
AlpsEncoded & writeRep(const T &value)
Write a single object of type T in repsentation_ .
Definition: AlpsEncoded.h:163
BcpsObject::setValidRegion
void setValidRegion(BcpsValidRegion val)
Set the appropriate property.
Definition: BcpsObject.h:203
BcpsValidRegion
BcpsValidRegion
Definition: Bcps.h:44
BcpsObject::setEffectiveness
void setEffectiveness(double eff)
Set the appropriate property.
Definition: BcpsObject.h:210
BcpsObject::setUbSoft
void setUbSoft(double ub)
Set the appropriate property.
Definition: BcpsObject.h:208
BcpsVariable::BcpsVariable
BcpsVariable()
Default constructor.
Definition: BcpsObject.h:386
BCPS_ALGO
Definition: BcpsObject.h:67
BcpsObject::infeasibility
virtual double infeasibility(BcpsModel *m, int &preferredWay) const
Infeasibility of the object This is some measure of the infeasibility of the object.
Definition: BcpsObject.h:231
BcpsObject::getValidRegion
BcpsValidRegion getValidRegion() const
Return the value of the appropriate field.
Definition: BcpsObject.h:188
BcpsObject::setNumInactive
void setNumInactive(int num)
Set the appropriate property.
Definition: BcpsObject.h:209
BCPS_PRIMAL_OBJECT
Definition: BcpsObject.h:54
AlpsReturnStatus
AlpsReturnStatus
Definition: Alps.h:118
BCPS_CORE
Definition: BcpsObject.h:65
BcpsObject::boundBranch
virtual bool boundBranch(BcpsModel *m) const
Return true if branches created by object will modify variable bounds.
Definition: BcpsObject.h:275
BcpsObject::getEffectiveness
double getEffectiveness() const
Return the value of the appropriate field.
Definition: BcpsObject.h:195
BcpsObject::BcpsObject
BcpsObject(double lbh, double ubh, double lbs, double ubs)
Definition: BcpsObject.h:140
BcpsObject::notPreferredNewFeasible
virtual BcpsBranchObject * notPreferredNewFeasible(BcpsModel *m) const
Given a valid solution (with reduced costs, etc.), return a branching object which would give a new f...
Definition: BcpsObject.h:263
BcpsObject::downEstimate
virtual double downEstimate() const
Return &quot;down&quot; estimate.
Definition: BcpsObject.h:287
BcpsVariable
Definition: BcpsObject.h:383
BcpsObject::createBranchObject
virtual BcpsBranchObject * createBranchObject(BcpsModel *m, int way) const
Create a branching object and indicate which way to branch first.
Definition: BcpsObject.h:241
BcpsVariable::BcpsVariable
BcpsVariable(double lbh, double ubh, double lbs, double ubs)
Useful constructor.
Definition: BcpsObject.h:389
BcpsObject::operator=
BcpsObject & operator=(const BcpsObject &rhs)
Assignment operator.
BcpsObject
A class for describing the objects that comprise a BCPS subproblem.
Definition: BcpsObject.h:76
BcpsConstraint::BcpsConstraint
BcpsConstraint()
Default constructor.
Definition: BcpsObject.h:359
BcpsIntegral_t
char BcpsIntegral_t
typedef&#39;s for various integral types.
Definition: BcpsObject.h:45
ALPS_DBL_MAX
#define ALPS_DBL_MAX
Definition: Alps.h:143
BcpsObject::floorCeiling
virtual void floorCeiling(double &floorValue, double &ceilingValue, double value, double tolerance) const
Returns floor and ceiling i.e.
BcpsBranchObject
BcpsBranchObject contains the member data required when choosing branching entities and excuting actu...
Definition: BcpsBranchObject.h:47
BcpsObject::resetBounds
virtual void resetBounds(BcpsModel *m)
Reset variable bounds to their original values.
Definition: BcpsObject.h:271
BcpsObject_p
BcpsObject * BcpsObject_p
Definition: BcpsObject.h:349
BcpsObject::~BcpsObject
virtual ~BcpsObject()
Definition: BcpsObject.h:156
BcpsVariable::~BcpsVariable
virtual ~BcpsVariable()
Destructor.
Definition: BcpsObject.h:395
AlpsEncoded
This data structure is to contain the packed form of an encodable knowledge.
Definition: AlpsEncoded.h:25
Bcps.h
BcpsObject::getLbHard
double getLbHard() const
Return the value of the appropriate field.
Definition: BcpsObject.h:190
AlpsReturnStatusOk
Definition: Alps.h:119
BcpsObject::getUbSoft
double getUbSoft() const
Return the value of the appropriate field.
Definition: BcpsObject.h:193
BcpsConstraint
Definition: BcpsObject.h:355
Alps.h
BcpsObject::getObjectIndex
int getObjectIndex() const
Return the value of the appropriate field.
Definition: BcpsObject.h:185
BcpsObject::getRepType
BcpsObjRep_t getRepType() const
Return the value of the appropriate field.
Definition: BcpsObject.h:186
BcpsObject::getNumInactive
int getNumInactive() const
Return the value of the appropriate field.
Definition: BcpsObject.h:194
BcpsObject_t
BcpsObject_t
The possible types of an object: primal or dual (i.e., variable or constraint.
Definition: BcpsObject.h:53
BcpsKnowledgeTypeVariable
Definition: Bcps.h:39
BcpsObject::getLbSoft
double getLbSoft() const
Return the value of the appropriate field.
Definition: BcpsObject.h:192
BcpsObject::effectiveness_
double effectiveness_
Effectiveness: nonnegative value.
Definition: BcpsObject.h:120
BcpsObjRep_t
BcpsObjRep_t
The possible representations types of an object.
Definition: BcpsObject.h:64
BcpsObject::upEstimate
virtual double upEstimate() const
Return &quot;up&quot; estimate.
Definition: BcpsObject.h:284
BcpsValidLocal
Definition: Bcps.h:45
BcpsModel
Definition: BcpsModel.h:40
BcpsObject::getUbHard
double getUbHard() const
Return the value of the appropriate field.
Definition: BcpsObject.h:191
BcpsVariable::getObjType
virtual BcpsObject_t getObjType() const
Definition: BcpsObject.h:403
BcpsObject::encodeBcpsObject
AlpsReturnStatus encodeBcpsObject(AlpsEncoded *encoded) const
Pack Bcps part to a encode object.
Definition: BcpsObject.h:294
BcpsObject::lbSoft_
double lbSoft_
The current lower bound of the object.
Definition: BcpsObject.h:108
AlpsKnowledge.h
BcpsObject::intType_
BcpsIntegral_t intType_
The integrality type of the object, i.e., what values it can take up between the specified bounds...
Definition: BcpsObject.h:90
BcpsObject::hashing
virtual void hashing(BcpsModel *model=NULL)
Hashing.
Definition: BcpsObject.h:215
AlpsKnowledge
The abstract base class of any user-defined class that Alps has to know about in order to encode/deco...
Definition: AlpsKnowledge.h:51
BcpsObject::setIntType
void setIntType(BcpsIntegral_t it)
Set the appropriate property.
Definition: BcpsObject.h:202
BcpsObject::printDesc
virtual void printDesc()
Definition: BcpsObject.h:289
BcpsObject::validRegion_
BcpsValidRegion validRegion_
Valid in the whole tree or only the subtree rooted at the node that generate this object...
Definition: BcpsObject.h:94
BcpsConstraint::getObjType
virtual BcpsObject_t getObjType() const
Definition: BcpsObject.h:376
BCPS_DUAL_OBJECT
Definition: BcpsObject.h:56
BcpsObject::lbHard_
double lbHard_
The lower bound of the object when it was first created.
Definition: BcpsObject.h:102
BCPS_INDEXED
Definition: BcpsObject.h:66
BcpsObject::status_
int status_
The status of the object.
Definition: BcpsObject.h:99
BcpsObject::feasibleRegion
virtual void feasibleRegion(BcpsModel *m)
Look at the current solution and set bounds to match the solution.
Definition: BcpsObject.h:236
BcpsConstraint::~BcpsConstraint
virtual ~BcpsConstraint()
Desctructor constructor.
Definition: BcpsObject.h:368
BcpsConstraint::BcpsConstraint
BcpsConstraint(const BcpsConstraint &rhs)
Copy constructor.
Definition: BcpsObject.h:371
BcpsObject::BcpsObject
BcpsObject(const BcpsObject &rhs)
Copy constructor.
Definition: BcpsObject.h:159
BcpsObject::setStatus
void setStatus(int st)
Set the appropriate property.
Definition: BcpsObject.h:204
BcpsKnowledgeTypeConstraint
Definition: Bcps.h:38
BcpsObject::setRepType
void setRepType(BcpsObjRep_t rt)
Set the appropriate property.
Definition: BcpsObject.h:201
BcpsObject::hashValue_
double hashValue_
The hash value of this object.
Definition: BcpsObject.h:114
BcpsObject::setObjectIndex
void setObjectIndex(int ind)
Set the appropriate property.
Definition: BcpsObject.h:200
BcpsObject::getStatus
int getStatus() const
Return the value of the appropriate field.
Definition: BcpsObject.h:189
BcpsObject::decodeBcpsObject
AlpsReturnStatus decodeBcpsObject(AlpsEncoded &encoded)
Unpack Bcps part from a encode object.
Definition: BcpsObject.h:310
BCPS_CON_OBJECT
Definition: BcpsObject.h:57
BCPS_VAR_OBJECT
Definition: BcpsObject.h:55
BcpsConstraint::BcpsConstraint
BcpsConstraint(double lbh, double ubh, double lbs, double ubs)
Useful constructor.
Definition: BcpsObject.h:362
AlpsKnowledge::encode
virtual AlpsEncoded * encode() const
This method should encode the content of the object and return a pointer to the encoded form...
BcpsObject::setLbHard
void setLbHard(double lb)
Set the appropriate property.
Definition: BcpsObject.h:205
BcpsObject::clone
virtual BcpsObject * clone() const
Clone an enity.
Definition: BcpsObject.h:178
BcpsObject::ubSoft_
double ubSoft_
The current upper bound of the object.
Definition: BcpsObject.h:111
BcpsObject::setLbSoft
void setLbSoft(double lb)
Set the appropriate property.
Definition: BcpsObject.h:207
AlpsKnowledge::setType
void setType(KnowledgeType t)
Definition: AlpsKnowledge.h:72
BcpsObject::encode
virtual AlpsReturnStatus encode(AlpsEncoded *encoded)
Pack into a encode object.
Definition: BcpsObject.h:331
BcpsObject::hashValue
double hashValue() const
Hashing.
Definition: BcpsObject.h:216
BcpsObject::numInactive_
int numInactive_
Number of inactive when in formulation.
Definition: BcpsObject.h:117