Bcps 0.95.1
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-2023, 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 "BcpsConfig.h"
30#include "Bcps.h"
31
32class BcpsModel;
34
35//#############################################################################
36
37#define BCPS_NONREMOVALBE 0x0001
38#define BCPS_BRACNEDON 0x0010
39#define BCPS_SENDABLE 0x0100
40
41//#############################################################################
42
46typedef char BcpsIntegral_t;
48
49//#############################################################################
52//#############################################################################
53
60
61//#############################################################################
63//#############################################################################
64
70
71//#############################################################################
75//#############################################################################
76
77class BCPSLIB_EXPORT BcpsObject : public AlpsKnowledge {
78
79 protected:
80
83
86
92
96
98 // branched on? non-removable ? can it be sent to the pool?
99 // do we need it at all?
101
103 double lbHard_;
104
106 double ubHard_;
107
109 double lbSoft_;
110
112 double ubSoft_;
113
116
119
122
123 public:
124
126 :
127 objectIndex_(-1),
129 intType_('C'),
131 status_(0),
132 lbHard_(0.0),
133 ubHard_(0.0),
134 lbSoft_(0.0),
135 ubSoft_(0.0),
136 hashValue_(0.0),
137 numInactive_(0),
138 effectiveness_(-ALPS_DBL_MAX)
139 {}
140
141 BcpsObject(double lbh, double ubh, double lbs, double ubs)
142 :
143 objectIndex_(-1),
145 intType_('C'),
147 status_(0),
148 lbHard_(lbh),
149 ubHard_(ubh),
150 lbSoft_(lbs),
151 ubSoft_(ubs),
152 hashValue_(0.0),
153 numInactive_(0),
154 effectiveness_(-ALPS_DBL_MAX)
155 {}
156
157 virtual ~BcpsObject() {}
158
160 BcpsObject (const BcpsObject & rhs) {
162 repType_ = rhs.repType_;
163 intType_ = rhs.intType_;
165 status_ = rhs.status_;
166 lbHard_ = rhs.lbHard_;
167 ubHard_ = rhs.ubHard_;
168 lbSoft_ = rhs.lbSoft_;
169 ubSoft_ = rhs.ubSoft_;
173 }
174
176 BcpsObject & operator = ( const BcpsObject& rhs);
177
179 virtual BcpsObject * clone() const {
180 BcpsObject * be = NULL;
181 return be;
182 }
183
186 inline int getObjectIndex() const { return objectIndex_; }
187 inline BcpsObjRep_t getRepType() const { return repType_; }
188 inline BcpsIntegral_t getIntType() const { return intType_; }
189 inline BcpsValidRegion getValidRegion() const { return validRegion_; }
190 inline int getStatus() const { return status_; }
191 inline double getLbHard() const { return lbHard_; }
192 inline double getUbHard() const { return ubHard_; }
193 inline double getLbSoft() const { return lbSoft_; }
194 inline double getUbSoft() const { return ubSoft_; }
195 inline int getNumInactive() const { return numInactive_; }
196 inline double getEffectiveness() const { return effectiveness_; }
198
201 inline void setObjectIndex(int ind) { objectIndex_ = ind; }
202 inline void setRepType(BcpsObjRep_t rt) { repType_ = rt; }
203 inline void setIntType(BcpsIntegral_t it) { intType_ = it; }
204 inline void setValidRegion(BcpsValidRegion val) { validRegion_ = val;}
205 inline void setStatus(int st) { status_ |= st; }
206 inline void setLbHard(double lb) { lbHard_ = lb; }
207 inline void setUbHard(double ub) { ubHard_ = ub; }
208 inline void setLbSoft(double lb) { lbSoft_ = lb; }
209 inline void setUbSoft(double ub) { ubSoft_ = ub; }
210 inline void setNumInactive(int num) { numInactive_ = num; }
211 inline void setEffectiveness(double eff) { effectiveness_= eff; }
213
216 virtual void hashing(BcpsModel *model=NULL) { hashValue_ = 0.0; }
217 double hashValue() const { return hashValue_; }
219
232 virtual double infeasibility(BcpsModel *m, int &preferredWay) const {
233 return 0.0;
234 }
235
237 virtual void feasibleRegion(BcpsModel *m) {}
238
242 virtual BcpsBranchObject * createBranchObject(BcpsModel *m, int way) const{
243 BcpsBranchObject *be = NULL;
244 return be;
245 }
246
254 BcpsBranchObject * temp = NULL;
255 return temp;
256 }
257
265 BcpsBranchObject * temp = NULL;
266 return temp;
267 }
268
272 virtual void resetBounds(BcpsModel *m) {}
273
276 virtual bool boundBranch(BcpsModel *m) const { return true; }
277
279 virtual void floorCeiling(double &floorValue,
280 double &ceilingValue,
281 double value,
282 double tolerance) const;
283
285 virtual double upEstimate() const { return 1.0e-5; }
286
288 virtual double downEstimate() const { return 1.0e-5; }
289
290 virtual void printDesc() {}
291
292 protected:
293
295 AlpsReturnStatus encodeBcpsObject(AlpsEncoded *encoded) const {
296 AlpsReturnStatus status = AlpsReturnStatusOk;
297 encoded->writeRep(objectIndex_);
298 encoded->writeRep(repType_);
299 encoded->writeRep(intType_);
300 encoded->writeRep(validRegion_);
301 encoded->writeRep(status_);
302 encoded->writeRep(lbHard_);
303 encoded->writeRep(ubHard_);
304 encoded->writeRep(lbSoft_);
305 encoded->writeRep(ubSoft_);
306 encoded->writeRep(hashValue_);
307 return status;
308 }
309
311 AlpsReturnStatus decodeBcpsObject(AlpsEncoded &encoded){
312 AlpsReturnStatus status = AlpsReturnStatusOk;
313 encoded.readRep(objectIndex_);
314 encoded.readRep(repType_);
315 encoded.readRep(intType_);
316 encoded.readRep(validRegion_);
317 encoded.readRep(status_);
318 encoded.readRep(lbHard_);
319 encoded.readRep(ubHard_);
320 encoded.readRep(lbSoft_);
321 encoded.readRep(ubSoft_);
322 encoded.readRep(hashValue_);
323 return status;
324 }
325
326protected:
327
328 public:
329
330 using AlpsKnowledge::encode ;
332 virtual AlpsReturnStatus encode(AlpsEncoded *encoded) {
333 AlpsReturnStatus status = AlpsReturnStatusOk;
334 assert(0);
335 return status;
336 }
337
339 virtual AlpsKnowledge* decode(AlpsEncoded& encoded) const {
340 AlpsKnowledge* know = NULL;
341 assert(0);
342 return know;
343 }
344};
345
346
347//#############################################################################
348
349
351
352
353//#############################################################################
354
355
357
358 public:
361
363 BcpsConstraint(double lbh, double ubh, double lbs, double ubs)
364 :
365 BcpsObject(lbh, ubh, lbs, ubs)
366 { setType(BcpsKnowledgeTypeConstraint); }
367
369 virtual ~BcpsConstraint() {}
370
373 :
374 BcpsObject(rhs)
375 {}
376
377 inline virtual BcpsObject_t getObjType() const { return BCPS_CON_OBJECT; }
378};
379
380
381//#############################################################################
382
383
385 public:
388
390 BcpsVariable(double lbh, double ubh, double lbs, double ubs)
391 :
392 BcpsObject(lbh, ubh, lbs, ubs)
393 { setType(BcpsKnowledgeTypeVariable); }
394
396 virtual ~BcpsVariable() {}
397
400 :
401 BcpsObject(rhs)
402 {}
403
404 inline virtual BcpsObject_t getObjType() const { return BCPS_VAR_OBJECT; }
405};
406
407
408//#############################################################################
409
410#endif
BcpsObject_t
The possible types of an object: primal or dual (i.e., variable or constraint.
Definition BcpsObject.h:54
@ BCPS_PRIMAL_OBJECT
Definition BcpsObject.h:55
@ BCPS_DUAL_OBJECT
Definition BcpsObject.h:57
@ BCPS_VAR_OBJECT
Definition BcpsObject.h:56
@ BCPS_CON_OBJECT
Definition BcpsObject.h:58
BcpsObjRep_t
The possible representations types of an object.
Definition BcpsObject.h:65
@ BCPS_INDEXED
Definition BcpsObject.h:67
@ BCPS_ALGO
Definition BcpsObject.h:68
@ BCPS_CORE
Definition BcpsObject.h:66
char BcpsIntegral_t
typedef's for various integral types.
Definition BcpsObject.h:46
BcpsObject * BcpsObject_p
Definition BcpsObject.h:350
@ BcpsKnowledgeTypeVariable
Definition Bcps.h:39
@ BcpsKnowledgeTypeConstraint
Definition Bcps.h:38
BcpsValidRegion
Definition Bcps.h:44
@ BcpsValidLocal
Definition Bcps.h:45
BcpsBranchObject contains the member data required when choosing branching entities and excuting actu...
virtual ~BcpsConstraint()
Desctructor constructor.
Definition BcpsObject.h:369
BcpsConstraint(double lbh, double ubh, double lbs, double ubs)
Useful constructor.
Definition BcpsObject.h:363
BcpsConstraint(const BcpsConstraint &rhs)
Copy constructor.
Definition BcpsObject.h:372
BcpsConstraint()
Default constructor.
Definition BcpsObject.h:360
virtual BcpsObject_t getObjType() const
Definition BcpsObject.h:377
A class for describing the objects that comprise a BCPS subproblem.
Definition BcpsObject.h:77
virtual bool boundBranch(BcpsModel *m) const
Return true if branches created by object will modify variable bounds.
Definition BcpsObject.h:276
virtual double downEstimate() const
Return "down" estimate.
Definition BcpsObject.h:288
BcpsObject(const BcpsObject &rhs)
Copy constructor.
Definition BcpsObject.h:160
virtual ~BcpsObject()
Definition BcpsObject.h:157
int getNumInactive() const
Definition BcpsObject.h:195
void setUbHard(double ub)
Definition BcpsObject.h:207
void setIntType(BcpsIntegral_t it)
Definition BcpsObject.h:203
double getLbSoft() const
Definition BcpsObject.h:193
double ubHard_
The upper bound of the object when it was first created.
Definition BcpsObject.h:106
virtual BcpsObject * clone() const
Clone an enity.
Definition BcpsObject.h:179
double lbHard_
The lower bound of the object when it was first created.
Definition BcpsObject.h:103
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:253
int getObjectIndex() const
Return the value of the appropriate field.
Definition BcpsObject.h:186
void setObjectIndex(int ind)
Set the appropriate property.
Definition BcpsObject.h:201
double effectiveness_
Effectiveness: nonnegative value.
Definition BcpsObject.h:121
void setStatus(int st)
Definition BcpsObject.h:205
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:85
virtual void printDesc()
Definition BcpsObject.h:290
double getUbHard() const
Definition BcpsObject.h:192
AlpsReturnStatus encodeBcpsObject(AlpsEncoded *encoded) const
Pack Bcps part to a encode object.
Definition BcpsObject.h:295
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:264
AlpsReturnStatus decodeBcpsObject(AlpsEncoded &encoded)
Unpack Bcps part from a encode object.
Definition BcpsObject.h:311
void setValidRegion(BcpsValidRegion val)
Definition BcpsObject.h:204
double lbSoft_
The current lower bound of the object.
Definition BcpsObject.h:109
void setLbSoft(double lb)
Definition BcpsObject.h:208
virtual AlpsKnowledge * decode(AlpsEncoded &encoded) const
Decode a constraint from an encoded object.
Definition BcpsObject.h:339
int status_
The status of the object.
Definition BcpsObject.h:100
double hashValue() const
Definition BcpsObject.h:217
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:232
int getStatus() const
Definition BcpsObject.h:190
BcpsIntegral_t getIntType() const
Definition BcpsObject.h:188
void setEffectiveness(double eff)
Definition BcpsObject.h:211
double hashValue_
The hash value of this object.
Definition BcpsObject.h:115
int objectIndex_
Global index of this object.
Definition BcpsObject.h:82
BcpsValidRegion validRegion_
Valid in the whole tree or only the subtree rooted at the node that generate this object.
Definition BcpsObject.h:95
void setNumInactive(int num)
Definition BcpsObject.h:210
double getLbHard() const
Definition BcpsObject.h:191
double getEffectiveness() const
Definition BcpsObject.h:196
virtual void feasibleRegion(BcpsModel *m)
Look at the current solution and set bounds to match the solution.
Definition BcpsObject.h:237
void setUbSoft(double ub)
Definition BcpsObject.h:209
virtual void resetBounds(BcpsModel *m)
Reset variable bounds to their original values.
Definition BcpsObject.h:272
void setRepType(BcpsObjRep_t rt)
Definition BcpsObject.h:202
virtual BcpsBranchObject * createBranchObject(BcpsModel *m, int way) const
Create a branching object and indicate which way to branch first.
Definition BcpsObject.h:242
BcpsObjRep_t getRepType() const
Definition BcpsObject.h:187
BcpsObject(double lbh, double ubh, double lbs, double ubs)
Definition BcpsObject.h:141
BcpsValidRegion getValidRegion() const
Definition BcpsObject.h:189
void setLbHard(double lb)
Definition BcpsObject.h:206
virtual double upEstimate() const
Return "up" estimate.
Definition BcpsObject.h:285
double ubSoft_
The current upper bound of the object.
Definition BcpsObject.h:112
virtual void hashing(BcpsModel *model=NULL)
Hashing.
Definition BcpsObject.h:216
virtual AlpsReturnStatus encode(AlpsEncoded *encoded)
Pack into a encode object.
Definition BcpsObject.h:332
double getUbSoft() const
Definition BcpsObject.h:194
int numInactive_
Number of inactive when in formulation.
Definition BcpsObject.h:118
BcpsIntegral_t intType_
The integrality type of the object, i.e., what values it can take up between the specified bounds.
Definition BcpsObject.h:91
BcpsVariable()
Default constructor.
Definition BcpsObject.h:387
virtual BcpsObject_t getObjType() const
Definition BcpsObject.h:404
virtual ~BcpsVariable()
Destructor.
Definition BcpsObject.h:396
BcpsVariable(const BcpsVariable &rhs)
Copy constructor.
Definition BcpsObject.h:399
BcpsVariable(double lbh, double ubh, double lbs, double ubs)
Useful constructor.
Definition BcpsObject.h:390
#define BCPSLIB_EXPORT
Definition config.h:5