source: trunk/Bonmin/experimental/Bcp/BB_cut.cpp @ 530

Last change on this file since 530 was 530, checked in by ladanyi, 13 years ago

prepare Bcp for changing some LPs into TM storage places. Serial version works, currently debugging parallel version.

  • Property svn:eol-style set to native
  • Property svn:keywords set to "Author Date Id Revision"
File size: 1.6 KB
Line 
1// (C) Copyright International Business Machines Corporation 2006, 2007
2// All Rights Reserved.
3// This code is published under the Common 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
14BB_cut* BB_cut::clone() const
15{
16    return new BB_cut(dynamic_cast<const OsiRowCut&>(*this));
17}
18
19/****************************************************************************/
20
21void
22BB_cut::pack(BCP_buffer& buf) const
23{
24    buf.pack(OsiRowCut::lb())
25        .pack(OsiRowCut::ub());
26    const CoinPackedVector& v = OsiRowCut::row();
27    const int numElem = v.getNumElements();
28    buf.pack(v.getIndices(), numElem)
29        .pack(v.getElements(), numElem);
30}
31
32/****************************************************************************/
33BB_cut::BB_cut(BCP_buffer& buf) :
34    BCP_cut_algo(-1e40, 1e40), OsiRowCut()
35{
36    double lb, ub;
37    buf.unpack(lb)
38        .unpack(ub);
39    OsiRowCut::setLb(lb);
40    OsiRowCut::setUb(ub);
41
42    int numElem;
43    int* indices;
44    double* elements;
45    buf.unpack(indices, numElem, true)
46        .unpack(elements, numElem, true);
47    OsiRowCut::setRow(numElem, indices, elements);
48
49    if(numElem > 0) {
50        delete[] indices;
51        delete[] elements;
52    }
53}
54
55/****************************************************************************/
56BB_cut::BB_cut(const OsiRowCut& cut) :
57    BCP_cut_algo(cut.lb(), cut.ub()), OsiRowCut(cut)
58{}
59
60/****************************************************************************/
61BCP_MemPool BB_cut::memPool(sizeof(BB_cut));
Note: See TracBrowser for help on using the repository browser.