PriQueue

class bnbpy.cython.priqueue.BasePriQueue

Bases: object

Base class for managing active nodes in Branch & Bound algorithm (not necessarily formally implementing a priority queue).

Note that due to Cython limitations this class is not implemented as an ABC class, but it is mandatory to implement the following methods in subclasses:

  • not_empty

  • enqueue

  • dequeue

  • get_lower_bound

  • pop_lower_bound

  • clear

clear()

Makes queue empty.

dequeue()

Removes and returns the next evaluated node.

Returns:

The next evaluated node.

Return type:

Node

enqueue(node)

Adds a node to the priority queue.

Parameters:

node (Node) – The node to add to the queue.

filter_by_lb(max_lb)

Filter nodes by lower bound. This method is not implemented in the base class, but can be overridden in subclasses.

Parameters:

max_lb (float) – The maximum lower bound value.

get_lower_bound()

Gets the node of lower bound but does not remove it from the queue.

Returns:

The node with the lowest lower bound.

Return type:

Node

not_empty()

Checks if the priority queue is not empty.

Returns:

True if the queue is not empty, False otherwise.

Return type:

bool

pop_lower_bound()

Removes and returns the node of lower bound.

Returns:

The node with the lowest lower bound.

Return type:

Node