# Branch and Bound

Terminology Deﬁnition 1 Live node is a node that has been generated but whose children have not yet been generated. Deﬁnition 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. Deﬁnition 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. Deﬁnition 4 Branch-and-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. • Used for state space search – In BFS, exploration of a new node cannot begin until the node currently being explored is fully explored General method • Both BFS and DFS generalize to branch-and-bound strategies – BFS is an FIFO search in terms of live nodes ∗ List of live nodes is a queue – DFS is an LIFO search in terms of live nodes ∗ List of live nodes is a stack • Just like backtracking, we will use bounding functions to avoid generating subtrees that do not contain an answer node • Example: 4-queens – FIFO branch-and-bound algorithm ∗ Initially, there is only one live node; no queen has been placed on the chessboard ∗ The only live node becomes E-node ∗ Expand and generate all its children; children being a queen in column 1, 2, 3, and 4 of row 1 (only live nodes left) ∗ Next E-node is the node with queen in row 1 and column 1 ∗ Expand this node, and add the possible nodes to the queue of live nodes ∗ Bound the nodes that become dead nodes – Compare with backtracking algorithm ∗ Backtracking is superior method for this search problem • Least Cost (LC) search – Selection rule does not give preference to nodes that will lead to answer quickly but just queues those behind the current live nodes ∗ In 4-queen problem, if three queens have been placed on the board, it is obvious that the answer may be reached in one more move ∗ The rigid selection rule requires that other live nodes be expanded and then, the current node be tested – Rank the live nodes by using a heuristic c(·) ˆ

the algorithm attempts the same sequence of moves – Intelligent solution ∗ Seeks out an answer node and adapts the path it takes through state space tree ∗ Associate a cost c(x) with each node x of state space tree · c(x) is the length of path from the root to nearest goal node (if any) in the subtree with root x ∗ Begin with root as E-node and generate a child node with c(·)-value the same as root · May not be always possible to compute c(·) ∗ Compute an estimate c(x) of c(x) ˆ . the empty spot is in one of the following positions: 2. right No node should have a child state that is the same as its parent Let us order the move of empty space as up.9 × 1012 ∗ Only about half of them are reachable from any given initial state – Check whether the goal state is reachable from initial state ∗ ∗ ∗ ∗ ∗ ∗ Number the frame positions from 1 to 16 pi is the frame position containing tile numbered i p16 is the position of empty spot For any state. 5. and l12 = 6 Let x = 1 if in the initial state. l1 = 0. left (clockwise moves) Perform depth-ﬁrst search and you will notice that successive moves take us away from the goal rather than closer · The search of state space tree is blind. – Organize state space search as a tree ∗ ∗ ∗ ∗ ∗ ∗ Children of each node x represent the states reachable from x in one legal move Consider the move as move of empty space rather than tile Empty space can have four legal moves: up. 6 – Each move creates a new arrangement of tiles. taking leftmost path from the root regardless of initial state · An answer node may never be found ∗ Breadth-ﬁrst search will always ﬁnd a goal state nearest to the root · It is still blind because no matter what the initial state. down. 3. 13. 5. called state of the puzzle – Initial and goal states – A state is reachable from the initial state iff there is a sequence of legal moves from initial state to this state – The state space of an initial state is all the states that can be reached from initial state – Search the state space for the goal state and use the path from initial state to goal state as the answer – Number of possible arrangments for tiles: 16! ≈ 20. right. transform it to the goal arrangement through a series of legal moves 1 3 4 15 2 5 12 7 6 11 14 8 9 10 13 Initial Arrangement 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Goal Arrangement – Legal move involves moving a tile adjacent to the empty spot E to E – Four possible moves in the initial state above: tiles 2. left. 4. 7. 10. l4 = 1. otherwise x = 0 16 Theorem 1 The goal state is reachable from the initial state iff i=1 li + x is even. down. 12.Branch and Bound 3 – 15 numbered tiles on a square frame with a capacity for 16 tiles – Given an initial arrangement. let li be the number of tiles j such that j < i and pj > pi For the initial arrangement above. 15.

// E-node Initialize the list of live nodes to be empty. list_node_t list_node. float cost. algorithm LCSearch ( t ) { // Search t for an answer node if ( *t is an answer node ) { print ( *t ). return. return. while ( true ) { for each child x of E { if x is an answer node { print the path from x to t. } E = t. } . we’ll substitute it by a heuristic estimate as c() ˆ – Algorithm LCSearch uses c() to ﬁnd an answer node ˆ typedef struct { list_node_t * next.Branch and Bound 4 ∗ c(x) = f (x) + g (x) where f (x) is the length of the path from root to 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 ∗ One possible choice for g (x) is the number of nonblank tiles not in their goal position ˆ ∗ There are at least g (x) moves to transform state x to a goal state ˆ · c(x) is a lower bound on c(x) ˆ · c(x) in the conﬁguration below is 1 but you need more moves ˆ 1 2 3 4 5 6 8 9 10 11 12 13 14 15 7 • Control abstractions for LC-search – Search space tree t – Cost function for the nodes in t: c(·) – Let x be any node in t ∗ c(x) is the minimum cost of any answer node in the subtree with root x ∗ c(t) is the cost of the minimum cost answer node in t – Since it is not easy to compute c(). } list_node_t. list_node_t * parent.