/home/coin/SVN-release/CoinAll-1.1.0/Bcp/src/include/BCP_tm.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_TM_H
00004 #define _BCP_TM_H
00005 
00006 #include <queue>
00007 #include <map>
00008 
00009 #include "BCP_math.hpp"
00010 #include "BCP_buffer.hpp"
00011 #include "BCP_enum.hpp"
00012 #include "BCP_enum_process_t.hpp"
00013 #include "BCP_tm_node.hpp"
00014 
00015 #include "BCP_tm_param.hpp"
00016 #include "BCP_lp_param.hpp"
00017 #include "BCP_cg_param.hpp"
00018 #include "BCP_vg_param.hpp"
00019 //#include "BCP_cp_param.hpp"
00020 //#include "BCP_vp_param.hpp"
00021 #include "BCP_parameters.hpp"
00022 
00023 #include "BCP_buffer.hpp"
00024 #include "BCP_message.hpp"
00025 #include "BCP_process.hpp"
00026 
00027 //#############################################################################
00028 class BCP_warmstart;
00029 class BCP_solution;
00030 
00031 class BCP_tm_user;
00032 
00033 class BCP_var;
00034 class BCP_cut;
00035 
00036 class BCP_var_set_change;
00037 class BCP_cut_set_change;
00038 
00039 class BCP_problem_core;
00040 class BCP_problem_core_change;
00041 
00042 class BCP_lp_statistics;
00043 
00044 //#############################################################################
00045 
00048 class BCP_slave_processes {
00049 
00053     BCP_slave_processes(const BCP_slave_processes&);
00055     BCP_slave_processes& operator=(const BCP_slave_processes&);
00058 public:
00062     BCP_proc_array* all;
00064     BCP_proc_array* lp;
00066     BCP_proc_array* cg;
00068     BCP_proc_array* cp;
00070     BCP_proc_array* vg;
00072     BCP_proc_array* vp;
00075 public:
00079     BCP_slave_processes() : all(0), lp(0), cg(0), cp(0), vg(0), vp(0) {}
00081     ~BCP_slave_processes() {
00082         delete all;   all = 0;
00083         delete lp;   lp = 0; 
00084         delete cp;   cp = 0; 
00085         delete vp;   vp = 0; 
00086         delete cg;   cg = 0; 
00087         delete vg;   vg = 0; 
00088     }
00090 };
00091 
00092 
00095 struct BCP_slave_params {
00097     BCP_parameter_set<BCP_lp_par> lp;
00098     //   BCP_parameter_set<BCP_cp_par> cp;
00099     //   BCP_parameter_set<BCP_vp_par> vp;
00101     BCP_parameter_set<BCP_cg_par> cg;
00103     BCP_parameter_set<BCP_vg_par> vg;
00104 };
00105 
00106 //-----------------------------------------------------------------------------
00107 
00110 struct BCP_tm_flags {
00114     bool root_pricing_unpacked; // set if the result of root pricing is already
00115     // unpacked. important in a single process
00116     // environment, so we don't unpack things twice
00117 };
00118 
00119 //-----------------------------------------------------------------------------
00120 
00123 class BCP_tm_prob : public BCP_process {
00124 private:
00128     BCP_tm_prob(const BCP_tm_prob&);
00130     BCP_tm_prob& operator=(const BCP_tm_prob&);
00133     //-------------------------------------------------------------------------
00134 public: // Data members
00138     BCP_tm_user* user;
00140     BCP_message_environment* msg_env;
00144     BCP_lp_statistics* lp_stat;
00145 
00147     BCP_solution* feas_sol;
00148 
00152     BCP_parameter_set<BCP_tm_par> par;
00154     BCP_slave_params slave_pars;
00159     // flags to signal various things
00161     BCP_tm_flags flags;
00167     BCP_buffer msg_buf;
00169     BCP_slave_processes slaves;
00172     //-------------------------------------------------------------------------
00174     double upper_bound;
00176     double start_time;
00177     //-------------------------------------------------------------------------
00181     BCP_problem_core* core;
00183     BCP_problem_core_change* core_as_change;
00187     int phase;
00189     BCP_column_generation current_phase_colgen;
00190 
00192     std::map<int, BCP_var*> vars; // *FIXME*: maybe hash_map better ?
00194     std::map<int, BCP_cut*> cuts; // *FIXME*: maybe hash_map better ?
00196     int next_cut_index_set_start;
00198     int next_var_index_set_start;
00199 
00200     //-------------------------------------------------------------------------
00202     BCP_tree search_tree;
00204     BCP_vec<BCP_tm_node*> active_nodes;
00206     BCP_node_queue candidates;
00208     BCP_vec<BCP_tm_node*> next_phase_nodes;
00210     BCP_vec<BCP_tm_node*> nodes_to_free;
00211 
00212     //-------------------------------------------------------------------------
00217     BCP_vec< std::pair<BCP_proc_id*, int> > leaves_per_cp;
00219     BCP_vec< std::pair<BCP_proc_id*, int> > leaves_per_vp;
00222     //-------------------------------------------------------------------------
00223 
00224 public:
00228     BCP_tm_prob(BCP_proc_id* my_id, BCP_proc_id* parent);
00230     virtual ~BCP_tm_prob();
00233 public:
00237     void pack_var(BCP_process_t target_proc, const BCP_var& var);
00239     BCP_var* unpack_var_without_bcpind(BCP_buffer& buf);
00241     BCP_var* unpack_var();
00243     void pack_cut(BCP_process_t target_proc, const BCP_cut& cut);
00245     BCP_cut* unpack_cut();
00247     void pack_var_set_change(const BCP_var_set_change& ch);
00249     void unpack_var_set_change(BCP_var_set_change& ch);
00251     void pack_cut_set_change(const BCP_cut_set_change& ch);
00253     void unpack_cut_set_change(BCP_cut_set_change& ch);
00255     //-------------------------------------------------------------------------
00256 
00260     inline char
00261     param(BCP_tm_par::chr_params key) const        { return par.entry(key); }
00263     inline int
00264     param(BCP_tm_par::int_params key) const        { return par.entry(key); }
00266     inline double
00267     param(BCP_tm_par::dbl_params key) const        { return par.entry(key); }
00269     inline const BCP_string&
00270     param(BCP_tm_par::str_params key) const        { return par.entry(key); }
00272     inline const BCP_vec<BCP_string>&
00273     param(BCP_tm_par::str_array_params key) const  { return par.entry(key); }
00274 
00276     inline double granularity() const {
00277         return param(BCP_tm_par::Granularity);
00278     }
00279 
00280     //-------------------------------------------------------------------------
00282     inline bool has_ub() const { return upper_bound < BCP_DBL_MAX / 10; }
00284     inline double ub() const { return upper_bound; }
00286     inline bool ub(double new_ub) {
00287         if (new_ub < upper_bound){
00288             upper_bound = new_ub;
00289             return true;
00290         }
00291         return false;
00292     }
00294     inline bool over_ub(const double lb) const {
00295         return lb > upper_bound - param(BCP_tm_par::Granularity);
00296     }
00298     //-------------------------------------------------------------------------
00299     virtual BCP_buffer& get_message_buffer() { return msg_buf; }
00300     virtual void process_message();
00301 };
00302 
00303 //#############################################################################
00304 
00305 #endif
00306 

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