Bcps 0.94.5
Loading...
Searching...
No Matches
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-2017, 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
31class BcpsModel;
33
34//#############################################################################
35
36#define BCPS_NONREMOVALBE 0x0001
37#define BCPS_BRACNEDON 0x0010
38#define BCPS_SENDABLE 0x0100
39
40//#############################################################################
41
45typedef char BcpsIntegral_t;
48//#############################################################################
51//#############################################################################
52
58};
59
60//#############################################################################
62//#############################################################################
63
67 BCPS_ALGO = 2
68};
69
70//#############################################################################
74//#############################################################################
75
76class BcpsObject : public AlpsKnowledge {
77
78 protected:
79
82
85
91
95
97 // branched on? non-removable ? can it be sent to the pool?
98 // do we need it at all?
100
102 double lbHard_;
103
105 double ubHard_;
106
108 double lbSoft_;
109
111 double ubSoft_;
112
115
118
121
122 public:
123
125 :
126 objectIndex_(-1),
128 intType_('C'),
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),
138 {}
139
140 BcpsObject(double lbh, double ubh, double lbs, double ubs)
141 :
142 objectIndex_(-1),
144 intType_('C'),
146 status_(0),
147 lbHard_(lbh),
148 ubHard_(ubh),
149 lbSoft_(lbs),
150 ubSoft_(ubs),
151 hashValue_(0.0),
152 numInactive_(0),
154 {}
155
156 virtual ~BcpsObject() {}
157
159 BcpsObject (const BcpsObject & rhs) {
161 repType_ = rhs.repType_;
162 intType_ = rhs.intType_;
164 status_ = rhs.status_;
165 lbHard_ = rhs.lbHard_;
166 ubHard_ = rhs.ubHard_;
167 lbSoft_ = rhs.lbSoft_;
168 ubSoft_ = rhs.ubSoft_;
172 }
173
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
253 BcpsBranchObject * temp = NULL;
254 return temp;
255 }
256
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
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
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
325protected:
326
327 public:
328
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
350
351
352//#############################################################################
353
354
356
357 public:
360
362 BcpsConstraint(double lbh, double ubh, double lbs, double ubs)
363 :
364 BcpsObject(lbh, ubh, lbs, ubs)
366
368 virtual ~BcpsConstraint() {}
369
372 :
373 BcpsObject(rhs)
374 {}
375
376 inline virtual BcpsObject_t getObjType() const { return BCPS_CON_OBJECT; }
377};
378
379
380//#############################################################################
381
382
383class BcpsVariable : public BcpsObject {
384 public:
387
389 BcpsVariable(double lbh, double ubh, double lbs, double ubs)
390 :
391 BcpsObject(lbh, ubh, lbs, ubs)
393
395 virtual ~BcpsVariable() {}
396
399 :
400 BcpsObject(rhs)
401 {}
402
403 inline virtual BcpsObject_t getObjType() const { return BCPS_VAR_OBJECT; }
404};
405
406
407//#############################################################################
408
409#endif
AlpsReturnStatus
AlpsReturnStatusOk
#define ALPS_DBL_MAX
BcpsObject_t
The possible types of an object: primal or dual (i.e., variable or constraint.
Definition: BcpsObject.h:53
@ BCPS_PRIMAL_OBJECT
Definition: BcpsObject.h:54
@ BCPS_DUAL_OBJECT
Definition: BcpsObject.h:56
@ BCPS_VAR_OBJECT
Definition: BcpsObject.h:55
@ BCPS_CON_OBJECT
Definition: BcpsObject.h:57
BcpsObjRep_t
The possible representations types of an object.
Definition: BcpsObject.h:64
@ BCPS_INDEXED
Definition: BcpsObject.h:66
@ BCPS_ALGO
Definition: BcpsObject.h:67
@ BCPS_CORE
Definition: BcpsObject.h:65
char BcpsIntegral_t
typedef's for various integral types.
Definition: BcpsObject.h:45
BcpsObject * BcpsObject_p
Definition: BcpsObject.h:349
@ BcpsKnowledgeTypeVariable
Definition: Bcps.h:39
@ BcpsKnowledgeTypeConstraint
Definition: Bcps.h:38
BcpsValidRegion
Definition: Bcps.h:44
@ BcpsValidLocal
Definition: Bcps.h:45
AlpsEncoded & readRep(T &value)
AlpsEncoded & writeRep(const T &value)
void setType(KnowledgeType t)
virtual AlpsEncoded * encode() const
BcpsBranchObject contains the member data required when choosing branching entities and excuting actu...
virtual ~BcpsConstraint()
Desctructor constructor.
Definition: BcpsObject.h:368
BcpsConstraint(double lbh, double ubh, double lbs, double ubs)
Useful constructor.
Definition: BcpsObject.h:362
BcpsConstraint(const BcpsConstraint &rhs)
Copy constructor.
Definition: BcpsObject.h:371
BcpsConstraint()
Default constructor.
Definition: BcpsObject.h:359
virtual BcpsObject_t getObjType() const
Definition: BcpsObject.h:376
A class for describing the objects that comprise a BCPS subproblem.
Definition: BcpsObject.h:76
BcpsObject & operator=(const BcpsObject &rhs)
Assignment operator.
virtual bool boundBranch(BcpsModel *m) const
Return true if branches created by object will modify variable bounds.
Definition: BcpsObject.h:275
virtual double downEstimate() const
Return "down" estimate.
Definition: BcpsObject.h:287
BcpsObject(const BcpsObject &rhs)
Copy constructor.
Definition: BcpsObject.h:159
virtual ~BcpsObject()
Definition: BcpsObject.h:156
int getNumInactive() const
Definition: BcpsObject.h:194
void setUbHard(double ub)
Definition: BcpsObject.h:206
void setIntType(BcpsIntegral_t it)
Definition: BcpsObject.h:202
double getLbSoft() const
Definition: BcpsObject.h:192
double ubHard_
The upper bound of the object when it was first created.
Definition: BcpsObject.h:105
virtual BcpsObject * clone() const
Clone an enity.
Definition: BcpsObject.h:178
double lbHard_
The lower bound of the object when it was first created.
Definition: BcpsObject.h:102
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
int getObjectIndex() const
Return the value of the appropriate field.
Definition: BcpsObject.h:185
void setObjectIndex(int ind)
Set the appropriate property.
Definition: BcpsObject.h:200
double effectiveness_
Effectiveness: nonnegative value.
Definition: BcpsObject.h:120
void setStatus(int st)
Definition: BcpsObject.h:204
virtual void floorCeiling(double &floorValue, double &ceilingValue, double value, double tolerance) const
Returns floor and ceiling i.e.
BcpsObjRep_t repType_
Core, indexed, or algorithmic.
Definition: BcpsObject.h:84
virtual void printDesc()
Definition: BcpsObject.h:289
double getUbHard() const
Definition: BcpsObject.h:191
AlpsReturnStatus encodeBcpsObject(AlpsEncoded *encoded) const
Pack Bcps part to a encode object.
Definition: BcpsObject.h:294
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
AlpsReturnStatus decodeBcpsObject(AlpsEncoded &encoded)
Unpack Bcps part from a encode object.
Definition: BcpsObject.h:310
void setValidRegion(BcpsValidRegion val)
Definition: BcpsObject.h:203
double lbSoft_
The current lower bound of the object.
Definition: BcpsObject.h:108
void setLbSoft(double lb)
Definition: BcpsObject.h:207
virtual AlpsKnowledge * decode(AlpsEncoded &encoded) const
Decode a constraint from an encoded object.
Definition: BcpsObject.h:338
int status_
The status of the object.
Definition: BcpsObject.h:99
double hashValue() const
Definition: BcpsObject.h:216
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
int getStatus() const
Definition: BcpsObject.h:189
BcpsIntegral_t getIntType() const
Definition: BcpsObject.h:187
void setEffectiveness(double eff)
Definition: BcpsObject.h:210
double hashValue_
The hash value of this object.
Definition: BcpsObject.h:114
int objectIndex_
Global index of this object.
Definition: BcpsObject.h:81
BcpsValidRegion validRegion_
Valid in the whole tree or only the subtree rooted at the node that generate this object.
Definition: BcpsObject.h:94
void setNumInactive(int num)
Definition: BcpsObject.h:209
double getLbHard() const
Definition: BcpsObject.h:190
double getEffectiveness() const
Definition: BcpsObject.h:195
virtual void feasibleRegion(BcpsModel *m)
Look at the current solution and set bounds to match the solution.
Definition: BcpsObject.h:236
void setUbSoft(double ub)
Definition: BcpsObject.h:208
virtual void resetBounds(BcpsModel *m)
Reset variable bounds to their original values.
Definition: BcpsObject.h:271
void setRepType(BcpsObjRep_t rt)
Definition: BcpsObject.h:201
virtual BcpsBranchObject * createBranchObject(BcpsModel *m, int way) const
Create a branching object and indicate which way to branch first.
Definition: BcpsObject.h:241
BcpsObjRep_t getRepType() const
Definition: BcpsObject.h:186
BcpsObject(double lbh, double ubh, double lbs, double ubs)
Definition: BcpsObject.h:140
BcpsValidRegion getValidRegion() const
Definition: BcpsObject.h:188
void setLbHard(double lb)
Definition: BcpsObject.h:205
virtual double upEstimate() const
Return "up" estimate.
Definition: BcpsObject.h:284
double ubSoft_
The current upper bound of the object.
Definition: BcpsObject.h:111
virtual void hashing(BcpsModel *model=NULL)
Hashing.
Definition: BcpsObject.h:215
virtual AlpsReturnStatus encode(AlpsEncoded *encoded)
Pack into a encode object.
Definition: BcpsObject.h:331
double getUbSoft() const
Definition: BcpsObject.h:193
int numInactive_
Number of inactive when in formulation.
Definition: BcpsObject.h:117
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
BcpsVariable()
Default constructor.
Definition: BcpsObject.h:386
virtual BcpsObject_t getObjType() const
Definition: BcpsObject.h:403
virtual ~BcpsVariable()
Destructor.
Definition: BcpsObject.h:395
BcpsVariable(const BcpsVariable &rhs)
Copy constructor.
Definition: BcpsObject.h:398
BcpsVariable(double lbh, double ubh, double lbs, double ubs)
Useful constructor.
Definition: BcpsObject.h:389