11/30/2012 Space of Search Strategies CSE 573: Artificial Intelligence Blind Search DFS, BFS, IDS Constraint Satisfaction Informed Search Informed Search Systematic: Uniform cost, greedy, A*, IDA* Daniel Weld Stochastic: Hill climbing w/ random walk & restarts Constraint Satisfaction Adversary Search Slides adapted from Dan Klein, Stuart Russell, Andrew Moore & Luke Zettlemoyer Min-max, alpha-beta, expectimax, MDPS… 2 Constraint Satisfaction Recap: Search Problem Kind of search in which States States are factored into sets of variables configurations of the world Search = assigning values to these variables Successor function: Goal test is encoded with constraints function from states to lists of triples function from states to lists of triples Gives structure to search space Gives structure to search space (state, action, cost) Exploration of one part informs others Start state Special techniques add speed Goal test Propagation Variable ordering Preprocessing 4 Constraint Satisfaction Problems Example: Map-Coloring Subset of search problems Variables: Domain: State is factored - defined by Variables X i with values from a Constraints: adjacent regions must have different colors Domain D (often D depends on i) Goal test is a set of constraints Solutions are assignments satisfying all constraints, e.g.: WHY STUDY? Simple example of a form formal repres al represent entat ation on language language Allows more powerful search algorithms 1
11/30/2012 Constraint Graphs Real-World CSPs Binary CSP: each constraint relates (at most) two Assignment problems: e.g., who teaches what class variables Timetabling problems: e.g., which class is offered when Binary constraint graph: nodes are variables, arcs and where? show constraints Hardware configuration Gate assignment in airports Gate assignment in airports Transportation scheduling Factory scheduling Fault diagnosis … lots more! General-purpose CSP algorithms use the graph Many real-world problems involve structure to speed up search. E.g., Tasmania is an real-valued variables… independent subproblem! Example: Sudoku Example: Cryptarithmetic Variables (circles): Variables: Each (open) square Domains: Domains: Domains: {1,2,…,9} Constraints (boxes): Constraints: 9-way alldiff for each column 9-way alldiff for each row 9-way alldiff for each region Crossword Puzzle Example: N-Queens Variables & domains? CSP Formulation 1: Constraints? Variables: Domains: Constraints Constraints X ij + X ik ≤ 1 X ij + X kj ≤ 1 X ij + X i+k,j+k ≤ 1 X ij + X i+k,j-k ≤ 1 11 2
11/30/2012 Example: N-Queens Example: N-Queens Formulation 2: CSP Formulation 1: Variables: Variables: Domains: Domains: Constraints Constraints Domains: Constraints: Implicit: -or- Explicit: Chinese Constraint Example: The Waltz Algorithm Network The Waltz algorithm is for interpreting line drawings of Must be solid polyhedra Hot&Sour An early example of a computation posed as a CSP Soup No Chicken Peanuts Appetizer Dish Dish Total Cost < $40 No Pork Dish Vegetable Peanuts ? Seafood Rice Not Both Look at all intersections Spicy Not Adjacent intersections impose constraints on each other Chow Mein 18 Waltz on Simple Scenes Legal Junctions Assume all objects: Only certain junctions are physically possible Have no shadows or cracks How can we formulate a CSP to Three-faced vertices label an image? “General position”: no junctions Variables: vertices change with small movements of Domains: junction labels Domains: junction labels th the eye. Constraints: both ends of a line Then each line on image is should have the same label one of the following: Boundary line (edge of an object) (>) with right hand of x arrow denoting “solid” and left (x,y) in hand denoting “space” , , … Interior convex edge (+) y Interior concave edge (-) 3
11/30/2012 Local vs Global Consistency Varieties of CSPs Discrete Variables Finite domains Size d means O( d n ) complete assignments E.g., Boolean CSPs, including Boolean satisfiability (NP-complete) Infinite domains (integers, strings, etc.) E.g., job scheduling, variables are start/end times for each job Linear constraints solvable, nonlinear undecidable Continuous variables E.g., start/end times for Hubble Telescope observations Linear constraints solvable in polynomial time by LP methods 22 Varieties of Constraints CSPs as Search? Varieties of Constraints States? Unary constraints involve a single variable (equiv. to shrinking domains): Binary constraints involve pairs of variables: Successor function? Higher-order constraints involve 3 or more variables: Start state? e.g., cryptarithmetic column constraints Preferences (soft constraints): Goal test? E.g., red is better than green Often representable by a cost for each variable assignment Gives constrained optimization problems (We’ll ignore these until we get to Bayes’ nets) Standard Search Formulation Backtracking Example • States are defined by the values assigned so far • Initial state: the empty assignment, {} • Successor function: • assign value to an unassigned variable • Goal test: • the current assignment is complete & • satisfies all constraints 4
11/30/2012 Backtracking Search Backtracking Search Note 2: Only allow legal assignments at each point Note 1: Only consider a single variable at each point I.e. Ignore values which conflict previous assignments Variable assignments are commutative, so fix ordering of variables Might need some computation to eliminate such conflicts I.e., [WA = red then NT = blue] same as [NT = blue then WA = red] [ ] “Incremental goal test” What is branching factor of this search? “Backtracking Search” Backtracking Search Depth-first search for CSPs with these two ideas One variable at a time, fixed order Only trying consistent assignments Is called “Backtracking Search” Basic uninformed algorithm for CSPs Can solve n-queens for n 25 What are the choice points? NT Q Improving Backtracking Forward Checking WA SA NSW V Idea: Keep track of remaining legal values for General-purpose ideas give huge gains in speed unassigned variables (using immediate constraints) Idea: Terminate when any variable has no legal values Ordering: Which variable should be assigned next? c a ab e s ou d be ass g ed e t In what order should its values be tried? Filtering: Can we detect inevitable failure early? Structure: Can we exploit the problem structure? 5
11/30/2012 Forward Checking Forward Checking Q A Q B Q C Q D Q A Q B Q C Q D Row 1 Row 1 Q Row 2 Row 2 Row 3 Row 3 Row 4 Row 4 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 36 37 Forward Checking Forward Checking Q A Q B Q C Q D Q A Q B Q C Q D Row 1 Q Row 1 Q Row 2 Row 2 Prune inconsistent values Where can Q B Go? Row 3 Row 3 Row 4 Row 4 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 38 39 Forward Checking Forward Checking Q A Q B Q C Q D Q A Q B Q C Q D Row 1 Q Row 1 Q Row 2 Row 2 Prune inconsistent values Where can Q B Go? Row 3 Q Row 3 Row 4 Row 4 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 40 41 6
11/30/2012 Forward Checking Cuts the Search Space Are We Done? 4 16 16 64 256 43 42 NT NT Q Q Constraint Propagation Arc Consistency WA WA SA SA NSW NSW V V Forward checking propagates information from assigned to adjacent Simplest form of propagation makes each arc consistent unassigned variables, but doesn't detect more distant failures: X Y is consistent iff for every value x there is some allowed y • If X loses a value, neighbors of X need to be rechecked! NT and SA cannot both be blue! • Arc consistency detects failure earlier than forward checking Why didn’t we detect this yet? • What’s the downside of arc consistency? Constraint propagation repeatedly enforces constraints (locally) • Can be run as a preprocessor or after each assignment Arc Consistency Limitations of Arc Consistency After running arc consistency: Can have one solution left Can have multiple solutions left Can have no solutions left (and not know it) Runtime: O(n 2 d 3 ), can be reduced to O(n 2 d 2 ) What went … but detecting all possible future problems is NP-hard – why? wrong here? [demo: arc consistency animation] 7
Recommend
More recommend