helps the choices in backtracking:
when choosing the variable vs. the first value
why? next slides
the tree of recursive calls depends on the choice of the variables
not the same size!
extreme case: with a variable, immediate inconsistency
but, another is chosen
example: constraint y < x with Dy = {1,2,3}
|
|
|
| choose variable y | choose another variable z
then others before y |
better choose y
inconsistency detected immediately
choose z: visit a tree
good = small subtrees
implicit assumption: no solutions in there
not intuitive…
finding solution is very quick, but …
only if correct path could be guessed each time
impossible to guarantee the correct choice at each node
one error ⇒ visit a tree
visiting a complete tree may be much larger than reaching the solution
visiting a subtree with no solution dominates the cost
⇒ optimize for that
rough estimation of the size of the subtree:
|
|
|
| few possible values | many possible values |
few values ⇒ few subtrees
not guaranteed: few large subtrees vs. many small subtrees
only an estimate!
estimate: better choose y
knowning the size of subtree would solve the problem
but, requires visiting them
(after done, no point into choosing another variable)
easy case?
easy case: empty subtrees
|
|
|
| few subtrees, none empty |
may subtrees, but many of them empty |
second is better
fewer non-empty subtrees
still a rough estimate
best variable x:
minimal number of values x=a that are not immediately inconsistent
principle: simulate the effects of adding x=a to the current evaluation
remove values that immediately lead to ionconsistency
choose variable with few possible remaining values
first do look-ahead (simulate x=a)
then do backtracking (add x=a)
same? repeated operations?
in short: backtracking does x=a only for the chosen variable
look-ahead does it for all variables, and does it for choosing the variable
look-ahead simulates the first step of backtracking
evaluates the usefulness of the possible next steps
for each x=a, estimate the cost
size of subtree
how to estimate: check whether subtree is empty
constraint immediately violated with x=a
improve estimate?
sometimes no solution has x=a
even if no constraint is violated
forward checking find some cases when it happens
simulates a simplification that can be done if x=a
for variable x and value a ∈ Dx:
all of this from a partial evaluation
instead of:
use:
example: instead of forward checking, use arc-consistency
both remove elements from domains
both prove inconsistency when a domain is empty
they differ
binary constraints
when checking x=a
in both cases, with D'x={a}
with x=a
red = constraints checked
less costly than arc consistency
detect inconsistency more often than forward checking
force arc consistency once, only in one direction
for each constraint, check and force arc consistency
do not repeat, unlike arc consistency
check consistency of a variable with the following
following = according to a given order
variable chosen
second choice: which value to try first, second, etc.
general principle: choose the value most likely to be part of a solution
“most likely” = can never be sure without actually find a solution
various methods
choose based on effects of the look ahead method used
(forward checking, arc consistency, ecc.)
look ahead done anyway ⇒ little additional cost
choose value such that look ahead remove the fewest values from the domains
do look ahead for each value
for each value, see which domain remains the smallest
first value is the one when this number is the largest
do look ahead for each value
multiply the size of domains (what remains after look ahead)
this is a (largely optimistic) estimate of the number of solution
use this for ordering the values (larger is better)
two variables give the same estimate ⇒ choose randomly