/home/coin/SVN-release/Bcp-1.2.1/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_math.hpp"
00009 #include "BCP_enum.hpp"
00010 #include "BCP_enum_process_t.hpp"
00011 #include "BCP_vector.hpp"
00012 
00013 #include "BCP_lp_param.hpp"
00014 #include "BCP_parameters.hpp"
00015 
00016 #include "BCP_buffer.hpp"
00017 #include "BCP_process.hpp"
00018 
00019 //#############################################################################
00020 class OsiObject;
00021 
00022 class BCP_lp_user;
00023 class BCP_user_pack;
00024 class OsiSolverInterface;
00025 class BCP_message_environment;
00026 
00027 class BCP_lp_result;
00028 
00029 class BCP_problem_core;
00030 class BCP_problem_core_change;
00031 
00032 class BCP_var;
00033 class BCP_cut;
00034 
00035 class BCP_col;
00036 class BCP_row;
00037 
00038 class BCP_solution;
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 class CoinWarmStart;
00046 
00047 //#############################################################################
00048 
00049 // Everything in BCP_lp_prob is public. If the user wants to shoot herself in
00050 // the leg she can do it.
00051 
00056 class BCP_lp_statistics {
00057 public:
00059     double time_feas_testing;
00061     double time_cut_generation;
00063     double time_var_generation;
00065     double time_heuristics;
00067     double time_lp_solving;
00069     double time_branching;
00070 
00071 public:
00073     BCP_lp_statistics() : 
00074         time_feas_testing(0),
00075         time_cut_generation(0),
00076         time_var_generation(0),
00077         time_heuristics(0),
00078         time_lp_solving(0),
00079         time_branching(0)
00080     {}
00081 
00085     void pack(BCP_buffer& buf);
00087     void unpack(BCP_buffer& buf);
00091     void display() const;
00092 
00095     void add(const BCP_lp_statistics& stat);
00096 };
00097 
00102 class BCP_lp_prob : public BCP_process {
00103 private:
00107     BCP_lp_prob(const BCP_lp_prob&);
00109     BCP_lp_prob& operator=(const BCP_lp_prob&);
00112 public:
00116     BCP_lp_prob(int my_id, int parent);
00118     virtual ~BCP_lp_prob();
00121 public:
00122     //-------------------------------------------------------------------------
00123     // The unpacking classes
00126     //------------------------------------------------------------------------
00127     // User provided members
00131     BCP_lp_user* user;
00133     BCP_user_pack* packer;
00135     OsiSolverInterface* master_lp;
00137     OsiSolverInterface* lp_solver;
00139     BCP_message_environment* msg_env;
00145     BCP_parameter_set<BCP_lp_par> par;
00148     //------------------------------------------------------------------------
00149     // the description of the core
00153     BCP_problem_core* core;
00155     BCP_problem_core_change* core_as_change;
00158     //------------------------------------------------------------------------
00161     std::vector<OsiObject *> intAndSosObjects;
00162    
00163     //------------------------------------------------------------------------
00164     // the search tree node we are working on and its parent
00168     BCP_lp_node* node;
00170     BCP_lp_parent* parent;
00174     CoinWarmStart* warmstartRoot;
00177     //------------------------------------------------------------------------
00178     // Info while processing a particular node. Need to be updated when
00179     // starting a new node.
00185     BCP_lp_result* lp_result;
00187     int var_bound_changes_since_logical_fixing;
00189     BCP_vec<BCP_cut*> slack_pool;
00191     BCP_lp_var_pool* local_var_pool;
00193     BCP_lp_cut_pool* local_cut_pool;
00194 
00195     // The next/last index we can assign to a newly generated var/cut
00197     int next_var_index;
00199     int last_var_index;
00201     int next_cut_index;
00203     int last_cut_index;
00206     //------------------------------------------------------------------------
00207     // time measurements
00211     double start_time;
00213     BCP_lp_statistics stat;
00216     //------------------------------------------------------------------------
00217     // Internal members
00218     //------------------------------------------------------------------------
00222     double upper_bound;
00224     int phase;
00226     int no_more_cuts_cnt; // a counter for how many places we got to get
00227                           // NO_MORE_CUTS message to know for sure not to
00228                           // expect more.
00230     int no_more_vars_cnt; // similar for vars
00233     // message passing related fields
00237     //    int tree_manager;
00239     BCP_buffer  msg_buf;
00241     //------------------------------------------------------------------------
00242     // Results of BCP_lp_user::process_lp_result() are stored here
00243     //------------------------------------------------------------------------
00244     bool user_has_lp_result_processing;
00245     BCP_vec<BCP_cut*> new_cuts;
00246     BCP_vec<BCP_row*> new_rows;
00247     BCP_vec<BCP_var*> new_vars;
00248     BCP_vec<BCP_col*> new_cols;
00249     BCP_solution* sol;
00250     double new_true_lower_bound;
00251 
00252     //------------------------------------------------------------------------  // end of data members 
00254    
00255 public:
00259     void pack_var(const BCP_var& var);
00261     BCP_var* unpack_var();
00263     void pack_cut(const BCP_cut& cut);
00265     BCP_cut* unpack_cut();
00267     //-------------------------------------------------------------------------
00270     // member functions related to accessing the parameters
00274     inline char
00275     param(BCP_lp_par::chr_params key) const        { return par.entry(key); }
00277     inline int
00278     param(BCP_lp_par::int_params key) const        { return par.entry(key); }
00280     inline double
00281     param(BCP_lp_par::dbl_params key) const        { return par.entry(key); }
00283     inline const BCP_string&
00284     param(BCP_lp_par::str_params key) const        { return par.entry(key); }
00286     inline const BCP_vec<BCP_string>&
00287     param(BCP_lp_par::str_array_params key) const  { return par.entry(key); }
00289     inline double granularity() const {
00290         return param(BCP_lp_par::Granularity);
00291     }
00294     //-------------------------------------------------------------------------
00298     inline bool has_ub() const { return upper_bound < BCP_DBL_MAX / 10; }
00300     inline double ub() const   { return upper_bound; }
00302     inline bool ub(double new_ub) {
00303         if (new_ub < upper_bound){
00304             upper_bound = new_ub;
00305             return true;
00306         }
00307         return false;
00308     }
00310     inline bool over_ub(double lb) const {
00311         return has_ub() && lb >= upper_bound - granularity();
00312     }
00314   // end of query methods 
00315     //-------------------------------------------------------------------------
00316     virtual BCP_buffer& get_message_buffer() { return msg_buf; }
00317     virtual void process_message();
00318 };
00319 
00320 #endif

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