Bcps 0.94.5
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-2017, 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
39template <class T> struct BcpsFieldListMod {
45
48
51
54};
55
56
57//#############################################################################
58
59
67
71
74
76 int numAdd;
79
89};
90
91
92//#############################################################################
93
119//#############################################################################
120
129
130 protected:
131
134
137
138 public:
139
142
145 :
146 AlpsNodeDesc(m) { initToNull(); }
147
149 virtual ~BcpsNodeDesc();
150
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
250
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
367 BcpsFieldListMod<double> * field) const;
368
371 BcpsFieldListMod<int> * field) const;
372
375 BcpsObjectListMod *objMod) const;
376
380
383 BcpsFieldListMod<int> *field);
384
387 BcpsObjectListMod *objMod);
388
389 public:
390
393
396
397};
398
399#endif /* End of file */
AlpsReturnStatus
For a given type, the objectVecStorage_ structure holds the description.
Definition: BcpsNodeDesc.h:128
BcpsObjectListMod * cons()
Accesss constraints.
Definition: BcpsNodeDesc.h:252
void delVariables(int numDel, int *indices)
Record deleted variables.
Definition: BcpsNodeDesc.h:357
void setAddedConstraints(int numAdd, BcpsObject **addCons)
Recode the added constraints.
Definition: BcpsNodeDesc.h:323
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.
BcpsObjectListMod * getCons() const
Get constraint objects.
Definition: BcpsNodeDesc.h:246
void setConHardBound(int numModHardConLB, const int *conLBi, const double *conLBv, int numModHardConUB, const int *conUBi, const double *conUBv)
Set constraint hard bounds.
void setVarHardBound(int numModHardVarLB, const int *varLBi, const double *varLBv, int numModHardVarUB, const int *varUBi, const double *varUBv)
Set variable hard bounds.
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.
BcpsObjectListMod * cons_
Constraint objects.
Definition: BcpsNodeDesc.h:136
virtual ~BcpsNodeDesc()
Destructor.
void appendAddedConstraints(int numAdd, BcpsObject **addCons)
Recode the added constraints.
Definition: BcpsNodeDesc.h:304
void assignVarHardBound(int numModHardVarLB, int *&varLBi, double *&varLBv, int numModHardVarUB, int *&varUBi, double *&varUBv)
Set variable hard bounds.
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.
AlpsReturnStatus decodeBcps(AlpsEncoded &encoded)
Unpack bcps node description into an encoded.
void setVarSoftBound(int numModSoftVarLB, const int *varLBi, const double *varLBv, int numModSoftVarUB, const int *varUBi, const double *varUBv)
Set variable soft bounds.
AlpsReturnStatus encodeBcps(AlpsEncoded *encoded) const
Pack bcps node description into an encoded.
BcpsObjectListMod * vars()
Accesss varaibles.
Definition: BcpsNodeDesc.h:249
AlpsReturnStatus decodeDblFieldMods(AlpsEncoded &encoded, BcpsFieldListMod< double > *field)
Unpack a double field from an encoded object.
void setConSoftBound(int numModSoftConLB, const int *conLBi, const double *conLBv, int numModSoftConUB, const int *conUBi, const double *conUBv)
Set constraint soft bounds.
void assignVarSoftBound(int numModSoftVarLB, int *&varLBi, double *&varLBv, int numModSoftVarUB, int *&varUBi, double *&varUBv)
Set variable soft bounds.
AlpsReturnStatus encodeDblFieldMods(AlpsEncoded *encoded, BcpsFieldListMod< double > *field) const
Pack a double field into an encoded object.
void addVariables(int numAdd, BcpsObject **addVars)
Record added variables.
Definition: BcpsNodeDesc.h:344
AlpsReturnStatus decodeIntFieldMods(AlpsEncoded &encoded, BcpsFieldListMod< int > *field)
Unpack a integer field from an encoded object.
AlpsReturnStatus decodeObjectMods(AlpsEncoded &encoded, BcpsObjectListMod *objMod)
Unpack object modifications to an encoded object.
void initToNull()
Initialize member data.
BcpsObjectListMod * getVars() const
Get variable objects.
Definition: BcpsNodeDesc.h:243
BcpsNodeDesc(BcpsModel *m)
Useful constructor.
Definition: BcpsNodeDesc.h:144
void delConstraints(int numDel, int *indices)
Record the constraints are deleted.
Definition: BcpsNodeDesc.h:337
AlpsReturnStatus encodeIntFieldMods(AlpsEncoded *encoded, BcpsFieldListMod< int > *field) const
Pack a integer field into an encoded object.
AlpsReturnStatus encodeObjectMods(AlpsEncoded *encoded, BcpsObjectListMod *objMod) const
Pack object modifications to an encoded object.
BcpsNodeDesc()
Default constructor.
Definition: BcpsNodeDesc.h:141
BcpsObjectListMod * vars_
Variable objects.
Definition: BcpsNodeDesc.h:133
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.
A class for describing the objects that comprise a BCPS subproblem.
Definition: BcpsObject.h:76
This class contains modifications for a single std::vector<T> object.
Definition: BcpsNodeDesc.h:39
bool relative
How the modification is stored, explicit means complete replacement, relative means relative to some ...
Definition: BcpsNodeDesc.h:44
T * entries
Values.
Definition: BcpsNodeDesc.h:53
int numModify
The number of entries to be modified.
Definition: BcpsNodeDesc.h:47
int * posModify
The positions to be modified.
Definition: BcpsNodeDesc.h:50
Here is the set of vectorMod_ objects that represent the list of objects of a particular type (either...
Definition: BcpsNodeDesc.h:66
int * posRemove
The positions of the entries to be deleted.
Definition: BcpsNodeDesc.h:73
BcpsFieldListMod< double > ubSoft
Definition: BcpsNodeDesc.h:86
BcpsObject ** objects
The objects to be added.
Definition: BcpsNodeDesc.h:78
BcpsFieldListMod< double > lbHard
These are the data structures that store the changes in the individual fields.
Definition: BcpsNodeDesc.h:83
BcpsFieldListMod< double > ubHard
Definition: BcpsNodeDesc.h:84
int numAdd
The number of objects that are to added.
Definition: BcpsNodeDesc.h:76
BcpsFieldListMod< double > lbSoft
Definition: BcpsNodeDesc.h:85
int numRemove
The number of entries to be deleted.
Definition: BcpsNodeDesc.h:70
BcpsFieldListMod< int > status
Definition: BcpsNodeDesc.h:87