3 #include <CoinDistance.hpp>
46 while (firstch != lastch) {
47 _change[*firstchpos] = *firstch;
108 printf(
" deleted pos:\n");
117 printf(
" changed pos/newval:\n");
118 for (
int chpos = 0; chpos < changed; ++chpos, ++
pos) {
119 printf(
" pos %i, status %i, lb %f, ub %f\n",
125 printf(
" new bcpind/newval:\n");
126 for (
int i = 0; i <
added_num(); ++i, ++chpos) {
127 printf(
" bcpind %i, status %i, lb %f, ub %f\n",
139 BCP_var_set_change::update(
const BCP_var_set_change& vars_change)
145 if (vars_change.deleted_num() > 0){
147 vars_change._del_change_pos.
begin();
149 vars_change._del_change_pos.
entry(vars_change.deleted_num());
150 _new_vars.erase_by_index(firstdel, lastdel);
151 _change.erase_by_index(firstdel, lastdel);
154 if (vars_change.added_num() > 0) {
155 _new_vars.append(vars_change._new_vars);
156 _change.append(vars_change._change.entry(vars_change.changed_num() -
157 vars_change.added_num()),
158 vars_change._change.end());
160 if (vars_change.changed_num() - vars_change.added_num() > 0){
166 vars_change._change.
begin();
168 vars_change._change.
entry(vars_change.changed_num() -
169 vars_change.added_num());
171 vars_change._del_change_pos.
entry(vars_change.deleted_num());
172 while (firstch != lastch) {
173 _change[*firstchpos] = *firstch;
207 BCP_cut_set_change::update(
const BCP_cut_set_change& cuts_change)
213 if (cuts_change.deleted_num() > 0){
215 cuts_change._del_change_pos.
begin();
217 cuts_change._del_change_pos.
entry(cuts_change.deleted_num());
220 _new_cuts.erase_by_index(firstdel, lastdel);
221 _change.erase_by_index(firstdel, lastdel);
224 if (cuts_change.added_num() > 0) {
225 _new_cuts.append(cuts_change._new_cuts);
226 _change.append(cuts_change._change.entry(cuts_change.changed_num() -
227 cuts_change.added_num()),
228 cuts_change._change.end());
230 if (cuts_change.changed_num() - cuts_change.added_num() > 0){
236 cuts_change._change.
begin();
238 cuts_change._change.
entry(cuts_change.changed_num() -
239 cuts_change.added_num());
241 cuts_change._del_change_pos.
entry(cuts_change.deleted_num());
242 while (firstch != lastch) {
243 _change[*firstchpos] = *firstch;
256 _del_change_pos(), _change(), _new_vars()
259 const int added_var_num = coinDistance(first, last);
261 _new_vars.reserve(added_var_num);
262 while (first != last) {
266 _new_vars.unchecked_push_back(*first);
280 _del_change_pos(), _change(), _new_vars()
282 const int new_added_num = coinDistance(first, last);
283 const int old_added_num = added_bcpind.
size();
292 for (i = 0, j = 0; i < new_added_num && j < old_added_num; ++
j) {
293 const BCP_var*
const var = *(first + i);
295 if (var->
bcpind() == added_bcpind[
j]) {
297 if (var->
lb() != added.
lb || var->
ub() != added.
ub ||
306 for ( ; j < old_added_num; ++
j) {
314 _new_vars.reserve(new_added_num - i);
315 for ( ; i < new_added_num; ++i){
316 _new_vars.unchecked_push_back(*(first + i));
323 const int chnum = chpos.
size();
325 for (i = 0; i < chnum; ++i) {
326 const BCP_var*
const var = *(first + chpos[i]);
335 BCP_var_set_change::swap(BCP_var_set_change&
x)
337 std::swap(_storage, x._storage);
338 std::swap(_deleted_num, x._deleted_num);
339 _del_change_pos.swap(x._del_change_pos);
340 _change.swap(x._change);
341 _new_vars.swap(x._new_vars);
347 BCP_var_set_change::pack_size()
const
349 return ( _del_change_pos.size() *
sizeof(
int) +
351 _new_vars.size() * (
sizeof(bool) +
sizeof(
int)) );
359 _del_change_pos(), _change(), _new_cuts()
362 const int added_cut_num = coinDistance(first, last);
364 _new_cuts.reserve(added_cut_num);
365 while (first != last) {
369 _new_cuts.unchecked_push_back(*first);
383 _del_change_pos(), _change(), _new_cuts()
385 const int new_added_num = coinDistance(first, last);
386 const int old_added_num = added_bcpind.
size();
395 for (i = 0, j = 0; i < new_added_num && j < old_added_num; ++
j) {
396 const BCP_cut*
const cut = *(first + i);
398 if (cut->
bcpind() == added_bcpind[
j]) {
400 if (cut->
lb() != added.
lb || cut->
ub() != added.
ub ||
409 for ( ; j < old_added_num; ++
j) {
417 _new_cuts.reserve(new_added_num - i);
418 for ( ; i < new_added_num; ++i){
419 _new_cuts.unchecked_push_back(*(first + i));
426 const int chnum = chpos.
size();
428 for (i = 0; i < chnum; ++i) {
429 const BCP_cut*
const cut = *(first + chpos[i]);
438 BCP_cut_set_change::swap(BCP_cut_set_change& x)
440 std::swap(_storage, x._storage);
441 std::swap(_deleted_num, x._deleted_num);
442 _del_change_pos.swap(x._del_change_pos);
443 _change.swap(x._change);
444 _new_cuts.swap(x._new_cuts);
450 BCP_cut_set_change::pack_size()
const
452 return ( _del_change_pos.size() *
sizeof(
int) +
454 _new_cuts.size() * (
sizeof(bool) +
sizeof(
int)) );
This class stores data about how an object set (set of vars or set of cuts) changes.
BCP_buffer & pack(const T &value)
Pack a single object of type T.
BCP_buffer & unpack(T &value)
Unpack a single object of type T.
pos
position where the operator should be printed when printing the expression
void clear()
Delete every entry.
void update(const BCP_obj_set_change &objs_change)
Abstract base class that defines members common to all types of cuts.
void pack(BCP_buffer &buf) const
iterator begin()
Return an iterator to the beginning of the object.
double ub() const
Return the upper bound on the cut.
void reserve(const size_t n)
Reallocate the object to make space for n entries.
The data stored is an explicit listing of values.
void swap(BCP_obj_set_change &x)
double lb() const
Return the lower bound on the cut.
double ub() const
Return the upper bound.
void erase_by_index(const BCP_vec< int > &positions)
Erase the entries indexed by indices.
BCP_obj_status status() const
Return the status of the cut.
The data stored is with respect to the same kind of data in the parent of the search tree node...
void clear()
Completely clear the buffer.
BCP_storage_t storage() const
Abstract base class that defines members common to all types of variables.
Currently there isn't any error handling in BCP.
int bcpind() const
Return the internal index of the variable.
size_t size() const
Return the current number of entries.
iterator end()
Return an iterator to the end of the object.
BCP_obj_status status() const
Return the status of the variable.
void unpack(BCP_buffer &buf)
The class BCP_vec serves the same purpose as the vector class in the standard template library...
This class describes the message buffer used for all processes of BCP.
void unchecked_push_back(const_reference x)
Append x to the end of the vector.
BCP_vec< int > _del_change_pos
double lb() const
Return the lower bound.
iterator entry(const int i)
Return an iterator to the i-th entry.
BCP_vec< BCP_obj_change > _change
int bcpind() const
Return the internal index of the cut.
void append(const BCP_vec< T > &x)
Append the entries in x to the end of the vector.
void swap(BCP_vec< T > &x)
Exchange the contents of the object with that of x.
void fint fint fint real fint real * x