/home/coin/Bcp-1.0.0/Bcp/src/include/BCP_lp.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_LP_H
00004 #define _BCP_LP_H
00005 
00006 #include <cfloat>
00007 
00008 #include "BCP_enum.hpp"
00009 #include "BCP_enum_process_t.hpp"
00010 #include "BCP_vector.hpp"
00011 
00012 #include "BCP_lp_param.hpp"
00013 #include "BCP_parameters.hpp"
00014 
00015 #include "BCP_buffer.hpp"
00016 #include "BCP_process.hpp"
00017 
00018 //#############################################################################
00019 class BCP_lp_user;
00020 class OsiSolverInterface;
00021 class BCP_message_environment;
00022 
00023 class BCP_lp_result;
00024 
00025 class BCP_problem_core;
00026 class BCP_problem_core_change;
00027 
00028 class BCP_var;
00029 class BCP_cut;
00030 class BCP_var_indexed;
00031 
00032 class BCP_col;
00033 class BCP_row;
00034 
00035 class BCP_solution;
00036 
00037 class BCP_var_set_change;
00038 class BCP_cut_set_change;
00039 
00040 class BCP_lp_var_pool;
00041 class BCP_lp_cut_pool;
00042 
00043 class BCP_lp_node;
00044 class BCP_lp_parent;
00045 
00046 //#############################################################################
00047 
00048 // Everything in BCP_lp_prob is public. If the user wants to shoot herself in
00049 // the leg she can do it.
00050 
00055 class BCP_lp_statistics {
00056 public:
00058     double time_feas_testing;
00060     double time_cut_generation;
00062     double time_var_generation;
00064     double time_heuristics;
00066     double time_lp_solving;
00068     double time_branching;
00069 
00070 public:
00072     BCP_lp_statistics() : 
00073         time_feas_testing(0),
00074         time_cut_generation(0),
00075         time_var_generation(0),
00076         time_heuristics(0),
00077         time_lp_solving(0),
00078         time_branching(0)
00079     {}
00080 
00084     void pack(BCP_buffer& buf);
00086     void unpack(BCP_buffer& buf);
00090     void display() const;
00091 
00094     void add(const BCP_lp_statistics& stat);
00095 };
00096 
00101 class BCP_lp_prob : public BCP_process {
00102 private:
00106     BCP_lp_prob(const BCP_lp_prob&);
00108     BCP_lp_prob& operator=(const BCP_lp_prob&);
00111 public:
00115     BCP_lp_prob(BCP_proc_id* my_id, BCP_proc_id* parent);
00117     virtual ~BCP_lp_prob();
00120 public:
00121     //-------------------------------------------------------------------------
00122     // The unpacking classes
00125     //------------------------------------------------------------------------
00126     // User provided members
00130     BCP_lp_user* user;
00132     OsiSolverInterface* master_lp;
00134     OsiSolverInterface* lp_solver;
00136     BCP_message_environment* msg_env;
00142     BCP_parameter_set<BCP_lp_par> par;
00145     //------------------------------------------------------------------------
00146     // the description of the core
00150     BCP_problem_core* core;
00152     BCP_problem_core_change* core_as_change;
00155     //------------------------------------------------------------------------
00156     // the search tree node we are working on and its parent
00160     BCP_lp_node* node;
00162     BCP_lp_parent* parent;
00165     //------------------------------------------------------------------------
00166     // Info while processing a particular node. Need to be updated when
00167     // starting a new node.
00173     BCP_lp_result* lp_result;
00175     int var_bound_changes_since_logical_fixing;
00177     BCP_vec<BCP_cut*> slack_pool;
00179     BCP_lp_var_pool* local_var_pool;
00181     BCP_lp_cut_pool* local_cut_pool;
00182 
00183     // The next/last index we can assign to a newly generated var/cut
00185     int next_var_index;
00187     int last_var_index;
00189     int next_cut_index;
00191     int last_cut_index;
00194     //------------------------------------------------------------------------
00195     // time measurements
00199     BCP_lp_statistics stat;
00202     //------------------------------------------------------------------------
00203     // Internal members
00204     //------------------------------------------------------------------------
00208     double upper_bound;
00210     int phase;
00212     int no_more_cuts_cnt; // a counter for how many places we got to get
00213     // NO_MORE_CUTS message to know for sure not to
00214     // expect more.
00216     int no_more_vars_cnt; // similar for vars
00219     // message passing related fields
00223     //    BCP_proc_id* tree_manager;
00225     BCP_buffer  msg_buf;
00227     //------------------------------------------------------------------------
00228     // Results of BCP_lp_user::process_lp_result() are stored here
00229     //------------------------------------------------------------------------
00230     bool user_has_lp_result_processing;
00231     BCP_vec<BCP_cut*> new_cuts;
00232     BCP_vec<BCP_row*> new_rows;
00233     BCP_vec<BCP_var*> new_vars;
00234     BCP_vec<BCP_col*> new_cols;
00235     BCP_solution* sol;
00236     double new_true_lower_bound;
00237 
00238     //------------------------------------------------------------------------  // end of data members 
00240    
00241 public:
00245     void pack_var(BCP_process_t target_proc, const BCP_var& var);
00247     BCP_var* unpack_var();
00249     void pack_cut(BCP_process_t target_proc, const BCP_cut& cut);
00251     BCP_cut* unpack_cut();
00253     void pack_var_set_change(const BCP_var_set_change& ch);
00255     void unpack_var_set_change(BCP_var_set_change& ch);
00257     void pack_cut_set_change(const BCP_cut_set_change& ch);
00259     void unpack_cut_set_change(BCP_cut_set_change& ch);
00261     //-------------------------------------------------------------------------
00264     // member functions related to accessing the parameters
00268     inline char
00269     param(BCP_lp_par::chr_params key) const        { return par.entry(key); }
00271     inline int
00272     param(BCP_lp_par::int_params key) const        { return par.entry(key); }
00274     inline double
00275     param(BCP_lp_par::dbl_params key) const        { return par.entry(key); }
00277     inline const BCP_string&
00278     param(BCP_lp_par::str_params key) const        { return par.entry(key); }
00280     inline const BCP_vec<BCP_string>&
00281     param(BCP_lp_par::str_array_params key) const  { return par.entry(key); }
00283     inline double granularity() const {
00284         return param(BCP_lp_par::Granularity);
00285     }
00288     //-------------------------------------------------------------------------
00292     inline bool has_ub() const { return upper_bound < DBL_MAX/2; }
00294     inline double ub() const   { return upper_bound; }
00296     inline bool ub(double new_ub) {
00297         if (new_ub < upper_bound){
00298             upper_bound = new_ub;
00299             return true;
00300         }
00301         return false;
00302     }
00304     inline bool over_ub(double lb) const {
00305         return has_ub() && lb >= upper_bound - granularity();
00306     }
00308   // end of query methods 
00309     //-------------------------------------------------------------------------
00310     virtual BCP_buffer& get_message_buffer() { return msg_buf; }
00311     virtual void process_message();
00312 };
00313 
00314 #endif

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