BCP_cut.cpp
Go to the documentation of this file.
1 // Copyright (C) 2000, International Business Machines
2 // Corporation and others. All Rights Reserved.
3 #include <cmath>
4 
5 #include "BCP_buffer.hpp"
6 #include "BCP_cut.hpp"
7 #include "BCP_branch.hpp"
8 
9 //#############################################################################
10 
11 void
14 {
15  BCP_vec<int>::const_iterator ii = indices.begin();
16  BCP_vec<int>::const_iterator lastii = indices.end();
17  for ( ; ii != lastii; ++ii){
18  const double lb = *bounds;
19  ++bounds;
20  const double ub = *bounds;
21  ++bounds;
22  operator[](*ii)->change_bounds(lb, ub);
23  }
24 }
25 
26 //-----------------------------------------------------------------------------
27 
28 void
30 {
33  iterator cut = begin();
34  while (chi != lastchi) {
35  (*cut)->change_lb_ub_st(*chi);
36  ++cut;
37  ++chi;
38  }
39 }
40 
41 //-----------------------------------------------------------------------------
42 
43 void
45  const BCP_vec<BCP_obj_change>& vc)
46 {
49  while (chi != lastchi){
50  operator[](*pos)->change_lb_ub_st(*chi);
51  ++pos;
52  ++chi;
53  }
54 }
55 
56 //-----------------------------------------------------------------------------
57 #if 0
58 void
59 BCP_cut_set::nonzero_slack(int first_to_check, const double * slacks,
60  const double etol, const int ineff_limit,
61  BCP_vec<int>& coll)
62 {
63  const int cutnum = size();
64  coll.reserve(cutnum);
65  for ( ; first_to_check < cutnum; ++first_to_check) {
66  BCP_cut *cut = operator[](first_to_check);
67  // Most cuts are removable, so it's not worth to test whether a cut is
68  // removable, just test the slackness. Who cares what is the
69  // effectiveness count of non-removable cuts.
70  if (slacks[first_to_check] > etol) {
71  if (cut->decrease_effective_count() <= -ineff_limit) {
72  coll.unchecked_push_back(first_to_check);
73  }
74  } else {
76  }
77  }
78 }
79 
80 //-----------------------------------------------------------------------------
81 void
82 BCP_cut_set::zero_dual(int first_to_check, const double * duals,
83  const double etol, const int ineff_limit,
84  BCP_vec<int>& coll)
85 {
86  const int cutnum = size();
87  coll.reserve(cutnum);
88  for ( ; first_to_check < cutnum; ++first_to_check) {
89  BCP_cut *cut = operator[](first_to_check);
90  // Most cuts are removable, so it's not worth to test whether a cut is
91  // removable, just test the slackness. Who cares what is the
92  // effectiveness count of non-removable cuts.
93  if (abs(duals[first_to_check]) <= etol) {
94  if (cut->decrease_effective_count() <= -ineff_limit) {
95  coll.unchecked_push_back(first_to_check);
96  }
97  }else{
99  }
100  }
101 }
102 //-----------------------------------------------------------------------------
103 
104 void
105 BCP_cut_set::deletable(int bcutnum, BCP_vec<int>& collection) const
106 {
107  const int cutnum = size();
108  collection.reserve(cutnum - bcutnum);
109  int i;
110  for (i = bcutnum; i < cutnum; ++i) {
111  BCP_cut *cut = operator[](i);
112  if (cut->is_to_be_removed())
113  collection.unchecked_push_back(i);
114  }
115 }
116 #endif
117 void
119  BCP_vec<BCP_cut*>& pool)
120 {
121  BCP_vec<int>::const_iterator ii = del_cuts.begin();
122  BCP_vec<int>::const_iterator lastii = del_cuts.end();
123  pool.reserve(pool.size() + del_cuts.size());
124  while (ii != lastii) {
125  pool.unchecked_push_back(operator[](*ii));
126  operator[](*ii) = 0;
127  ++ii;
128  }
129 }
130 
131 //#############################################################################
132 
134 
virtual ~BCP_cut_algo()=0
The destructor deletes the object.
Definition: BCP_cut.cpp:133
pos
position where the operator should be printed when printing the expression
Abstract base class that defines members common to all types of cuts.
Definition: BCP_cut.hpp:29
reference operator[](const size_t i)
Return a reference to the i-th entry.
Definition: BCP_vector.hpp:124
void move_deletable_to_pool(const BCP_vec< int > &deletable_cuts, BCP_vec< BCP_cut * > &pool)
Move the cut pointers whose indices are listed in deletable_cuts into the pool.
Definition: BCP_cut.cpp:118
void set_lb_ub_st(const BCP_vec< BCP_obj_change > &cc)
Set the lower/upper bound pairs and the stati of the first cc.
Definition: BCP_cut.cpp:29
iterator begin()
Return an iterator to the beginning of the object.
Definition: BCP_vector.hpp:99
void reserve(const size_t n)
Reallocate the object to make space for n entries.
int decrease_effective_count()
Decrease the effectiveness count by 1 (or to -1 if it was positive).
Definition: BCP_cut.hpp:124
void change_lb_ub_st(const BCP_obj_change &change)
Set the lower/upper bounds and the status of the cut simultaneously to the values given in the data m...
Definition: BCP_cut.hpp:134
int increase_effective_count()
Increase the effectiveness count by 1 (or to 1 if it was negative).
Definition: BCP_cut.hpp:118
size_t size() const
Return the current number of entries.
Definition: BCP_vector.hpp:116
iterator end()
Return an iterator to the end of the object.
Definition: BCP_vector.hpp:104
void change_bounds(const double lb, const double ub)
Change just the lower/upper bounds.
Definition: BCP_cut.hpp:142
void unchecked_push_back(const_reference x)
Append x to the end of the vector.
void set_lb_ub(const BCP_vec< int > &pos, BCP_vec< double >::const_iterator bounds)
Set the lower/upper bound pairs of the entries given by the contents of pos to the values in [bounds...
Definition: BCP_cut.cpp:12
bool is_to_be_removed() const
Return whether the cut must be removed from the formulation.
Definition: BCP_cut.hpp:106