Week-7 - CSPs
Week-7 - CSPs
8 10
7 9 9
X6 X5
6
X7 8
X3 9
X7 9
States need to be encoded
Initial Population
o Domains:
Explicit:
oConstraints:
Implicit:
(1,2)?
Explicit:
• Variables:
• Domains:
• Constraints:
o Variables:
o Each (open) square
o Domains:
o {1,2,…,9}
o Constraints:
9-way alldiff for each column
9-way alldiff for each row
9-way alldiff for each region
(or can have a bunch of
pairwise inequality
constraints) (Unary
constraints)
oThe Waltz algorithm is for interpreting line
drawings of solid polyhedra as 3D objects
oAn early example of an AI computation
posed as a CSP
?
oApproach:
o Each intersection is a variable
o Adjacent intersections impose
constraints on each other
o Solutions are physically realizable 3D
interpretations
oDiscrete Variables
o Finite domains
o Size d means O(𝑑 𝑛 ) complete assignments
o E.g., Boolean CSPs, including Boolean satisfiability
o each of the variables has two things: True and False
o Infinite domains (integers, strings, etc.)
o E.g., job scheduling, variables are start/end times for each job
o Linear constraints solvable
o E.g., this job has to end before that job starts
oContinuous variables
o E.g., start/end times for Hubble Telescope observations
o Non-integer – real valued times
o Varieties of Constraints
o Unary constraints involve a single variable
(equivalent to reducing domains), e.g.:
oOrdering:
o Which variable should be assigned next?
o In what order should its values be tried?
oFiltering:
o Can we detect inevitable failure early?
o as opposed to wait until hitting a dead-end
oFiltering: Keep track of domains for unassigned variables and cross off bad options
oForward checking: Cross off values that violate a constraint when added to the
existing assignment
NT Q
WA
SA NSW
V
NT Q
WA
SA
NSW
V
NT Q
WA
SA
NSW
V
Not
Consistent
consistent
NT Q
WA SA
NSW
V Empty domain
Consistent
Not Consistent
Consistent (detected failure)
ConsistentNotConsistent
NotConsistent Consistent
Consistent
𝑑2
oSpeed-ups:
o Ordering
o Filtering
Thanks for your attention!