0% found this document useful (0 votes)
5 views

Lecture#6 - Branch-and-Bound Algorithm

Uploaded by

Pritom Das
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Lecture#6 - Branch-and-Bound Algorithm

Uploaded by

Pritom Das
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

BRANCH & BOUND

CSE-237 : ALGORITHM DESIGN AND


A N A LY S I S
BASIC TERMINOLOGY

• 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.

• So, branch-and-bound is a general technique for improving the searching


process by systematically enumerating all candidate solutions and
disposing of obviously impossible solutions.

Branch-and-Bound Algorithms ‹#›


PROPERTIES OF BRANCH-AND-BOUND

• Branch-and-bound usually applies to those problems that have


• finite solutions, in which the solutions can be represented as a sequence of options.

• The first part of branch-and-bound, branching, requires several choices to be


made so that the choices branch out into the solution space.
• In these methods, the solution space is organized as a treelike structure (search tree).
• Branching guarantees that no potential solutions will be left uncovered.

• 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.

Branch-and-Bound Algorithms ‹#›


PROPERTIES OF BRANCH-AND-BOUND ...

• The following figure is the state space tree of the 0/1 backpack problem
for 3 products:

Branch-and-Bound Algorithms ‹#›


PROBLEM SOLVING USING SEARCH

• We may define solution of a problem using search, because search will


• help to explore alternatives in state-space tree
• find sequence of steps in a planning situation/case

• Principle : Reduce a problem to one of searching a graph


• View problem solving as a process of moving through a sequence of problem
states inital state to reach a goal state
• Move from one state to another by taking an action
• A sequence of actions and states leading to a goal state is a solution to the
problem.

Branch-and-Bound Algorithms ‹#›


PROBLEM SOLVING USING SEARCH

•Grpah Search as Tree Search <=> Finding the paths reachable from
the node S

State Space
Tree

Branch-and-Bound Algorithms ‹#›


STATE SPACE REPRESENTATION

• 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.

Branch-and-Bound Algorithms ‹#›


STATE SPACE REPRESENTATION ...

• Goal Test - whether the goal (optimal) is found in the state space problem

• Popular Searching Strategies


• Blind Serach like BFS, DFS, Bi-Directional, Uniform Cost
• Heuristics Search like Hill-Climbing, Best-First, Greedy
• Optimal Search like A*

Branch-and-Bound Algorithms ‹#›


PROBLEM SOLVING USING SEARCH

Branch-and-Bound Algorithms ‹#›


8 PUZZLE PROBLEM

Greedy Algorithms
8 PUZZLE PROBLEM

1 5 2 1 2 3

Initial State 4 3 Goal State 4 5 6

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.

Branch-and-Bound Algorithms ‹#›


STATE SPACE TREE REPRESENTS POSSIBLE
MOVES

Branch-and-Bound Algorithms ‹#›


STATE SPACE TREE EVALUATION - MOVE
SELECTION
1 5 2
• Consider the following generalized evaluation function
4 3
f(n) = g(n) + h(n)
7 8 6

where n is any state in the search


g(n) is the cost from the start1 state
5 2 1 5 1 5 2
h(n) is the heuristic estimate of
4 3 4 3 2 4 3 6
the cost to the goal node
7 8 6 7 8 6 7 8

Stage 1.1 Stage 1.2


Stage 1.3

Branch-and-Bound Algorithms ‹#›


THREE COST FUNCTIONS - MOVE
SELECTION
1 5
• Recall the
4 3 2
4 6 GOAL state
7 8 6
1 2 3
1 5 2
4 5 6
4 3
4 4 7 8
7 8 6

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)

here g(n) = Current Cost


h(n) = Manhattan
Distance

Branch-and-Bound Algorithms ‹#›


ALGORITHM FOR 8 PUZZLE PROBLEM

• 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

• Finally, if the result of the check is negative, we then expand


the node.

Goal State

Branch-and-Bound Algorithms ‹#›


ALGORITHM FOR 8 PUZZLE PROBLEM ......

• To expand a given node,


• we generate successor nodes adjacent to the current node, and
• add them to the frontier set.

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

Branch-and-Bound Algorithms ‹#›


ALGORITHM FOR 8 PUZZLE PROBLEM ....

Branch-and-Bound Algorithms ‹#›


SOLIUTION FOR 8 PUZZLE PROBLEM - BFS

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:

Branch-and-Bound Algorithms ‹#›


SOLIUTION FOR 8 PUZZLE PROBLEM - BFS

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:

Branch-and-Bound Algorithms ‹#›


N-QUEEN PROBLEM

Greedy Algorithms
N-QUEEN PROBLEM

• Given a chessboard of n x n, the n-queen problem involves placing n


queens in such a way that they cannot attack each other.

• The queens can attack each


other if they are placed in:

• the same column


• the same row
• the same diagonal

Branch-and-Bound Algorithms ‹#›


N-QUEEN PROBLEM - SOLUTION

• Two ways to solve the N-Queen problem:

• Practice #1 : n queens need to be placed on different columns, and check which


row each queen is on the column to which it belongs is where it should be placed.
• i.e. the size of the answer-state space is n x n x n x… x n = nn [ 256 for n=4 ]

• Practice #2 : n queens need to be placed in different columns and different rows.


In addition to the position of the queen who was placed before, it is necessary to
check which row of each queen is the place where it should be placed.
• i.e. the size of answer-state space is n x (n-1) x (n-2) x… x 1 = n! [ 24 for n=4 ]

Branch-and-Bound Algorithms ‹#›


STATE-SPACE TREE FOR 4-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

Branch-and-Bound Algorithms ‹#›


JUDGEMENT RULES FOR STATE SELECTION

• 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.

• If b = a, it means that both the queens Q1 and


Q2 are in the same column
• If xb = xa, it means that both the queens Q1 and
Q2 are on the same line
• If (xb- xa) = b – a, it means that both the queens
Q1 and Q2 are inclined 45o to the right
• If (xb- xa) = -(b – a), it means that both the
queens Q1 and Q2 are on the left oblique 45o line

Branch-and-Bound Algorithms ‹#›


SOLUTION-SPACE TREE FOR 4-QUEEN
PROBLEM
1
1 4
2 3
2 11 18 25
2 4 1 4 1 4 1 3
3 3 2 2
3 4 7 12 13 14 19 23 24 26 30 33
3 4 2 4 2 3 3 4 1 4 1 3 2 4 1 4 1 2 2 3 1 3 1 2
5 6 8 10 15 17 20 21 27 28 31 32

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
() ()

Branch-and-Bound Algorithms ‹#›


GRAPH COLORING PROBLEM

Greedy Algorithms
GRAPH (VERTEX) COLORING PROBLEM

• Graph (Vertex) coloring is the procedure of assignment of colors to each


vertex of a graph G such that no adjacent vertices get same color.
• no two vertices of an edge should be of the same color.

• The objective is to minimize the number of colors


while coloring a graph.

• 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.

Branch-and-Bound Algorithms ‹#›


SIMPLE GRAPH COLORING ALGORITHM

• The steps required to color a graph G with n number of vertices are as follows −

• Step 1 − Arrange the vertices of the graph in some order.

• 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.

Branch-and-Bound Algorithms ‹#›


GRAPH COLORING EXAMPLE - MAP COLORING

(a) Map (b) Adjacency between zones

1
1
4
2 2 3 4
3

6 6
5
5

(c) The connection relationship as a graph (d) Re-arrangement of (c)

Branch-and-Bound Algorithms ‹#›


GRAPH COLORING EXAMPLE - MAP COLORING
1
1, 1
• State-Space Tree
1
2 3
2, 1 2, 2

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

Branch-and-Bound Algorithms ‹#›


FLOW NETWORK
Explore it on NEXT DAY

Branch-and-Bound Algorithms ‹#›

You might also like