
































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

































Chapter 5
Chapter 5
1
CSP examples
Backtracking search for CSPs
Problem structure and problem decomposition
Local search for CSPs
Chapter 5
2
Territory Northern
Australia South
Queensland
New South Wales
Victoria
Tasmania
Variables
Domains
i
=
red, green, blue
Constraints
: adjacent regions must have different colors
e.g.,
(if the language allows this), or
red, green
red, blue
green, red
green, blue
Chapter 5
4
Australia Western
Territory Northern
Australia South
Queensland
New South Wales
Victoria
Tasmania
Solutions
are assignments satisfying all constraints, e.g.,
(^) red, N T
green, Q
(^) red, N SW
(^) green, V
red, SA
blue, T
(^) green
Chapter 5
5
docsity.co
Discrete variables
finite domains; size
d ⇒ O ( d n )
complete assignments
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
StartJob
3
linear
constraints solvable,
nonlinear
undecidable
Continuous variables
e.g., start/end times for Hubble Telescope observations
linear constraints solvable in poly time by LP methods
Chapter 5
7
Unary
constraints involve a single variable,
e.g.,
green
Binary
constraints involve pairs of variables,
e.g.,
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
constrained optimization problems
Chapter 5
8
Assignment problems
e.g., who teaches what class
Timetabling problems
e.g., which class is offered when and where?
Notice that many real-world problems involve real-valued variablesFloorplanningFactory schedulingTransportation schedulingSpreadsheetsHardware configuration
Chapter 5
10
♦ States are defined by the values assigned so far Let’s start with the straightforward, dumb approach, then fix it
Initial state
: the empty assignment,
Successor function
: assign a value to an unassigned variable
that does not conflict with current assignment. ⇒
fail if no legal assignments (not fixable!)
Goal test
: the current assignment is complete
n
with
n
variables
use depth-first search
b
= (
n
d
at depth
, hence
n
! d
n
leaves!!!!
Chapter 5
11
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
failure
then return
result
remove
{ var
=
value
}
from
assignment
return
failure
Chapter 5
13
Chapter 5
14
Chapter 5
16
Chapter 5
17
Minimum remaining values (MRV):
choose the variable with the fewest legal values
Chapter 5
19
Degree heuristic: Tie-breaker among MRV variables
choose the variable with the most constraints on remaining variables
Chapter 5
20