/************************************************************************/ BCP_branching_object_relation BB_lp:: compare_branching_candidates(BCP_presolved_lp_brobj* new_presolved, BCP_presolved_lp_brobj* old_presolved) { BCP_lp_prob *p = getLpProblemPointer(); // change the objvals according to the termcodes (in order to be able to // make decisions based on objval, no matter what the termcode is). new_presolved->fake_objective_values(p->lp_result->objval()); // If using this branching object we can fathom all children, then choose // this object double objlim = p->ub() - p->granularity(); if(new_presolved->fathomable(objlim)) { return(BCP_NewPresolvedIsBetter_BranchOnIt); } BCP_vec new_obj; new_presolved->get_lower_bounds(new_obj); std::sort(new_obj.begin(), new_obj.end()); const int new_not_fathomed = new_obj.index(std::lower_bound(new_obj.begin(), new_obj.end(), 1e100 / 2)); // If this is the first, keep it if (! old_presolved) return(BCP_NewPresolvedIsBetter); BCP_vec old_obj; old_presolved->get_lower_bounds(old_obj); std::sort(old_obj.begin(), old_obj.end()); const int old_not_fathomed = old_obj.index(std::lower_bound(old_obj.begin(), old_obj.end(), 1e100 / 2)); // If something had gone wrong with at least one descendant in the new then // we prefer to keep the old. if (new_presolved->had_numerical_problems()) return(BCP_OldPresolvedIsBetter); // OK, so all descendants finished just fine. Do whatever the parameter says #ifdef NO_BRANCH_ON_SINGLE if (new_not_fathomed < old_not_fathomed) return BCP_OldPresolvedIsBetter; if (new_not_fathomed > old_not_fathomed) return BCP_NewPresolvedIsBetter; #else if (new_not_fathomed < old_not_fathomed) return BCP_NewPresolvedIsBetter; if (new_not_fathomed > old_not_fathomed) return BCP_OldPresolvedIsBetter; #endif BCP_vec::const_iterator new_first = new_obj.begin(); BCP_vec::const_iterator new_last = new_obj.end(); BCP_vec::const_iterator old_first = old_obj.begin(); BCP_vec::const_iterator old_last = old_obj.end(); double newmin, newmax, oldmin, oldmax, newval, oldval; newmin = 1e100 / 2; newmax = -1e100 / 2; for ( ; new_first != new_last; ++new_first) { if (*new_first < newmin) newmin = *new_first; if ((*new_first < 1e100 / 2) && (*new_first > newmax)) newmax = *new_first; } newval = (5 * newmin + newmax) / 6; oldmin = 1e100 / 2; oldmax = -1e100 / 2; for ( ; old_first != old_last; ++old_first) { if (*old_first < oldmin) oldmin = *old_first; if ((*old_first < 1e100 / 2) && (*old_first > oldmax)) oldmax = *old_first; } oldval = (5 * oldmin + oldmax) / 6; #ifdef TRACE_ALL printf("oldmin: %8.3f oldmax: %8.3f oldval: %8.3f\n", oldmin, oldmax, oldval); printf("newmin: %8.3f newmax: %8.3f newval: %8.3f\n", newmin, newmax, newval); #endif return newval > oldval ? BCP_NewPresolvedIsBetter : BCP_OldPresolvedIsBetter; } /* compare_branching_candidates */