00001
00002
00003 #ifndef _BCP_PROCESS_H
00004 #define _BCP_PROCESS_H
00005
00006 #if 1
00007 #define TMDBG
00008 #define LPDBG
00009 #else
00010 #define TMDBG printf("TMDBG: %s:%i\n", __FILE__, __LINE__)
00011 #define LPDBG printf("LPDBG: %s:%i\n", __FILE__, __LINE__)
00012 #endif
00013
00014 class BCP_buffer;
00015
00016 class BCP_process {
00017 private:
00018 const int me;
00019 const int parent;
00020 public:
00021 BCP_process(int self, int my_parent) : me(self), parent(my_parent) {}
00022
00023 virtual ~BCP_process() {}
00024 int get_process_id() const { return me; }
00025 int get_parent() const { return parent; }
00026
00027 virtual BCP_buffer& get_message_buffer() = 0;
00028 virtual void process_message() = 0;
00029 };
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #include <map>
00045 #include <vector>
00046 #include <cmath>
00047 #include "CoinHelperFunctions.hpp"
00048
00049 class BCP_scheduler {
00050 public:
00052 BCP_scheduler();
00053
00063 void setParams(double OverEstimationStatic,
00064 double SwitchToRateThreshold,
00065 double TimeRootNodeSolve,
00066 double FactorTimeHorizon,
00067 double OverEstimationRate,
00068 double MaxNodeIdRatio,
00069 int MaxNodeIdNum,
00070 int MaxSbIdNum,
00071 int MinSbIdNum);
00072
00074 void add_free_ids(int numIds, const int* ids);
00081 int request_sb_ids(int numIds, int* ids);
00083 void release_sb_id(int id);
00084
00087 int request_node_id();
00089 void release_node_id(int id);
00091 inline bool has_free_node_id() const {
00092 return (!freeIds_.empty() && maxNodeIds_ > numNodeIds_);
00093 }
00095 inline int numNodeIds() const {
00096 return numNodeIds_;
00097 }
00099 inline int maxNodeIds() const {
00100 return maxNodeIds_;
00101 }
00103 inline double node_idle(int p) {
00104 return node_idle_time_[p];
00105 }
00107 inline double sb_idle(int p) {
00108 return sb_idle_time_[p];
00109 }
00111 void update_idle_times();
00112
00113 private:
00115 int max_id_allocation(int numIds);
00117 void update_rates(int add_req, int add_rel);
00118
00119 private:
00121 std::map<int, double> sb_idle_time_;
00123 std::map<int, double> node_idle_time_;
00125 std::map<int, double> last_release_type_;
00127 std::map<int, double> last_release_time_;
00129 int totalNumberIds_;
00131 std::vector<int> freeIds_;
00133 int numNodeIds_;
00135 int maxNodeIds_;
00136
00139 double maxNodeIdRatio_;
00142 int maxNodeIdNum_;
00145 int maxSbIds_;
00148 int minSbIds_;
00149
00151 double rho_static_;
00153 double switch_thresh_;
00155 int numSecRateInterval_;
00157 std::vector<int> request_counts_;
00159 int request_counts_tot_;
00161 std::vector<int> release_counts_;
00163 int release_counts_tot_;
00165 int counts_ptr_;
00167 time_t time_last_action_;
00169 double rho_rate_;
00172 bool static_;
00175 bool have_rates_;
00176 };
00177
00178 #endif