Branch and Bound


Algorithm Series 2

Branch and Bound

What is branch and bound?
Branch-and-bound consists of a systematic enumeration of all candidate solutions, where large subsets of fruitless candidates are discarded en masse, by using upper and lower estimated bounds of the quantity being optimized.

The key idea of the BB algorithm is: if the lower bound for some tree node (set of candidates) A is greater than the upper bound for some other node B, then A may be safely discarded from the search. This step is called pruning.

How?
Branch-and-bound is composed of two main actions:
The first step is the branching. This is where we define the tree structure from the set of candidates in a recursive manner.
The second action is called bounding since this procedure calculates the upper and lower bounds of each node from the tree.

Furthermore, there's the additional pruning step that we can add. It means that if the lower bound for some node of the tree is greater than the upper bound of some other node of the tree, then the first node of the tree can be "discarded" from the search. A variable always holds the value of the global minimum upper bound.

A branch and bound algorithm is based on an advanced breadth-first search. The said BFS is done with a priority queue instead of the traditional list.

Main steps is to branch and prune, then enqueue/and dequeue.

Normally branch and bound algorithm is implemented with breadth-first search and FIFO queue or priority queue.

Both the backtracking and divide and conquer traverse the tree of problem space in its depth, though they take opposite routes. The greedy strategy picks a single route and forgets about the rest. Dynamic programming approaches this in a sort of breadth-first search variation (BFS).

Examples
KnapSack
Knapsack Backtracking Solutions with/without bounding functions
KnapSack_Back.java        0/1 knapsack implemented in Java
IntKS_Back.java           Integer knapsack implemented in Java

0/1 KnapSack
cw(i) = sum(j=1..i)w[j]*x[j]
Constraint function
C(i) = cw(i-1) + w[i] if C(i) > W then discard its subtree
Bound function
B(i) = C(i) + r(i)
r(i) = sum(j=i+1..n)v[j]
if B(i) <=bestw, then discard its subtree

Put special node to the queue (-1) to indicate we have done finishes this layer of the tree.

Max loading
Similar as 0/1 KnapSack

Travelling salesman problem
cw(i) = sum(j=2..i)w[x[j-1],x[j]]
Bound function
B(i) = cw(i-1) + w[x[j-1],x[j]] if B(i) >= bestw, then discard its subtree

Flow shop[to-do]
N queen [FIFO BB]
运动员最佳匹配

Resources:

Labels

adsense (5) Algorithm (69) Algorithm Series (35) Android (7) ANT (6) bat (8) Big Data (7) Blogger (14) Bugs (6) Cache (5) Chrome (19) Code Example (29) Code Quality (7) Coding Skills (5) Database (7) Debug (16) Design (5) Dev Tips (63) Eclipse (32) Git (5) Google (33) Guava (7) How to (9) Http Client (8) IDE (7) Interview (88) J2EE (13) J2SE (49) Java (186) JavaScript (27) JSON (7) Learning code (9) Lesson Learned (6) Linux (26) Lucene-Solr (112) Mac (10) Maven (8) Network (9) Nutch2 (18) Performance (9) PowerShell (11) Problem Solving (11) Programmer Skills (6) regex (5) Scala (6) Security (9) Soft Skills (38) Spring (22) System Design (11) Testing (7) Text Mining (14) Tips (17) Tools (24) Troubleshooting (29) UIMA (9) Web Development (19) Windows (21) xml (5)