OS_var.cpp
Go to the documentation of this file.
1 /* $Id: OS_var.cpp 2698 2009-06-09 04:14:07Z kmartin $ */
2 #include "OS_var.hpp"
3 
4 
5 
6 
7 /*---------------------------------------------------------------------------*/
8 
9 
10 OS_var::OS_var(int idx, const CoinPackedVector& f, double w) :
11  BCP_var_algo(BCP_IntegerVar, w, 0, 1),
12  varIndex( idx), coinPackedVec(false), weight(w)
13 {
14  std::cout << "INSIDE VAR CONSTRUCTOR OS_var(int idx, const CoinPackedVector& f, double w) " << std::endl;
15  new (&coinPackedVec) CoinPackedVector(f.getNumElements(),
16  f.getIndices(), f.getElements(), false);
17 
18 }
19 /*---------------------------------------------------------------------------*/
20 
22  // we don't know the onj coeff (weight) yet, so temporarily set it to 0
23  BCP_var_algo( BCP_IntegerVar, 0, 0, 1)
24 {
25 
26  std::cout << "INSIDE VAR CONSTRUCTOR OS_var(BCP_buffer& buf) " << std::endl;
27 
28  buf.unpack( varIndex);
29  int nonz;
30  int* indexes;
31  double* values;
32  buf.unpack(indexes, nonz);
33  buf.unpack(values, nonz);
34  coinPackedVec.assignVector(nonz, indexes, values, false ); //false -- don't test for duplicates
35  buf.unpack( weight);
36  set_obj( weight);
37 }
38 
39 /*===========================================================================*/
40 
41 
42 
43 void OS_var::pack(BCP_buffer& buf) const
44 {
45  std::cout << "PACKING OS_var::pack(BCP_buffer& buf) " << std::endl;
46  buf.pack( varIndex);
47  int nonz = coinPackedVec.getNumElements();
48  buf.pack(coinPackedVec.getIndices(), nonz);
49  buf.pack(coinPackedVec.getElements(), nonz);
50  buf.pack( weight);
51 }
52 
53 
double * values
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
double weight
Definition: OS_var.hpp:17
void fint fint fint real fint real real real real * f
void pack(BCP_buffer &buf) const
Definition: OS_var.cpp:43
OS_var(int idx, const CoinPackedVector &f, double w)
Definition: OS_var.cpp:10
This is the class from which the user should derive her own algorithmic variables.
Definition: BCP_var.hpp:277
This class describes the message buffer used for all processes of BCP.
Definition: BCP_buffer.hpp:39
void set_obj(const double obj)
Set the objective coefficient.
Definition: BCP_var.hpp:143
int varIndex
Definition: OS_var.hpp:13
CoinPackedVector coinPackedVec
Definition: OS_var.hpp:15
void fint fint fint real fint real real real real real real real real * w
General integer variable.
Definition: BCP_enum.hpp:165