Bcp 1.4.4
Loading...
Searching...
No Matches
BCP_cut.hpp
Go to the documentation of this file.
1// Copyright (C) 2000, International Business Machines
2// Corporation and others. All Rights Reserved.
3#ifndef _BCP_CUT_H
4#define _BCP_CUT_H
5
6// This file is fully docified.
7
8//#############################################################################
9
10#include "CoinSmartPtr.hpp"
11#include "BCP_math.hpp"
12#include "BCP_error.hpp"
13#include "BCP_enum.hpp"
14#include "BCP_vector.hpp"
15#include "BCP_obj_change.hpp"
16
17//#############################################################################
18
19// Generic cut definition
20
28
29class BCP_cut : public Coin::ReferencedObject {
30private:
34 BCP_cut();
36 BCP_cut(const BCP_cut&);
38 BCP_cut& operator=(const BCP_cut&);
40
41private:
46 int _bcpind;
48 BCP_obj_status _status;
50 int _eff_cnt;
52
53protected:
56 double _lb;
58 double _ub;
60
61public:
68 BCP_cut(const double lb, const double ub) :
69 _bcpind(0), _status(BCP_ObjNoInfo), _eff_cnt(0), _lb(lb), _ub(ub) {}
70
72 virtual ~BCP_cut() {}
74
78 virtual BCP_object_t obj_type() const = 0;
80 inline int effective_count() const { return _eff_cnt; }
82 inline double lb() const { return _lb; }
84 inline double ub() const { return _ub; }
86 inline int bcpind() const { return _bcpind; }
87
88 /* *@name Query methods about the status of the variable */
89 /* @{*/
91 inline BCP_obj_status status() const { return _status; }
95 inline bool dont_send_to_pool() const {
96 return _status & BCP_ObjDoNotSendToPool ? true : false;
97 }
98
100 inline bool is_non_removable() const {
101 return (_status & BCP_ObjNotRemovable) ? true : false;
102 }
103
106 inline bool is_to_be_removed() const {
107 return (_status & BCP_ObjToBeRemoved) != 0;
108 }
109 /* @}*/
111
115 inline void set_effective_count(const int cnt) { _eff_cnt = cnt; }
119 _eff_cnt = _eff_cnt <= 0 ? 1 : _eff_cnt + 1;
120 return _eff_cnt;
121 }
122
125 _eff_cnt = _eff_cnt >= 0 ? -1 : _eff_cnt - 1;
126 return _eff_cnt;
127 }
128
129 inline void set_lb(const double lb) { _lb = lb; }
131 inline void set_ub(const double ub) { _ub = ub; }
134 inline void change_lb_ub_st(const BCP_obj_change& change) {
135 _lb = change.lb;
136 _ub = change.ub;
137 _status = change.stat;
139 _status = static_cast<BCP_obj_status>(_status | BCP_ObjInactive);
140 }
141
142 inline void change_bounds(const double lb, const double ub) {
143 _lb = lb;
144 _ub = ub;
146 _status = static_cast<BCP_obj_status>(_status | BCP_ObjInactive);
147 }
148
149 inline void set_bcpind(const int bcpind) { _bcpind = bcpind; }
151 inline void set_bcpind_flip() { _bcpind = -_bcpind; }
152
153 /* *@name Status modifying methods */
154 /* @{*/
156 inline void set_status(const BCP_obj_status stat) { _status = stat; }
159 inline void dont_send_to_pool(bool flag) {
160 _status = static_cast<BCP_obj_status>(flag ?
161 _status | BCP_ObjDoNotSendToPool :
162 _status & ~BCP_ObjDoNotSendToPool);
163 }
164
167 inline void make_active() {
168 _status = static_cast<BCP_obj_status>(_status & ~BCP_ObjInactive);
169 }
170
171 inline void make_non_removable() {
172 _status =
173 static_cast<BCP_obj_status> ((_status & ~BCP_ObjToBeRemoved) |
175 }
176
178 inline void make_to_be_removed() {
179 _status = BCP_ObjToBeRemoved;
180 }
181 /* @}*/
183};
184
185//#############################################################################
186//#############################################################################
187
194
195class BCP_cut_core : public BCP_cut {
196
197private:
201 BCP_cut_core();
203 BCP_cut_core& operator=(const BCP_cut_core&);
205
206public:
210 BCP_cut_core(const BCP_cut_core& x) : BCP_cut(x._lb, x._ub) {
211 set_bcpind(x.bcpind());
212 set_status(x.status());
214 }
215
217 BCP_cut_core(const double lb, const double ub) : BCP_cut(lb, ub) {}
221
226 inline BCP_object_t obj_type() const { return BCP_CoreObj; }
228};
229
230//#############################################################################
231
232// This is the class the user should derive his/her own algorithmic cuts
233
241
242class BCP_cut_algo : public BCP_cut {
243private:
247 BCP_cut_algo();
249 BCP_cut_algo(const BCP_cut_algo&);
251 BCP_cut_algo& operator=(const BCP_cut_algo&);
253
254public:
259 BCP_cut_algo(const double lb, const double ub) : BCP_cut(lb, ub) {}
261 virtual ~BCP_cut_algo() = 0;
263
268 inline BCP_object_t obj_type() const { return BCP_AlgoObj; }
270};
271
272//#############################################################################
273//#############################################################################
274
278
279class BCP_cut_set : public BCP_vec<BCP_cut*> {
280private:
284 BCP_cut_set(const BCP_cut_set&);
286 BCP_cut_set& operator=(const BCP_cut_set&);
288
289public:
298
299
304 inline void append(const BCP_vec<BCP_cut*>& x) {
306 }
307
313
317 void set_lb_ub(const BCP_vec<int>& pos,
330 const BCP_vec<BCP_obj_change>& cc);
332#if 0
333 //--------------------------------------------------------------------------
351 void nonzero_slack(int first_to_check, const double * slacks,
352 const double etol, const int ineff_limit,
353 BCP_vec<int>& coll);
356 void zero_dual(int first_to_check, const double * duals,
357 const double etol, const int ineff_limit,
358 BCP_vec<int>& coll);
360#endif
363#if 0
367 void deletable(const int bcutnum, BCP_vec<int>& collection) const;
368#endif
373 void move_deletable_to_pool(const BCP_vec<int>& deletable_cuts,
374 BCP_vec<BCP_cut*>& pool);
376 //-----------------------------------------------------------------------
377};
378
379#endif
BCP_obj_status
This enumerative constant gives the status of an object (variable or cut).
Definition BCP_enum.hpp:105
@ BCP_ObjToBeRemoved
The object is to be removed next time when the formulation is compressed.
Definition BCP_enum.hpp:119
@ BCP_ObjNoInfo
No special information is given about the object.
Definition BCP_enum.hpp:107
@ BCP_ObjDoNotSendToPool
The object does not need to be sent to the variable/cut pool.
Definition BCP_enum.hpp:109
@ BCP_ObjNotRemovable
The object is not removable from the LP formulation, even if the object becomes inactive.
Definition BCP_enum.hpp:115
@ BCP_ObjInactive
The object is inactive.
Definition BCP_enum.hpp:123
BCP_object_t
This enumerative constant describes the possible types of objects (variables and cuts).
Definition BCP_enum.hpp:49
@ BCP_CoreObj
Base object.
Definition BCP_enum.hpp:51
@ BCP_AlgoObj
Algorithmic object.
Definition BCP_enum.hpp:53
#define BCP_DBL_MAX
Definition BCP_math.hpp:6
BCP_object_t obj_type() const
Return BCP_AlgoObj indicating that the object is an algorithmic cut.
Definition BCP_cut.hpp:268
BCP_cut_algo(const double lb, const double ub)
This constructor just sets the data members to the given values.
Definition BCP_cut.hpp:259
virtual ~BCP_cut_algo()=0
The destructor deletes the object.
BCP_object_t obj_type() const
Return BCP_CoreObj indicating that the object is a core cut.
Definition BCP_cut.hpp:226
BCP_cut_core(const double lb, const double ub)
This constructor just sets the data members to the given values.
Definition BCP_cut.hpp:217
BCP_cut_core(const BCP_cut_core &x)
The copy constructor makes a replica of the argument.
Definition BCP_cut.hpp:210
~BCP_cut_core()
The destructor deletes the object.
Definition BCP_cut.hpp:219
void append(const BCP_vec< BCP_cut * > &x)
Append the cuts in the vector x to the end of the cut set.
Definition BCP_cut.hpp:304
BCP_cut_set()
The default constructor creates a cut set with no cuts in it.
Definition BCP_cut.hpp:293
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,...
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.
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.
void set_lb_ub_st(BCP_vec< int >::const_iterator pos, const BCP_vec< BCP_obj_change > &cc)
Set the lower/upper bound pairs and the stati of the entries given by the content of [pos,...
void append(BCP_cut_set::const_iterator first, BCP_cut_set::const_iterator last)
Append the cuts in [first, last) to the end of the cut set.
Definition BCP_cut.hpp:309
~BCP_cut_set()
The destructor empties the cut set.
Definition BCP_cut.hpp:296
double lb() const
Return the lower bound on the cut.
Definition BCP_cut.hpp:82
int bcpind() const
Return the internal index of the cut.
Definition BCP_cut.hpp:86
void make_non_removable()
Mark the cut as NotRemovable.
Definition BCP_cut.hpp:171
void make_to_be_removed()
Mark the cut as ToBeRemoved.
Definition BCP_cut.hpp:178
double _lb
Lower bound of the cut.
Definition BCP_cut.hpp:56
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
void change_bounds(const double lb, const double ub)
Change just the lower/upper bounds.
Definition BCP_cut.hpp:142
void dont_send_to_pool(bool flag)
Set/unset the flag controlling whether the cut could be sent to the Cut Pool process.
Definition BCP_cut.hpp:159
void set_bcpind_flip()
Flip the internal index of the variable to its negative.
Definition BCP_cut.hpp:151
int increase_effective_count()
Increase the effectiveness count by 1 (or to 1 if it was negative).
Definition BCP_cut.hpp:118
int effective_count() const
Return the effectiveness count of the cut (only in LP process).
Definition BCP_cut.hpp:80
void make_active()
Mark the cut as active.
Definition BCP_cut.hpp:167
void set_ub(const double ub)
Set the upper bound on the cut.
Definition BCP_cut.hpp:131
bool is_non_removable() const
Return whether the cut marked as NotRemovable.
Definition BCP_cut.hpp:100
void set_lb(const double lb)
Set the lower bound on the cut.
Definition BCP_cut.hpp:129
void set_effective_count(const int cnt)
Set the effectiveness count to the given value.
Definition BCP_cut.hpp:115
void set_bcpind(const int bcpind)
Set the internal index of the cut.
Definition BCP_cut.hpp:149
BCP_obj_status status() const
Return the status of the cut.
Definition BCP_cut.hpp:91
virtual BCP_object_t obj_type() const =0
Return the type of the variable.
BCP_cut(const double lb, const double ub)
The constructor sets the internal index of the cut to zero and the other data members to the given ar...
Definition BCP_cut.hpp:68
bool dont_send_to_pool() const
Return whether the cut should be sent to the Cut Pool process.
Definition BCP_cut.hpp:95
bool is_to_be_removed() const
Return whether the cut must be removed from the formulation.
Definition BCP_cut.hpp:106
double _ub
Upper bound of the cut.
Definition BCP_cut.hpp:58
int decrease_effective_count()
Decrease the effectiveness count by 1 (or to -1 if it was positive).
Definition BCP_cut.hpp:124
void set_status(const BCP_obj_status stat)
Set the status of the cut.
Definition BCP_cut.hpp:156
double ub() const
Return the upper bound on the cut.
Definition BCP_cut.hpp:84
virtual ~BCP_cut()
The destructor is virtual so that the appropriate destructor is invoked for every cut.
Definition BCP_cut.hpp:72
BCP_obj_status stat
const BCP_cut ** const_iterator
BCP_vec(const size_t n, const_reference value)
void append(const BCP_vec< T > &x)
Append the entries in x to the end of the vector.