Techniques for Dealing with Hard Problems Backtrack: –Systematically enumerates all potential solutions by continually trying to extend a partial solution.

Slides:



Advertisements
Similar presentations
1 Finite Constraint Domains. 2 u Constraint satisfaction problems (CSP) u A backtracking solver u Node and arc consistency u Bounds consistency u Generalized.
Advertisements

Study Group Randomized Algorithms 21 st June 03. Topics Covered Game Tree Evaluation –its expected run time is better than the worst- case complexity.
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2008.
Lecture 12 Last time: CSPs, backtracking, forward checking Today: Game Playing.
Search Strategies.  Tries – for word searchers, spell checking, spelling corrections  Digital Search Trees – for searching for frequent keys (in text,
This time: Outline Game playing The minimax algorithm
Branch and Bound Searching Strategies
Branch and Bound Similar to backtracking in generating a search tree and looking for one or more solutions Different in that the “objective” is constrained.
3 -1 Chapter 3 The Greedy Method 3 -2 The greedy method Suppose that a problem can be solved by a sequence of decisions. The greedy method has that each.
November 10, 2009Introduction to Cognitive Science Lecture 17: Game-Playing Algorithms 1 Decision Trees Many classes of problems can be formalized as search.
1 search CS 331/531 Dr M M Awais A* Examples:. 2 search CS 331/531 Dr M M Awais 8-Puzzle f(N) = g(N) + h(N)
Find a Path s A D B E C F G Heuristically Informed Methods  Which node do I expand next?  What information can I use to guide this.
MAE 552 – Heuristic Optimization Lecture 26 April 1, 2002 Topic:Branch and Bound.
1 Bipartite Matching Lecture 3: Jan Bipartite Matching A graph is bipartite if its vertex set can be partitioned into two subsets A and B so that.
1 Branch and Bound Searching Strategies 2 Branch-and-bound strategy 2 mechanisms: A mechanism to generate branches A mechanism to generate a bound so.
Ch 13 – Backtracking + Branch-and-Bound
Alpha-Beta Search. 2 Two-player games The object of a search is to find a path from the starting position to a goal position In a puzzle-type problem,
Backtracking.
Game Playing: Adversarial Search Chapter 6. Why study games Fun Clear criteria for success Interesting, hard problems which require minimal “initial structure”
1 Adversary Search Ref: Chapter 5. 2 Games & A.I. Easy to measure success Easy to represent states Small number of operators Comparison against humans.
Busby, Dodge, Fleming, and Negrusa. Backtracking Algorithm Is used to solve problems for which a sequence of objects is to be selected from a set such.
© The McGraw-Hill Companies, Inc., Chapter 3 The Greedy Method.
Artificial Intelligence Lecture 9. Outline Search in State Space State Space Graphs Decision Trees Backtracking in Decision Trees.
Game Playing.
Backtracking. N-Queens The object is to place queens on a chess board in such a way as no queen can capture another one in a single move –Recall that.
Game Playing Chapter 5. Game playing §Search applied to a problem against an adversary l some actions are not under the control of the problem-solver.
Lecture 5: Backtracking Depth-First Search N-Queens Problem Hamiltonian Circuits.
HISTORY The problem was originally proposed in 1848 by the chess player Max Bezzel, and over the years, many mathematicians, including Gauss have worked.
Design and Analysis of Algorithms - Chapter 111 How to tackle those difficult problems... There are two principal approaches to tackling NP-hard problems.
For Wednesday Read Weiss, chapter 12, section 2 Homework: –Weiss, chapter 10, exercise 36 Program 5 due.
BackTracking CS335. N-Queens The object is to place queens on a chess board in such as way as no queen can capture another one in a single move –Recall.
Contents of Chapter 7 Chapter 7 Backtracking 7.1 The General method
CS 312: Algorithm Analysis Lecture #32: Intro. to State-Space Search This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported.
Games. Adversaries Consider the process of reasoning when an adversary is trying to defeat our efforts In game playing situations one searches down the.
Discrete Structures Lecture 12: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
CSE332: Data Abstractions Lecture 24.5: Interlude on Intractability Dan Grossman Spring 2012.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
GAME PLAYING 1. There were two reasons that games appeared to be a good domain in which to explore machine intelligence: 1.They provide a structured task.
1 Branch and Bound Searching Strategies Updated: 12/27/2010.
Adversarial Search Chapter Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent reply Time limits.
Adversarial Games. Two Flavors  Perfect Information –everything that can be known is known –Chess, Othello  Imperfect Information –Player’s have each.
COPING WITH THE LIMITATIONS OF ALGORITHM POWER
ARTIFICIAL INTELLIGENCE (CS 461D) Princess Nora University Faculty of Computer & Information Systems.
Search in State Spaces Problem solving as search Search consists of –state space –operators –start state –goal states A Search Tree is an efficient way.
Analysis & Design of Algorithms (CSCE 321)
Chapter 13 Backtracking Introduction The 3-coloring problem
CSCE350 Algorithms and Data Structure Lecture 21 Jianjun Hu Department of Computer Science and Engineering University of South Carolina
February 11, 2016Introduction to Artificial Intelligence Lecture 6: Search in State Spaces II 1 State-Space Graphs There are various methods for searching.
Branch and Bound Searching Strategies
Adversarial Search 2 (Game Playing)
Optimization Problems The previous examples simply find a single solution What if we have a cost associated with each solution and we want to find the.
Artificial Intelligence in Game Design Board Games and the MinMax Algorithm.
Midwestern State University Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm 1.
CMPT 463. What will be covered A* search Local search Game tree Constraint satisfaction problems (CSP)
CSG3F3/ Desain dan Analisis Algoritma
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
Integer Programming An integer linear program (ILP) is defined exactly as a linear program except that values of variables in a feasible solution have.
BackTracking CS255.
Depth-First Search N-Queens Problem Hamiltonian Circuits
The minimum cost flow problem
Adversarial Search and Game Playing (Where making good decisions requires respecting your opponent) R&N: Chap. 6.
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
Analysis and design of algorithm
Branch and Bound.
Kevin Mason Michael Suggs
Applied Combinatorics, 4th Ed. Alan Tucker
Haskell Tips You can turn any function that takes two inputs into an infix operator: mod 7 3 is the same as 7 `mod` 3 takeWhile returns all initial.
Branch and Bound Searching Strategies
Backtracking and Branch-and-Bound
Unit –VII Coping with limitations of algorithm power.
Presentation transcript:

Techniques for Dealing with Hard Problems Backtrack: –Systematically enumerates all potential solutions by continually trying to extend a partial solution component by component, starting from null. –At each stage of the search, if an extension of the current partial solution is not possible, we “backtrack” to a shorter partial solution and try again with a different choice for extension. Branch-and Bound: A special case of backtrack with costs. Key point: Most problems have special structures, so we don’t end up trying all possible solutions.

Backtrack Set up a 1-1 correspondence between configurations and possible solution sequences (or partial solution vectors). Decision Tree: The root corresponds to the initial state of the problem (usually is null, means no decision is made), and each branch corresponds to a decision concerning one parameter.

Backtrack Example: 3-coloring with R/G/B R 1B,2G 3R 4B 4G4R 3B 4G A graph is legally colored with k colors if each vertex has a color (label) between 1 and k (inclusive), and no adjacent vertices have the same color. Example: colors are R, G, B. Question: Does the ordering of the vertices (1, 2, 3, 4, 5) matter? B G B G R

Backtrack Example: Non-Attacking Queens Put N queens on an N x N chessboard such that no queen attacks another queen A queen in chess can attack any square on the same row, column, or diagonal. Given an n x n chessboard, we seek to place n queens onto squares of the chessboard, such that no queen attacks another queen. The example shows a placement (red squares) of four mutually non- attacking queens.

Backtrack Example: Non-Attacking Queens

“Domino” Phenomenon Suppose the solution is represented by a vector. Then a partial solution could be represented by a partial vector. Once we find a partial vector that does not satisfy the solution requirements, there is no point in extending the partial vector into a more complete solution Domino phenomenon: P k false  P k+1 false Note: Domino phenomenon must be true for backtrack to work.

Estimating Backtrack Efficiency Backtrack is usually exponential in the worst case but performs much better on average. One way to estimate: count #nodes in decision tree (unrealistic) –#nodes for the 4-queens problem is *4 + 4*4*4 + 4*4*4*4 = 341 Alternative way: only count #nodes of feasible choices. But, we don’t know the #feasible choices at each node in advance

Estimating Backtrack Efficiency: Monte Carlo To estimate the number of nodes in a decision tree, can use the Monte Carlo approach. Monte Carlo approach: –Traverse the decision tree, selecting among feasible choices randomly at each node –When a computation path is completed, assume that all the computation paths (those we did not travel) are exactly the same as the one path we chose randomly.

Monte Carlo Example: Case 1 To illustrate the Monte Carlo approach, again use the 4*4 chessboard. Case 1: Assume that X 1 is chosen randomly to be 1 from 4 possible values (1, 2, 3, 4), and X 2 is chosen randomly to be 4 from two possible values (3, 4), then X 3 is set to be 2 since it is the only choice. So, what will the decision tree look like according to the Monte Carlo approach?

Monte Carlo Example: Case 1 X 1 =1 X 2 =4 X 3 =2 Thus, we have *2 + 4*2 = 21 nodes

Monte Carlo Example: Case 2 Case 2: X 1 =1, X 2 =3 X 1 =1 X 2 =3 We would conclude that there are 13 nodes.

Monte Carlo Example: Case 3 Case 3: X 1 =2, X 2 =4, X 3 =1, X 4 =3 X 2 =4 X 1 =2 X 3 =1 X 4 =3 We could imagine the decision tree has 17 nodes.

Monte Carlo Example The real decision tree

Monte Carlo Example The real decision tree has 17 nodes. Suppose we got Case 1 twice, Case 2 once, and Case 3 once. Then we could have estimated the #nodes in decision tree to be (2*21 + 1*13 + 1*17) / 4 = 18 This is actually close to the real answer of 17 nodes

Branch-and-Bound (B&B) Special variation of backtrack –Associate a cost with a partial solution, such that the cost of a parent is always less than or equal to the cost of its child in the decision tree –do not branch from an internal node whose cost is higher than the current bound = cost of the minimum- cost complete solution found so far –the bound is updated if a better solution is found Key points –Used for optimization problems –Cost-driven –Bounding prunes the decision tree, saves time

Branch-and-Bound Example: Game Tree In games (e.g., chess) can model the different stages of the game by a rooted tree –Don’t need to consider all possible situations of a game –Can predict the outcome of the game using the concept of branch-and-bound Questions –Who is the winner if both players play optimally ? –How much is the payoff? (Initially, we only know the payoff of the terminal nodes (end-states) of the game.)

Game Tree Example – “NIM” NIM: –Two players alternately take chips from a given pile –Each player must take at least one chip, and at most three chips in his turn –The winner is the player who empties the pile –The amount of payoff is the number of chips the winner takes in his last turn Way to think about it: payoff = amount the 1 st player receives at the end of game 1 st player wants to maximize payoff (Call her Max) 2 nd player wants to minimize payoff (Call her Min)

Game Tree Example Basic Idea Use both upper and lower cut-off values in a game tree TU  Q RS  If the value of a Max son is , then  is a lower cut-off value on the value of Max If Max has a lower cut-off value , then all Max’s children have lower cut-off value 

Game Tree Example If the value of a Min son is , then  is a upper cut-off value on the value of Min. If Min has a upper cut-off value , then all Min’s children have upper cut-off value .  Q RS            TU

Game Tree Example (before pruning) A B C DE F G H K J I M LN

Game Tree Example (after pruning) A B C DE F G H K J I M LN 11 11 11 11 11 11 11 11 11 11 11 11 -2 22

SPARE SLIDES

Backtrack example: 3-coloring Algorithm 3-coloring (G, var U); Input: G = (V,E) (an undirected graph). Let U = set of vertices that have already been colored together with their colors. U is initially empty) Output: An assignment of one of three colors to each vertex of G Begin if U = V then print “coloring is completed”; return; else pick a vertex v not in U; for C := 1 to 3 do if no neighbor of v is colored with color C then add v to U with color C; 3-coloring(G,U) end