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

- File List
- File Members

BcpsNodeDesc.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 BcpsNodeDesc_h_
24 #define BcpsNodeDesc_h_
25
26 #include "BcpsModel.h"
27
28 #include "Alps.h"
29 #include "AlpsNodeDesc.h"
30
31 #include "BcpsObject.h"
32
33
34 //#############################################################################
35
39 template <class T> struct BcpsFieldListMod {
44 bool relative;
45
47 int numModify;
48
50 int* posModify;
51
53 T* entries;
54 };
55
56
57 //#############################################################################
58
59
66 struct BcpsObjectListMod {
67
70 int numRemove;
71
73 int* posRemove;
74
76 int numAdd;
78 BcpsObject **objects;
79
83 BcpsFieldListMod<double> lbHard;
84 BcpsFieldListMod<double> ubHard;
85 BcpsFieldListMod<double> lbSoft;
86 BcpsFieldListMod<double> ubSoft;
87 BcpsFieldListMod<int> status;
89 };
90
91
92 //#############################################################################
93
119 //#############################################################################
120
128 class BcpsNodeDesc : public AlpsNodeDesc {
129
130 protected:
131
133 BcpsObjectListMod *vars_;
134
136 BcpsObjectListMod *cons_;
137
138 public:
139
141 BcpsNodeDesc() { initToNull(); }
142
144 BcpsNodeDesc(BcpsModel* m)
145 :
146 AlpsNodeDesc(m) { initToNull(); }
147
149 virtual ~BcpsNodeDesc();
150
152 void initToNull();
153
155 void setVars(int numRem,
156 const int *posRem,
157 int numAdd,
158 const BcpsObject **objects,
159 bool relvlh,
160 int numvlh,
161 const int *vlhp,
162 const double *vlhe,
163 bool relvuh,
164 int numvuh,
165 const int *vuhp,
166 const double *vuhe,
167 bool relvls,
168 int numvls,
169 const int *vlsp,
170 const double *vlse,
171 bool relvus,
172 int numvus,
173 const int *vusp,
174 const double *vuse);
175
177 void assignVars(int numRem,
178 int *&posRem,
179 int numAdd,
180 BcpsObject **&objects,
181 bool relvlh,
182 int numvlh,
183 int *&vlhp,
184 double *&vlhe,
185 bool relvuh,
186 int numvuh,
187 int *&vuhp,
188 double *&vuhe,
189 bool relvls,
190 int numvls,
191 int *&vlsp,
192 double *&vlse,
193 bool relvus,
194 int numvus,
195 int *&vusp,
196 double *&vuse);
197
199 void setCons(int numRem,
200 const int *posRem,
201 int numAdd,
202 const BcpsObject **objects,
203 bool relclh,
204 int numclh,
205 const int *clhp,
206 const double *clhe,
207 bool relcuh,
208 int numcuh,
209 const int *cuhp,
210 const double *cuhe,
211 bool relcls,
212 int numcls,
213 const int *clsp,
214 const double *clse,
215 bool relcus,
216 int numcus,
217 const int *cusp,
218 const double *cuse);
219
221 void assignCons(int numRem,
222 int *&posRem,
223 int numAdd,
224 BcpsObject **&objects,
225 bool relclh,
226 int numclh,
227 int *&clhp,
228 double *&clhe,
229 bool relcuh,
230 int numcuh,
231 int *&cuhp,
232 double *&cuhe,
233 bool relcls,
234 int numcls,
235 int *&clsp,
236 double *&clse,
237 bool relcus,
238 int numcus,
239 int *&cusp,
240 double *&cuse);
241
243 BcpsObjectListMod *getVars() const { return vars_; }
244
246 BcpsObjectListMod *getCons() const { return cons_; }
247
249 BcpsObjectListMod *vars() { return vars_; }
250
252 BcpsObjectListMod *cons() { return cons_; }
253
255 void assignVarSoftBound(int numModSoftVarLB,
256 int *&varLBi,
257 double *&varLBv,
258 int numModSoftVarUB,
259 int *&varUBi,
260 double *&varUBv);
261
263 void setVarSoftBound(int numModSoftVarLB,
264 const int *varLBi,
265 const double *varLBv,
266 int numModSoftVarUB,
267 const int *varUBi,
268 const double *varUBv);
269
271 void assignVarHardBound(int numModHardVarLB,
272 int *&varLBi,
273 double *&varLBv,
274 int numModHardVarUB,
275 int *&varUBi,
276 double *&varUBv);
277
279 void setConSoftBound(int numModSoftConLB,
280 const int *conLBi,
281 const double *conLBv,
282 int numModSoftConUB,
283 const int *conUBi,
284 const double *conUBv);
285
287 void setVarHardBound(int numModHardVarLB,
288 const int *varLBi,
289 const double *varLBv,
290 int numModHardVarUB,
291 const int *varUBi,
292 const double *varUBv);
293
295 void setConHardBound(int numModHardConLB,
296 const int *conLBi,
297 const double *conLBv,
298 int numModHardConUB,
299 const int *conUBi,
300 const double *conUBv);
301
304 void appendAddedConstraints(int numAdd, BcpsObject **addCons){
305 int numAll = numAdd + cons_->numAdd;
306 BcpsObject ** allAdd = new BcpsObject* [numAll];
307 int k;
308
309 for (k = 0; k < cons_->numAdd; ++k) {
310 allAdd[k] = cons_->objects[k];
311 }
312 for (k = 0; k < numAdd; ++k) {
313 allAdd[(k+cons_->numAdd)] = addCons[k];
314 }
315
316 delete [] cons_->objects;
317 cons_->numAdd = numAll;
318 cons_->objects = allAdd;
319 }
320
323 void setAddedConstraints(int numAdd, BcpsObject **addCons){
324 // NOTE: make sure objects can be safely deleted.
325 if (cons_->objects) {
326 for (int k = 0; k < cons_->numAdd; ++k) {
327 delete cons_->objects[k];
328 }
329 delete [] cons_->objects;
330 }
331 cons_->numAdd = numAdd;
332 cons_->objects = addCons;
333 }
334
337 void delConstraints(int numDel, int *indices){
338 if ( cons_->posRemove) delete [] cons_->posRemove;
339 cons_->numRemove = numDel;
340 cons_->posRemove = indices;
341 }
342
344 void addVariables(int numAdd, BcpsObject **addVars){
345 if (vars_->objects) {
346 for (int k = 0; k < vars_->numAdd; ++k) {
347 delete vars_->objects[k];
348 }
349 delete [] vars_->objects;
350 }
351
352 vars_->numAdd = numAdd;
353 vars_->objects = addVars;
354 }
355
357 void delVariables(int numDel, int *indices){
358 if (vars_->posRemove) delete [] vars_->posRemove;
359 vars_->numRemove = numDel;
360 vars_->posRemove = indices;
361 }
362
363 protected:
364
366 AlpsReturnStatus encodeDblFieldMods(AlpsEncoded *encoded,
367 BcpsFieldListMod<double> * field) const;
368
370 AlpsReturnStatus encodeIntFieldMods(AlpsEncoded *encoded,
371 BcpsFieldListMod<int> * field) const;
372
374 AlpsReturnStatus encodeObjectMods(AlpsEncoded *encoded,
375 BcpsObjectListMod *objMod) const;
376
378 AlpsReturnStatus decodeDblFieldMods(AlpsEncoded &encoded,
379 BcpsFieldListMod<double>*field);
380
382 AlpsReturnStatus decodeIntFieldMods(AlpsEncoded &encoded,
383 BcpsFieldListMod<int> *field);
384
386 AlpsReturnStatus decodeObjectMods(AlpsEncoded &encoded,
387 BcpsObjectListMod *objMod);
388
389 public:
390
392 AlpsReturnStatus encodeBcps(AlpsEncoded *encoded) const;
393
395 AlpsReturnStatus decodeBcps(AlpsEncoded &encoded);
396
397 };
398
399 #endif /* End of file */
BcpsNodeDesc
For a given type, the objectVecStorage_ structure holds the description.
Definition: BcpsNodeDesc.h:128
BcpsObjectListMod::objects
BcpsObject ** objects
The objects to be added.
Definition: BcpsNodeDesc.h:78
AlpsNodeDesc.h
BcpsNodeDesc::setConHardBound
void setConHardBound(int numModHardConLB, const int *conLBi, const double *conLBv, int numModHardConUB, const int *conUBi, const double *conUBv)
Set constraint hard bounds.
BcpsNodeDesc::cons
BcpsObjectListMod * cons()
Accesss constraints.
Definition: BcpsNodeDesc.h:252
BcpsObjectListMod::lbHard
BcpsFieldListMod< double > lbHard
These are the data structures that store the changes in the individual fields.
Definition: BcpsNodeDesc.h:83
AlpsReturnStatus
AlpsReturnStatus
Definition: Alps.h:118
BcpsObject
A class for describing the objects that comprise a BCPS subproblem.
Definition: BcpsObject.h:76
BcpsFieldListMod::relative
bool relative
How the modification is stored, explicit means complete replacement, relative means relative to some ...
Definition: BcpsNodeDesc.h:44
BcpsNodeDesc::assignCons
void assignCons(int numRem, int *&posRem, int numAdd, BcpsObject **&objects, bool relclh, int numclh, int *&clhp, double *&clhe, bool relcuh, int numcuh, int *&cuhp, double *&cuhe, bool relcls, int numcls, int *&clsp, double *&clse, bool relcus, int numcus, int *&cusp, double *&cuse)
Assign constraint objects.
BcpsNodeDesc::decodeDblFieldMods
AlpsReturnStatus decodeDblFieldMods(AlpsEncoded &encoded, BcpsFieldListMod< double > *field)
Unpack a double field from an encoded object.
BcpsNodeDesc::initToNull
void initToNull()
Initialize member data.
BcpsNodeDesc::decodeObjectMods
AlpsReturnStatus decodeObjectMods(AlpsEncoded &encoded, BcpsObjectListMod *objMod)
Unpack object modifications to an encoded object.
BcpsNodeDesc::setVarSoftBound
void setVarSoftBound(int numModSoftVarLB, const int *varLBi, const double *varLBv, int numModSoftVarUB, const int *varUBi, const double *varUBv)
Set variable soft bounds.
BcpsNodeDesc::vars_
BcpsObjectListMod * vars_
Variable objects.
Definition: BcpsNodeDesc.h:133
AlpsEncoded
This data structure is to contain the packed form of an encodable knowledge.
Definition: AlpsEncoded.h:25
BcpsNodeDesc::vars
BcpsObjectListMod * vars()
Accesss varaibles.
Definition: BcpsNodeDesc.h:249
BcpsNodeDesc::getCons
BcpsObjectListMod * getCons() const
Get constraint objects.
Definition: BcpsNodeDesc.h:246
BcpsNodeDesc::setCons
void setCons(int numRem, const int *posRem, int numAdd, const BcpsObject **objects, bool relclh, int numclh, const int *clhp, const double *clhe, bool relcuh, int numcuh, const int *cuhp, const double *cuhe, bool relcls, int numcls, const int *clsp, const double *clse, bool relcus, int numcus, const int *cusp, const double *cuse)
Set constraint objects.
BcpsModel.h
Alps.h
BcpsNodeDesc::assignVarHardBound
void assignVarHardBound(int numModHardVarLB, int *&varLBi, double *&varLBv, int numModHardVarUB, int *&varUBi, double *&varUBv)
Set variable hard bounds.
BcpsFieldListMod::numModify
int numModify
The number of entries to be modified.
Definition: BcpsNodeDesc.h:47
BcpsObjectListMod::ubHard
BcpsFieldListMod< double > ubHard
These are the data structures that store the changes in the individual fields.
Definition: BcpsNodeDesc.h:84
BcpsNodeDesc::delConstraints
void delConstraints(int numDel, int *indices)
Record the constraints are deleted.
Definition: BcpsNodeDesc.h:337
BcpsNodeDesc::decodeIntFieldMods
AlpsReturnStatus decodeIntFieldMods(AlpsEncoded &encoded, BcpsFieldListMod< int > *field)
Unpack a integer field from an encoded object.
BcpsNodeDesc::setVarHardBound
void setVarHardBound(int numModHardVarLB, const int *varLBi, const double *varLBv, int numModHardVarUB, const int *varUBi, const double *varUBv)
Set variable hard bounds.
BcpsObjectListMod::ubSoft
BcpsFieldListMod< double > ubSoft
These are the data structures that store the changes in the individual fields.
Definition: BcpsNodeDesc.h:86
BcpsObjectListMod
Here is the set of vectorMod_ objects that represent the list of objects of a particular type (either...
Definition: BcpsNodeDesc.h:66
BcpsObject.h
BcpsNodeDesc::setVars
void setVars(int numRem, const int *posRem, int numAdd, const BcpsObject **objects, bool relvlh, int numvlh, const int *vlhp, const double *vlhe, bool relvuh, int numvuh, const int *vuhp, const double *vuhe, bool relvls, int numvls, const int *vlsp, const double *vlse, bool relvus, int numvus, const int *vusp, const double *vuse)
Set variable objects.
BcpsNodeDesc::addVariables
void addVariables(int numAdd, BcpsObject **addVars)
Record added variables.
Definition: BcpsNodeDesc.h:344
BcpsObjectListMod::status
BcpsFieldListMod< int > status
These are the data structures that store the changes in the individual fields.
Definition: BcpsNodeDesc.h:87
BcpsNodeDesc::encodeDblFieldMods
AlpsReturnStatus encodeDblFieldMods(AlpsEncoded *encoded, BcpsFieldListMod< double > *field) const
Pack a double field into an encoded object.
BcpsNodeDesc::setConSoftBound
void setConSoftBound(int numModSoftConLB, const int *conLBi, const double *conLBv, int numModSoftConUB, const int *conUBi, const double *conUBv)
Set constraint soft bounds.
BcpsNodeDesc::decodeBcps
AlpsReturnStatus decodeBcps(AlpsEncoded &encoded)
Unpack bcps node description into an encoded.
BcpsNodeDesc::appendAddedConstraints
void appendAddedConstraints(int numAdd, BcpsObject **addCons)
Recode the added constraints.
Definition: BcpsNodeDesc.h:304
BcpsModel
Definition: BcpsModel.h:40
BcpsNodeDesc::encodeIntFieldMods
AlpsReturnStatus encodeIntFieldMods(AlpsEncoded *encoded, BcpsFieldListMod< int > *field) const
Pack a integer field into an encoded object.
BcpsNodeDesc::getVars
BcpsObjectListMod * getVars() const
Get variable objects.
Definition: BcpsNodeDesc.h:243
BcpsNodeDesc::assignVars
void assignVars(int numRem, int *&posRem, int numAdd, BcpsObject **&objects, bool relvlh, int numvlh, int *&vlhp, double *&vlhe, bool relvuh, int numvuh, int *&vuhp, double *&vuhe, bool relvls, int numvls, int *&vlsp, double *&vlse, bool relvus, int numvus, int *&vusp, double *&vuse)
Assign variable objects.
BcpsFieldListMod
This class contains modifications for a single std::vector&lt;T&gt; object.
Definition: BcpsNodeDesc.h:39
BcpsNodeDesc::~BcpsNodeDesc
virtual ~BcpsNodeDesc()
Destructor.
BcpsNodeDesc::BcpsNodeDesc
BcpsNodeDesc(BcpsModel *m)
Useful constructor.
Definition: BcpsNodeDesc.h:144
BcpsNodeDesc::assignVarSoftBound
void assignVarSoftBound(int numModSoftVarLB, int *&varLBi, double *&varLBv, int numModSoftVarUB, int *&varUBi, double *&varUBv)
Set variable soft bounds.
BcpsNodeDesc::encodeObjectMods
AlpsReturnStatus encodeObjectMods(AlpsEncoded *encoded, BcpsObjectListMod *objMod) const
Pack object modifications to an encoded object.
BcpsObjectListMod::posRemove
int * posRemove
The positions of the entries to be deleted.
Definition: BcpsNodeDesc.h:73
BcpsFieldListMod::entries
T * entries
Values.
Definition: BcpsNodeDesc.h:53
BcpsNodeDesc::cons_
BcpsObjectListMod * cons_
Constraint objects.
Definition: BcpsNodeDesc.h:136
BcpsObjectListMod::numRemove
int numRemove
The number of entries to be deleted.
Definition: BcpsNodeDesc.h:70
BcpsNodeDesc::BcpsNodeDesc
BcpsNodeDesc()
Default constructor.
Definition: BcpsNodeDesc.h:141
AlpsNodeDesc
A class to refer to the description of a search tree node.
Definition: AlpsNodeDesc.h:35
BcpsNodeDesc::encodeBcps
AlpsReturnStatus encodeBcps(AlpsEncoded *encoded) const
Pack bcps node description into an encoded.
BcpsObjectListMod::lbSoft
BcpsFieldListMod< double > lbSoft
These are the data structures that store the changes in the individual fields.
Definition: BcpsNodeDesc.h:85
BcpsFieldListMod::posModify
int * posModify
The positions to be modified.
Definition: BcpsNodeDesc.h:50
BcpsObjectListMod::numAdd
int numAdd
The number of objects that are to added.
Definition: BcpsNodeDesc.h:76
BcpsNodeDesc::setAddedConstraints
void setAddedConstraints(int numAdd, BcpsObject **addCons)
Recode the added constraints.
Definition: BcpsNodeDesc.h:323
BcpsNodeDesc::delVariables
void delVariables(int numDel, int *indices)
Record deleted variables.
Definition: BcpsNodeDesc.h:357