BB_cut.cpp
Go to the documentation of this file.
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 /****************************************************************************/
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 /****************************************************************************/
BCP_buffer & pack(const T &value)
Pack a single object of type T.
Definition: BCP_buffer.hpp:177
BCP_buffer & unpack(T &value)
Unpack a single object of type T.
Definition: BCP_buffer.hpp:186
BB_cut(BCP_buffer &buf)
Constructor from content of buffer.
Definition: BB_cut.cpp:44
This is the class from which the user should derive her own algorithmic cuts.
Definition: BCP_cut.hpp:242
double ub() const
Return the upper bound on the cut.
Definition: BCP_cut.hpp:84
double lb() const
Return the lower bound on the cut.
Definition: BCP_cut.hpp:82
void pack(BCP_buffer &buf) const
Packing cut to a buffer.
Definition: BB_cut.cpp:33
Simple representation of a cut by storing non zero coefficients only.
Definition: BB_cut.hpp:64
static BCP_MemPool memPool
Definition: BB_cut.hpp:68
This class describes the message buffer used for all processes of BCP.
Definition: BCP_buffer.hpp:39