Search Algorithms Guessing versus Inference Backtrack Search All the search algorithms we’ve seen so far are 1. DFS variations of guessing and backtracking 2. BFS / Dijkstra’s Algorithm But we can reduce the amount of guesswork by 3. Iterative Deepening doing more reasoning about the 4. Best-first search consequences of past choices 5. A* • Example: planning a trip Constraint Propagation Idea: 1. Forward Checking • Problem solving as constraint 2. k-Consistency satisfaction 3. DPLL & Resolution Local Search • As choices (guesses) are made, propagate constraints 1. Hillclimbing 2. Simulated annealing 3. Walksat Map Coloring CSP • V is a set of variables v1, v2, …, vn • D is a set of finite domains D1, D2, …, Dn • C is a set of constraints C1, C2, …, Cm Each constraint specifies a restriction over joint values of a subset of the variables E.g.: v1 is Spain, v2 is France, v3 is Germany, … Di = { Red, Blue, Green} for all i For each adjacent vi, vj there is a constraint Ck (vi,vj) ∈ ∈ ∈ ∈ { (R,G), (R,B), (G,R), (G,B), (B,R), (B,G) } Chinese Dinner Constraint Network Variations Must be Hot&Sour Soup • Find a solution that satisfies all constraints No • Find all solutions Chicken Appetizer Peanuts • Find a “tightest form” for each constraint Dish Total Cost (v1,v2) ∈ ∈ { (R,G), (R,B), (G,R), (G,B), (B,R), (B,G) } ∈ ∈ < $30 ! No Pork Dish Vegetable (v1,v2) ∈ ∈ { (R,G), (R,B), (B,G) } ∈ ∈ Peanuts • Find a solution that minimizes some additional objective function Seafood Rice Not Both Spicy Not Chow Mein 1
Exploiting CSP Structure Running Example: 4 Queens Interleave inference and guessing Constraints: Variables: • At each internal node: • Select unassigned variable Q1 Q2 Q1 ∈ ∈ ∈ ∈ {1,2,3,4} Q • Select a value in domain 1 3 Q2 ∈ ∈ ∈ ∈ {1,2,3,4} Q • Backtracking: try another value Q3 ∈ ∈ {1,2,3,4} ∈ ∈ Q 1 4 – Branching factor? Q3 ∈ ∈ ∈ ∈ {1,2,3,4} Q 2 4 • At each node: 3 1 • Propagate Constraints 4 1 4 2 Constraint Checking Forward Checking x x x x When variable is set, immediately remove Q Q x x Q x x inconsistent values from x x x x x x x domains of other variables Q Q x Q x x Q x x x Q x x x Q Q Q x Q x x Q x x x x x x x x x x x x x Q x Q x x x x Q x Q x Q x x Q x x x Q x x x Q x x x Takes 5 guesses to determine first guess was wrong Takes 3 guesses to determine first guess was wrong Huffman-Clowes Arc Consistency Labeling x x x x x x x x x x x x x x x x Q x x x Q x x x Q x x Q x x + - + + + Iterate forward checking + + Propagations: Q3=3 inconsistent with Q4 ∈ ∈ {2,3,4} 1. ∈ ∈ Q2=1 and Q2=2 inconsistent with Q3 ∈ ∈ ∈ ∈ {1} 2. Inference alone determines first guess was wrong! 2
Waltz’s Filtering: Arc- No labeling! Consistency • Lines: variables • Conjunctions: constraints • Initially Di = {+,-, " " " , # " # # ) # • Repeat until no changes: Choose edge (variable) Delete labels on edge not consistent with both endpoints Path Consistency Variable and Value Selection Path consistency (3-consistency): • Select variable with smallest domain • Check every triple of variables – Minimize branching factor – Most likely to propagate: most constrained variable • More expensive! heuristic • k-consistency: • Which values to try first? k | V | k-tuples to check – Most likely value for solution – Least propagation! Least constrained value Worst case: each iteration eliminates 1 choice • Why different? | D V || | iterations – Every constraint must be eventually satisfied + 1 k – Not every value must be assigned to a variable! | D V || | steps! (But usually not this bad) • Tie breaking? – In general randomized tie breaking best – less likely to • n -consistency: backtrack-free search get stuck on same bad pattern of choices Quasigroup Completion CSPs in the real world Problem (QCP) Given a partial assignment of colors (10 colors in this case), can the partial quasigroup (latin square) • Scheduling Space Shuttle Repair be completed so we obtain a full quasigroup? • Transportation Planning • Computer Configuration Example: – AT&T CLASSIC Configurator • #5ESS Switching System • Configuring new orders: 2 months # 2 hours 32% preassignment (Gomes & Selman 97) CPGomes - AAAI00 3
QCP Example Use: Routers in QCP as a CSP Fiber Optic Networks 2 ( n ) Dynamic wavelength routing in Fiber Optic Networks can be O • Variables - directly mapped into the Quasigroup Completion Problem. , ; , = 1 , 2 , ..., . x color of cell i j i j n , i j • each channel cannot be repeated in the same input port (row constraints); ∈ { 1 , 2 , ..., } x n i , j • each channel cannot be repeated in the same output port (column constraints); O ( n ) • Constraints - Output ports Input Port Output Port ( , ,..., ); = 1 , 2 , ..., . row alldiff x x x i n 1 1 Input ports , 1 , 2 i , n i i 2 2 3 3 column alldiff ( x , x ,..., x ); j = 1 , 2 , ..., n . 4 4 1 , 2 , n , j j j CONFLICT FREE LATIN ROUTER (Barry and Humblet 93, Cheung et al. 90, Green 92, Kumar et al. 99) CPGomes - AAAI00 CPGomes - AAAI00 Hill Climbing Simulated Annealing / Random Walk • Objective: avoid local minima • Technique: • Idea – For the most part use hill climbing – Always choose best child, no backtracking – Occasionally take non-optimal step • Evaluation – Annealing: Reduce probability (non-optimal) over time – Complete? • Comparison to Hill Climbing – Completeness? – Speed? – Space Complexity? – Complexity of random restart hillclimbing, with success – Space Complexity? Temperature probability P Objective Time # # # # Backtracking with Randomized Demos! Restarts • Idea: • N-Queens – If backtracking algorithm does not find solution quickly, Backtracking vs. Local Search it is like to be stuck in the wrong part of the search space • Quasigroup Completion • Early decisions were bad! Randomized Restarts – So kill the run after T seconds, and restart • Travelling Salesman • Requires randomized heuristic, so choices not always the same – Why does it often work? Simulated Annealing • Many problems have a small set of “backdoor” variables – guess them on a restart, and your are done! (Andrew, Selman, Gomes 2003) – Completeness? 4
Planning as CSP Exercise • Phase 1 - Convert planning problem in a CSP Peer interviews: Real-world constraint • Choose a fixed plan length satisfaction problems • Boolean variables 1. Break into pairs – Action executed at a specific time point 2. 7 minute interview – example of needing to – Proposition holds at a specific time point solve a CSP type problem (work or life). Interviewer takes notes: • Constraints • Describe problem – Initial conditions true in first state, goals true in final state • What techniques actually used – Actions do not interfere • Any techniques from class that could have been used? – Relation between action, preconditions, effects 3. Switch roles • Phase 2 - Solution Extraction 4. A few teams present now • Solve the CSP 5. Hand in notes (MSR – have someone collect and mail to me at dept) Planning Graph Representation of CSP Constructing the planning graph… Precondition Effect constraints constraints • Initial proposition layer – Just the initial conditions • Action layer i – If all of an action’s preconditionss are in i-1 – Then add action to layer I • Proposition layer i+1 – For each action at layer i – Add all its effects at layer i+1 Proposition Action Proposition Action Init State Time 1 Time 1 Time 2 27 Mutual Exclusion Solution Extraction • For each goal G at last time slice N: • Actions A,B exclusive (at a level) if • Solve( G, N ) – A deletes B’s precondition, or – B deletes A’s precondition, or • Solve( G, t ): – A & B have inconsistent preconditions CHOOSE action A making G true @t that is not • Propositions P,Q inconsistent (at a level) if mutex with a previously chosen action – All ways to achieve P exclude all ways to achieve Q If no such action, backtrack to last choice point • Constraint propagation (arc consistency) For each precondition P of A: – Can force variables to become true or false Solve(P, t-1) – Can create new mutexes 29 30 5
Recommend
More recommend