1
play

1 Optimality Summary What is Search For? Tree search: Models of - PDF document

Announcements Introduction to Artificial Intelligence Please ask for help on assignment V22.0472-001 Fall 2009 Lecture 4: Constraint Lecture 4: Constraint Satisfaction Problems Rob Fergus Dept of Computer Science, Courant Institute,


  1. Announcements Introduction to Artificial Intelligence • Please ask for help on assignment V22.0472-001 Fall 2009 Lecture 4: Constraint Lecture 4: Constraint Satisfaction Problems Rob Fergus – Dept of Computer Science, Courant Institute, NYU Many slides from Dan Klein, Stuart Russell or Andrew Moore 2 Today A* Review • A* uses both backward costs g and forward estimate h: f(n) = g(n) + h(n) • Search Conclusion • A* tree search is optimal with admissible heuristics p • Constraint Satisfaction Problems C S f P bl (optimistic future cost estimates) • Heuristic design is key: relaxed problems can help A* Graph Search Gone Wrong Consistency State space graph The story on Consistency: Search tree • Definition: A h=1 cost(A to C) + h(C) ≥ h(A) S (0+2) 1 A A h=4 C 1 • Consequence in search tree: 1 h=4 h=4 A (1+4) A (1 4) B (1 1) B (1+1) S S S S C C Two nodes along a path: N A, N C h=1 1 g(N C ) = g(N A ) + cost(A to C) 3 h=2 2 C (2+1) C (3+1) g(N C ) + h(C) ≥ g(N A ) + h(A) 3 B B • The f value along a path never G G (5+0) G (6+0) decreases h=1 G G • Non-decreasing f means you’re optimal to every state (not just goals) h=0 1

  2. Optimality Summary What is Search For? • Tree search: • Models of the world: single agents, deterministic actions, fully • A* optimal if heuristic is admissible (and non-negative) observed state, discrete state space • Uniform Cost Search is a special case (h = 0) • Planning: sequences of actions • Graph search: p • The path to the goal is the important thing • The path to the goal is the important thing • A* optimal if heuristic is consistent • Paths have various costs, depths • UCS optimal (h = 0 is consistent) • Heuristics to guide, fringe to keep backups • In general, natural admissible heuristics tend to be • Identification: assignments to variables consistent • The goal itself is important, not the path • All paths at the same depth (for some formulations) • Remember, costs are always positive in search! • CSPs are specialized for identification problems 8 Constraint Satisfaction Problems Example: N-Queens • • Formulation 1: Standard search problems: • State is a “black box”: arbitrary data structure • • Variables: Goal test: any function over states • Successor function can be anything • Domains: • Constraint satisfaction problems (CSPs): • Constraints • Constraints A special subset of search problems A special subset of search problems • State is defined by variables X i with values from a domain D (sometimes D depends on i ) • Goal test is a set of constraints specifying allowable combinations of values for subsets of variables • Simple example of a formal representation language • Allows useful general-purpose algorithms with more power than standard search algorithms 9 10 Example: N-Queens Example: N-Queens • Formulation 1.5: • Formulation 2: • Variables: • Variables: • Domains: • Domains: Domains: Domains: • Constraints: • Constraints: Implicit: -or- Explicit: … there’s an even better way! What is it? 2

  3. Example: Map-Coloring Constraint Graphs • • Binary CSP: each constraint Variables: relates (at most) two variables • Domain: • Binary constraint graph: nodes are • Constraints: adjacent regions must have different colors variables, arcs show constraints • General-purpose CSP algorithms use the graph structure to speed up search. E.g., Tasmania is an • Solutions are assignments satisfying all independent subproblem! constraints, e.g.: 13 14 Example: Cryptarithmetic Example: Sudoku • Variables (circles): � Variables: • Domains: � Each (open) square � Domains: � Domains: • Constraints (boxes): � {1,2,…,9} � Constraints: 9-way alldiff for each column 9-way alldiff for each row 9-way alldiff for each region 15 Example: The Waltz Algorithm Waltz on Simple Scenes • Assume all objects: • The Waltz algorithm is for interpreting line drawings of solid polyhedra • Have no shadows or cracks • An early example of a computation posed as a CSP • Three-faced vertices • “General position”: no junctions change with small movements of the eye eye. • Then each line on image is one of the following: • Boundary line (edge of an object) ( → ) with right hand of arrow ? denoting “solid” and left hand denoting “space” • Look at all intersections • Interior convex edge (+) • Adjacent intersections impose constraints on each other • Interior concave edge (-) 17 18 3

  4. Legal Junctions Varieties of CSPs • Only certain junctions are physically • Discrete Variables possible • Finite domains • How can we formulate a CSP to • Size d means O( d n ) complete assignments label an image? • E.g., Boolean CSPs, including Boolean satisfiability (NP-complete) • Variables: vertices • Infinite domains (integers, strings, etc.) • Domains: junction labels • E g job scheduling variables are start/end times for each job • E.g., job scheduling, variables are start/end times for each job • Constraints: both ends of a line • Linear constraints solvable, nonlinear undecidable should have the same label • Continuous variables • E.g., start/end times for Hubble Telescope observations x • Linear constraints solvable in polynomial time by LP methods (see cs170 for a bit of this theory) (x,y) in , , … y 19 20 Varieties of Constraints Real-World CSPs • • Assignment problems: e.g., who teaches what class Varieties of Constraints • Unary constraints involve a single variable (equiv. to shrinking domains): • Timetabling problems: e.g., which class is offered when and where? • Hardware configuration • Binary constraints involve pairs of variables: • Transportation scheduling p g • Factory scheduling • Higher-order constraints involve 3 or more variables: • Floorplanning e.g., cryptarithmetic column constraints • Fault diagnosis • Preferences (soft constraints): • … lots more! • E.g., red is better than green • Often representable by a cost for each variable assignment • Gives constrained optimization problems • Many real-world problems involve real-valued variables… • (We’ll ignore these until we get to Bayes’ nets) 21 22 Standard Search Formulation Search Methods • What does BFS do? • Standard search formulation of CSPs (incremental) • Let's start with the straightforward, dumb approach, then fix it • States are defined by the values assigned so far y g • What does DFS do? What does DFS do? • Initial state: the empty assignment, {} • Successor function: assign a value to an unassigned variable • Goal test: the current assignment is complete and satisfies all • What’s the obvious problem here? constraints • What’s the slightly-less-obvious problem? • Simplest CSP ever: two bits, constrained to be equal 23 24 4

  5. Backtracking Search Backtracking Search • Idea 1: Only consider a single variable at each point • Variable assignments are commutative, so fix ordering • I.e., [WA = red then NT = green] same as [NT = green then WA = red] • Only need to consider assignments to a single variable at each step • How many leaves are there? • Idea 2: Only allow legal assignments at each point y g g p • I.e. consider only values which do not conflict previous assignments • Might have to do some computation to figure out whether a value is ok • “Incremental goal test” • Depth-first search for CSPs with these two improvements is called backtracking search • Backtracking search is the basic uninformed algorithm for CSPs • What are the choice points? Can solve n-queens for n ≈ 25 • 25 26 Backtracking Example Improving Backtracking • General-purpose ideas can give huge gains in speed: • Which variable should be assigned next? • In what order should its values be tried? • Can we detect inevitable failure early? • Can we take advantage of problem structure? 27 28 Minimum Remaining Values Degree Heuristic • Tie-breaker among MRV variables • Minimum remaining values (MRV): • Degree heuristic: • Choose the variable with the fewest legal values • Choose the variable participating in the most constraints on remaining variables • Why min rather than max? • Also called “most constrained variable” • Why most rather than fewest constraints? • “Fail-fast” ordering 29 30 5

Recommend


More recommend