BB_cut.cpp
Go to the documentation of this file.
1 // Copyright (C) 2003, International Business Machines
2 // Corporation and others. All Rights Reserved.
3 
4 #include "BCP_math.hpp"
5 #include "BCP_buffer.hpp"
6 #include "BB_cut.hpp"
7 
8 /****************************************************************************/
9 void
11 {
12  buf.pack(index_).pack(lb()).pack(ub());
13 }
14 
15 /****************************************************************************/
17  BCP_cut_algo(-1e40, 1e40)
18 {
19  double lbound, ubound;
20  buf.unpack(index_).unpack(lbound).unpack(ubound);
21  change_bounds(lbound, ubound);
22 }
23 
24 /****************************************************************************/
25 BB_indexed_cut::BB_indexed_cut(int index, double lbound, double ubound) :
26  BCP_cut_algo(lbound, ubound), index_(index) {}
27 
28 /****************************************************************************/
30 
31 /****************************************************************************/
32 void
34 {
35  buf.pack(OsiRowCut::lb())
36  .pack(OsiRowCut::ub());
37  const CoinPackedVector& v = OsiRowCut::row();
38  const int numElem = v.getNumElements();
39  buf.pack(v.getIndices(), numElem)
40  .pack(v.getElements(), numElem);
41 }
42 
43 /****************************************************************************/
45  BCP_cut_algo(-BCP_DBL_MAX, BCP_DBL_MAX), OsiRowCut()
46 {
47  double lb, ub;
48  buf.unpack(lb)
49  .unpack(ub);
50  OsiRowCut::setLb(lb);
51  OsiRowCut::setUb(ub);
52 
53  int numElem;
54  int* indices = NULL;
55  double* elements = NULL;
56  buf.unpack(indices, numElem, true)
57  .unpack(elements, numElem, true);
58  OsiRowCut::setRow(numElem, indices, elements);
59 
60  if(numElem > 0) {
61  delete[] indices;
62  delete[] elements;
63  }
64 }
65 
66 /****************************************************************************/
67 BB_cut::BB_cut(const OsiRowCut& cut) :
68  BCP_cut_algo(cut.lb(), cut.ub()), OsiRowCut(cut)
69 {}
70 
71 /****************************************************************************/
void pack(BCP_buffer &buf) const
Packing cut to a buffer.
Definition: BB_cut.cpp:10
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
When doing a sprint sort of algorithm on the cuts (i.e., leave out a number of cuts at the beginning ...
Definition: BB_cut.hpp:19
double ub() const
Return the upper bound on the cut.
Definition: BCP_cut.hpp:84
#define BCP_DBL_MAX
Definition: BCP_math.hpp:6
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
void change_bounds(const double lb, const double ub)
Change just the lower/upper bounds.
Definition: BCP_cut.hpp:142
static BCP_MemPool memPool
Definition: BB_cut.hpp:29