| 1 |
// (C) Copyright International Business Machines Corporation 2006, 2007 |
| 2 |
// All Rights Reserved. |
| 3 |
// This code is published under the Eclipse Public License. |
| 4 |
// |
| 5 |
// Authors : |
| 6 |
// Laszlo Ladanyi, International Business Machines Corporation |
| 7 |
// Pierre Bonami, Carnegie Mellon University |
| 8 |
|
| 9 |
#include "BCP_buffer.hpp" |
| 10 |
#include "BB_cut.hpp" |
| 11 |
|
| 12 |
/****************************************************************************/ |
| 13 |
|
| 14 |
void |
| 15 |
BB_cut::pack(BCP_buffer& buf) const |
| 16 |
{ |
| 17 |
buf.pack(OsiRowCut::lb()) |
| 18 |
.pack(OsiRowCut::ub()); |
| 19 |
const CoinPackedVector& v = OsiRowCut::row(); |
| 20 |
const int numElem = v.getNumElements(); |
| 21 |
buf.pack(v.getIndices(), numElem) |
| 22 |
.pack(v.getElements(), numElem); |
| 23 |
} |
| 24 |
|
| 25 |
/****************************************************************************/ |
| 26 |
BB_cut::BB_cut(BCP_buffer& buf) : |
| 27 |
BCP_cut_algo(-1e40, 1e40), OsiRowCut() |
| 28 |
{ |
| 29 |
double lb, ub; |
| 30 |
buf.unpack(lb) |
| 31 |
.unpack(ub); |
| 32 |
OsiRowCut::setLb(lb); |
| 33 |
OsiRowCut::setUb(ub); |
| 34 |
|
| 35 |
int numElem; |
| 36 |
int* indices; |
| 37 |
double* elements; |
| 38 |
buf.unpack(indices, numElem, true) |
| 39 |
.unpack(elements, numElem, true); |
| 40 |
OsiRowCut::setRow(numElem, indices, elements); |
| 41 |
|
| 42 |
if(numElem > 0) { |
| 43 |
delete[] indices; |
| 44 |
delete[] elements; |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
/****************************************************************************/ |
| 49 |
BB_cut::BB_cut(const OsiRowCut& cut) : |
| 50 |
BCP_cut_algo(cut.lb(), cut.ub()), OsiRowCut(cut) |
| 51 |
{} |
| 52 |
|
| 53 |
/****************************************************************************/ |
| 54 |
BCP_MemPool BB_cut::memPool(sizeof(BB_cut)); |