Class BranchAndBoundThreads
java.lang.Object
topics.branchandbound.utils.threads.BranchAndBoundThreads
- Direct Known Subclasses:
RectanglesPlacementTestTimeThreads, RectanglesPlacementThreads
Concurrent Branch and Bound Execution Engine
An abstract base class providing the core algorithmic framework for solving combinatorial optimization problems using a multithreaded Branch and Bound paradigm.
This engine manages the state space tree explicitly using a concurrent priority queue. It dispatches a specified number of worker threads that collaboratively explore the state space, sharing a globally visible upper bound to systematically prune sub-optimal branches across all execution contexts.
- Author:
- vicegd
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static NodeThe node representing the optimal valid configuration discovered globally across all threads.protected static intThe global upper bound metric used to prune paths mathematically incapable of yielding a better outcome.protected static HeapThreadsThe concurrent priority queue managing the active, unexplored nodes in the state space tree.protected static NodeThe origin state of the problem environment. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInitializes the concurrent memory structures required for the execution engine. -
Method Summary
Modifier and TypeMethodDescriptionvoidbranchAndBound(Node initialNode, int numberOfThreads) Executes the multithreaded Branch and Bound systemic loop.Retrieves the node encapsulating the mathematically optimal path or configuration.Retrieves the foundational starting state of the problem.voidExtracts and logs the complete topological lineage of the optimal path, detailing every state transition from the root node to the final solution leaf.
-
Field Details
-
nodeHeap
The concurrent priority queue managing the active, unexplored nodes in the state space tree. -
bestNode
The node representing the optimal valid configuration discovered globally across all threads. Marked as volatile to ensure immediate visibility across CPU caches. -
rootNode
The origin state of the problem environment. -
globalUpperBound
protected static volatile int globalUpperBoundThe global upper bound metric used to prune paths mathematically incapable of yielding a better outcome. Marked as volatile to guarantee thread-safe visibility.
-
-
Constructor Details
-
BranchAndBoundThreads
protected BranchAndBoundThreads()Initializes the concurrent memory structures required for the execution engine.
-
-
Method Details
-
branchAndBound
Executes the multithreaded Branch and Bound systemic loop.- Parameters:
initialNode- The starting mathematical state of the problem environment.numberOfThreads- The total number of concurrent worker threads to dispatch.
-
getRootNode
Retrieves the foundational starting state of the problem.- Returns:
- The root node of the execution tree.
-
getBestNode
Retrieves the node encapsulating the mathematically optimal path or configuration.- Returns:
- The best discovered node, or
nullif no valid solution exists.
-
printSolutionTrace
public void printSolutionTrace()Extracts and logs the complete topological lineage of the optimal path, detailing every state transition from the root node to the final solution leaf.
-