coin-Bcp
BCP_process.hpp
Go to the documentation of this file.
1 // Copyright (C) 2000, International Business Machines
2 // Corporation and others. All Rights Reserved.
3 #ifndef _BCP_PROCESS_H
4 #define _BCP_PROCESS_H
5 
6 #if 1
7  #define TMDBG
8  #define LPDBG
9 #else
10  #define TMDBG printf("TMDBG: %s:%i\n", __FILE__, __LINE__)
11  #define LPDBG printf("LPDBG: %s:%i\n", __FILE__, __LINE__)
12 #endif
13 
14 class BCP_buffer;
15 
16 class BCP_process {
17 private:
18  const int me;
19  const int parent;
20 public:
21  BCP_process(int self, int my_parent) : me(self), parent(my_parent) {}
22  // default copy constructor & assignment operator are OK.
23  virtual ~BCP_process() {}
24  int get_process_id() const { return me; }
25  int get_parent() const { return parent; }
26 
27  virtual BCP_buffer& get_message_buffer() = 0;
28  virtual void process_message() = 0;
29 };
30 
31 //#############################################################################
32 
33 // (C) 2007 Copyright International Business Machines Corporation
34 // All Rights Reserved.
35 // This code is published under the Common Public License.
36 //
37 // Authors :
38 // Pierre Bonami, International Business Machines Corporation
39 // Andreas Waechter, International Business Machines Corporation
40 // Laszlo Ladanyi, International Business Machines Corporation
41 //
42 // Date : 10/03/2007
43 
44 #include <map>
45 #include <vector>
46 #include <cmath>
47 #include "CoinHelperFunctions.hpp"
48 
50 public:
52  BCP_scheduler();
53 
63  void setParams(double OverEstimationStatic,
64  double SwitchToRateThreshold,
65  double TimeRootNodeSolve,
66  double FactorTimeHorizon,
67  double OverEstimationRate,
68  double MaxNodeIdRatio,
69  int MaxNodeIdNum,
70  int MaxSbIdNum,
71  int MinSbIdNum);
72 
74  void add_free_ids(int numIds, const int* ids);
81  int request_sb_ids(int numIds, int* ids);
83  void release_sb_id(int id);
84 
87  int request_node_id();
89  void release_node_id(int id);
91  inline bool has_free_node_id() const {
92  return (!freeIds_.empty() && maxNodeIds_ > numNodeIds_);
93  }
95  inline int numNodeIds() const {
96  return numNodeIds_;
97  }
99  inline int maxNodeIds() const {
100  return maxNodeIds_;
101  }
103  inline double node_idle(int p) {
104  return node_idle_time_[p];
105  }
107  inline double sb_idle(int p) {
108  return sb_idle_time_[p];
109  }
111  void update_idle_times();
112 
113 private:
115  int max_id_allocation(int numIds);
117  void update_rates(int add_req, int add_rel);
118 
119 private:
121  std::map<int, double> sb_idle_time_;
123  std::map<int, double> node_idle_time_;
125  std::map<int, double> last_release_type_;
127  std::map<int, double> last_release_time_;
131  std::vector<int> freeIds_;
136 
149 
151  double rho_static_;
157  std::vector<int> request_counts_;
161  std::vector<int> release_counts_;
169  double rho_rate_;
172  bool static_;
176 };
177 
178 #endif
bool static_
flag indicating whether we are in the static or the rate-based phase
int maxSbIds_
Upper threshold for IDs returned at a request.
void setParams(double OverEstimationStatic, double SwitchToRateThreshold, double TimeRootNodeSolve, double FactorTimeHorizon, double OverEstimationRate, double MaxNodeIdRatio, int MaxNodeIdNum, int MaxSbIdNum, int MinSbIdNum)
Method for setting scheduler parameters.
int get_process_id() const
Definition: BCP_process.hpp:24
int maxNodeIdNum_
At most this many ids can be used as a nodeid.
int numNodeIds_
number of lp ids served.
std::map< int, double > sb_idle_time_
the SB idle time for each process
int maxNodeIds() const
Return the maximum possible number of busy LP processes.
Definition: BCP_process.hpp:99
std::map< int, double > node_idle_time_
the node idle time for each process
void update_idle_times()
Update idle times with the last idle time.
bool has_free_node_id() const
Decide if there is an id that can be returned for processin a node.
Definition: BCP_process.hpp:91
double maxNodeIdRatio_
At most this fraction of the total number of ids can be used as a nodeid.
int request_counts_tot_
total number of requests in considered time interval
int numSecRateInterval_
Number of seconds in time horizon for rate computation.
std::map< int, double > last_release_time_
when was the process release last time
const int me
Definition: BCP_process.hpp:18
void add_free_ids(int numIds, const int *ids)
Pass in a list of freeIds_ to add.
virtual void process_message()=0
int minSbIds_
Lower threshold for IDs returned at a request.
int request_sb_ids(int numIds, int *ids)
Request for a number of id&#39;s to do some strong branching.
virtual ~BCP_process()
Definition: BCP_process.hpp:23
int numNodeIds() const
Return the number of busy LP processes.
Definition: BCP_process.hpp:95
time_t time_last_action_
Time stamp of last request or release.
double rho_static_
overestimation factor for static strategy
const int parent
Definition: BCP_process.hpp:19
int counts_ptr_
Array counter.
int request_node_id()
Request an id for processing nodes.
BCP_scheduler()
Default constructor.
int get_parent() const
Definition: BCP_process.hpp:25
BCP_process(int self, int my_parent)
Definition: BCP_process.hpp:21
virtual BCP_buffer & get_message_buffer()=0
int max_id_allocation(int numIds)
Compute max allowed allocation of CPUs.
void release_sb_id(int id)
Gives back to scheduler an id used for strong branching.
std::vector< int > freeIds_
List of free CPUs ids.
std::map< int, double > last_release_type_
the type of the last release (0: algo start, 1: from SB, 2: from node
double switch_thresh_
percentage threshold to swtich to rate-based strategy
int release_counts_tot_
total number of releases in considered time interval
This class describes the message buffer used for all processes of BCP.
Definition: BCP_buffer.hpp:39
int totalNumberIds_
Store the total number of CPUs.
double rho_rate_
overestimation factor for rate-based strategy
int maxNodeIds_
The maximum number of lp ids that can be served.
bool have_rates_
flag indicating whether we have rate information (i.e., the time horizon has passed at least once) ...
void update_rates(int add_req, int add_rel)
Update the counts and the static_ flag.
std::vector< int > release_counts_
vector for counting released sb id requests per time unit
void release_node_id(int id)
Give back an id to scheduler used for processing a node.
double node_idle(int p)
Return how much time did process p spent idling as a node process.
double sb_idle(int p)
Return how much time did process p spent idling as a SB process.
std::vector< int > request_counts_
vector for counting id requests per time unit