3#ifndef _BCP_LP_BRANCH_H
4#define _BCP_LP_BRANCH_H
70class BCP_lp_branching_object {
75 BCP_lp_branching_object(
const BCP_lp_branching_object&);
77 BCP_lp_branching_object& operator=(
const BCP_lp_branching_object&);
172 if ( ((fvp == 0) ^ (fvb == 0)) || ((fcp == 0) ^ (fcb == 0)) ||
173 ((ivp == 0) ^ (ivb == 0)) || ((icp == 0) ^ (icb == 0)) )
175 if ( (fvp && (2 * children* fvp->
size() != fvb->
size())) ||
176 (fcp && (2 * children* fcp->
size() != fcb->
size())) ||
177 (ivp && (2 * children* ivp->
size() != ivb->
size())) ||
178 (icp && (2 * children* icp->
size() != icb->
size())) )
297 const int added_cuts_start);
305 const double* x,
const double * obj)
const;
321class BCP_presolved_lp_brobj {
326 BCP_presolved_lp_brobj(
const BCP_presolved_lp_brobj&);
328 BCP_presolved_lp_brobj& operator=(
const BCP_presolved_lp_brobj&);
365 for (
int i =
candidate->child_num; i; --i) {
366 _lpres.unchecked_push_back(new BCP_lp_result);
367 _new_cuts.push_back(BCP_vec<BCP_cut*>());
368 _new_rows.push_back(BCP_vec<BCP_row*>());
376 for (
int i = _new_cuts.size() - 1; i >= 0; --i) {
398 return *(_lpres[child_ind]);
404 return _child_action;
408 return _child_action;
433 for (
int i = _candidate->child_num - 1; i >= 0; --i) {
434 _lpres[i]->fake_objective_value(val);
438 for (
int i = _child_action.size() - 1; i >= 0; --i) {
443 for (
int i = _child_action.size() - 1; i >= 0; --i) {
452 obj.
reserve(_candidate->child_num);
453 const int num_children = _lpres.size();
454 for (
int i = 0; i < num_children; ++i)
460 const int num_children = _lpres.size();
461 for (
int i = 0; i < num_children; ++i)
462 _lpres[i]->fake_objective_value(obj[i]);
468 _lpres[child_ind]->get_results(lp);
487 const double itlim_objval);
490 void swap(BCP_presolved_lp_brobj& rhs) {
491 std::swap(_candidate, rhs._candidate);
492 _lpres.swap(rhs._lpres);
493 _child_action.swap(rhs._child_action);
494 _user_data.swap(rhs._user_data);
495 _new_cuts.swap(rhs._new_cuts);
496 _new_rows.swap(rhs._new_rows);
@ BCP_ReturnChild
This child should be returned to the Tree Manager for later processing.
@ BCP_FathomChild
This child should be fathomed.
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.
Currently there isn't any error handling in BCP.
This class describes a generic branching object.
BCP_lp_branching_object(const int children, BCP_vec< BCP_var * > *const new_vars, BCP_vec< BCP_cut * > *const new_cuts, const BCP_vec< int > *const fvp, const BCP_vec< int > *const fcp, const BCP_vec< double > *const fvb, const BCP_vec< double > *const fcb, const BCP_vec< int > *const ivp, const BCP_vec< int > *const icp, const BCP_vec< double > *const ivb, const BCP_vec< double > *const icb)
The constructor makes a copy of each vector passed to it.
int vars_added() const
Return the number of variables added in the branching.
BCP_vec< double >::const_iterator forced_cut_bd_child(const int index) const
Return a const iterator to the position in the forced cut bound changes where the new bounds for the ...
BCP_vec< BCP_cut * > * cuts_to_add
Cuts to be added to the formulation.
BCP_vec< int > * termcode_
int cuts_added() const
Return the number of cuts added in the branching.
void apply_child_bd(OsiSolverInterface *lp, const int child_ind) const
This method invokes the appropriate methods of lp to apply the forced and implied bound changes of th...
BCP_vec< int > * forced_var_pos
Positions of variables whose bounds change ("forcibly", by branching) in the children.
int child_num
The number of children for this branching object.
BCP_vec< int > * implied_cut_pos
void set_presolve_result(const BCP_vec< double > &objval, const BCP_vec< int > &termcode)
BCP_vec< double >::const_iterator forced_var_bd_child(const int index) const
Return a const iterator to the position in the forced variable bound changes where the new bounds for...
BCP_lp_branching_object(const OsiSolverInterface *osi, const BCP_lp_sos_branching_object &o, const int *order)
BCP_vec< double >::const_iterator implied_cut_bd_child(const int index) const
Return a const iterator to the position in the implied cut bound changes where the new bounds for the...
BCP_vec< int > * forced_cut_pos
Positions of cuts whose bounds change ("forcibly", by branching) in the children.
BCP_vec< double > * objval_
void print_branching_info(const int orig_varnum, const double *x, const double *obj) const
This method prints out some information about the branching object.
int vars_affected() const
Return the number of variables whose bounds are affected by the branching.
BCP_vec< BCP_var * > * vars_to_add
Variables to be added to the formulation.
BCP_vec< double > * implied_cut_bd
BCP_vec< double >::const_iterator implied_var_bd_child(const int index) const
Return a const iterator to the position in the implied variable bound changes where the new bounds fo...
~BCP_lp_branching_object()
The destructor deletes each vector.
BCP_vec< double > * forced_cut_bd
Contains the actual bounds for the cuts indexed by forced_cut_pos.
BCP_vec< int > * implied_var_pos
BCP_vec< double > * forced_var_bd
Contains the actual bounds for the variables indexed by forced_var_pos.
void init_pos_for_added(const int added_vars_start, const int added_cuts_start)
This method "cleans up" the positions and bounds.
BCP_vec< double > * implied_var_bd
int cuts_affected() const
Return the number of cuts whose bounds are affected by the branching.
BCP_lp_branching_object(const BCP_lp_integer_branching_object &o, const int *order)
This class exist only so that we can extract information from OsiIntegerBranchingObject.
BCP_lp_integer_branching_object(const OsiIntegerBranchingObject *o)
~BCP_lp_integer_branching_object()
const double * childBounds(int i) const
This class holds the results after solving an LP relaxation.
This class exist only so that we can extract information from OsiIntegerBranchingObject.
~BCP_lp_sos_branching_object()
BCP_lp_sos_branching_object(const OsiSOSBranchingObject *o)
void initialize_lower_bound(const double val)
const BCP_lp_branching_object * candidate() const
Return a const pointer to the candidate.
const BCP_lp_result & lpres(const int child_ind) const
Return a const reference to the presolved results of the child_ind-th child.
void get_lower_bounds(BCP_vec< double > &obj)
Fill up obj with the lower bound on each child.
BCP_vec< BCP_vec< BCP_row * > > & get_new_rows()
bool fathomable(const double objval_limit) const
Return true if every children can be fathomed.
void fake_objective_values(const double itlim_objval)
Examine the termination codes for the children and for those that do not have a valid lower bound fak...
BCP_vec< BCP_child_action > & action()
Return a reference to the actions to be taken.
bool had_numerical_problems() const
Return true if at least one child had numerical difficulties while presolving.
void set_objective_values(const BCP_vec< double > &obj, const BCP_vec< int > &termcode, const double itlim_objval)
Set the appropriate fields of all _lpres to the given termcode and objval if the termcode is "normal"...
void set_lower_bounds(const BCP_vec< double > &obj)
Fill up the lower bounds on the children with the content of obj.
const BCP_vec< BCP_user_data * > & user_data() const
Return a const reference to the user data vector.
~BCP_presolved_lp_brobj()
The destructor simply deletes every member (deletes every lpres in the vector).
BCP_vec< BCP_user_data * > & user_data()
Return a reference to the user data vector.
const BCP_vec< BCP_child_action > & action() const
Return a const reference to the actions to be taken.
BCP_lp_branching_object * candidate()
Return a pointer to the candidate.
void swap(BCP_presolved_lp_brobj &rhs)
swap the two presolved branching object
BCP_presolved_lp_brobj(BCP_lp_branching_object *candidate)
The only one way to construct a presolved branching object is to create it from a regular branching o...
void get_results(OsiSolverInterface &lp, const int child_ind)
Extract the lp results from the LP solver for the child_ind-th child.
BCP_vec< BCP_vec< BCP_cut * > > & get_new_cuts()
The class BCP_vec serves the same purpose as the vector class in the standard template library.
void clear()
Delete every entry.
void unchecked_push_back(const_reference x)
Append x to the end of the vector.
size_t size() const
Return the current number of entries.
void reserve(const size_t n)
Reallocate the object to make space for n entries.
OsiIntegerBranchingObject()