11 #include "CoinTime.hpp"
63 for (cnt = 0; cnt < argc; ++cnt) {
64 if (argv[cnt] == NULL)
71 #if defined(COIN_HAS_MPI)
72 BCP_mpi_environment* mpi_env =
73 dynamic_cast<BCP_mpi_environment*
>(msg_env);
74 if (!mpi_env && argc != 1) {
89 const bool maxheap_set =
false;
95 ptype =
BCP_lp_main(msg_env, user_init, my_id, parent, ub);
107 ptype =
BCP_cg_main(msg_env, user_init, my_id, parent, ub);
110 ptype =
BCP_vg_main(msg_env, user_init, my_id, parent, ub);
123 New process identity is BCP_ProcessType_Any!\n");
126 New process identity is BCP_ProcessType_TM!\n");
142 const int argnum,
const char*
const * arglist)
166 #if defined(COIN_HAS_MPI)
167 BCP_mpi_environment* mpi_env =
dynamic_cast<BCP_mpi_environment*
>(msg_env);
177 Number of process in parameter file %d > n_proc in mpirun -np %d!\n",
192 char *logname =
new char[len + 300];
193 memcpy(logname, log.
c_str(), len);
194 memcpy(logname + len,
"-tm-", 4);
197 len = strlen(logname);
198 logname[len++] =
'-';
199 sprintf(logname + len,
"%i", static_cast<int>(
GETPID));
200 logfile = freopen(logname,
"a", stdout);
202 fprintf(stderr,
"Error while redirecting stdout: %i\n", errno);
205 setvbuf(logfile, NULL, _IOLBF, 0);
208 setvbuf(stdout, NULL, _IOLBF, 0);
245 #if ! defined(BCP_ONLY_LP_PROCESS_HANDLING_WORKS)
248 for (
int i = p.slaves.cp->procs().size() - 1; i >= 0; --i)
252 for (
int i = p.slaves.vp->procs().size() - 1; i >= 0; --i)
272 bool something_died =
false;
324 const double t0 = CoinWallclockTime();
328 const double t1 = CoinWallclockTime();
355 const int bvarnum = bvars.
size();
358 for (i = 0; i < bvarnum; ++i) {
371 const int bcutnum = bcuts.
size();
374 for (i = 0; i < bcutnum; ++i) {
426 if (cutfile.
length() > 0) {
429 FILE*
f = fopen(cutfile.
c_str(),
"r");
431 if (fread(&size, 1,
sizeof(size), f) !=
sizeof(size))
433 char * data =
new char[size];
434 if (fread(data, 1, size, f) != size)
443 for (
int i = 0; i < num; ++i) {
453 if (added_vars.
size() > 0) {
454 const int num = added_vars.
size();
459 for (
int i = 0; i < num; ++i) {
470 if (added_cuts.
size() > 0) {
471 const int num = added_cuts.
size();
476 for (
int i = 0; i < num; ++i) {
504 printf(
"##########################################################\n");
505 printf(
"TM: Starting phase %i\n", p.
phase);
506 printf(
"##########################################################\n");
524 BCP_tm_tasks_before_new_phase: candidate_list should be empty!\n");
530 CoinSearchTreeBase* candidates = NULL;
532 if (candidates == NULL) {
533 candidates =
new CoinSearchTree<CoinSearchTreeCompareBest>;
This class describes changes in the core of the problem.
BCP_buffer msg_buf
members to measure how long it took to process the root node.
Indicates whether to trim the search tree before a new phase.
BCP_problem_core * BCP_tm_create_core(BCP_tm_prob &p)
void BCP_tm_notify_about_new_phase(BCP_tm_prob &p)
This class describes the core of the MIP problem, the variables/cuts in it as well as the matrix corr...
void set_arguments(const int argnum, const char *const *args)
Parameters related to scheduling the LP processes.
This class stores data about how an object set (set of vars or set of cuts) changes.
virtual int num_procs()
Return the number of processes.
BCP_parameter_set< BCP_vg_par > vg
Used when receiving, message with any message tag will be received.
int next_cut_index_set_start
void print(bool final, double t)
BCP_parameter_set< BCP_cg_par > cg
void set_ub(const double ub)
Set the upper bound.
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.
The data stored is with respect to the original description of the base problem (as was given by the ...
virtual void receive(const int source, const BCP_message_tag tag, BCP_buffer &buf, const double timeout)=0
Blocking receive with timeout.
Parameters related to scheduling the LP processes.
void clear()
Delete every entry.
std::map< int, Coin::SmartPtr< BCP_cut > > cuts_local
BCP_process_t BCP_vg_main(BCP_message_environment *msg_env, USER_initialize *user_init, int my_id, int parent, double ub)
void update_idle_times()
Update idle times with the last idle time.
This is an abstract base class that describes the message passing environment.
Abstract base class that defines members common to all types of cuts.
void insert(BCP_tm_node *node)
Return the worst true lower bound in the search tree.
virtual BCP_cut_algo * unpack_cut_algo(BCP_buffer &buf)
Unpack an algorithmic cut.
void set_bcpind(const int bcpind)
Set the internal index of the cut.
BCP_process_t
This enumerative constant describes the various process types.
Indicates whether message passing is serial (all processes are on the same processor) or not...
char entry(const chr_params key) const
const char * c_str() const
virtual BCP_user_pack * packer_init(BCP_user_class *p)
void set_bcpind(const int bcpind)
Set the internal index of the variable.
BCP_vec< std::pair< int, int > > leaves_per_cp
BCP_storage_t _storage
Describes how the change is stored.
Indicates whether message passing is serial (all processes are on the same processor) or not...
bool BCP_tm_is_data_balanced(BCP_tm_prob &p)
This function is invoked from exactly one place, the beginning of BCP_tm_unpack_node_description().
The number of Variable Generator processes that should be spawned.
void update_queue_length(int i, int len)
Core cuts are the cuts that always stay in the LP formulation.
double ub() const
Return the upper bound on the cut.
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)
CoinSearchTreeManager candidate_list
BCP_vec< BCP_tm_node * > next_phase_nodes
a vector of nodes to be processed in the next phase
void reserve(const size_t n)
Reallocate the object to make space for n entries.
bool BCP_tm_balance_data(BCP_tm_prob &p)
This function is invoked after data from an LP is unpacked (and only if p.need_a_TS is true)...
void BCP_tm_main(BCP_message_environment *msg_env, USER_initialize *user_init, const int argnum, const char *const *arglist)
Indicates whether message passing is serial (all processes are on the same processor) or not...
virtual BCP_message_environment * msgenv_init(int argc, char *argv[])
Create a message passing environment.
This class is a very simple impelementation of a constant length string.
void setTmProblemPointer(BCP_tm_prob *ptr)
Set the pointer.
void set_content(const char *data, const size_t size, int sender, BCP_message_tag msgtag)
Set the buffer to be a copy of the given data.
void BCP_tm_stop_processes(BCP_tm_prob &p)
Indicates whether message passing is serial (all processes are on the same processor) or not...
Core variables are the variables that always stay in the LP formulation.
Parameters related to scheduling the LP processes.
void push_back(const_reference x)
Append x to the end of the vector.
virtual void process_message()
void BCP_tm_start_processes(BCP_tm_prob &p)
void fint fint fint real fint real real real real * f
BCP_process_t BCP_cg_main(BCP_message_environment *msg_env, USER_initialize *user_init, int my_id, int parent, double ub)
BCP_obj_status
This enumerative constant gives the status of an object (variable or cut).
The data stored is an explicit listing of values.
Print the "Starting phase x" line.
void BCP_tm_parse_command_line(BCP_tm_prob &p, const int argnum, const char *const *arglist)
The name of the file where cuts to be added to the root description should be read ot from...
int bcp_main(int argc, char *argv[], USER_initialize *user_init)
This is the function the user must invoke when (s)he is ready to turn contrl over to BCP...
double lb() const
Return the lower bound on the cut.
void fint fint fint real fint real real real real real real real real real * e
BCP_problem_core_change core_change
BCP_process_t BCP_lp_main(BCP_message_environment *msg_env, USER_initialize *user_init, int my_id, int parent, double ub)
int numNodeIds() const
Return the number of busy LP processes.
std::map< int, Coin::SmartPtr< BCP_var > > vars_local
BCP_node_start_result BCP_tm_start_new_nodes(BCP_tm_prob &p)
void BCP_tm_tasks_before_new_phase(BCP_tm_prob &p)
double ub() const
Return the upper bound.
Coin::SmartPtr< BCP_node_change > _desc
BCP_obj_set_change cut_change
The number of Cut Generator processes that should be spawned.
This class is an abstract base class for the initializer class the user has to provide.
int next_var_index_set_start
BCP_vec< std::pair< int, int > > leaves_per_vp
static long BCP_used_heap()
void set_entry(const chr_params key, const char val)
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)
void BCP_tm_trim_tree_wrapper(BCP_tm_prob &p, const bool between_phases)
BCP_obj_status status() const
Return the status of the cut.
bool BCP_tm_do_one_phase(BCP_tm_prob &p)
void set_status(const BCP_obj_status stat)
Set the status of the cut.
BCP_parameter_set< BCP_tm_par > par
void BCP_tm_idle_processes(BCP_tm_prob &p)
void clear()
Completely clear the buffer.
void BCP_sanity_checks(BCP_tm_prob &p)
BCP_message_tag msgtag() const
Return the message tag of the message in the buffer.
void BCP_tm_wrapup(BCP_tm_prob *tm, BCP_lp_prob *lp, BCP_cg_prob *cg, BCP_vg_prob *vg, bool final_stat)
BCP_var_t var_type() const
Return the integrality type of the variable.
virtual void init_new_phase(int phase, BCP_column_generation &colgen, CoinSearchTreeBase *&candidates)
Do whatever initialization is necessary before the phase-th phase.
Coin::SmartPtr< BCP_user_data > _user
Abstract base class that defines members common to all types of variables.
Currently there isn't any error handling in BCP.
BCP_message_environment * msg_env
A class that holds the methods about how to pack things.
BCP_user_pack * packer
A class that holds the methods about how to pack things.
virtual BCP_tm_user * tm_init(BCP_tm_prob &p, const int argnum, const char *const *arglist)
size_t size() const
Return the current number of entries.
BCP_obj_status status() const
Return the status of the variable.
void BCP_tm_notify_processes(BCP_tm_prob &p)
virtual void create_root(BCP_vec< BCP_var * > &added_vars, BCP_vec< BCP_cut * > &added_cuts, BCP_user_data *&user_data)
Create the set of extra variables and cuts that should be added to the formulation in the root node...
This class describes the message buffer used for all processes of BCP.
void change_bounds(const double lb, const double ub)
Change just the lower/upper bounds.
void unchecked_push_back(const_reference x)
Append x to the end of the vector.
BCP_scheduler lp_scheduler
members to measure how long it took to process the root node.
BCP_parameter_set< BCP_lp_par > lp
virtual int parent_process()=0
Return the process id of the parent process (the process that spawned the currnet process...
virtual void initialize_core(BCP_vec< BCP_var_core * > &vars, BCP_vec< BCP_cut_core * > &cuts, BCP_lp_relax *&matrix)
Create the core of the problem by filling out the last three arguments.
std::multiset< double > lower_bounds
double lb() const
Return the lower bound.
BCP_tm_user * user
A class that holds the methods about how to pack things.
void set_lb(const double lb)
Set the lower bound.
BCP_problem_core_change * core_as_change
The number of Variable Pool processes that should be spawned.
BCP_slave_params slave_pars
virtual int register_process(USER_initialize *user_init)=0
A process can register (receive its process id) with the message passing environment.
BCP_obj_set_change var_change
BCP_tm_node * BCP_tm_create_root(BCP_tm_prob &p)
BCP_column_generation current_phase_colgen
Max how many SB nodes should the scheduler give to an LP process.
BCP_vec< BCP_obj_change > _change
BCP_object_t
This enumerative constant describes the possible types of objects (variables and cuts).
char param(BCP_tm_par::chr_params key) const
void update_wait_time(int i, double t)
static BCP_cut * BCP_tm_unpack_root_cut(BCP_tm_prob &tm)
An object of type BCP_lp_relax holds the description of an lp relaxation.
The number of Cut Pool processes that should be spawned.
CouExpr & log(CouExpr &e)
The number of LP processes that should be spawned.