BCP_cg.cpp
Go to the documentation of this file.
1 // Copyright (C) 2000, International Business Machines
2 // Corporation and others. All Rights Reserved.
3 
4 #include "BCP_math.hpp"
5 #include "BCP_message.hpp"
6 #include "BCP_vector.hpp"
7 #include "BCP_problem_core.hpp"
8 #include "BCP_var.hpp"
9 #include "BCP_cut.hpp"
10 #include "BCP_cg.hpp"
11 #include "BCP_cg_user.hpp"
12 
13 #include "BCP_warmstart.hpp"
14 
15 BCP_cg_prob::BCP_cg_prob(int my_id, int parent) :
16  BCP_process(my_id, parent),
17  user(0), msg_env(0), core(new BCP_problem_core),
18  upper_bound(BCP_DBL_MAX), phase(0) {}
19 
20 
22 {
23  delete user; user = 0;
24  delete packer; packer = 0;
25  delete core; core = 0;
27 }
28 
29 bool
31 {
34  double new_ub;
35  msg_buf.unpack(new_ub);
36  if (new_ub < upper_bound)
37  upper_bound = new_ub;
38  }
39 
41  return true;
43  return true;
45  return true;
47  return true;
48 
50  return true;
51  return false;
52 }
53 
54 BCP_var*
56 {
57  BCP_object_t obj_t;
58  int bcpind;
59  BCP_var_t var_t;
60  double obj, lb, ub;
61  BCP_obj_status stat;
62  msg_buf.unpack(bcpind)
63  .unpack(obj_t).unpack(stat)
64  .unpack(var_t).unpack(obj).unpack(lb).unpack(ub);
65 
66  BCP_var* var = 0;
67  switch (obj_t) {
68  case BCP_CoreObj:
69  var = new BCP_var_core(var_t, obj, lb, ub);
70  break;
71  case BCP_AlgoObj:
73  var->set_var_type(var_t);
74  var->change_bounds(lb, ub);
75  var->set_obj(obj);
76  break;
77  default:
78  throw BCP_fatal_error("BCP_cg_prob::_unpack_var(): unexpected obj_t.\n");
79  }
80  var->set_bcpind(bcpind);
81  var->set_status(stat);
82 
83  return var;
84 }
This class describes the core of the MIP problem, the variables/cuts in it as well as the matrix corr...
BCP has finished.
BCP_buffer & unpack(T &value)
Unpack a single object of type T.
Definition: BCP_buffer.hpp:186
void set_var_type(const BCP_var_t type)
Set the integrality type of the variable.
Definition: BCP_var.hpp:141
virtual void receive(const int source, const BCP_message_tag tag, BCP_buffer &buf, const double timeout)=0
Blocking receive with timeout.
BCP_problem_core * core
The description of the core of the problem.
Definition: BCP_cg.hpp:67
const int BCP_AnyProcess
Definition: BCP_message.hpp:21
All primal variables.
void set_bcpind(const int bcpind)
Set the internal index of the variable.
Definition: BCP_var.hpp:176
Core variables are the variables that always stay in the LP formulation.
Definition: BCP_var.hpp:230
Only primal variables currently at nonzero level.
The user packed everything.
bool probe_messages()
Test if there is a message in the message queue waiting to be processed.
Definition: BCP_cg.cpp:30
BCP_obj_status
This enumerative constant gives the status of an object (variable or cut).
Definition: BCP_enum.hpp:105
void change_bounds(const double lb, const double ub)
Change the lower and upper bounds to the given values.
Definition: BCP_var.hpp:170
#define BCP_DBL_MAX
Definition: BCP_math.hpp:6
BCP_vec< BCP_var * > vars
Cuts are to be generated for the LP solution given by these variables and their values (next member)...
Definition: BCP_cg.hpp:83
void fint fint fint * phase
virtual bool probe(const int source, const BCP_message_tag tag)=0
Probe if there are any messages from the given process with the given message tag.
BCP_buffer msg_buf
The message buffer of the Cut Generator process.
Definition: BCP_cg.hpp:61
double upper_bound
The proc id of the tree manager.
Definition: BCP_cg.hpp:73
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
Only primal variables currently at fractional level.
Algorithmic object.
Definition: BCP_enum.hpp:53
virtual BCP_var_algo * unpack_var_algo(BCP_buffer &buf)
Unpack an algorithmic variable.
Definition: BCP_USER.hpp:93
void set_obj(const double obj)
Set the objective coefficient.
Definition: BCP_var.hpp:143
BCP_cg_prob(const BCP_cg_prob &)
The copy constructor is declared but not defined to disable it.
virtual ~BCP_cg_prob()
The destructor deletes everything.
Definition: BCP_cg.cpp:21
void fint fint fint fint fint fint fint fint fint fint real real real real real real real real real fint real fint real char real * user
void purge_ptr_vector(BCP_vec< T * > &pvec, typename BCP_vec< T * >::iterator first, typename BCP_vec< T * >::iterator last)
This function purges the entries [first,last) from the vector of pointers pvec.
Definition: BCP_vector.hpp:266
BCP_user_pack * packer
A class that holds the methods about how to pack things.
Definition: BCP_cg.hpp:53
BCP_message_environment * msg_env
The message passing environment.
Definition: BCP_cg.hpp:58
Any process to TM or TM to any process: a new upper bound found.
void set_status(const BCP_obj_status status)
Set the status of the variable.
Definition: BCP_var.hpp:183
BCP_var * unpack_var()
Unpack a variable.
Definition: BCP_cg.cpp:55
BCP_object_t
This enumerative constant describes the possible types of objects (variables and cuts).
Definition: BCP_enum.hpp:49
BCP_cg_user * user
The user object holding the user&#39;s data.
Definition: BCP_cg.hpp:50
Base object.
Definition: BCP_enum.hpp:51
double ub() const
Return the current upper bound (BCP_DBL_MAX if there&#39;s no upper bound found yet.) ...
Definition: BCP_cg.hpp:118
BCP_var_t
This enumerative constant describes the integrality type of a variable.
Definition: BCP_enum.hpp:161