00001 #ifndef MCF3_data_hpp
00002 #define MCF3_data_hpp
00003
00004 #include <iostream>
00005 #include "BCP_buffer.hpp"
00006 #include "BCP_USER.hpp"
00007
00008
00009
00010
00011
00012 class MCF3_data {
00013 public:
00014 struct arc {
00015 int tail;
00016 int head;
00017 int lb;
00018 int ub;
00019 double weight;
00020 };
00021 struct commodity {
00022 int source;
00023 int sink;
00024 int demand;
00025 };
00026 char* problem_name;
00027 arc* arcs;
00028 commodity* commodities;
00029 int numarcs;
00030 int numnodes;
00031 int numcommodities;
00032
00033 public:
00034 MCF3_data() :
00035 arcs(NULL), commodities(NULL),
00036 numarcs(0), numnodes(0), numcommodities(0) {}
00037
00038
00039 ~MCF3_data() {
00040 delete[] arcs;
00041 delete[] commodities;
00042 delete[] problem_name;
00043 }
00044
00045 int readDimacsFormat(std::istream& s, bool addDummyArcs);
00046 void pack(BCP_buffer& buf) const;
00047 void unpack(BCP_buffer& buf);
00048 };
00049
00050
00051
00052 class MCF3_branch_decision
00053 {
00054 public:
00055 int arc_index;
00056 int lb;
00057 int ub;
00058 public:
00059 MCF3_branch_decision() : arc_index(-1), lb(0), ub(0) {}
00060 MCF3_branch_decision(int i, int l, int u) : arc_index(i), lb(l), ub(u) {}
00061 void pack(BCP_buffer& buf) const;
00062 void unpack(BCP_buffer& buf);
00063 };
00064
00065
00066
00067 class MCF3_user : public BCP_user_data {
00068 private:
00069 MCF3_user& operator=(const MCF3_user& rhs);
00070
00071 public:
00072 int numCommodities;
00073 std::vector<MCF3_branch_decision>* branch_history;
00074
00075 public:
00076 MCF3_user(int numComm=-1) : numCommodities(numComm), branch_history(NULL) {
00077 if (numComm > 0) {
00078 branch_history = new std::vector<MCF3_branch_decision>[numComm];
00079 }
00080 }
00081 MCF3_user(const MCF3_user& rhs) : numCommodities(0), branch_history(NULL) {
00082 numCommodities = rhs.numCommodities;
00083 branch_history = new std::vector<MCF3_branch_decision>[numCommodities];
00084 for (int i = 0; i < numCommodities; ++i) {
00085 branch_history[i] = rhs.branch_history[i];
00086 }
00087 }
00088 MCF3_user(BCP_buffer& buf) : numCommodities(0), branch_history(NULL) {
00089 unpack(buf);
00090 }
00091 ~MCF3_user() {
00092 delete[] branch_history;
00093 }
00094 void pack(BCP_buffer& buf) const;
00095 void unpack(BCP_buffer& buf);
00096 };
00097
00098 #endif