Bcp  1.4.4
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_;
129  int totalNumberIds_;
131  std::vector<int> freeIds_;
133  int numNodeIds_;
135  int maxNodeIds_;
136 
139  double maxNodeIdRatio_;
142  int maxNodeIdNum_;
145  int maxSbIds_;
148  int minSbIds_;
149 
151  double rho_static_;
153  double switch_thresh_;
155  int numSecRateInterval_;
157  std::vector<int> request_counts_;
159  int request_counts_tot_;
161  std::vector<int> release_counts_;
163  int release_counts_tot_;
165  int counts_ptr_;
167  time_t time_last_action_;
169  double rho_rate_;
172  bool static_;
175  bool have_rates_;
176 };
177 
178 #endif
BCP_process::get_message_buffer
virtual BCP_buffer & get_message_buffer()=0
BCP_scheduler::maxNodeIds
int maxNodeIds() const
Return the maximum possible number of busy LP processes.
Definition: BCP_process.hpp:99
BCP_process::BCP_process
BCP_process(int self, int my_parent)
Definition: BCP_process.hpp:21
BCP_scheduler::setParams
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.
BCP_scheduler::has_free_node_id
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
BCP_scheduler::update_idle_times
void update_idle_times()
Update idle times with the last idle time.
BCP_scheduler::request_node_id
int request_node_id()
Request an id for processing nodes.
BCP_process::get_process_id
int get_process_id() const
Definition: BCP_process.hpp:24
BCP_scheduler::release_node_id
void release_node_id(int id)
Give back an id to scheduler used for processing a node.
BCP_process::get_parent
int get_parent() const
Definition: BCP_process.hpp:25
CoinHelperFunctions.hpp
BCP_scheduler::add_free_ids
void add_free_ids(int numIds, const int *ids)
Pass in a list of freeIds_ to add.
BCP_scheduler::node_idle
double node_idle(int p)
Return how much time did process p spent idling as a node process.
Definition: BCP_process.hpp:103
BCP_process::process_message
virtual void process_message()=0
BCP_scheduler
Definition: BCP_process.hpp:49
BCP_scheduler::request_sb_ids
int request_sb_ids(int numIds, int *ids)
Request for a number of id's to do some strong branching.
BCP_scheduler::sb_idle
double sb_idle(int p)
Return how much time did process p spent idling as a SB process.
Definition: BCP_process.hpp:107
BCP_scheduler::release_sb_id
void release_sb_id(int id)
Gives back to scheduler an id used for strong branching.
BCP_process::~BCP_process
virtual ~BCP_process()
Definition: BCP_process.hpp:23
BCP_process
Definition: BCP_process.hpp:16
BCP_scheduler::numNodeIds
int numNodeIds() const
Return the number of busy LP processes.
Definition: BCP_process.hpp:95
BCP_scheduler::BCP_scheduler
BCP_scheduler()
Default constructor.
BCP_buffer
This class describes the message buffer used for all processes of BCP.
Definition: BCP_buffer.hpp:39