BCP_var.cpp
Go to the documentation of this file.
1 // Copyright (C) 2000, International Business Machines
2 // Corporation and others. All Rights Reserved.
3 #include "BCP_buffer.hpp"
4 #include "BCP_var.hpp"
5 #include "BCP_branch.hpp"
6 
7 //#############################################################################
8 
9 void
12 {
13  BCP_vec<int>::const_iterator ii = indices.begin();
14  BCP_vec<int>::const_iterator lastii = indices.end();
15  for ( ; ii != lastii; ++ii){
16  const double lb = *bounds;
17  ++bounds;
18  const double ub = *bounds;
19  ++bounds;
20  operator[](*ii)->change_bounds(lb, ub);
21  }
22 }
23 
24 //-----------------------------------------------------------------------------
25 
26 void
28 {
31  iterator var = begin();
32  while (chi != lastchi){
33  (*var)->change_lb_ub_st(*chi);
34  ++var;
35  ++chi;
36  }
37 }
38 
39 //-----------------------------------------------------------------------------
40 
41 void
43  const BCP_vec<BCP_obj_change>& vc){
46  while (chi != lastchi){
47  operator[](*pos)->change_lb_ub_st(*chi);
48  ++pos;
49  ++chi;
50  }
51 }
52 
53 //-----------------------------------------------------------------------------
54 
55 void
56 BCP_var_set::deletable(const int bvarnum, BCP_vec<int>& collection){
57  collection.clear();
58  collection.reserve(size() - bvarnum);
59  iterator var = entry(bvarnum);
60  for (int i = bvarnum; var != end(); ++var, ++i) {
61  if ((*var)->is_to_be_removed())
62  collection.unchecked_push_back(i);
63  }
64 }
65 
66 //#############################################################################
67 
69 
70 void
71 BCP_var::display(const double val) const
72 {
73  switch (obj_type()) {
74  case BCP_CoreObj:
75  printf(" Core var (internal index: %6i ) at %.4f\n",
76  _bcpind, val);
77  break;
78  case BCP_AlgoObj:
79  printf(" Algo var (internal index: %6i ) at %.4f\n",
80  _bcpind, val);
81  break;
82  default:
83  throw BCP_fatal_error("Untyped object in BCP_solution_gen::display()\n");
84  }
85 }
86 
pos
position where the operator should be printed when printing the expression
void clear()
Delete every entry.
reference operator[](const size_t i)
Return a reference to the i-th entry.
Definition: BCP_vector.hpp:124
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.
void change_lb_ub_st(const BCP_obj_change &change)
Set the lower/upper bounds and the status of the variable simultaneously to the values given in the d...
Definition: BCP_var.hpp:163
void change_bounds(const double lb, const double ub)
Change the lower and upper bounds to the given values.
Definition: BCP_var.hpp:170
void display(const double val) const
Display the object type, internal index, and the value given in the argument.
Definition: BCP_var.cpp:71
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_var.cpp:10
Abstract base class that defines members common to all types of variables.
Definition: BCP_var.hpp:28
Currently there isn&#39;t any error handling in BCP.
Definition: BCP_error.hpp:20
size_t size() const
Return the current number of entries.
Definition: BCP_vector.hpp:116
Algorithmic object.
Definition: BCP_enum.hpp:53
iterator end()
Return an iterator to the end of the object.
Definition: BCP_vector.hpp:104
void deletable(const int bvarnum, BCP_vec< int > &collection)
Collect the indices of the variables marked to be removed.
Definition: BCP_var.cpp:56
void unchecked_push_back(const_reference x)
Append x to the end of the vector.
int _bcpind
The internal, unique index of the variable.
Definition: BCP_var.hpp:46
iterator entry(const int i)
Return an iterator to the i-th entry.
Definition: BCP_vector.hpp:109
virtual BCP_object_t obj_type() const =0
Return the type of the variable.
Base object.
Definition: BCP_enum.hpp:51
virtual ~BCP_var_algo()=0
The destructor deletes the object.
Definition: BCP_var.cpp:68
void set_lb_ub_st(const BCP_vec< BCP_obj_change > &vc)
Set the lower/upper bound pairs and the stati of the first cc.
Definition: BCP_var.cpp:27