MCF3_var.cpp
Go to the documentation of this file.
1 #include "MCF3_var.hpp"
2 
3 //#############################################################################
4 
5 void MCF3_var::pack(BCP_buffer& buf) const
6 {
7  buf.pack(commodity);
8  int numarcs = flow.getNumElements();
9  buf.pack(flow.getIndices(), numarcs);
10  buf.pack(flow.getElements(), numarcs);
11  buf.pack(weight);
12 }
13 
14 /*---------------------------------------------------------------------------*/
15 
17  // we don't know the onj coeff (weight) yet, so temporarily set it to 0
19 {
20  buf.unpack(commodity);
21  int numarcs;
22  int* ind;
23  double* val;
24  buf.unpack(ind, numarcs);
25  buf.unpack(val, numarcs);
26  flow.assignVector(numarcs, ind, val, false /*don't test for duplicates*/);
27  buf.unpack(weight);
28  set_obj(weight);
29 }
30 
31 /*===========================================================================*/
32 
33 void MCF3_pack_var(const BCP_var_algo* var, BCP_buffer& buf)
34 {
35  const MCF3_var* v = dynamic_cast<const MCF3_var*>(var);
36  if (v) {
37  v->pack(buf);
38  }
39 }
40 
41 /*---------------------------------------------------------------------------*/
42 
44 {
45  return new MCF3_var(buf);
46 }
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
void MCF3_pack_var(const BCP_var_algo *var, BCP_buffer &buf)
Definition: MCF3_var.cpp:33
void pack(BCP_buffer &buf) const
Definition: MCF3_var.cpp:5
double weight
Definition: MCF3_var.hpp:22
BCP_var_algo * MCF3_unpack_var(BCP_buffer &buf)
Definition: MCF3_var.cpp:43
MCF3_var(int com, const CoinPackedVector &f, double w)
Definition: MCF3_var.hpp:25
int commodity
Definition: MCF3_var.hpp:20
CoinPackedVector flow
Definition: MCF3_var.hpp:21
Continuous variable.
Definition: BCP_enum.hpp:167
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