Heuristics & Constraint Satisfaction CSE 573 University of Washington.

Slides:



Advertisements
Similar presentations
Constraint Satisfaction Problems
Advertisements

Informed search algorithms
An Introduction to Artificial Intelligence
1 Constraint Satisfaction Problems A Quick Overview (based on AIMA book slides)
This lecture topic (two lectures) Chapter 6.1 – 6.4, except 6.3.3
Search I: Chapter 3 Aim: achieving generality Q: how to formulate a problem as a search problem?
1 Finite Constraint Domains. 2 u Constraint satisfaction problems (CSP) u A backtracking solver u Node and arc consistency u Bounds consistency u Generalized.
CSC344: AI for Games Lecture 5 Advanced heuristic search Patrick Olivier
Review: Search problem formulation
4 Feb 2004CS Constraint Satisfaction1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3.
Constraint Satisfaction CSE 473 University of Washington.
Constraint Satisfaction Problems
Problem Spaces & Search CSE 473. © Daniel S. Weld Topics Agents & Environments Problem Spaces Search & Constraint Satisfaction Knowledge Repr’n.
Informed Search CSE 473 University of Washington.
Review Best-first search uses an evaluation function f(n) to select the next node for expansion. Greedy best-first search uses f(n) = h(n). Greedy best.
CSC344: AI for Games Lecture 4: Informed search
Outline Introduction & Logistics Textbook: Russell and Norvig chapters 3, 4 and 5. Notion of a Problem Space Search Techniques Constraint Satisfaction.
Chapter 5 Outline Formal definition of CSP CSP Examples
Heuristics CSE 473 University of Washington. © Daniel S. Weld Topics Agency Problem Spaces SearchKnowledge Representation Planning PerceptionNLPMulti-agentRobotics.
Constraint Satisfaction Problems
Constraint Satisfaction Problems
Informed search algorithms
CPS 270: Artificial Intelligence More search: When the path to the solution doesn’t matter Instructor: Vincent.
Informed search algorithms
Informed (Heuristic) Search
Informed search algorithms
Chapter 5 Section 1 – 3 1.  Constraint Satisfaction Problems (CSP)  Backtracking search for CSPs  Local search for CSPs 2.
Informed search algorithms Chapter 4. Outline Best-first search Greedy best-first search A * search Heuristics.
1 Shanghai Jiao Tong University Informed Search and Exploration.
CSE 473: Artificial Intelligence Spring 2012
Constraint Satisfaction CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Hande ÇAKIN IES 503 TERM PROJECT CONSTRAINT SATISFACTION PROBLEMS.
Informed search algorithms Chapter 4. Best-first search Idea: use an evaluation function f(n) for each node –estimate of "desirability"  Expand most.
Informed search strategies Idea: give the algorithm “hints” about the desirability of different states – Use an evaluation function to rank nodes and select.
Chapter 5: Constraint Satisfaction ICS 171 Fall 2006.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Fall 2006 Jim Martin.
Review: Tree search Initialize the frontier using the starting state While the frontier is not empty – Choose a frontier node to expand according to search.
Problem Spaces & Search CSE 573. © Daniel S. Weld 2 Logistics Mailing list Reading Ch 4.2, Ch 6 Mini-Project I Partners Game Playing?
Chapter 5 Constraint Satisfaction Problems
CSE 473: Artificial Intelligence Constraint Satisfaction Daniel Weld Slides adapted from Dan Klein, Stuart Russell, Andrew Moore & Luke Zettlemoyer.
CSE 573: Artificial Intelligence Autumn2012 Heuristics & Pattern Databases for Search With many slides from Dan Klein, Richard Korf, Stuart Russell, Andrew.
Outline for 3/28 Introduction & Logistics Textbook: chapters 3, 4 and 5. Notion of a Problem Space Search Techniques Constraint Satisfaction Techniques.
4/11/2005EE562 EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS Lecture 4, 4/11/2005 University of Washington, Department of Electrical Engineering Spring 2005.
A General Introduction to Artificial Intelligence.
Feng Zhiyong Tianjin University Fall  Best-first search  Greedy best-first search  A * search  Heuristics  Local search algorithms  Hill-climbing.
© Daniel S. Weld 1 Logistics PS3 Project Additional problem Reading Planning & CSP for “today” SAT plan paper review for Wed.
CHAPTER 5 SECTION 1 – 3 4 Feb 2004 CS Constraint Satisfaction 1 Constraint Satisfaction Problems.
Problem Spaces & Search Dan Weld CSE 573. © Daniel S. Weld 2 Logistics Read rest of R&N chapter 4 Also read chapter 5 PS 1 will arrive by , so be.
© Daniel S. Weld 1 Midterm Search Space Bayes Net Learning / Cross Validation Lessons for the Final I’ll hit these areas again I’ll include one midterm.
1. 2 Outline of Ch 4 Best-first search Greedy best-first search A * search Heuristics Functions Local search algorithms Hill-climbing search Simulated.
Chapter 5 Team Teaching AI (created by Dewi Liliana) PTIIK Constraint Satisfaction Problems.
Constraint Satisfaction CSE 473 University of Washington.
CSE 473: Artificial Intelligence Spring 2012 Search: Cost & Heuristics Luke Zettlemoyer Lecture adapted from Dan Klein’s slides Multiple slides from Stuart.
CPSC 420 – Artificial Intelligence Texas A & M University Lecture 5 Lecturer: Laurie webster II, M.S.S.E., M.S.E.e., M.S.BME, Ph.D., P.E.
CMPT 463. What will be covered A* search Local search Game tree Constraint satisfaction problems (CSP)
Review: Tree search Initialize the frontier using the starting state
Constraint Satisfaction
Logistics Problem Set 1 Mailing List Due 10/13 at start of class
Constraint Satisfaction
Logistics Problem Set 1 Office Hours Reading Mailing List Dan’s Travel
Local Search Algorithms
Instructor: Vincent Conitzer
Heuristics Local Search
Constraints and Search
Heuristics Local Search
CS 8520: Artificial Intelligence
Search.
Search.
Constraint Satisfaction Problems
Presentation transcript:

Heuristics & Constraint Satisfaction CSE 573 University of Washington

© Daniel S. Weld 2 Logistics Reading for Monday Ch 6 (Game playing) Guest Speaker Henry Kautz Mini Projects A. Game Playing Choose your own game Experiment with heursitics B. Compare two SAT solvers DPLL vs WalkSAT Experiment with heuristics, constraint propagation, …

© Daniel S. Weld Topics Agency Problem Spaces Search Knowledge Representation Reinforcement Learning InferencePlanning Supervised Learning Logic-Based Probabilistic Multi-agent NLPSoftboticsRobotics

© Daniel S. Weld 4 Symbolic Integration E.g. x 2 e x dx = e x (x 2 -2x+2) + C  Operators: Integration by parts Integration by substitution …

© Daniel S. Weld 5 Problem spaces Blind Depth-first, breadth-first, iterative-deepening, iterative broadening Informed Best-first, Dijkstra's, A*, IDA*, SMA*, DFB&B, Beam, Local search hill climb, limited discrep, RTDP Heuristics Evaluation, construction via relaxation Pattern databases Constraint satisfaction Adversary search Search      

© Daniel S. Weld 6 Symbolic Integration E.g. x 2 e x dx = e x (x 2 -2x+2) + C  Operators: Integration by parts Integration by substitution …

© Daniel S. Weld 7 Depth-First Branch & Bound Single DF search  uses linear space Keep track of best solution so far If f(n) = g(n)+h(n)  cost(best-soln) Then prune n Requires Finite search tree, or Good upper bound on solution cost Generates duplicate nodes in cyclic graphs Adapted from Richard Korf presentation

© Daniel S. Weld 8 No O(b^d) O(b + N) Beam Search Idea Best first but only keep N best items on priority queue Evaluation Complete? Time Complexity? Space Complexity?

© Daniel S. Weld 9 Hill Climbing Idea Always choose best child; no backtracking Beam search with |queue| = 1 Problems? Local maxima Plateaus Diagonal ridges “Gradient ascent”

© Daniel S. Weld 10 Randomizing Hill Climbing Randomly disobeying heuristic Random restarts ( heavy tailed distributions )

© Daniel S. Weld 11 Simulated Annealing Objective: avoid local minima Technique: For the most part use hill climbing When no improvement possible Choose random neighbor Let  be the decrease in quality Move to neighbor with probability e -  -/T Reduce “temperature” (T) over time Pros & cons Optimal? temp If T decreased slowly enough, will reach optimal state Widely used See alsoWalkSAT

© Daniel S. Weld 12 Limited Discrepancy Search Discrepancy bound indicates how often to violate heuristic Iteratively increase... a b c d e f g h Assume that heuristic says go left

© Daniel S. Weld Genetic Algorithms Start with random population Representation serialized States are ranked with “fitness function” Produce new generation Select random pair(s): probability ~ fitness Randomly choose “crossover point” Offspring mix halves Randomly mutate bits Crossover Mutation 

© Daniel S. Weld 14 Search Problem spaces Blind Depth-first, breadth-first, iterative-deepening, iterative broadening Informed Best-first, Dijkstra's, A*, IDA*, SMA*, DFB&B, Beam, hill climb, limited discrep, RTDP Local search Heuristics Evaluation, construction via relaxation Pattern databases Constraint satisfaction Adversary search        

© Daniel S. Weld 15 Admissable Heuristics f(x) = g(x) + h(x) g: cost so far h: underestimate of remaining costs Where do heuristics come from?

© Daniel S. Weld 16 Relaxed Problems Derive admissible heuristic from exact cost of a solution to a relaxed version of problem For transportation planning, relax requirement that car has to stay on road  Euclidean dist For blocks world, distance = # move operations heuristic = number of misplaced blocks What is relaxed problem? # out of place = 2, true distance to goal = 3 Cost of optimal soln to relaxed problem  cost of optimal soln for real problem

© Daniel S. Weld 17 Simplifying Integrals vertex = formula goal = closed form formula without integrals arcs = mathematical transformations heuristic = number of integrals still in formula what is being relaxed?

© Daniel S. Weld 18 Traveling Salesman Problem Problem Space Heuristic? States = partial path (not nec. connected) Operator = add an edge Start state = empty path Goal = complete path What can be Relaxed?

© Daniel S. Weld 19 Heuristics for eight puzzle startgoal  What can we relax?

© Daniel S. Weld 20 Importance of Heuristics D IDS A*(h1)A*(h2) h1 = number of tiles in wrong place h2 =  distances of tiles from correct loc

© Daniel S. Weld 21 Need More Power! Performance of Manhattan Distance Heuristic 8 Puzzle< 1 second 15 Puzzle1 minute 24 Puzzle65000 years Need even better heuristics! Adapted from Richard Korf presentation

© Daniel S. Weld 22 Subgoal Interactions Manhattan distance assumes Each tile can be moved independently of others Underestimates because Doesn’t consider interactions between tiles Adapted from Richard Korf presentation

© Daniel S. Weld 23 Pattern Databases Pick any subset of tiles E.g., 3, 7, 11, 12, 13, 14, 15 Precompute a table Optimal cost of solving just these tiles For all possible configurations 57 Million in this case Use breadth first search back from goal state State = position of just these tiles (& blank) Adapted from Richard Korf presentation [Culberson & Schaeffer 1996]

© Daniel S. Weld 24 Using a Pattern Database As each state is generated Use position of chosen tiles as index into DB Use lookup value as heuristic, h(n) Admissible? Adapted from Richard Korf presentation

© Daniel S. Weld 25 Combining Multiple Databases Can choose another set of tiles Precompute multiple tables How combine table values? E.g. Optimal solutions to Rubik’s cube First found w/ IDA* using pattern DB heuristics Multiple DBs were used (dif subsets of cubies) Most problems solved optimally in 1 day Compare with 574,000 years for IDDFS Adapted from Richard Korf presentation

© Daniel S. Weld 26 Drawbacks of Standard Pattern DBs Since we can only take max Diminishing returns on additional DBs Would like to be able to add values Adapted from Richard Korf presentation

© Daniel S. Weld 27 Disjoint Pattern DBs Partition tiles into disjoint sets For each set, precompute table E.g. 8 tile DB has 519 million entries And 7 tile DB has 58 million During search Look up heuristic values for each set Can add values without overestimating! Manhattan distance is a special case of this idea where each set is a single tile Adapted from Richard Korf presentation

© Daniel S. Weld 28 Performance 15 Puzzle: 2000x speedup vs Manhattan dist IDA* with the two DBs shown previously solves 15 Puzzles optimally in 30 milliseconds 24 Puzzle: 12 million x speedup vs Manhattan IDA* can solve random instances in 2 days. Requires 4 DBs as shown Each DB has 128 million entries Without PDBs: years Adapted from Richard Korf presentation

© Daniel S. Weld 29 Outline Problem spaces Search Blind Informed Local Heuristics & Pattern DBs for Constraint satisfaction Adversary search       Definition Factoring state spaces Backtracking policies Variable-ordering heuristics Preprocessing algorithms

© Daniel S. Weld 30 Constraint Satisfaction Kind of search in which States are factored into sets of variables Search = assigning values to these variables Structure of space is encoded with constraints Backtracking-style algorithms work E.g. DFS for SAT (i.e. DPLL) But other techniques add speed Propagation Variable ordering Preprocessing

© Daniel S. Weld 31 Chinese Food as Search? States? Operators? Start state? Goal states? Partially specified meals Add, remove, change dishes Null meal Meal meeting certain conditions (rating?)

© Daniel S. Weld 32 Factoring States Rather than state = meal Model state’s (independent) parts, e.g. Suppose every meal for n people Has n dishes plus soup Soup = Meal 1 = Meal 2 = … Meal n = Or… physical state = X coordinate = Y coordinate =

© Daniel S. Weld 33 Chinese Constraint Network Soup Total Cost < $30 Chicken Dish Vegetable RiceSeafood Pork Dish Appetizer Must be Hot&Sour No Peanuts No Peanuts Not Chow Mein Not Both Spicy

© Daniel S. Weld 34 CSPs in the Real World Scheduling space shuttle repair Airport gate assignments Transportation Planning Supply-chain management Computer configuration Diagnosis UI optimization Etc...

© Daniel S. Weld 35 Binary Constraint Network Set of n variables: x 1 … x n Value domains for each variable: D 1 … D n Set of binary constraints (also “relations”) R ij  D i  D j Specifies which value pairs (x i x j ) are consistent V for each country Each domain = 4 colors R ij enforces 

© Daniel S. Weld 36 Binary Constraint Network Partial assignment of values = tuple of pairs {...(x, a)…} means variable x gets value a... Tuple=consistent if all constraints satisfied Tuple=full solution if consistent + has all vars Tuple {(x i, a i ) … (x j, a j )} = consistent w/ a set of vars {x m … x n } iff  a m … a n such that {(x i, a i )…(x j, a j ), (x m, a m )…(x n, a n )} } = consistent

© Daniel S. Weld 37 Cryptarithmetic SEND + MORE MONEY State Space Set of states Operators [and costs] Start state Goal states Variables? Domains (variable values)? Constraints?

© Daniel S. Weld 38 Classroom Scheduling Variables? Domains (possible values for variables)? Constraints?

© Daniel S. Weld 39 N Queens As a CSP?

© Daniel S. Weld 40 N Queens Variables = board columns Domain values = rows R ij = {(a i, a j ) : (a i  a j )  (|i-j|  |a i -a j |) e.g. R 12 = {(1,3), (1,4), (2,4), (3,1), (4,1), (4,2)} Q Q Q {(x 1, 2), (x 2, 4), (x 3, 1)} consistent with (x 4 ) Shorthand: “{2, 4, 1} consistent with x 4 ”

© Daniel S. Weld 41 CSP as a search problem? What are states? (nodes in graph) What are the operators? (arcs between nodes) Initial state? Goal test? Q Q Q

© Daniel S. Weld 42 Chronological Backtracking (BT) (e.g., depth first search) Q Q Q Q Q Q Q Q Q Q Q Consistency check performed in the order in which vars were instantiated If c-check fails, try next value of current var If no more values, backtrack to most recent var

© Daniel S. Weld 43 Backjumping (BJ) Similar to BT, but more efficient when no consistent instantiation can be found for the current var Instead of backtracking to most recent var… BJ reverts to deepest var which was c-checked against the current var BJ Discovers (2, 5, 3, 6) inconsistent with x 6 No sense trying other values of x 5 Q Q Q Q Q

© Daniel S. Weld 44 5 Conflict-Directed Backjumping (CBJ) More sophisticated backjumping behavior Each variable has conflict set CS Set of vars that failed c-checks w/ current val Update this set on every failed c-check When no more values to try for x i Backtrack to deepest var, x d, in CS(x i ) And updateCS(x d ):=CS(x d )  CS(x i )-{x d } CBJ Discovers (2, 5, 3) inconsistent with {x 5, x 6 } Q Q Q Q Q x1x1 x2x2 x3x3 x4x4 x5x5 x6x6 CS(x 5 ) 1,2,3 CS(x 6 ) 1, 2,3,5

© Daniel S. Weld 45 BT vs. BJ vs. CBJ {

© Daniel S. Weld 46 Forward Checking (FC) Perform Consistency Check Forward Whenever a var is assigned a value Prune inconsistent values from As-yet unvisited variables Backtrack if domain of any var ever collapses Q Q Q Q Q FC only visits consistent nodes but not all such nodes skips (2, 5, 3, 4) which CBJ visits But FC can’t detect that (2, 5, 3) inconsistent with {x 5, x 6 }

© Daniel S. Weld 47 Number of Nodes Explored BT=BM BJ=BMJ=BMJ2 CBJ=BM-CBJ FC-CBJ FC More Fewer =BM-CBJ2

© Daniel S. Weld 48 Number of Consistency Checks BMJ2 BT BJ BMJ BM-CBJ CBJ FC-CBJ BM BM-CBJ2 FC More Fewer