/home/coin/SVN-release/OS-2.2.0/Bcp/src/VG/BCP_vg.cpp

Go to the documentation of this file.
00001 // Copyright (C) 2000, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 #include "BCP_math.hpp"
00004 #include "BCP_message.hpp"
00005 #include "BCP_vector.hpp"
00006 #include "BCP_problem_core.hpp"
00007 #include "BCP_var.hpp"
00008 #include "BCP_cut.hpp"
00009 #include "BCP_vg.hpp"
00010 #include "BCP_vg_user.hpp"
00011 
00012 BCP_vg_prob::BCP_vg_prob(int my_id, int parent) :
00013    BCP_process(my_id, parent),
00014    user(0), msg_env(0), core(new BCP_problem_core),
00015    upper_bound(BCP_DBL_MAX), phase(0) {}
00016 
00017 
00018 BCP_vg_prob::~BCP_vg_prob()
00019 {
00020    delete user;   user = 0;
00021    delete packer; packer = 0;
00022    delete core;   core = 0;
00023    purge_ptr_vector(cuts);
00024 }
00025 
00026 bool
00027 BCP_vg_prob::probe_messages()
00028 {
00029    while (msg_env->probe(BCP_AnyProcess, BCP_Msg_UpperBound)) {
00030       msg_env->receive(BCP_AnyProcess, BCP_Msg_UpperBound, msg_buf, 0);
00031       double new_ub;
00032       msg_buf.unpack(new_ub);
00033       if (new_ub < upper_bound)
00034          upper_bound = new_ub;
00035    }
00036 
00037    if (msg_env->probe(BCP_AnyProcess, BCP_Msg_ForVG_DualNonzeros))
00038       return true;
00039    if (msg_env->probe(BCP_AnyProcess, BCP_Msg_ForVG_DualFull))
00040       return true;
00041    if (msg_env->probe(BCP_AnyProcess, BCP_Msg_ForVG_User))
00042       return true;
00043 
00044    if (msg_env->probe(BCP_AnyProcess, BCP_Msg_FinishedBCP))
00045       return true;
00046    return false;
00047 }
00048 
00049 BCP_cut* 
00050 BCP_vg_prob::unpack_cut()
00051 {
00052   BCP_object_t obj_t;
00053   int bcpind;
00054   double lb, ub;
00055   BCP_obj_status stat;
00056   msg_buf.unpack(bcpind)
00057          .unpack(obj_t).unpack(stat).unpack(lb).unpack(ub);
00058 
00059   BCP_cut* cut = 0;
00060   switch (obj_t) {
00061   case BCP_CoreObj:
00062     cut = new BCP_cut_core(lb, ub);
00063     break;
00064   case BCP_AlgoObj:
00065     cut = packer->unpack_cut_algo(msg_buf);
00066     cut->change_bounds(lb, ub);
00067     break;
00068   default:
00069     throw BCP_fatal_error("BCP_vg_prob::_unpack_cut(): unexpected obj_t.\n");
00070   }
00071   cut->set_bcpind(bcpind);
00072   cut->set_status(stat);
00073 
00074   return cut;
00075 }
00076 

Generated on Thu Aug 5 03:02:53 2010 by  doxygen 1.4.7