Bcp 1.4.4
Loading...
Searching...
No Matches
BCP_obj_change.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_OBJ_CHANGE_H
4#define _BCP_OBJ_CHANGE_H
5
6//#############################################################################
7
8#include "BCP_enum.hpp"
9#include "BCP_vector.hpp"
10
11//#############################################################################
12
13class BCP_var;
14class BCP_cut;
15
16class BCP_cut_set;
17class BCP_var_set;
18
19class BCP_buffer;
20
21//#############################################################################
22
24public:
25 double lb;
26 double ub;
28public:
29 BCP_obj_change(const double lower, const double upper,
30 const BCP_obj_status status) :
31 lb(lower), ub(upper), stat(status) {}
34 // default copy constructor and assignment operator are fine
35
36 static inline int pack_size() {
37 return 2 * sizeof(double) + sizeof(BCP_obj_status);
38 }
39};
40
41inline bool operator==(const BCP_obj_change& ch0, const BCP_obj_change& ch1)
42{
43 return ch0.lb == ch1.lb && ch0.ub == ch1.ub && ch0.stat == ch1.stat;
44}
45
46inline bool operator!=(const BCP_obj_change& ch0, const BCP_obj_change& ch1)
47{
48 return ch0.lb != ch1.lb || ch0.ub != ch1.ub || ch0.stat != ch1.stat;
49}
50
51//#############################################################################
52
58 // _storage tells how the var_set is stored.
59 // -- If wrt parent then _deleted_num tells how many are deleted from the
60 // parent, and their indices are listed on the first _deleted_num slots of
61 // _del_change_pos. The rest of _del_change_pos shows the indices of
62 // the vars that have some param changed. _change contains these changes
63 // and finally _new_vars has the vars to be added, that is, their bcpind,
64 // which might be the negative of the real bcpind in case a var has not
65 // yet been sent to the TM.
66 // -- If explicite list then _new_vars has the complete list.
67private:
68 // disable default copy constructor and assignment operator
69 // BCP_obj_set_change(const BCP_obj_set_change&);
70 // BCP_obj_set_change& operator=(const BCP_obj_set_change&);
71public:
77public:
81 // default copy constructor and assignment op are OK (though expensive...)
83
84 inline BCP_storage_t storage() const { return _storage; }
85
86 inline int deleted_num() const { return _deleted_num; }
87 inline int changed_num() const { return _change.size(); }
88 inline int added_num() const { return _new_objs.size(); }
89
90 void update(const BCP_obj_set_change& objs_change);
91 void swap(BCP_obj_set_change& x); // *INLINE ?*
92
93 int pack_size() const;
94 void pack(BCP_buffer& buf) const;
95 void unpack(BCP_buffer& buf);
96
97 void print() const;
98};
99
100#if 0
101//#############################################################################
102
103class BCP_var_set_change {
104 // _storage tells how the var_set is stored.
105 // -- If wrt parent then _deleted_num tells how many are deleted from the
106 // parent, and their indices are listed on the first _deleted_num slots of
107 // _del_change_pos. The rest of _del_change_pos shows the indices of
108 // the vars that have some param changed. _change contains these changes
109 // and finally _new_vars has the vars to be added, that is, their bcpind,
110 // which might be the negative of the real bcpind in case a var has not
111 // yet been sent to the TM.
112 // -- If explicite list then _new_vars has the complete list.
113private:
114 // disable default copy constructor and assignment operator
115 BCP_var_set_change(const BCP_var_set_change&);
116 BCP_var_set_change& operator=(const BCP_var_set_change&);
117public:
118 BCP_storage_t _storage;
119 int _deleted_num;
120 BCP_vec<int> _del_change_pos;
122 BCP_vec<int> _new_vars;
123public:
124 BCP_var_set_change() :
125 _storage(BCP_Storage_Explicit), _deleted_num(0),
126 _del_change_pos(), _change(), _new_vars() {}
127#if 0
128 BCP_var_set_change(BCP_vec<BCP_var*>::const_iterator firstvar,
130 BCP_var_set_change(BCP_vec<BCP_var*>::const_iterator firstvar,
132 const BCP_vec<int>& added_index,
133 const BCP_vec<BCP_obj_change>& added_desc);
134#endif
135 ~BCP_var_set_change() {}
136
137 void swap(BCP_var_set_change& x); // *INLINE ?*
138
139 inline BCP_storage_t storage() const { return _storage; }
140
141 inline int deleted_num() const { return _deleted_num; }
142 inline int changed_num() const { return _change.size(); }
143 inline int added_num() const { return _new_vars.size(); }
144
145 int pack_size() const;
146
147 void update(const BCP_var_set_change& vars_change);
148};
149
150//#############################################################################
151
152class BCP_cut_set_change {
153 // _storage tells how the cut_set is stored.
154 // -- If wrt parent then _deleted_num tells how many are deleted from the
155 // parent, and their indices are listed on the first _deleted_num slots of
156 // _del_change_pos. The rest of _del_change_pos shows the indices of
157 // the cuts that have some param changed. _change contains these changes
158 // and finally _new_cuts has the cuts to be added, that is, their bcpind,
159 // which might be the negative of the real bcpind in case a var has not
160 // yet been sent to the TM.
161 // -- If explicite list then _new_cuts has the complete list.
162private:
163 // disable default copy constructor and assignment operator
164 BCP_cut_set_change(const BCP_cut_set_change&);
165 BCP_cut_set_change& operator=(const BCP_cut_set_change&);
166public:
167 BCP_storage_t _storage;
168 int _deleted_num;
169 BCP_vec<int> _del_change_pos;
171 BCP_vec<int> _new_cuts;
172public:
173 BCP_cut_set_change() :
174 _storage(BCP_Storage_Explicit), _deleted_num(0),
175 _del_change_pos(), _change(), _new_cuts() {}
176#if 0
177 BCP_cut_set_change(BCP_vec<BCP_cut*>::const_iterator firstcut,
179 BCP_cut_set_change(BCP_vec<BCP_cut*>::const_iterator firstcut,
181 const BCP_vec<int>& added_index,
182 const BCP_vec<BCP_obj_change>& added_desc);
183#endif
184 ~BCP_cut_set_change() {}
185
186 void swap(BCP_cut_set_change& x); // *INLINE ?*
187
188 inline BCP_storage_t storage() const { return _storage; }
189
190 inline int deleted_num() const { return _deleted_num; }
191 inline int changed_num() const { return _change.size(); }
192 inline int added_num() const { return _new_cuts.size(); }
193
194 int pack_size() const;
195
196 void update(const BCP_cut_set_change& cuts_change);
197};
198
199//#############################################################################
200#endif
201
202#endif
BCP_storage_t
This enumerative constant describes how to store certain data for a search tree node.
Definition BCP_enum.hpp:84
@ BCP_Storage_Explicit
The data stored is an explicit listing of values.
Definition BCP_enum.hpp:88
BCP_obj_status
This enumerative constant gives the status of an object (variable or cut).
Definition BCP_enum.hpp:105
@ BCP_ObjNoInfo
No special information is given about the object.
Definition BCP_enum.hpp:107
bool operator==(const BCP_obj_change &ch0, const BCP_obj_change &ch1)
bool operator!=(const BCP_obj_change &ch0, const BCP_obj_change &ch1)
This class describes the message buffer used for all processes of BCP.
This class is just a collection of pointers to cuts with a number of methods to manipulate these cuts...
Definition BCP_cut.hpp:279
Abstract base class that defines members common to all types of cuts.
Definition BCP_cut.hpp:29
BCP_obj_status stat
static int pack_size()
BCP_obj_change(const double lower, const double upper, const BCP_obj_status status)
This class stores data about how an object set (set of vars or set of cuts) changes.
BCP_vec< BCP_obj_change > _change
void unpack(BCP_buffer &buf)
void swap(BCP_obj_set_change &x)
BCP_vec< int > _new_objs
BCP_storage_t storage() const
BCP_storage_t _storage
int pack_size() const
void update(const BCP_obj_set_change &objs_change)
void pack(BCP_buffer &buf) const
BCP_vec< int > _del_change_pos
void print() const
This class is just a collection of pointers to variables with a number of methods to manipulate these...
Definition BCP_var.hpp:316
Abstract base class that defines members common to all types of variables.
Definition BCP_var.hpp:28
The class BCP_vec serves the same purpose as the vector class in the standard template library.
size_t size() const
Return the current number of entries.