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

Last change on this file since 1 was 1, checked in by andreasw, 13 years ago

imported initial code

  • Property svn:eol-style set to native
  • Property svn:keywords set to "Author Date Id Revision"
File size: 1.3 KB
Line 
1// Copyright (C) 2003, International Business Machines
2// Corporation and others.  All Rights Reserved.
3// File from COIN project Examples/Bac/BB_cut.cpp
4#include "BCP_buffer.hpp"
5#include "BB_cut.hpp"
6
7/****************************************************************************/
8void
9BB_cut::pack(BCP_buffer& buf) const
10{
11    buf.pack(OsiRowCut::lb())
12        .pack(OsiRowCut::ub());
13    const CoinPackedVector& v = OsiRowCut::row();
14    const int numElem = v.getNumElements();
15    buf.pack(v.getIndices(), numElem)
16        .pack(v.getElements(), numElem);
17}
18
19/****************************************************************************/
20BB_cut::BB_cut(BCP_buffer& buf) :
21    BCP_cut_algo(-1e40, 1e40), OsiRowCut()
22{
23    double lb, ub;
24    buf.unpack(lb)
25        .unpack(ub);
26    OsiRowCut::setLb(lb);
27    OsiRowCut::setUb(ub);
28
29    int numElem;
30    int* indices;
31    double* elements;
32    buf.unpack(indices, numElem, true)
33        .unpack(elements, numElem, true);
34    OsiRowCut::setRow(numElem, indices, elements);
35
36    if(numElem > 0) {
37        delete[] indices;
38        delete[] elements;
39    }
40}
41
42/****************************************************************************/
43BB_cut::BB_cut(const OsiRowCut& cut) :
44    BCP_cut_algo(cut.lb(), cut.ub()), OsiRowCut(cut)
45{}
46
47/****************************************************************************/
48BCP_MemPool BB_cut::memPool(sizeof(BB_cut));
Note: See TracBrowser for help on using the repository browser.