BCP_vg.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_math.hpp"
4 #include "BCP_message.hpp"
5 #include "BCP_vector.hpp"
6 #include "BCP_problem_core.hpp"
7 #include "BCP_var.hpp"
8 #include "BCP_cut.hpp"
9 #include "BCP_vg.hpp"
10 #include "BCP_vg_user.hpp"
11 
12 BCP_vg_prob::BCP_vg_prob(int my_id, int parent) :
13  BCP_process(my_id, parent),
14  user(0), msg_env(0), core(new BCP_problem_core),
15  upper_bound(BCP_DBL_MAX), phase(0) {}
16 
17 
19 {
20  delete user; user = 0;
21  delete packer; packer = 0;
22  delete core; core = 0;
24 }
25 
26 bool
28 {
31  double new_ub;
32  msg_buf.unpack(new_ub);
33  if (new_ub < upper_bound)
34  upper_bound = new_ub;
35  }
36 
38  return true;
40  return true;
42  return true;
43 
45  return true;
46  return false;
47 }
48 
49 BCP_cut*
51 {
52  BCP_object_t obj_t;
53  int bcpind;
54  double lb, ub;
55  BCP_obj_status stat;
56  msg_buf.unpack(bcpind)
57  .unpack(obj_t).unpack(stat).unpack(lb).unpack(ub);
58 
59  BCP_cut* cut = 0;
60  switch (obj_t) {
61  case BCP_CoreObj:
62  cut = new BCP_cut_core(lb, ub);
63  break;
64  case BCP_AlgoObj:
66  cut->change_bounds(lb, ub);
67  break;
68  default:
69  throw BCP_fatal_error("BCP_vg_prob::_unpack_cut(): unexpected obj_t.\n");
70  }
71  cut->set_bcpind(bcpind);
72  cut->set_status(stat);
73 
74  return cut;
75 }
76 
This class describes the core of the MIP problem, the variables/cuts in it as well as the matrix corr...
BCP_vg_user * user
The user object holding the user&#39;s data.
Definition: BCP_vg.hpp:49
BCP has finished.
BCP_buffer & unpack(T &value)
Unpack a single object of type T.
Definition: BCP_buffer.hpp:186
virtual void receive(const int source, const BCP_message_tag tag, BCP_buffer &buf, const double timeout)=0
Blocking receive with timeout.
const int BCP_AnyProcess
Definition: BCP_message.hpp:21
Abstract base class that defines members common to all types of cuts.
Definition: BCP_cut.hpp:29
virtual BCP_cut_algo * unpack_cut_algo(BCP_buffer &buf)
Unpack an algorithmic cut.
Definition: BCP_USER.hpp:109
void set_bcpind(const int bcpind)
Set the internal index of the cut.
Definition: BCP_cut.hpp:149
BCP_message_environment * msg_env
The message passing environment.
Definition: BCP_vg.hpp:57
Pack all dual variables.
Core cuts are the cuts that always stay in the LP formulation.
Definition: BCP_cut.hpp:195
BCP_buffer msg_buf
The message buffer of the Variable Generator process.
Definition: BCP_vg.hpp:60
Pack only dual variables currently at nonzero level.
BCP_obj_status
This enumerative constant gives the status of an object (variable or cut).
Definition: BCP_enum.hpp:105
#define BCP_DBL_MAX
Definition: BCP_math.hpp:6
double ub() const
Return the current upper bound (BCP_DBL_MAX/10 if there&#39;s no upper bound found yet.)
Definition: BCP_vg.hpp:116
The user packed everything.
virtual ~BCP_vg_prob()
The destructor deletes everything.
Definition: BCP_vg.cpp:18
void fint fint fint * phase
BCP_cut * unpack_cut()
Unpack a cut.
Definition: BCP_vg.cpp:50
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.
void set_status(const BCP_obj_status stat)
Set the status of the cut.
Definition: BCP_cut.hpp:156
BCP_problem_core * core
The description of the core of the problem.
Definition: BCP_vg.hpp:66
Currently there isn&#39;t any error handling in BCP.
Definition: BCP_error.hpp:20
bool probe_messages()
Test if there is a message in the message queue waiting to be processed.
Definition: BCP_vg.cpp:27
Algorithmic object.
Definition: BCP_enum.hpp:53
void change_bounds(const double lb, const double ub)
Change just the lower/upper bounds.
Definition: BCP_cut.hpp:142
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
BCP_vg_prob(const BCP_vg_prob &)
The copy constructor is declared but not defined to disable it.
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_vg.hpp:52
BCP_vec< BCP_cut * > cuts
Variables are to be generated for the LP solution given by these cuts and their values (next member)...
Definition: BCP_vg.hpp:82
Any process to TM or TM to any process: a new upper bound found.
double upper_bound
The proc id of the Tree Manager.
Definition: BCP_vg.hpp:72
BCP_object_t
This enumerative constant describes the possible types of objects (variables and cuts).
Definition: BCP_enum.hpp:49
Base object.
Definition: BCP_enum.hpp:51