DOC PREVIEW
Berkeley COMPSCI 188 - CSPs (2PP)

This preview shows page 1-2-22-23 out of 23 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 23 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 23 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 23 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 23 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 23 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1CS 188: Artificial IntelligenceFall 2007Lecture 4: CSPs9/6/2007Dan Klein – UC BerkeleyMany slides over the course adapted from either Stuart Russell or Andrew MooreConstraint Satisfaction Problems Standard search problems: State is a “black box”: any old data structure Goal test: any function over states Successors: any map from states to sets of states Constraint satisfaction problems (CSPs): State is defined by variables Xiwith values from a domain D (sometimes Ddepends 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 algorithms2Example: N-Queens Formulation 1: Variables: Domains: ConstraintsExample: N-Queens Formulation 2: Variables: Domains: Constraints:… there’s an even better way! What is it?3Example: Map-Coloring Variables: Domain: Constraints: adjacent regions must have different colors Solutions are assignments satisfying all constraints, e.g.:Example: The Waltz Algorithm The Waltz algorithm is for interpreting line drawings of solid polyhedra An early example of a computation posed as a CSP  Look at all intersections Adjacent intersections impose constraints on each other?4Waltz on Simple Scenes Assume all objects: Have no shadows or cracks Three-faced vertices “General position”: no junctions change with small movements of the 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” Interior convex edge (+) Interior concave edge (-)Legal Junctions Only certain junctions are physically possible How can we formulate a CSP to label an image? Variables: vertices Domains: junction labels Constraints: both ends of a line should have the same labelxy(x,y) in, , …5Constraint Graphs Binary CSP: each constraint relates (at most) two variables Constraint graph: nodes are variables, arcs show constraints General-purpose CSP algorithms use the graph structure to speed up search. E.g., Tasmania is an independent subproblem!Example: Cryptarithmetic Variables: Domains: Constraints:6Varieties of CSPs Discrete Variables Finite domains Size dmeans O(dn)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 Need a constraint language, e.g., StartJob1+ 5 < StartJob3 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 (see cs170 for a bit of this theory)Varieties of Constraints Varieties of Constraints Unary constraints involve a single variable (equiv. to shrinking domains): Binary constraints involve pairs of variables: Higher-order constraints involve 3 or more variables:e.g., cryptarithmetic column constraints Preferences (soft constraints): 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)7Real-World CSPs Assignment problems: e.g., who teaches what class Timetabling problems: e.g., which class is offered when and where? Hardware configuration Spreadsheets Transportation scheduling Factory scheduling Floorplanning Many real-world problems involve real-valued variables…Standard Search Formulation 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 Initial state: the empty assignment, {} Successor function: assign a value to an unassigned variable Goal test: the current assignment is complete and satisfies all constraints8Search Methods What does BFS do? What does DFS do? [ANIMATION] What’s the obvious problem here? What’s the slightly-less-obvious problem?Backtracking Search Idea 1: Only consider a single variable at each point: Variable assignments are commutative 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 Depth-first search for CSPs with these two improvements is called backtracking search [ANIMATION] Backtracking search is the basic uninformed algorithm for CSPs Can solve n-queens for n ≈ 259Backtracking Search What are the choice points?Backtracking Example10Improving 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?Minimum Remaining Values Minimum remaining values (MRV): Choose the variable with the fewest legal values Why min rather than max? Called most constrained variable “Fail-fast” ordering11Degree Heuristic Tie-breaker among MRV variables Degree heuristic: Choose the variable with the most constraints on remaining variables Why most rather than fewest constraints?Least Constraining Value Given a choice of variable: Choose the least constraining value The one that rules out the fewest 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 feasible12Forward Checking Idea: Keep track of remaining legal values for unassigned variables Idea: Terminate when any variable has no legal valuesWASANTQNSWVConstraint Propagation Forward checking propagates information from assigned to unassigned variables, but doesn't provide early detection for all failures: NT and SA cannot both be blue! Why didn’t we detect this yet? Constraint propagation repeatedly enforces constraints


View Full Document

Berkeley COMPSCI 188 - CSPs (2PP)

Documents in this Course
CSP

CSP

42 pages

Metrics

Metrics

4 pages

HMMs II

HMMs II

19 pages

NLP

NLP

23 pages

Midterm

Midterm

9 pages

Agents

Agents

8 pages

Lecture 4

Lecture 4

53 pages

CSPs

CSPs

16 pages

Midterm

Midterm

6 pages

MDPs

MDPs

20 pages

mdps

mdps

2 pages

Games II

Games II

18 pages

Load more
Download CSPs (2PP)
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view CSPs (2PP) and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view CSPs (2PP) 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?