Chapter - Three - Part Two
Chapter - Three - Part Two
2 Constraint Graph
3 Types of Variables
4 Backtracking Search
5 Summary
Definition
State is defined by a set of variables Xi
Each variable can be unassigned (partial solution) or have a value
from domain Di.
Constraints are a set of rules specifying allowable combinations
of values for subsets of variables
Solution: a state that is a
Consistent assignment: satisfies all constraints
Complete assignment: assigns value to each variable
Discrete variables
finite domains:
n variables, domain size d = complete assignments
e.g., Boolean CSPs, such as 3 SAT (NP complete)
Worst case, can’t solve finite-domain CSPs in less than exponential
time
infinite domains:
integers, strings, etc.
e.g., job scheduling, variables are start/end days for each job
need a constraint language, e.g., StartJob1 + 5 less than or equal to
StartJob3
Continuous variables
e.g., start/end times for Hubble Space Telescope observations
linear constraints solvable in polynomial time by linear
programming
Prepared by Adem (MSc.) Introduction to Artificial intelligence August 10, 2022 12 / 26
Cont..
Assignment problems
e.g., who teaches what class
Timetabling problems
e.g., which class is offered when and where
Transportation scheduling
Factory scheduling
State:
Values assigned so far
Initial state:
The empty assignment (all variables are unassigned)
Successor function:
Choose an unassigned variable and assign it a value that does not
violate any constraints Fail if no legal assignment is found
Goal state:
Any complete and consistent assignment.
Improving backtracking
Can we improve backtracking using general-purpose ideas, without
domain specic knowledge
Ordering:
Which variable should be assigned next?
In what order should its values be tried?
Filtering:
can we detect inevitable failure early?
Structure:
can we exploit the problem structure?
Variable ordering
Minimum remaining values:
Choose the variable with the fewest legal values left in its domain.
Also known as the fail-first heuristic
Detecting failures quickly is equivalentto pruning large parts ofthe
search tree.
Value ordering
Least constraining value:
Given a choice of variable, choose the least constraining value.
i.e.,the value that rules out the fewest values in the remaining
variables.
Arc consistency
X is arc consistent wrt Y, for every value of X there is some
allowed value of Y.
Make X arc consistent wrt Y by throwing out any values of X for
which there is no allowed value of Y.