recap search
play

Recap: Search CS 188: Artificial Intelligence Search problem: - PDF document

Recap: Search CS 188: Artificial Intelligence Search problem: States (configurations of the world) Successor function: a function from states to lists of (state, action, cost) triples; drawn as a graph Start state and goal


  1. Recap: Search CS 188: Artificial Intelligence § Search problem: § States (configurations of the world) § Successor function: a function from states to lists of (state, action, cost) triples; drawn as a graph § Start state and goal test Lecture 4 and 5: Constraint Satisfaction Problems (CSPs) § Search tree: § Nodes: represent plans for reaching states § Plans have costs (sum of action costs) § Search Algorithm: Pieter Abbeel – UC Berkeley § Systematically builds a search tree Many slides from Dan Klein § Chooses an ordering of the fringe (unexplored nodes) What is Search For? Constraint Satisfaction Problems § Standard search problems: § Models of the world: single agents, deterministic actions, § State is a “ black box ” : arbitrary data structure fully observed state, discrete state space § Goal test: any function over states § Successor function can be anything § Planning: sequences of actions § Constraint satisfaction problems (CSPs): § The path to the goal is the important thing § A special subset of search problems § State is defined by variables X i with values from a § Paths have various costs, depths domain D (sometimes D depends on i ) § Heuristics to guide, fringe to keep backups § Goal test is a set of constraints specifying allowable combinations of values for subsets of variables § Identification: assignments to variables § Simple example of a formal representation § The goal itself is important, not the path language § All paths at the same depth (for some formulations) § CSPs are specialized for identification problems § Allows useful general-purpose algorithms with more power than standard search algorithms 3 4 Example CSP: Map-Coloring Example CSP: N-Queens § Variables: § Formulation 1: § Domain: § Variables: § Domains: § Constraints: adjacent regions must have different colors § Constraints § Solutions are assignments satisfying all constraints, e.g.: 5 6 1

  2. Example CSP: N-Queens Constraint Graphs § Binary CSP: each constraint § Formulation 2: relates (at most) two variables § Variables: § Binary constraint graph: nodes are variables, arcs show § Domains: constraints § General-purpose CSP § Constraints: algorithms use the graph structure to speed up search. Implicit: E.g., Tasmania is an -or- independent subproblem! Explicit: 10 Example CSP: Cryptarithmetic Example CSP: Sudoku § Variables (circles): § Variables: § Domains: § Each (open) square § 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 12 Example CSP: The Waltz Algorithm Varieties of CSPs § The Waltz algorithm is for interpreting line drawings of § Discrete Variables solid polyhedra § Finite domains § An early example of a computation posed as a CSP § 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 state of a robot ? § Linear constraints solvable in polynomial time by LP methods (see cs170 for a bit of this theory) § Look at all intersections § Adjacent intersections impose constraints on each other 15 18 2

  3. Varieties of Constraints Real-World CSPs § Varieties of Constraints § Assignment problems: e.g., who teaches what class § 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 § Factory scheduling § Higher-order constraints involve 3 or more variables: e.g., cryptarithmetic column constraints § Floorplanning § 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 § (We ’ ll ignore these until we get to Bayes ’ nets) variables … 19 20 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 § What does DFS do? § States are defined by the values assigned so far § [demo] § Initial state: the empty assignment, {} § Successor function: assign a value to an unassigned variable § Goal test: the current assignment is complete and satisfies all constraints § What ’ s the obvious problem here? § What ’ s the slightly-less-obvious problem? § Simplest CSP ever: two bits, constrained to be equal 21 22 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 § 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 (useless name, really) § [DEMO] § Backtracking search is the basic uninformed algorithm for CSPs § Backtracking = DFS + var-ordering + fail-on-violation § What are the choice points? 23 24 § Can solve n-queens for n ≈ 25 3

  4. Improving Backtracking Minimum Remaining Values § Minimum remaining values (MRV): § General-purpose ideas give huge gains in speed § Choose the variable with the fewest legal values § Ordering: § Which variable should be assigned next? § In what order should its values be tried? § Filtering: Can we detect inevitable failure early? § Why min rather than max? § Also called “ most constrained variable ” § Structure: Can we exploit the problem structure? § Also called “ fail-fast ” ordering 25 27 Degree Heuristic Least Constraining Value § Tie-breaker among MRV variables § Given a choice of variable: § Choose the least constraining § Degree heuristic: value § Choose the variable participating in the most § The one that rules out the fewest constraints on remaining variables values in the remaining variables § Note that it may take some computation to determine this! § Why least rather than most? § Combining these heuristics makes 1000 queens feasible § Why most rather than fewest constraints? 28 29 Filtering: Forward Checking NT Filtering: Forward Checking NT Q Q WA WA SA SA NSW NSW V V § Idea: Keep track of remaining legal values for § Forward checking propagates information from assigned to adjacent unassigned variables, but doesn't detect more distant failures: unassigned variables (using immediate constraints) § Idea: Terminate when any variable has no legal values § NT and SA cannot both be blue! § Why didn ’ t we detect this yet? § Constraint propagation repeatedly enforces constraints (locally) 30 31 [demo: forward checking animation] 4

Recommend


More recommend