/home/coin/Bcp-1.0.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_buffer.hpp"
00010 #include "BCP_enum.hpp"
00011 #include "BCP_enum_process_t.hpp"
00012 #include "BCP_tm_node.hpp"
00013 
00014 #include "BCP_tm_param.hpp"
00015 #include "BCP_lp_param.hpp"
00016 #include "BCP_cg_param.hpp"
00017 #include "BCP_vg_param.hpp"
00018 //#include "BCP_cp_param.hpp"
00019 //#include "BCP_vp_param.hpp"
00020 #include "BCP_parameters.hpp"
00021 
00022 #include "BCP_buffer.hpp"
00023 #include "BCP_message.hpp"
00024 #include "BCP_process.hpp"
00025 
00026 //#############################################################################
00027 class BCP_warmstart;
00028 class BCP_solution;
00029 
00030 class BCP_tm_user;
00031 
00032 class BCP_var;
00033 class BCP_cut;
00034 
00035 class BCP_var_set_change;
00036 class BCP_cut_set_change;
00037 
00038 class BCP_problem_core;
00039 class BCP_problem_core_change;
00040 
00041 class BCP_lp_statistics;
00042 
00043 //#############################################################################
00044 
00047 class BCP_slave_processes {
00048 
00052    BCP_slave_processes(const BCP_slave_processes&);
00054    BCP_slave_processes& operator=(const BCP_slave_processes&);
00057 public:
00061    BCP_proc_array* all;
00063    BCP_proc_array* lp;
00065    BCP_proc_array* cg;
00067    BCP_proc_array* cp;
00069    BCP_proc_array* vg;
00071    BCP_proc_array* vp;
00074 public:
00078    BCP_slave_processes() : all(0), lp(0), cg(0), cp(0), vg(0), vp(0) {}
00080    ~BCP_slave_processes() {
00081       delete all;   all = 0;
00082       delete lp;   lp = 0; 
00083       delete cp;   cp = 0; 
00084       delete vp;   vp = 0; 
00085       delete cg;   cg = 0; 
00086       delete vg;   vg = 0; 
00087    }
00089 };
00090 
00091 
00094 struct BCP_slave_params {
00096    BCP_parameter_set<BCP_lp_par> lp;
00097    //   BCP_parameter_set<BCP_cp_par> cp;
00098    //   BCP_parameter_set<BCP_vp_par> vp;
00100    BCP_parameter_set<BCP_cg_par> cg;
00102    BCP_parameter_set<BCP_vg_par> vg;
00103 };
00104 
00105 //-----------------------------------------------------------------------------
00106 
00109 struct BCP_tm_flags {
00113    bool root_pricing_unpacked; // set if the result of root pricing is already
00114                                // unpacked. important in a single process
00115                                // environment, so we don't unpack things twice
00116 };
00117 
00118 //-----------------------------------------------------------------------------
00119 
00122 class BCP_tm_prob : public BCP_process {
00123 private:
00127     BCP_tm_prob(const BCP_tm_prob&);
00129     BCP_tm_prob& operator=(const BCP_tm_prob&);
00132   //---------------------------------------------------------------------------
00133 public: // Data members
00137     BCP_tm_user* user;
00139     BCP_message_environment* msg_env;
00143   BCP_lp_statistics* lp_stat;
00144 
00146   BCP_solution* feas_sol;
00147 
00151     BCP_parameter_set<BCP_tm_par> par;
00153     BCP_slave_params slave_pars;
00158     // flags to signal various things
00160     BCP_tm_flags flags;
00166     BCP_buffer msg_buf;
00168     BCP_slave_processes slaves;
00171   //-------------------------------------------------------------------------
00173   double upper_bound;
00175   double start_time;
00176   //-------------------------------------------------------------------------
00180     BCP_problem_core* core;
00182     BCP_problem_core_change* core_as_change;
00186   int phase;
00188   BCP_column_generation current_phase_colgen;
00189 
00191   std::map<int, BCP_var*> vars; // *FIXME*: maybe hash_map better ?
00193   std::map<int, BCP_cut*> cuts; // *FIXME*: maybe hash_map better ?
00195   int next_cut_index_set_start;
00197   int next_var_index_set_start;
00198 
00199   //-------------------------------------------------------------------------
00201   BCP_tree search_tree;
00203   BCP_vec<BCP_tm_node*> active_nodes;
00205   BCP_node_queue candidates;
00207   BCP_vec<BCP_tm_node*> next_phase_nodes;
00209   BCP_vec<BCP_tm_node*> nodes_to_free;
00210 
00211   //-------------------------------------------------------------------------
00216     BCP_vec< std::pair<BCP_proc_id*, int> > leaves_per_cp;
00218     BCP_vec< std::pair<BCP_proc_id*, int> > leaves_per_vp;
00221   //---------------------------------------------------------------------------
00222 
00223 public:
00227     BCP_tm_prob(BCP_proc_id* my_id, BCP_proc_id* parent);
00229     virtual ~BCP_tm_prob();
00232 public:
00236     void pack_var(BCP_process_t target_proc, const BCP_var& var);
00238     BCP_var* unpack_var_without_bcpind(BCP_buffer& buf);
00240     BCP_var* unpack_var();
00242     void pack_cut(BCP_process_t target_proc, const BCP_cut& cut);
00244     BCP_cut* unpack_cut();
00246     void pack_var_set_change(const BCP_var_set_change& ch);
00248     void unpack_var_set_change(BCP_var_set_change& ch);
00250     void pack_cut_set_change(const BCP_cut_set_change& ch);
00252     void unpack_cut_set_change(BCP_cut_set_change& ch);
00254   //---------------------------------------------------------------------------
00255 
00259    inline char
00260    param(BCP_tm_par::chr_params key) const        { return par.entry(key); }
00262    inline int
00263    param(BCP_tm_par::int_params key) const        { return par.entry(key); }
00265    inline double
00266    param(BCP_tm_par::dbl_params key) const        { return par.entry(key); }
00268    inline const BCP_string&
00269    param(BCP_tm_par::str_params key) const        { return par.entry(key); }
00271    inline const BCP_vec<BCP_string>&
00272    param(BCP_tm_par::str_array_params key) const  { return par.entry(key); }
00273 
00275    inline double granularity() const {
00276       return param(BCP_tm_par::Granularity);
00277    }
00278 
00279    //--------------------------------------------------------------------------
00281    inline bool has_ub() const { return upper_bound < DBL_MAX/2; }
00283    inline double ub() const { return upper_bound; }
00285    inline bool ub(double new_ub) {
00286       if (new_ub < upper_bound){
00287          upper_bound = new_ub;
00288          return true;
00289       }
00290       return false;
00291    }
00293    inline bool over_ub(const double lb) const {
00294       return lb > upper_bound - param(BCP_tm_par::Granularity);
00295    }
00297    //--------------------------------------------------------------------------
00298    virtual BCP_buffer& get_message_buffer() { return msg_buf; }
00299    virtual void process_message();
00300 };
00301 
00302 //#############################################################################
00303 
00304 #endif
00305 

Generated on Wed Aug 22 03:00:54 2007 for coin-Bcp by  doxygen 1.4.7