coin-Bcp
MCF3_data.hpp
Go to the documentation of this file.
1 #ifndef MCF3_data_hpp
2 #define MCF3_data_hpp
3 
4 #include <iostream>
5 #include "BCP_buffer.hpp"
6 #include "BCP_USER.hpp"
7 
8 //#############################################################################
9 
10 // This structure holds the input data
11 
12 class MCF3_data {
13 public:
14  struct arc {
15  int tail;
16  int head;
17  int lb;
18  int ub;
19  double weight;
20  };
21  struct commodity {
22  int source;
23  int sink;
24  int demand;
25  };
26  char* problem_name;
29  int numarcs;
30  int numnodes;
32 
33 public:
35  arcs(NULL), commodities(NULL),
36  numarcs(0), numnodes(0), numcommodities(0) {}
37 
38 
40  delete[] arcs;
41  delete[] commodities;
42  delete[] problem_name;
43  }
44 
45  int readDimacsFormat(std::istream& s, bool addDummyArcs);
46  void pack(BCP_buffer& buf) const;
47  void unpack(BCP_buffer& buf);
48 };
49 
50 //#############################################################################
51 
53 {
54 public:
55  int arc_index;
56  int lb;
57  int ub;
58 public:
59  MCF3_branch_decision() : arc_index(-1), lb(0), ub(0) {}
60  MCF3_branch_decision(int i, int l, int u) : arc_index(i), lb(l), ub(u) {}
61  void pack(BCP_buffer& buf) const;
62  void unpack(BCP_buffer& buf);
63 };
64 
65 //#############################################################################
66 
67 class MCF3_user : public BCP_user_data {
68 private:
69  MCF3_user& operator=(const MCF3_user& rhs);
70 
71 public:
73  std::vector<MCF3_branch_decision>* branch_history;
74 
75 public:
76  MCF3_user(int numComm=-1) : numCommodities(numComm), branch_history(NULL) {
77  if (numComm > 0) {
78  branch_history = new std::vector<MCF3_branch_decision>[numComm];
79  }
80  }
83  branch_history = new std::vector<MCF3_branch_decision>[numCommodities];
84  for (int i = 0; i < numCommodities; ++i) {
85  branch_history[i] = rhs.branch_history[i];
86  }
87  }
89  unpack(buf);
90  }
92  delete[] branch_history;
93  }
94  void pack(BCP_buffer& buf) const;
95  void unpack(BCP_buffer& buf);
96 };
97 
98 #endif
commodity * commodities
Definition: MCF3_data.hpp:28
void unpack(BCP_buffer &buf)
int numcommodities
Definition: MCF3_data.hpp:31
arc * arcs
Definition: MCF3_data.hpp:27
MCF3_branch_decision(int i, int l, int u)
Definition: MCF3_data.hpp:60
MCF3_user(int numComm=-1)
Definition: MCF3_data.hpp:76
int numCommodities
Definition: MCF3_data.hpp:72
int numarcs
Definition: MCF3_data.hpp:29
void pack(BCP_buffer &buf) const
MCF3_user & operator=(const MCF3_user &rhs)
int readDimacsFormat(std::istream &s, bool addDummyArcs)
std::vector< MCF3_branch_decision > * branch_history
Definition: MCF3_data.hpp:73
void pack(BCP_buffer &buf) const
This class describes the message buffer used for all processes of BCP.
Definition: BCP_buffer.hpp:39
int numnodes
Definition: MCF3_data.hpp:30
void unpack(BCP_buffer &buf)
char * problem_name
Definition: MCF3_data.hpp:26
MCF3_user(const MCF3_user &rhs)
Definition: MCF3_data.hpp:81
void unpack(BCP_buffer &buf)
MCF3_user(BCP_buffer &buf)
Definition: MCF3_data.hpp:88
void pack(BCP_buffer &buf) const