Lecture#6 - Branch-and-Bound Algorithm
Lecture#6 - Branch-and-Bound Algorithm
• Branch and Bound (BnB) is an algorithm design paradigm which is generally used
for solving combinatorial optimization problems.
• These problems are typically exponential in terms of time complexity and may require
exploring all possible permutations in worst case.
• The Branch and Bound Algorithm technique solves these problems relatively quickly.
• Bounding refers to setting a bound on the solution quality and trimming off
branches in the solution tree (pruning) whose solution quality is estimated to be
poor.
• The following figure is the state space tree of the 0/1 backpack problem
for 3 products:
•Grpah Search as Tree Search <=> Finding the paths reachable from
the node S
State Space
Tree
• State Space - described by an initial state, a set of possible actions and a goal
state.
• A State Space Tree - the collection of all possible states, a problem can have.
• A Path - any sequence of actions that lead from a state to another state and
finally reached (hopefully) the goal node.
• Path cost - the aggregated of a path that lead to the goal state.
• Goal Test - whether the goal (optimal) is found in the state space problem
Greedy Algorithms
8 PUZZLE PROBLEM
1 5 2 1 2 3
7 8 6 7 8
• Initial State: The location of each of the 8-puzzle in one of the nine squares
• Path cost: Each step costs 1 point, total path cost will be equal to the
number of steps taken
• Goal test: State matches the goal configuration (given board pattern)
• Operators: blank moves [1] Left, [2] Right, [3] Up & [4] Down.
1 5 2
4 3 6 3 4
7 8 • Two Potential
No of Tiles Sum of
the Cost functions
Out of place Manhattan
Branch-and-Bound Algorithms
Distances ‹#›
ANSWER STATE SPACE FOR 8-PUZZLE
PROBLEM
• Cost Function,
f(n) = g(n) + h(n)
• The searches begin by visiting the root node of the search tree, given
by the initial state.
• Among other book-keeping details, three major things happen in
sequence in order to visit a node:
• First, we remove a node from the frontier set.
• Second, we check the state against the goal state to
determine if a solution has been found. Initial State
Goal State
Initial State
• Note that if these successor nodes are already in the
frontier, or have already been visited, then they should not
be added to the frontier again.
Goal State
THE PATH TO THE GOAL NODE WITH BFS THE NODES EXPANDED BY BFS ARE
IS SHOWN IN THE FOLLOWING FIGURE: SHOWN IN THE FOLLOWING FIGURE:
THE PATH TO THE GOAL NODE WITH DFS THE NODES EXPANDED BY BFS ARE
IS SHOWN IN THE FOLLOWING FIGURE: SHOWN IN THE FOLLOWING FIGURE:
Greedy Algorithms
N-QUEEN PROBLEM
X1 1 4
2 3
X2 2 4 1 4 1 4 1 3
3 3 2 2
X3 3 4 2 4 2 3 3 4 1 4 1 3 2 4 1 4 1 2 2 3 1 3 1 2
X4 4 3 4 2 3 2 4 3 4 1 3 1 4 2 4 1 2 1 3 2 3 1 2 1
• Assuming that the position of Queen Q1 is (a, xa) and the position of Queen Q2
is (b, xb), the following positions will cause the two queens to eat each other.
4 3 4 2 3 2 4 3 4 1 3 1 4 2 4 1 2 1 3 2 3 1 2 1
9 16 22 29
() ()
Greedy Algorithms
GRAPH (VERTEX) COLORING PROBLEM
• The smallest number of colors required to color a graph G is called its chromatic
number of that graph. Graph coloring problem is a NP Complete problem.
• The steps required to color a graph G with n number of vertices are as follows −
• Step 2 − Choose the first vertex and color it with the first color.
• Step 3 − Choose the next vertex and color it with the lowest numbered color that has
not been colored on any vertices adjacent to it.
• If all the adjacent vertices are colored with this color, assign a new color to it.
• Repeat this step until all the vertices are colored.
1
1
4
2 2 3 4
3
6 6
5
5
1 4 5
3, 1 3, 2 3 4
2
6 7
3 4 4, 1 4, 2
2
5 6
8
5, 1
6
5 Coloring the Map with k=3
9 10 11
Graphical Presentation of Map 6, 1 6, 2 6, 3