Branch and Bound

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 30

Branch and Bound

• Branch and Bound is another method to systematically search a solution


space. Just like backtracking, we will use bounding functions to avoid
generating subtrees that do not contain an answer node. However branch
and Bound differs from backtracking in two important manners:
• 1. It has a branching function, which can be a depth first search, breadth
first search or based on bounding function.

• 2. It has a bounding function, which goes far beyond the feasibility test as
a mean to prune efficiently the search tree.

• Branch and Bound refers to all state space search methods in which all
children of the E-node are generated before any other live node becomes
the E-node
• Branch and Bound is the generalisation of both graph search strategies,
BFS and D- search.
• A BFS like state space search is called as FIFO
(First in first out) search as the list of live
nodes in a first in first out list (or queue).

• A D search like state space search is called as


LIFO (Last in first out) search as the list of live
nodes in a last in first out (or stack).
• Definition 1: Live node is a node that has been
generated but whose children have not yet been
generated.
• Definition 2: E-node is a live node whose children are
currently being explored. In other words, an E-node is a
node currently being expanded.
• Definition 3: Dead node is a generated node that is not
to be expanded or explored any further. All children of a
dead node have already been expanded.
• Definition 4: Branch-an-bound refers to all state space
search methods in which all children of an E-node are
generated before any other live node can become the
E-node.
• Definition 5: The adjective "heuristic", means" related
to improving problem solving performance". As a noun
it is also used in regard to "any method or trick used to
improve the efficiency of a problem solving problem".
But imperfect methods are not necessarily heuristic or
vice versa. "A heuristic (heuristic rule, heuristic method)
is a rule of thumb, strategy, trick simplification or any
other kind of device which drastically limits search for
solutions in large problem spaces. Heuristics do not
guarantee optimal solutions, they do not guarantee
any solution at all. A useful heuristic offers solutions
which are good enough most of the time.
Least Cost (LC) search:
• In both LIFO and FIFO Branch and Bound the selection
rule for the next E-node in rigid and blind. The
selection rule for the next E-node does not give any
preference to a node that has a very good chance of
getting the search to an answer node quickly.
• The search for an answer node can be speeded by
using an “intelligent” ranking function c( .) for live
nodes. The next E-node is selected on the basis of this
ranking function. The node x is assigned a rank using:
• c( x ) = f(h(x)) + g( x ) where, c( x ) is the cost of x.
• h(x) is the cost of reaching x from the root and f(.) is
any non-decreasing function.
• g ( x ) is an estimate of the additional effort needed to
reach an answer node from x.
• A search strategy that uses a cost function c( x ) = f(h(x)
+ g( x ) to select the next E-node would always choose
for its next E-node a live node with least LC–search
(Least Cost search)
• c(.) is called a BFS and D-search are special cases of LC-
search. If g( x ) = 0 and f(h(x)) = level of node x, then an
LC search generates nodes by levels.
• This is eventually the same as a BFS. If f(h(x)) = 0 and
essentially a D-search.
• g( x ) > g( y ) whenever y is a child of x, then the search
is
• An LC-search coupled with bounding functions
is called an LC-branch and bound search
• We associate a cost c(x) with each node x in
the state space tree. It is not possible to easily
compute the function c(x). So we compute a
estimate c( x ) of c(x).
Control Abstraction for LC-Search:
• Let t be a state space tree and c() a cost function for
the nodes in t. If x is a node in t, then c(x) is the
minimum cost of any answer node in the subtree with
root x. Thus, c(t) is the cost of a minimum-cost answer
node in t.
• A heuristic c(.) is used to estimate c(). This heuristic
should be easy to compute and generally has the
property that if x is either an answer node or a leaf
node, then c(x) = c( x ) .
• LC-search uses c to find an answer node. The algorithm
uses two functions Least() and Add() to delete and add
a live node from or to the list of live nodes, respectively.
• Least() finds a live node with least c(). This node is
deleted from the list of live nodes and returned.
• Algorithm LCSearch outputs the path from the
answer node it finds to the root node t.
• This is easy to do if with each node x that
becomes live, we associate a field parent which
gives the parent of node x. When the answer
node g is found, the path from g to t can be
determined by following a sequence of parent
values starting from the current E-node (which is
the parent of g) and ending at node t.
• Listnode = record
• {
• Listnode * next, *parent; float cost;
• }
• Algorithm LCSearch(t)
• { //Search t for an answer node
• if *t is an answer node then output *t and return; E := t; //E-node.
• initialize the list of live nodes to be empty;
• repeat
• {
• for each child x of E do
• {
• if x is an answer node then output the path from x to t and return; Add (x); //x is a new live node.
• (x ->parent) := E; // pointer for path to root
• }
• if there are no more live nodes then
• {
• write (“No answer node”); return;
• }
• E := Least();
• } until (false);
• }
Bounding:
• A branch and bound method searches a state
space tree using any search mechanism in which
all the children of the E-node are generated
before another node becomes the E-node.
• We assume that each answer node x has a cost
c(x) associated with it and that a minimum-cost
answer node is to be found. Three common
search strategies are FIFO, LIFO, and LC. The three
search methods differ only in the selection rule
used to obtain the next E-node.
• To formulate the search for an optimal solution for a least-cost answer
node in a state space tree, it is necessary to define the cost function c(.),
such that c(x) is minimum for all nodes representing an optimal solution.
The easiest way to do this is to use the objective function itself for c(.).
• For nodes representing feasible solutions, c(x) is the value of the
objective function for that feasible solution.

• For nodes representing infeasible solutions, c(x) = infinity.

• For nodes representing partial solutions, c(x) is the cost of the minimum-
cost node in the subtree with root x.

• Since, c(x) is generally hard to compute, the branch-and-bound algorithm


will use an estimate c( x ) such that c( x ) < c(x) for all x.
The 15 – Puzzle Problem:
• The 15 puzzle is to search the state space for the goal state
and use the path from the initial state to the goal state as
the answer. There are 16! (16! ≈ 20.9 x 1012) different
arrangements of the tiles on the frame.
• As the state space for the problem is very large it would be
worthwhile to determine whether the goal state is
reachable from the initial state. Number the frame
positions 1 to 16.
• Position i is the frame position containing title numbered i
in the goal arrangement of Figure 8.1(b). Position 16 is the
empty spot. Let position(i) be the position number in the
initial state of the title number i. Then position(16) will
denote the position of the empty spot.
• Here, x = 1 if in the initial state the empty spot
is at one of the shaded positions of figure
8.1(c) and x = 0 if it is at one of the remaining
positions.
LC Search for 15 Puzzle Problem:
• A depth first state space tree generation will result in the subtree of Figure
8.3 when the next moves are attempted in the order: move the empty
space up, right, down and left. The search of the state space tree is blind.
It will take the leftmost path from the root regardless of the starting
configuration. As a result, the answer node may never be found.
• A breadth first search will always find a goal node nearest to the root.
However, such a search is also blind in the sense that no matter what the
initial configuration, the algorithm attempts to make the same sequence
of moves.
• We need a more intelligent search method. We associate a cost c(x) with
each node x in the state space tree. The cost c(x) is the length of a path
from the root to a
• nearest goal node in the subtree with root x. The easy to compute
estimate c (x) of
• c(x) is as follows:
• c (x) = f(x) + g (x)
• where, f(x) is the length of the path from the
root to node x and
• g (x) is an estimate of the length of a shortest
path from x to a goal node in the subtree with
root x. Here, g (x) is the number of nonblank
tiles not in
• their goal position.
• An LC-search of Figure 8.2, begin with the root as the E-node and
generate all child nodes 2, 3, 4 and 5. The next node to become the
E-node is a live node with least
• c (x).
• c (2) = 1 + 4 = 5
• c (3) = 1 + 4 = 5
• c (4) = 1 + 2 = 3 and
• c (5) = 1 + 4 = 5.
• Node 4 becomes the E-node and its children are generated. The live
nodes at this time are 2, 3, 5, 10, 11 and 12. So:
• c (10) = 2 + 1 = 3
• c (11) = 2 + 3 = 5 and
• c (12) = 2 + 3 = 5.
• The live node with least c is node 10. This
becomes the next E-node. Nodes 22 and 23
are generated next. Node 23 is the goal node,
so search terminates.
• LC-search was almost as efficient as using the
exact function c(), with a suitable choice for c
(), LC-search will be far more selective than
any of the other search
• methods.
Traveling Sale Person Problem:
Procedure for solving traveling sale
person problem:
• Reduce the given cost matrix. A matrix is reduced if every row and column is
reduced. A row (column) is said to be reduced if it contain at least one zero and all-
remaining entries are non-negative. This can be done as follows:

• a) Row reduction: Take the minimum element from first row, subtract it from all
elements of first row, next take minimum element from the second row and
subtract it from second row. Similarly apply the same procedure for all rows.
• b) Find the sum of elements, which were subtracted from rows.

• c) Apply column reductions for the matrix obtained after row reduction.
• Column reduction: Take the minimum element from first column, subtract it from
all elements of first column, next take minimum element from the second column
and subtract it from second column. Similarly apply the same procedure for all
columns.
• d) Find the sum of elements, which were subtracted from columns.
• e) Obtain the cumulative sum of row wise
reduction and column wise reduction.
• Cumulative reduced sum = Row wise
reduction sum + column wise reduction sum.
• Associate the cumulative reduced sum to the
starting state as lower bound and infinity as
upper bound.

You might also like