/home/coin/SVN-release/CoinAll-1.1.0/Bcp/examples/MCF-3/include/MCF3_data.hpp

Go to the documentation of this file.
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 // This structure holds the input data
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     ~MCF3_data() {
00039         delete[] arcs;
00040         delete[] commodities;
00041         delete[] problem_name;
00042     }
00043 
00044     int readDimacsFormat(std::istream& s, bool addDummyArcs);
00045     void pack(BCP_buffer& buf) const;
00046     void unpack(BCP_buffer& buf);
00047 };
00048 
00049 //#############################################################################
00050 
00051 class MCF3_branch_decision
00052 {
00053 public:
00054     int arc_index;
00055     int lb;
00056     int ub;
00057 public: 
00058     MCF3_branch_decision() : arc_index(-1), lb(0), ub(0) {}
00059     MCF3_branch_decision(int i, int l, int u) : arc_index(i), lb(l), ub(u) {}
00060     void pack(BCP_buffer& buf) const;
00061     void unpack(BCP_buffer& buf);
00062 };
00063 
00064 //#############################################################################
00065 
00066 class MCF3_user : public BCP_user_data {
00067 private:
00068     MCF3_user& operator=(const MCF3_user& rhs);
00069 
00070 public:
00071     int numCommodities;
00072     std::vector<MCF3_branch_decision>* branch_history;
00073 
00074 public:
00075     MCF3_user(int numComm=-1) : numCommodities(numComm), branch_history(NULL) {
00076         if (numComm > 0) {
00077             branch_history = new std::vector<MCF3_branch_decision>[numComm];
00078         }
00079     }
00080     MCF3_user(const MCF3_user& rhs) : numCommodities(0), branch_history(NULL) {
00081         numCommodities = rhs.numCommodities;
00082         branch_history = new std::vector<MCF3_branch_decision>[numCommodities];
00083         for (int i = 0; i < numCommodities; ++i) {
00084             branch_history[i] = rhs.branch_history[i];
00085         }
00086     }
00087     ~MCF3_user() {
00088         delete[] branch_history;
00089     }
00090     void pack(BCP_buffer& buf) const;
00091     void unpack(BCP_buffer& buf);
00092 };
00093 
00094 #endif

Generated on Sun Nov 14 14:06:28 2010 for Coin-All by  doxygen 1.4.7