pybnb.problem¶
Branch-and-bound problem definition.
Copyright by Gabriel A. Hackebeil (gabe.hackebeil@gmail.com).
- class pybnb.problem.Problem[source]¶
The abstract base class used for defining branch-and-bound problems.
- abstractmethod sense()[source]¶
Returns the objective sense for this problem.
Note
This method is abstract and must be defined by the user.
- abstractmethod bound()[source]¶
Returns a value that is a bound on the objective of the current problem state or
self.unbounded_objective()
if no non-trivial bound is available.Note
This method is abstract and must be defined by the user.
- abstractmethod objective()[source]¶
Returns a feasible value for the objective of the current problem state or
self.infeasible_objective()
if the current state is not feasible.Note
This method is abstract and must be defined by the user.
- abstractmethod save_state(node)[source]¶
Saves the current problem state into the given
pybnb.node.Node
object.This method is guaranteed to be called once at the start of the solve by all processes involved to collect the root node problem state, but it may be called additional times. When it is called for the root node, the
node.tree_depth
will be zero.Note
This method is abstract and must be defined by the user.
- abstractmethod load_state(node)[source]¶
Loads the problem state that is stored on the given
pybnb.node.Node
object.Note
This method is abstract and must be defined by the user.
- abstractmethod branch()[source]¶
Returns a list of
Node
objects that partition the node state into zero or more children. This method can also be defined as a generator.Note
This method is abstract and must be defined by the user.
- infeasible_objective()[source]¶
Returns the value that represents an infeasible objective (i.e., +inf or -inf depending on the sense). The
Problem
base class implements this method.
- unbounded_objective()[source]¶
Returns the value that represents an unbounded objective (i.e., +inf or -inf depending on the sense). The
Problem
base class implements this method.
- notify_solve_begins(comm, worker_comm, convergence_checker)[source]¶
Called when a branch-and-bound solver begins as solve. The
Problem
base class provides a default implementation for this method that does nothing.- Parameters
comm (
mpi4py.MPI.Comm
orNone
) – The full MPI communicator that includes all processes. Will be None if MPI has been disabled.worker_comm (
mpi4py.MPI.Comm
orNone
) – The MPI communicator that includes only worker processes. Will be None if MPI has been disabled.convergence_checker (
ConvergenceChecker
:) – The class used for comparing the objective and bound values during the solve.
- notify_new_best_node(node, current)[source]¶
Called when a branch-and-bound solver receives a new best node from the dispatcher. The
Problem
base class provides a default implementation for this method that does nothing.- Parameters
node (
Node
) – The new best node.current (bool) – Indicates whether or not the node argument is the currently loaded node (from the most recent
load_state
call).
- notify_solve_finished(comm, worker_comm, results)[source]¶
Called when a branch-and-bound solver finishes. The
Problem
base class provides a default implementation for this method that does nothing.- Parameters
comm (
mpi4py.MPI.Comm
orNone
) – The full MPI communicator that includes all processes. Will be None if MPI has been disabled.worker_comm (
mpi4py.MPI.Comm
orNone
) – The MPI communicator that includes only worker processes. Will be None if MPI has been disabled.results (
SolverResults
) – The fully populated results container that will be returned from the solver.