OS_cut.cpp
Go to the documentation of this file.
1 /* $Id: OS_cut.cpp 2698 2009-06-09 04:14:07Z kmartin $ */
2 // Copyright (C) 2003, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 
5 #include "BCP_math.hpp"
6 #include "BCP_buffer.hpp"
7 #include "OS_cut.hpp"
8 
9 /****************************************************************************/
10 void
12 {
13  buf.pack(OsiRowCut::lb());
14  buf.pack(OsiRowCut::ub());
15  const CoinPackedVector& v = OsiRowCut::row();
16  const int numElem = v.getNumElements();
17  buf.pack(v.getIndices(), numElem);
18  buf.pack(v.getElements(), numElem);
19 }
20 
21 /****************************************************************************/
23  BCP_cut_algo(-BCP_DBL_MAX, BCP_DBL_MAX), OsiRowCut()
24 {
25  double lb, ub;
26  buf.unpack( lb);
27  buf.unpack( ub);
28  OsiRowCut::setLb( lb);
29  OsiRowCut::setUb( ub);
30 
31  int numElem;
32  int* indices;
33  double* elements;
34  buf.unpack(indices, numElem, true);
35  buf.unpack(elements, numElem, true);
36  OsiRowCut::setRow(numElem, indices, elements);
37 
38  if(numElem > 0) {
39  delete[] indices;
40  delete[] elements;
41  }
42 }
43 
44 /****************************************************************************/
45 OS_cut::OS_cut(const OsiRowCut& cut) :
46  BCP_cut_algo(cut.lb(), cut.ub()), OsiRowCut(cut)
47 {}
48 
49 /****************************************************************************/
Simple representation of a cut by storing non zero coefficients only.
Definition: OS_cut.hpp:17
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
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
OS_cut(BCP_buffer &buf)
Constructor from content of buffer.
Definition: OS_cut.cpp:22
static BCP_MemPool memPool
Definition: OS_cut.hpp:21
#define BCP_DBL_MAX
Definition: BCP_math.hpp:6
double lb() const
Return the lower bound on the cut.
Definition: BCP_cut.hpp:82
This class describes the message buffer used for all processes of BCP.
Definition: BCP_buffer.hpp:39
void pack(BCP_buffer &buf) const
Packing cut to a buffer.
Definition: OS_cut.cpp:11