/home/coin/SVN-release/OS-2.0.0/Bcp/src/VG/BCP_vg_user.cpp

Go to the documentation of this file.
00001 // Copyright (C) 2000, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 
00004 #include <cassert>
00005 #include "BCP_message_tag.hpp"
00006 #include "BCP_buffer.hpp"
00007 #include "BCP_var.hpp"
00008 #include "BCP_cut.hpp"
00009 
00010 #include "BCP_vg.hpp"
00011 #include "BCP_vg_user.hpp"
00012 
00013 //#############################################################################
00014 // Informational methods for the user
00015 double BCP_vg_user::upper_bound() const    { return p->ub(); }
00016 int BCP_vg_user::current_phase() const     { return p->phase; }
00017 int BCP_vg_user::current_level() const     { return p->node_level; }
00018 int BCP_vg_user::current_index() const     { return p->node_index; }
00019 int BCP_vg_user::current_iteration() const { return p->node_iteration; }
00020 
00021 //#############################################################################
00022 // Informational methods for the user
00023 /* Methods to get/set BCP parameters on the fly */
00024 char
00025 BCP_vg_user::get_param(const BCP_vg_par::chr_params key) const
00026 { return p->par.entry(key); }
00027 int
00028 BCP_vg_user::get_param(const BCP_vg_par::int_params key) const
00029 { return p->par.entry(key); }
00030 double
00031 BCP_vg_user::get_param(const BCP_vg_par::dbl_params key) const
00032 { return p->par.entry(key); }
00033 const BCP_string&
00034 BCP_vg_user::get_param(const BCP_vg_par::str_params key) const
00035 { return p->par.entry(key); }
00036 
00037 void BCP_vg_user::set_param(const BCP_vg_par::chr_params key, const bool val)
00038 { p->par.set_entry(key, val); }
00039 void BCP_vg_user::set_param(const BCP_vg_par::chr_params key, const char val)
00040 { p->par.set_entry(key, val); }
00041 void BCP_vg_user::set_param(const BCP_vg_par::int_params key, const int val)
00042 { p->par.set_entry(key, val); }
00043 void BCP_vg_user::set_param(const BCP_vg_par::dbl_params key, const double val)
00044 { p->par.set_entry(key, val); }
00045 void BCP_vg_user::set_param(const BCP_vg_par::str_params key, const char * val)
00046 { p->par.set_entry(key, val); }
00047 
00048 //#############################################################################
00049 
00050 void
00051 BCP_vg_user::send_var(const BCP_var& var)
00052 {
00053   BCP_buffer& buf = p->msg_buf;
00054   buf.clear();
00055   const int bcpind = var.bcpind();
00056   const BCP_object_t obj_t = var.obj_type();
00057   const BCP_obj_status stat = var.status();
00058   const BCP_var_t var_t = var.var_type();
00059   const double obj = var.obj();
00060   const double lb = var.lb();
00061   const double ub = var.ub();
00062   buf.pack(bcpind)
00063      .pack(obj_t).pack(stat).pack(var_t).pack(obj).pack(lb).pack(ub);
00064   assert(obj_t == BCP_AlgoObj);
00065   p->packer->pack_var_algo(&dynamic_cast<const BCP_var_algo&>(var), buf);
00066   p->msg_env->send(p->sender, BCP_Msg_VarDescription, buf);
00067 }
00068 
00069 //#############################################################################
00070 
00071 void
00072 BCP_vg_user::unpack_module_data(BCP_buffer& buf)
00073 {
00074   if (p->par.entry(BCP_vg_par::ReportWhenDefaultIsExecuted)) {
00075     printf(" VG: Default unpack_module_data() executed.\n");
00076   }
00077 }
00078 
00079 //#############################################################################
00080 
00081 void
00082 BCP_vg_user::unpack_dual_solution(BCP_buffer& buf)
00083 {
00084   if (p->par.entry(BCP_vg_par::ReportWhenDefaultIsExecuted)) {
00085     printf(" VG: Default unpack_dual_solution() executed.\n");
00086   }
00087   
00088    if (buf.msgtag() == BCP_Msg_ForVG_User) {
00089       throw BCP_fatal_error("\
00090 VG: BCP_Msg_LpSolution_User message arrived but the unpack_dual_solution() \n\
00091     function is not overridden.\n");
00092    } else {
00093       int cutnum;
00094       buf.unpack(cutnum);
00095       if (cutnum > 0) {
00096          // Just to be on the safe side... If it's already empty, it won't
00097          // take long.
00098          purge_ptr_vector(p->cuts);
00099          p->pi.clear();
00100          p->cuts.reserve(cutnum);
00101          p->pi.reserve(cutnum);
00102          double val;
00103          while (--cutnum >= 0) {
00104             buf.unpack(val);
00105             p->pi.unchecked_push_back(val);
00106             p->cuts.unchecked_push_back(p->unpack_cut());
00107          }
00108       }
00109    }
00110 }
00111 
00112 //#############################################################################
00113 
00114 void
00115 BCP_vg_user::generate_vars(BCP_vec<BCP_cut*>& cuts, BCP_vec<double>& pi)
00116 {
00117   if (p->par.entry(BCP_vg_par::ReportWhenDefaultIsExecuted)) {
00118     printf(" VG: Default generate_vars() executed.\n");
00119   }
00120 }

Generated on Mon Aug 3 03:02:16 2009 by  doxygen 1.4.7