00001 // Copyright (C) 2000, International Business Machines 00002 // Corporation and others. All Rights Reserved. 00003 #include "BCP_buffer.hpp" 00004 #include "BCP_var.hpp" 00005 #include "BCP_branch.hpp" 00006 00007 //############################################################################# 00008 00009 void 00010 BCP_var_set::set_lb_ub(const BCP_vec<int>& indices, 00011 BCP_vec<double>::const_iterator bounds) 00012 { 00013 BCP_vec<int>::const_iterator ii = indices.begin(); 00014 BCP_vec<int>::const_iterator lastii = indices.end(); 00015 for ( ; ii != lastii; ++ii){ 00016 const double lb = *bounds; 00017 ++bounds; 00018 const double ub = *bounds; 00019 ++bounds; 00020 operator[](*ii)->change_bounds(lb, ub); 00021 } 00022 } 00023 00024 //----------------------------------------------------------------------------- 00025 00026 void 00027 BCP_var_set::set_lb_ub_st(const BCP_vec<BCP_obj_change>& vc) 00028 { 00029 BCP_vec<BCP_obj_change>::const_iterator chi = vc.begin(); 00030 BCP_vec<BCP_obj_change>::const_iterator lastchi = vc.end(); 00031 iterator var = begin(); 00032 while (chi != lastchi){ 00033 (*var)->change_lb_ub_st(*chi); 00034 ++var; 00035 ++chi; 00036 } 00037 } 00038 00039 //----------------------------------------------------------------------------- 00040 00041 void 00042 BCP_var_set::set_lb_ub_st(BCP_vec<int>::const_iterator pos, 00043 const BCP_vec<BCP_obj_change>& vc){ 00044 BCP_vec<BCP_obj_change>::const_iterator chi = vc.begin(); 00045 BCP_vec<BCP_obj_change>::const_iterator lastchi = vc.end(); 00046 while (chi != lastchi){ 00047 operator[](*pos)->change_lb_ub_st(*chi); 00048 ++pos; 00049 ++chi; 00050 } 00051 } 00052 00053 //----------------------------------------------------------------------------- 00054 00055 void 00056 BCP_var_set::deletable(const int bvarnum, BCP_vec<int>& collection){ 00057 collection.clear(); 00058 collection.reserve(size() - bvarnum); 00059 iterator var = entry(bvarnum); 00060 for (int i = bvarnum; var != end(); ++var, ++i) { 00061 if ((*var)->is_to_be_removed()) 00062 collection.unchecked_push_back(i); 00063 } 00064 } 00065 00066 //############################################################################# 00067 00068 BCP_var_algo::~BCP_var_algo() {} 00069 00070 void 00071 BCP_var::display(const double val) const 00072 { 00073 switch (obj_type()) { 00074 case BCP_CoreObj: 00075 printf(" Core var (internal index: %6i ) at %.4f\n", 00076 _bcpind, val); 00077 break; 00078 case BCP_AlgoObj: 00079 printf(" Algo var (internal index: %6i ) at %.4f\n", 00080 _bcpind, val); 00081 break; 00082 default: 00083 throw BCP_fatal_error("Untyped object in BCP_solution_gen::display()\n"); 00084 } 00085 } 00086