DOC PREVIEW
Berkeley COMPSCI 188 - CSPs

This preview shows page 1-2-3-4-5 out of 16 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 16 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 16 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 16 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 16 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 16 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 16 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1CS 188: Artificial IntelligenceSpring 2006Lecture 6: CSPs2/2/2006Dan Klein – UC BerkeleyMany slides from either Stuart Russell or Andrew Moore Constraint 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 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 algorithms2Example: N-Queens Formulation 1: Variables: Domains: ConstraintsExample: N-Queens Formulation 2: Variables: Domains: Constraints:3Example: Map-Coloring Variables: Domain: Constraints: adjacent regions must have different colors Solutions are assignments satisfying all constraints, e.g.:Constraint 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!4Example: Cryptarithmetic Variables: Domains: Constraints:Varieties of CSPs Discrete Variables Finite domains size d means 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)5Varieties 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 problemsReal-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…6Standard 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 constraintsSearch Methods What does BFS do? What does DFS do? What’s the obvious problem here? What’s the slightly-less-obvious problem?7Backtracking 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 assignmesnts Depth-first search for CSPs with these two improvements is called backtracking search Backtracking search is the basic uninformed algorithm for CSPs Can solve n-queens for n ≈ 25Backtracking Search What are the choice points?8Backtracking ExampleImproving 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?9Minimum 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” orderingDegree Heuristic Tie-breaker among MRV variables Degree heuristic: Choose the variable with the most constraints on remaining variables Why most rather than fewest constraints?10Least 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 feasibleForward Checking Idea: Keep track of remaining legal values for unassigned variables Idea: Terminate when any variable has no legal valuesWASANTQNSWV11Constraint 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 (locally)WASANTQNSWVArc Consistency Simplest form of propagation makes each arc consistent X → Y is consistent iff for every value x there is some allowed y If X loses a value, neighbors of X need to be rechecked! Arc consistency detects failure earlier than forward checking What’s the downside of arc consistency? Can be run as a preprocessor or after each assignment WASANTQNSWV12Arc Consistency Runtime: O(n2d3), can be reduced to O(n2d2) … but detecting all possible future problem is NP-hard – why?Problem Structure Tasmania and mainland are independent subproblems Identifiable as connected components of constraint graph Suppose each subproblem has c variables out of n total Worst-case solution cost is O((n/c)(dc)), linear in n E.g., n = 80, d = 2, c =20 280= 4 billion years at 10 million nodes/sec (4)(220) = 0.4 seconds at 10 million nodes/sec13Tree-Structured CSPs Theorem: if the constraint graph has no loops, the CSP can be solved in O(n d2) time Compare to general CSPs, where worst-case time is O(dn) This property also applies to logical and probabilistic reasoning:


View Full Document

Berkeley COMPSCI 188 - CSPs

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

Midterm

Midterm

6 pages

MDPs

MDPs

20 pages

mdps

mdps

2 pages

Games II

Games II

18 pages

Load more
Download CSPs
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 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 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?