Node

class bnbpy.cython.node.Node

Bases: object

Class for representing a node in a search tree.

branch()

Calls problem branch() method to create derived sub-problems. Each subproblem is used to instantiate a child node. Child nodes are evaluated in terms of lower bound as they are initialized.

Returns:

List of child nodes, if any

Return type:

list[Node]

check_feasible()

Calls problem check_feasible() method

Returns:

Feasibility check result

Return type:

bool

children
cleanup()
compute_bound()

Computes the lower bound of the problem and sets it to problem attribute lb, which is referenced as a Node property.

copy(deep=True)
index
lb
level
parent
primal_heuristic()

Calls problem primal_heuristic() method to generate a feasible solution from the current node, if any.

Returns:

A child node with a feasible solution, if any

Return type:

Node | None

problem
save_children(children)

Saves the list of child nodes to children attribute of the node.

Parameters:

children (list[Node]) – List of child nodes to save

set_solution(solution)

Calls method set_solution of problem, which also computes its lower bound if not yet solved.

Parameters:

solution (Solution) – New solution to overwrite current

solution
upgrade_bound()

Calls problem upgrade_bound() method to compute a stronger lower bound, if possible, and updates node’s lower bound accordingly.