Constraint Satisfaction Problems on CPS - Examination | CMSC 421, Exams of Computer Science

Material Type: Exam; Professor: Nau; Class: INTRO ARTIFICIAL INTELLI; Subject: Computer Science; University: University of Maryland; Term: Fall 2008;

Typology: Exams

Pre 2010

Uploaded on 07/30/2009

koofers-user-4c8-2
koofers-user-4c8-2 🇺🇸

5

(2)

10 documents

1 / 42

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Last update: September 16, 2008
Constraint Satisfaction Problems
CMSC 421, Chapter 5
CMSC 421, Chapter 5 1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a

Partial preview of the text

Download Constraint Satisfaction Problems on CPS - Examination | CMSC 421 and more Exams Computer Science in PDF only on Docsity!

Last update: September 16, 2008

Constraint Satisfaction Problems

CMSC 421, Chapter 5

Outline

♦ CSP examples

♦ Backtracking search for CSPs

♦ Problem structure and problem decomposition

♦ Local search for CSPs

Example: map coloring

Western Australia

Northern Territory

South Australia

Queensland

New South Wales

Victoria

Variables W A, N T , Q, N SW , V , SA, T Tasmania Domain of each variable is {red, green, blue} Constraints: adjacent regions must have different colors e.g., W A 6 = N T (if the language allows this), or (W A, N T ) ∈ {(red, green), (red, blue), (green, red), (green, blue), (blue, red), (blue, green)}

Example: map coloring, continued

Western Australia

Northern Territory

South Australia

Queensland

New South Wales

Victoria

Tasmania

Solutions are assignments that satisfy all the constraints, e.g., {W A = red, N T = green, Q = red, N SW = green, V = red, SA = blue, T = green}

Varieties of CSPs

Discrete variables finite domains of size d ⇒ O(dn) complete assignments for n variables ♦ e.g., Boolean CSPs, incl. Boolean satisfiability (NP-complete) infinite domains (integers, strings, etc.) ♦ e.g., job scheduling, variables are start/end days for each job ♦ need a constraint language, e.g., StartJob 1 + 5 ≤ StartJob 3 ♦ linear constraints solvable but NP-hard nonlinear constraints undecidable

Continuous variables ♦ e.g., start/end times for Hubble Space Telescope observations ♦ linear constraints solvable using Linear Programming (LP) methods can be done in polynomial time, but very high overhead usually use a low-overhead algorithm with exponential worst-case

Varieties of constraints

Unary constraints involve a single variable, e.g., SA 6 = green

Binary constraints involve pairs of variables e.g., SA 6 = W A

Preferences (soft constraints), e.g., red is better than green often representable by a cost for each variable assignment e.g., cost(red) = 1, cost(green) = 5 → constrained optimization problems

Higher-order constraints involve 3 or more variables, e.g., cryptarithmetic (next slide)

Real-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 (e.g., factory layouts)

Notice that many real-world problems involve real-valued variables

Standard search formulation (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: choose an unassigned variable v assign a value to v that doesn’t conflict with the other variables ⇒ fail if no legal assignments

♦ Goal test: the current assignment is complete

  1. This is the same for all CSPs
  2. With n variables, every solution is at depth n ⇒ use depth-first search
  3. Path is irrelevant
  4. If there are d possible values for each variable, then for i = 1,... , n, branching factor at depth i is bi = (n − i)d, so there are b 0 b 1... bn = n!dn^ leaves!

Backtracking search

function Backtracking-Search(csp) returns solution/failure return Recursive-Backtracking({ }, csp)

function Recursive-Backtracking(assignment, csp) returns soln/failure if assignment is complete then return assignment var ← Select-Unassigned-Variable(Variables[csp], assignment, csp) for each value in Order-Domain-Values(var, assignment, csp) do if value is consistent with assignment given Constraints[csp] then add {var = value} to assignment result ← Recursive-Backtracking(assignment, csp) if result 6 = failure then return result remove {var = value} from assignment return failure

Backtracking example

Backtracking example

Backtracking example

1. Which variable to assign next?

Minimum remaining values (MRV) heuristic:

♦ choose the variable with the fewest legal values

a=1a= b=2 b=

a=1^ a=

b=1 (^) b=4 b=1b=2^ b=3 b=

b=1 (^) b=2 b=3 b=

a=1 a=2 (^) a=1a=2 a=1a=

1. Which variable to assign next?

Degree heuristic:

♦ Choose the variable with the most constraints on remaining variables e.g., suppose a doesn’t constrain b, but c does constrain b:

b=

b=

a=1^ a=

b=1 (^) b= b=

b=1 b=3 b= b=

b=

c=1^ c=

b= b=

b=1 (^) b=

⇒ Use this as a tie-breaker among MRV variables