Bcps 0.95.1
Loading...
Searching...
No Matches
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-2023, 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 "BcpsConfig.h"
32#include "BcpsObject.h"
33
34
35//#############################################################################
36
39
40template <class T> struct BcpsFieldListMod {
46
49
52
55};
56
57
58//#############################################################################
59
60
66
91
92
93//#############################################################################
94
119
120//#############################################################################
121
129class BCPSLIB_EXPORT BcpsNodeDesc : public AlpsNodeDesc {
130
131 protected:
132
135
138
139 public:
140
143
146 :
147 AlpsNodeDesc(m) { initToNull(); }
148
150 virtual ~BcpsNodeDesc();
151
154
156 void setVars(int numRem,
157 const int *posRem,
158 int numAdd,
159 const BcpsObject **objects,
160 bool relvlh,
161 int numvlh,
162 const int *vlhp,
163 const double *vlhe,
164 bool relvuh,
165 int numvuh,
166 const int *vuhp,
167 const double *vuhe,
168 bool relvls,
169 int numvls,
170 const int *vlsp,
171 const double *vlse,
172 bool relvus,
173 int numvus,
174 const int *vusp,
175 const double *vuse);
176
178 void assignVars(int numRem,
179 int *&posRem,
180 int numAdd,
181 BcpsObject **&objects,
182 bool relvlh,
183 int numvlh,
184 int *&vlhp,
185 double *&vlhe,
186 bool relvuh,
187 int numvuh,
188 int *&vuhp,
189 double *&vuhe,
190 bool relvls,
191 int numvls,
192 int *&vlsp,
193 double *&vlse,
194 bool relvus,
195 int numvus,
196 int *&vusp,
197 double *&vuse);
198
200 void setCons(int numRem,
201 const int *posRem,
202 int numAdd,
203 const BcpsObject **objects,
204 bool relclh,
205 int numclh,
206 const int *clhp,
207 const double *clhe,
208 bool relcuh,
209 int numcuh,
210 const int *cuhp,
211 const double *cuhe,
212 bool relcls,
213 int numcls,
214 const int *clsp,
215 const double *clse,
216 bool relcus,
217 int numcus,
218 const int *cusp,
219 const double *cuse);
220
222 void assignCons(int numRem,
223 int *&posRem,
224 int numAdd,
225 BcpsObject **&objects,
226 bool relclh,
227 int numclh,
228 int *&clhp,
229 double *&clhe,
230 bool relcuh,
231 int numcuh,
232 int *&cuhp,
233 double *&cuhe,
234 bool relcls,
235 int numcls,
236 int *&clsp,
237 double *&clse,
238 bool relcus,
239 int numcus,
240 int *&cusp,
241 double *&cuse);
242
244 BcpsObjectListMod *getVars() const { return vars_; }
245
247 BcpsObjectListMod *getCons() const { return cons_; }
248
251
254
256 void assignVarSoftBound(int numModSoftVarLB,
257 int *&varLBi,
258 double *&varLBv,
259 int numModSoftVarUB,
260 int *&varUBi,
261 double *&varUBv);
262
264 void setVarSoftBound(int numModSoftVarLB,
265 const int *varLBi,
266 const double *varLBv,
267 int numModSoftVarUB,
268 const int *varUBi,
269 const double *varUBv);
270
272 void assignVarHardBound(int numModHardVarLB,
273 int *&varLBi,
274 double *&varLBv,
275 int numModHardVarUB,
276 int *&varUBi,
277 double *&varUBv);
278
280 void setConSoftBound(int numModSoftConLB,
281 const int *conLBi,
282 const double *conLBv,
283 int numModSoftConUB,
284 const int *conUBi,
285 const double *conUBv);
286
288 void setVarHardBound(int numModHardVarLB,
289 const int *varLBi,
290 const double *varLBv,
291 int numModHardVarUB,
292 const int *varUBi,
293 const double *varUBv);
294
296 void setConHardBound(int numModHardConLB,
297 const int *conLBi,
298 const double *conLBv,
299 int numModHardConUB,
300 const int *conUBi,
301 const double *conUBv);
302
305 void appendAddedConstraints(int numAdd, BcpsObject **addCons){
306 int numAll = numAdd + cons_->numAdd;
307 BcpsObject ** allAdd = new BcpsObject* [numAll];
308 int k;
309
310 for (k = 0; k < cons_->numAdd; ++k) {
311 allAdd[k] = cons_->objects[k];
312 }
313 for (k = 0; k < numAdd; ++k) {
314 allAdd[(k+cons_->numAdd)] = addCons[k];
315 }
316
317 delete [] cons_->objects;
318 cons_->numAdd = numAll;
319 cons_->objects = allAdd;
320 }
321
324 void setAddedConstraints(int numAdd, BcpsObject **addCons){
325 // NOTE: make sure objects can be safely deleted.
326 if (cons_->objects) {
327 for (int k = 0; k < cons_->numAdd; ++k) {
328 delete cons_->objects[k];
329 }
330 delete [] cons_->objects;
331 }
332 cons_->numAdd = numAdd;
333 cons_->objects = addCons;
334 }
335
338 void delConstraints(int numDel, int *indices){
339 if ( cons_->posRemove) delete [] cons_->posRemove;
340 cons_->numRemove = numDel;
341 cons_->posRemove = indices;
342 }
343
345 void addVariables(int numAdd, BcpsObject **addVars){
346 if (vars_->objects) {
347 for (int k = 0; k < vars_->numAdd; ++k) {
348 delete vars_->objects[k];
349 }
350 delete [] vars_->objects;
351 }
352
353 vars_->numAdd = numAdd;
354 vars_->objects = addVars;
355 }
356
358 void delVariables(int numDel, int *indices){
359 if (vars_->posRemove) delete [] vars_->posRemove;
360 vars_->numRemove = numDel;
361 vars_->posRemove = indices;
362 }
363
364 protected:
365
367 AlpsReturnStatus encodeDblFieldMods(AlpsEncoded *encoded,
368 BcpsFieldListMod<double> * field) const;
369
371 AlpsReturnStatus encodeIntFieldMods(AlpsEncoded *encoded,
372 BcpsFieldListMod<int> * field) const;
373
375 AlpsReturnStatus encodeObjectMods(AlpsEncoded *encoded,
376 BcpsObjectListMod *objMod) const;
377
379 AlpsReturnStatus decodeDblFieldMods(AlpsEncoded &encoded,
381
383 AlpsReturnStatus decodeIntFieldMods(AlpsEncoded &encoded,
384 BcpsFieldListMod<int> *field);
385
387 AlpsReturnStatus decodeObjectMods(AlpsEncoded &encoded,
388 BcpsObjectListMod *objMod);
389
390 public:
391
393 AlpsReturnStatus encodeBcps(AlpsEncoded *encoded) const;
394
396 AlpsReturnStatus decodeBcps(AlpsEncoded &encoded);
397
398};
399
400#endif /* End of file */
BcpsObjectListMod * cons()
Accesss constraints.
void delVariables(int numDel, int *indices)
Record deleted variables.
void setAddedConstraints(int numAdd, BcpsObject **addCons)
Recode the added constraints.
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.
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.
virtual ~BcpsNodeDesc()
Destructor.
void appendAddedConstraints(int numAdd, BcpsObject **addCons)
Recode the added constraints.
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.
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.
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.
BcpsNodeDesc(BcpsModel *m)
Useful constructor.
void delConstraints(int numDel, int *indices)
Record the constraints are deleted.
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.
BcpsObjectListMod * vars_
Variable objects.
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:77
#define BCPSLIB_EXPORT
Definition config.h:5
This class contains modifications for a single std::vector<T> object.
bool relative
How the modification is stored, explicit means complete replacement, relative means relative to some ...
T * entries
Values.
int numModify
The number of entries to be modified.
int * posModify
The positions to be modified.
Here is the set of vectorMod_ objects that represent the list of objects of a particular type (either...
int * posRemove
The positions of the entries to be deleted.
BcpsFieldListMod< double > ubSoft
BcpsObject ** objects
The objects to be added.
BcpsFieldListMod< double > lbHard
These are the data structures that store the changes in the individual fields.
BcpsFieldListMod< double > ubHard
int numAdd
The number of objects that are to added.
BcpsFieldListMod< double > lbSoft
int numRemove
The number of entries to be deleted.
BcpsFieldListMod< int > status