/home/coin/SVN-release/Bcp-1.2.1/Bcp/src/include/BCP_process.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2000, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
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     // default copy constructor & assignment operator are OK.
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 // (C) 2007 Copyright International Business Machines Corporation
00034 // All Rights Reserved.
00035 // This code is published under the Common Public License.
00036 //
00037 // Authors :
00038 // Pierre Bonami, International Business Machines Corporation
00039 // Andreas Waechter, International Business Machines Corporation
00040 // Laszlo Ladanyi, International Business Machines Corporation
00041 //
00042 // Date : 10/03/2007
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

Generated on Thu Jan 15 03:00:59 2009 for coin-Bcp by  doxygen 1.4.7