/home/coin/SVN-release/OS-2.1.1/Bcp/src/Member/BCP_cut.cpp

Go to the documentation of this file.
00001 // Copyright (C) 2000, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 #include <cmath>
00004 
00005 #include "BCP_buffer.hpp"
00006 #include "BCP_cut.hpp"
00007 #include "BCP_branch.hpp"
00008 
00009 //#############################################################################
00010 
00011 void
00012 BCP_cut_set::set_lb_ub(const BCP_vec<int>& indices,
00013                        BCP_vec<double>::const_iterator bounds)
00014 {
00015    BCP_vec<int>::const_iterator ii = indices.begin();
00016    BCP_vec<int>::const_iterator lastii = indices.end();
00017    for ( ; ii != lastii; ++ii){
00018       const double lb = *bounds;
00019       ++bounds;
00020       const double ub = *bounds;
00021       ++bounds;
00022       operator[](*ii)->change_bounds(lb, ub);
00023    }
00024 }
00025 
00026 //-----------------------------------------------------------------------------
00027 
00028 void
00029 BCP_cut_set::set_lb_ub_st(const BCP_vec<BCP_obj_change>& vc)
00030 {
00031    BCP_vec<BCP_obj_change>::const_iterator chi = vc.begin();
00032    BCP_vec<BCP_obj_change>::const_iterator lastchi = vc.end();
00033    iterator cut = begin();
00034    while (chi != lastchi) {
00035       (*cut)->change_lb_ub_st(*chi);
00036       ++cut;
00037       ++chi;
00038    }
00039 }
00040 
00041 //-----------------------------------------------------------------------------
00042 
00043 void
00044 BCP_cut_set::set_lb_ub_st(BCP_vec<int>::const_iterator pos,
00045                           const BCP_vec<BCP_obj_change>& vc)
00046 {
00047    BCP_vec<BCP_obj_change>::const_iterator chi = vc.begin();
00048    BCP_vec<BCP_obj_change>::const_iterator lastchi = vc.end();
00049    while (chi != lastchi){
00050       operator[](*pos)->change_lb_ub_st(*chi);
00051       ++pos;
00052       ++chi;
00053    }
00054 }
00055 
00056 //-----------------------------------------------------------------------------
00057 #if 0
00058 void
00059 BCP_cut_set::nonzero_slack(int first_to_check, const double * slacks,
00060                            const double etol, const int ineff_limit,
00061                            BCP_vec<int>& coll)
00062 {
00063    const int cutnum = size();
00064    coll.reserve(cutnum);
00065    for ( ; first_to_check < cutnum; ++first_to_check) {
00066       BCP_cut *cut = operator[](first_to_check);
00067       // Most cuts are removable, so it's not worth to test whether a cut is
00068       // removable, just test the slackness. Who cares what is the
00069       // effectiveness count of non-removable cuts.
00070       if (slacks[first_to_check] > etol) {
00071         if (cut->decrease_effective_count() <= -ineff_limit) {
00072           coll.unchecked_push_back(first_to_check);
00073         }
00074       } else {
00075         cut->increase_effective_count();
00076       }
00077    }
00078 }
00079 
00080 //-----------------------------------------------------------------------------
00081 void
00082 BCP_cut_set::zero_dual(int first_to_check, const double * duals,
00083                        const double etol, const int ineff_limit,
00084                        BCP_vec<int>& coll)
00085 {
00086    const int cutnum = size();
00087    coll.reserve(cutnum);
00088    for ( ; first_to_check < cutnum; ++first_to_check) {
00089       BCP_cut *cut = operator[](first_to_check);
00090       // Most cuts are removable, so it's not worth to test whether a cut is
00091       // removable, just test the slackness. Who cares what is the
00092       // effectiveness count of non-removable cuts.
00093       if (abs(duals[first_to_check]) <= etol) {
00094         if (cut->decrease_effective_count() <= -ineff_limit) {
00095           coll.unchecked_push_back(first_to_check);
00096         }
00097       }else{
00098         cut->increase_effective_count();
00099       }
00100    }
00101 }
00102 //-----------------------------------------------------------------------------
00103 
00104 void
00105 BCP_cut_set::deletable(int bcutnum, BCP_vec<int>& collection) const
00106 {
00107    const int cutnum = size();
00108    collection.reserve(cutnum - bcutnum);
00109    int i;
00110    for (i = bcutnum; i < cutnum; ++i) {
00111       BCP_cut *cut = operator[](i);
00112       if (cut->is_to_be_removed())
00113          collection.unchecked_push_back(i);
00114    }
00115 }
00116 #endif
00117 void
00118 BCP_cut_set::move_deletable_to_pool(const BCP_vec<int>& del_cuts,
00119                                     BCP_vec<BCP_cut*>& pool)
00120 {
00121    BCP_vec<int>::const_iterator ii = del_cuts.begin();
00122    BCP_vec<int>::const_iterator lastii = del_cuts.end();
00123    pool.reserve(pool.size() + del_cuts.size());
00124    while (ii != lastii) {
00125       pool.unchecked_push_back(operator[](*ii));
00126       operator[](*ii) = 0;
00127       ++ii;
00128    }
00129 }
00130 
00131 //#############################################################################
00132 
00133 BCP_cut_algo::~BCP_cut_algo() {}
00134 

Generated on Mon May 3 03:05:12 2010 by  doxygen 1.4.7