19 #define TS_MAX_HEAP_SIZE p.par.entry(BCP_ts_par::MaxHeapSize)
53 int my_id,
int parent,
double ub)
76 char *logname =
new char[len + 300];
77 memcpy(logname, log.
c_str(), len);
78 memcpy(logname + len,
"-ts-", 4);
81 len = strlen(logname);
83 sprintf(logname + len,
"%i", static_cast<int>(
GETPID));
84 logfile = freopen(logname,
"a", stdout);
86 fprintf(stderr,
"Error while redirecting stdout: %i\n", errno);
89 setvbuf(logfile, NULL, _IOLBF, 0);
92 setvbuf(stdout, NULL, _IOLBF, 0);
152 std::map<int, BCP_ts_node_data*>::iterator
n;
154 delete n->second->_desc;
155 delete n->second->_user;
158 std::map<int, BCP_cut_algo*>::iterator
c;
159 for (c =
cuts.begin(); c !=
cuts.end(); ++
c) {
162 std::map<int, BCP_var_algo*>::iterator v;
163 for (v =
vars.begin(); v !=
vars.end(); ++v) {
178 bool has_user_data =
false;
196 buf.
unpack(has_user_data);
198 p.
nodes[index] = data;
216 const int num = nodelevels.
size();
222 for (
int i = 0; i < num; ++i) {
223 std::map<int, BCP_ts_node_data*>::iterator
n = p.
nodes.find(inds[i]);
224 if (n == p.
nodes.end()) {
229 buf.
pack(nodelevels[i]);
233 bool has_user_data = data->
_user != 0;
234 buf.
pack(has_user_data);
248 const int num = inds.
size();
249 for (
int i = 0; i < num; ++i) {
250 std::map<int, BCP_ts_node_data*>::iterator
n = p.
nodes.find(inds[i]);
251 if (n == p.
nodes.end()) {
255 delete n->second->_desc;
256 delete n->second->_user;
303 const int num = pos.
size();
309 for (
int i = 0; i < num; ++i) {
310 std::map<int, BCP_cut_algo*>::iterator
c = p.
cuts.find(inds[i]);
311 if (c == p.
cuts.end()) {
329 const int num = inds.
size();
330 for (
int i = 0; i < num; ++i) {
331 std::map<int, BCP_cut_algo*>::iterator
c = p.
cuts.find(inds[i]);
332 if (c == p.
cuts.end()) {
382 const int num = pos.
size();
388 for (
int i = 0; i < num; ++i) {
389 std::map<int, BCP_var_algo*>::iterator
c = p.
vars.find(inds[i]);
390 if (c == p.
vars.end()) {
408 const int num = inds.
size();
409 for (
int i = 0; i < num; ++i) {
410 std::map<int, BCP_var_algo*>::iterator v = p.
vars.find(inds[i]);
411 if (v == p.
vars.end()) {
432 TS: BCP_ts_prob::process_message(): BCP_Msg_InitialUserInfo arrived\n");
479 TS: BCP_ts_prob::process_message(): Unexpected message tag (%i) arrived\n",
std::map< int, BCP_ts_node_data * > nodes
BCP_message_tag
This enumerative constant describes the message tags different processes of BCP understand.
virtual void send(const int target, const BCP_message_tag tag)=0
Send an empty message (message tag only) to the process given by the frist argument.
void unpack(BCP_user_pack *packer, const bool def, BCP_buffer &buf)
BCP_buffer & pack(const T &value)
Pack a single object of type T.
Used when receiving, message with any message tag will be received.
Used to indicate that there is no message in the buffer of a process.
BCP_buffer & unpack(T &value)
Unpack a single object of type T.
void pack(BCP_user_pack *packer, const bool def, BCP_buffer &buf) const
void create_keyword_list()
Method for creating the list of keyword looked for in the parameter file.
virtual void receive(const int source, const BCP_message_tag tag, BCP_buffer &buf, const double timeout)=0
Blocking receive with timeout.
pos
position where the operator should be printed when printing the expression
This is an abstract base class that describes the message passing environment.
static void process_Msg_CutListDelete(BCP_ts_prob &p, BCP_buffer &buf)
virtual BCP_cut_algo * unpack_cut_algo(BCP_buffer &buf)
Unpack an algorithmic cut.
virtual BCP_user_data * unpack_user_data(BCP_buffer &buf)
Unpack an user data.
BCP_process_t
This enumerative constant describes the various process types.
char entry(const chr_params key) const
const char * c_str() const
virtual BCP_user_pack * packer_init(BCP_user_class *p)
The TM sends the description of the core formulation to the slave process.
The TM sends the process type to the process (LP, Cut Generator, etc.)
BCP_process_t BCP_tmstorage_main(BCP_message_environment *msg_env, USER_initialize *user_init, int my_id, int parent, double ub)
void unpack(BCP_buffer &buf)
Unpack the contents of the core description from the buffer.
void set_default_entries()
Method for setting the default values for the parameters.
BCP_vec< std::pair< BCP_string, BCP_parameter > > keys
The keyword, parameter pairs.
#define setpriority(x, y, z)
This class is a very simple impelementation of a constant length string.
static void process_Msg_CutList(BCP_ts_prob &p, BCP_buffer &buf)
void push_back(const_reference x)
Append x to the end of the vector.
virtual BCP_ts_user * ts_init(BCP_ts_prob &p)
BCP_parameter_set< BCP_ts_par > par
void setTsProblemPointer(BCP_ts_prob *ptr)
Set the pointer.
BCP_vec< int > positions
positions in the TM of requested nodes/vars/cuts
virtual void pack_cut_algo(const BCP_cut_algo *cut, BCP_buffer &buf)
Pack an algorithmic cut.
std::map< int, BCP_cut_algo * > cuts
This class is an abstract base class for the initializer class the user has to provide.
BCP_vec< int > indices
a list of indices of nodes/vars/cuts that are requested/tobe deleted
std::map< int, BCP_var_algo * > vars
static long BCP_used_heap()
void set_entry(const chr_params key, const char val)
static void process_Msg_VarListRequest(BCP_ts_prob &p, BCP_buffer &buf)
BCP_user_class * user_class
A pointer ot the usr class of the process from which the methods of this class are invoked from...
#define gethostname(x, y)
The TM sends the appropriate parameters to the slave process.
This parameter indeintifies a single parameter entry.
The TM sends the initial user packed information to the slave process.
void clear()
Completely clear the buffer.
BCP_message_tag msgtag() const
Return the message tag of the message in the buffer.
Currently there isn't any error handling in BCP.
static void process_Msg_VarListDelete(BCP_ts_prob &p, BCP_buffer &buf)
size_t size() const
Return the current number of entries.
virtual BCP_var_algo * unpack_var_algo(BCP_buffer &buf)
Unpack an algorithmic variable.
This class describes the message buffer used for all processes of BCP.
static void process_Msg_NodeListDelete(BCP_ts_prob &p, BCP_buffer &buf)
virtual void pack_var_algo(const BCP_var_algo *var, BCP_buffer &buf)
Pack an algorithmic variable.
static void process_Msg_NodeList(BCP_ts_prob &p, BCP_buffer &buf)
BCP_message_environment * msg_env
void unpack(BCP_buffer &buf)
Unpack the parameter set from the buffer.
Any process to TM or TM to any process: a new upper bound found.
virtual bool alive(const int pid)=0
Test if the process given by the argument is alive or not.
static void process_Msg_VarList(BCP_ts_prob &p, BCP_buffer &buf)
virtual void pack_user_data(const BCP_user_data *ud, BCP_buffer &buf)
Pack an user data.
virtual void process_message()
virtual void unpack_module_data(BCP_buffer &buf)
Unpack the initial information sent to the LP process by the Tree Manager.
static void process_Msg_NodeListRequest(BCP_ts_prob &p, BCP_buffer &buf)
Same as BCP_tm_node_data, just there's no need to use smart pointers in this process.
static void process_Msg_CutListRequest(BCP_ts_prob &p, BCP_buffer &buf)
CouExpr & log(CouExpr &e)