Priority Managers

Priority-manager node managers use a native C++ binary min-heap to select the next node according to a configurable ordering criterion (depth-first or best-first bound). They all extend PriorityManagerTemplate, which itself extends BaseNodeManager.

For simpler stack / queue managers without priority ordering see Node Managers.

PriorityManagerTemplate

class bnbpy.cython.primanager.PriorityManagerTemplate

Bases: BaseNodeManager

Priority queue manager backed by a native C++ binary heap.

Stores nodes with vector[double] priorities; the queue is a min-heap (smallest priority dequeued first).

Subclasses must override make_priority().

clear()

Makes the manager empty.

dequeue()

Removes and returns the next node, updating bound_memory.

Returns:

The next node, or None if empty.

Return type:

Node

enqueue(node)

Adds a node to the manager and records it in bound_memory.

Parameters:

node (Node) – The node to add.

enqueue_all(nodes)

Adds a list of nodes to the manager.

Parameters:

nodes (list[Node]) – The list of nodes to add.

filter_by_lb(max_lb)

Remove nodes with lb >= max_lb and update bound_memory.

Parameters:

max_lb (float) – The maximum lower bound value (exclusive upper bound).

get_lower_bound()

Gets a node with the global minimum lower bound without removing it.

Returns:

A node with the lowest lower bound, or None if empty.

Return type:

Node

make_priority(node)
not_empty()

Checks if the manager is not empty.

Returns:

True if the manager is not empty, False otherwise.

Return type:

bool

size()

Returns the number of nodes in the manager.

Returns:

The number of nodes in the manager.

Return type:

int

DepthFirstSearch

class bnbpy.cython.primanager.DepthFirstSearch

Bases: PriorityManagerTemplate

Depth-first variant: priority (-level, lb, -index).

BestFirstSearch

class bnbpy.cython.primanager.BestFirstSearch

Bases: PriorityManagerTemplate

Best-first variant: priority (lb, -level, -index).