6 #include "CoinTime.hpp"
20 #ifndef BCP_DEBUG_PRINT
21 #define BCP_DEBUG_PRINT 0
28 const int bvarnum,
const int bcutnum,
55 if ((lines % 41) == 0) {
70 if ((processed % freq) == 0 || processed == 1) {
74 printf(
"%7i ", processed);
75 printf(
"%10g ", p.
ub());
99 if ((cnt % 100) == 0) {
102 printf(
" mallinfo used: %li\n", usedheap);
122 const int lp_id = node->
lp;
125 BCP_tm_unpack_node_description: received node is different from processed.\n");
132 const double oldTrueLB = floor(node->getTrueLB()*p.
lb_multiplier);
135 node->setTrueLB(tlb);
155 bool desc_sent =
false;
263 return (quality < 0 && topq / quality < ratio) ?
271 const int bvarnum,
const int bcutnum,
274 if (bvarnum + bcutnum == 0) {
282 int affected_core = 0;
285 while (posi != lastposi) {
291 if (affected_core > 0) {
294 var_pos.
reserve(affected_core);
299 while (posi != lastposi) {
300 if (*posi < bvarnum) {
302 const double lb = *boundsi;
303 const double ub = *(boundsi+1);
315 int affected_core = 0;
318 while (posi != lastposi) {
324 if (affected_core > 0) {
327 cut_pos.
reserve(affected_core);
332 while (posi != lastposi) {
333 if (*posi < bcutnum) {
335 const double lb = *boundsi;
336 const double ub = *(boundsi+1);
355 int affected_added = 0;
358 while (posi != lastposi) {
359 if (*posi >= bvarnum)
364 if (affected_added == 0) {
377 dc_pos.
reserve(affected_added);
381 while (posi != lastposi) {
382 if (*posi >= bvarnum) {
384 const double lb = *boundsi;
385 const double ub = *(boundsi+1);
401 int affected_added = 0;
404 while (posi != lastposi) {
405 if (*posi >= bcutnum)
410 if (affected_added == 0) {
423 dc_pos.
reserve(affected_added);
427 while (posi != lastposi) {
428 if (*posi >= bcutnum) {
430 const double lb = *boundsi;
431 const double ub = *(boundsi+1);
453 const int depth = node->getDepth() + 1;
454 const BitVector128 nodePref = node->getPreferred();
480 child->setDepth(depth);
481 child->setQuality(qualities[child_ind]);
482 child->setTrueLB(true_lb[child_ind]);
483 if (child_ind > 0 && depth <= 127) {
484 BitVector128 pref = nodePref;
485 pref.setBit(127-depth);
486 child->setPreferred(pref);
488 child->setPreferred(nodePref);
493 switch (action[child_ind]){
505 child->
vp = node->
vp;
506 child->
cp = node->
cp;
508 #if (BCP_DEBUG_PRINT != 0)
509 printf(
"TM %.3lf: parent: %i sibling: %i siblingind: %i depth: %i quality: %lf pref: %s\n",
511 child->getPreferred().str().c_str());
540 const int child_num = action.
size();
541 user_data.
insert(user_data.
end(), child_num, 0);
542 bool has_user_data =
false;
543 for (
int i = 0; i < child_num; ++i) {
544 buf.
unpack(has_user_data);
560 if (node->
cp != -1) {
569 if (node->
vp != -1) {
579 CoinTreeNode** children =
new CoinTreeNode*[child_num];
580 int numChildrenAdded = 0;
581 #if (BCP_DEBUG_PRINT != 0)
584 printf(
"TM %.3lf: parent: %i cand_list empty\n", tt, node->
_index);
586 printf(
"TM %.3lf: parent: %i cand_list top pref: %s\n",
593 for (i = 0; i < child_num; ++i) {
604 for (i = 0; i < child_num; ++i) {
612 int reply_to_lp = -1;
613 if (numChildrenAdded > 0) {
614 CoinTreeSiblings siblings(numChildrenAdded, children);
622 child = node->
child(0);
624 reply_to_lp = node->
lp;
639 siblings.advanceNode();
659 if (child != node->
child(0)) {
661 BCP_tm_unpack_branching_info: the value of child is messed up!\n");
663 if (node->
lp == -1) {
665 BCP_tm_unpack_branching_info: the (old) node has no LP associated with!\n");
667 child->
lp = node->
lp;
668 child->
cg = node->
cg;
669 child->
vg = node->
vg;
671 node->
lp = node->
cg = node->
vg = -1;
678 for (
int i = true_lb.
size()-1; i >= 0; --i) {
690 if (reply_to_lp >= 0) {
698 #ifdef BCP__DUMP_PROCINFO
699 #if (BCP__DUMP_PROCINFO == 1)
700 dump_procinfo(p,
"BCP_tm_unpack_branching_info()");
static double lb_multiplier
The lower bounds of the unexplored search tree nodes.
static int BCP_tm_unpack_node_description(BCP_tm_prob &p, BCP_buffer &buf)
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.
This child should be kept and dived into (provided diving is decided on.
BCP_buffer & pack(const T &value)
Pack a single object of type T.
const BCP_vec< int > & var_positions() const
Return a const reference to the vector of positions of variables affected by the branching.
static int num_local_nodes
int child_num() const
Return the number of children.
BCP_buffer & unpack(T &value)
Unpack a single object of type T.
BCP_vec< double >::const_iterator cut_bounds_child(const int index) const
Return a const iterator within _cut_bounds to the location where the bound pairs for the index-th chi...
void increase_processed()
std::map< int, BCP_tm_node * > active_nodes
A map from the process ids to the nodes (what they work on)
Print out a message when the default version of an overridable method is executed.
virtual void change_candidate_heap(CoinSearchTreeManager &candidates, const bool new_solution)
static BCP_diving_status BCP_tm_shall_we_dive(BCP_tm_prob &p, const double quality)
void insert(BCP_tm_node *node)
Return the worst true lower bound in the search tree.
virtual BCP_user_data * unpack_user_data(BCP_buffer &buf)
Unpack an user data.
BCP_tm_node_status status
BCP_storage_t storage() const
Return the storage type.
void reserve_child_num(int num)
BCP_vec< std::pair< int, int > > leaves_per_cp
BCP_tm_node * BCP_tm_unpack_node_no_branching_info(BCP_tm_prob &p, BCP_buffer &buf)
static void BCP_tm_create_cut_change(BCP_node_change *desc, const BCP_node_change *parentdesc, const int bcutnum, const BCP_internal_brobj *brobj, const int childind)
BCP_storage_t _storage
Describes how the change is stored.
static int num_remote_nodes
At every this many search tree node provide a single line info on the progress of the search tree...
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().
iterator begin()
Return an iterator to the beginning of the object.
CoinSearchTreeManager candidate_list
const BCP_vec< int > & cut_positions() const
Return a const reference to the vector of positions of cuts affected by the branching.
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)...
The object is not removable from the LP formulation, even if the object becomes inactive.
BCP_vec< int > cut_pos
The positions of the core cuts (in the cuts member of [BCP_problem_core]{BCP_problem_core.html}) whose bounds and/or stati have changed.
Do not use any warmstart information.
virtual BCP_warmstart * unpack_warmstart(BCP_buffer &buf, bool report_if_default=false)
Unpack warmstarting information.
TM sends diving information.
This class is the internal representation of a branching object.
The data stored is an explicit listing of values.
size_t varnum() const
Return the number of variables in the core.
BCP_vec< int > var_pos
The positions of the core variables (in the vars member of [BCP_problem_core]{BCP_problem_core.html}) whose bounds and/or stati have changed.
BCP_vec< BCP_obj_change > var_ch
The new lb/ub/status triplet for each variable for which any of those three have changed.
BCP_problem_core_change core_change
void BCP_tm_unpack_node_with_branching_info(BCP_tm_prob &p, BCP_buffer &buf)
void unpack(BCP_buffer &buf)
Unpack an internal branching object from the buffer.
static double ratio(Bigint *a, Bigint *b)
static BCP_tm_node * BCP_tm_create_child(BCP_tm_prob &p, const int child_ind, BCP_tm_node *node, const BCP_internal_brobj *brobj, const BCP_vec< BCP_child_action > &action, const BCP_vec< BCP_user_data * > &user_data, const BCP_vec< double > &true_lb, const BCP_vec< double > &qualities)
Coin::SmartPtr< BCP_node_change > _desc
BCP_obj_set_change cut_change
BCP_diving_status
This enumerative constant describes the diving status of the search tree node processed by the LP pro...
The probability with which the LP process is directed to dive.
The LP process is allowed to dive if the ratio between the quality (for now the presolved objective v...
BCP_vec< std::pair< int, int > > leaves_per_vp
virtual BCP_storage_t storage() const =0
Return how the warmstarting info is stored.
virtual BCP_warmstart * empty_wrt_this() const =0
Create a warmstart info describing that no change should be done.
static long BCP_used_heap()
size_t cutnum() const
Return the number of cuts in the core.
int affected_cutnum() const
Return the number of affected cuts.
Use the warmstart info from the end of the parent in the children.
BCP_tm_node * child(int ind)
The data stored is with respect to the same kind of data in the parent of the search tree node...
static void BCP_tm_print_info_line(BCP_tm_prob &p, BCP_tm_node &node)
void BCP_tm_free_procs_of_node(BCP_tm_prob &p, BCP_tm_node *node)
void new_child(BCP_tm_node *node)
void clear()
Completely clear the buffer.
After branching the LP process is free to decide whether it keeps a child to dive into...
BCP_vec< double >::const_iterator var_bounds_child(const int index) const
Return a const iterator within _var_bounds to the location where the bound pairs for the index-th chi...
static void BCP_tm_create_core_change(BCP_node_change *desc, const int bvarnum, const int bcutnum, const BCP_internal_brobj *brobj, const int childind)
void insert(iterator position, const void *first, const size_t num)
Insert num entries starting from memory location first into the vector from position pos...
static void BCP_tm_unpack_branching_info(BCP_tm_prob &p, BCP_buffer &buf, BCP_tm_node *node)
void unpack(BCP_buffer &buf)
Unpack the core change data from the buffer.
void BCP_print_memusage(BCP_tm_prob &p)
Coin::SmartPtr< BCP_user_data > _user
static void BCP_tm_create_var_change(BCP_node_change *desc, const BCP_node_change *parentdesc, const int bvarnum, const BCP_internal_brobj *brobj, const int childind)
Use the warmstart info from the end of the root in all search tree nodes.
BCP_storage_t storage() const
This child should be returned to the Tree Manager for later processing.
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.
size_t size() const
Return the current number of entries.
iterator end()
Return an iterator to the end of the object.
void unpack(BCP_buffer &buf)
After branching all children must be returned to the Tree Manager and the LP process should wait for ...
This class describes the message buffer used for all processes of BCP.
void unchecked_push_back(const_reference x)
Append x to the end of the vector.
BCP_vec< int > _del_change_pos
std::multiset< double > lower_bounds
BCP_tm_user * user
A class that holds the methods about how to pack things.
BCP_obj_set_change var_change
BCP_warmstart * warmstart
Same as above, but this value is used if an upper bound does not exist yet.
virtual void display_node_information(BCP_tree &search_tree, const BCP_tm_node &node)
Display user information just before a new node is sent to the LP or diving into a node is acknowledg...
After branching the LP process must inquire of the Tree Manager whether it can dive into one of the c...
BCP_vec< BCP_obj_change > _change
BCP_vec< std::pair< int, int > >::iterator BCP_tm_identify_process(BCP_vec< std::pair< int, int > > &proclist, int proc)
char param(BCP_tm_par::chr_params key) const
Specifies how warmstart information should be stored in the TM.
int affected_varnum() const
Return the number of affected variables.
BCP_vec< BCP_obj_change > cut_ch
The new lb/ub/status triplet for each cut for which any of those three have changed.
This child should be fathomed.