Docsity

Constraint Programming: Achieving Arc-Consistency and Bounds Consistency, Exercises of Computer Numerical Control

Toggle sidebar
bg1
Constraint Programming
Problems on consistency
1. Give an algorithm for achieving bounds consistency on a constraint of the form X6=Y,
where Xand Yare distinct variables with arithmetic domains.
2. Consider a constraint of the form X=cx→Y=cy, where Xand Yare any finite-
domain variables, cxand cyare any values, and “→” denotes implication. Consider
three algorithms that take a constraint of this form and prune the domains of Xand
Y. We write Dom(Z) to denote the domain of any variable Z.
Algorithm A1: if Dom(X) = ∅then set Dom(Y) to ∅
else if Dom(X) = {cx}then set Dom(Y) to Dom(Y)− {v|v6=cy};
if cy6∈ Dom(Y) then set Dom(X) to Dom(X)− {cx};
Algorithm A2: if Dom(X) = ∅then set Dom(Y) to ∅
else if Dom(X) = {cx}then set Dom(Y) to Dom(Y)− {v|v6=cy};
if Dom(Y) = ∅then set Dom(X) to ∅
else if cy6∈ Dom(Y) then set Dom(X) to Dom(X)− {cx};
Algorithm A3: if Dom(X) = ∅then set Dom(Y) to ∅
else if Dom(X) = {cx}then set Dom(Y) to {cy};
if Dom(Y) = ∅then set Dom(X) to ∅
else if cy6∈ Dom(Y) then set Dom(X) to Dom(X)− {cx};
(a) Given a constraint of this form in which Xand Yare distinct variables, exactly one
of these three algorithms is guaranteed to make the given constraint arc-consistent.
Which is it? For each of the other two algorithms argue, through use of an example,
that it can fail to make the given constraint arc-consistent.
(b) If we assume that in this constraint Xand Yare the same variable, then even the
correct algorithm goes wrong. Through use of an example, show this.
(c) Give an algorithm that takes a constraint of the form X=c1→X=c2and
prunes the domain of Xto make the constraint arc consistent without losing any
solutions.
3. Recall the AC-3 algorithm given in class:
algorithm AC-3(G)
Let Qbe the set of (directed) arcs of G
while Qnot empty do
select and remove any arc (x,y) from Q;
REVISEac(x,y);
if REVISEac(x,y) changed the domain of x
then to Qadd all arcs of Gthat go into x, except (y,x);
The input to the AC-3 algorithm is a directed constraint graph; every binary constraint
between variables xand yis represented by an arc from xto y(written (x,y)) and an
arc from yto x(written (y,x)). We assume that the graph contains no self arcs, (x,x),
and that there is at most one arc from any node to any other node. REVISEac is a
procedure that takes an arc (x,y) and achieves arc consistency from xto y.
For this question you are to present a new algorithm XC-3 that is to take a graph in
the same form as that given to AC-3 except that each edge is labelled with either “a”
or “b”. These labels are such that every arc (x,y) has the same label as its inverse arc
(y,x). The algorithm is to prune the domains of the variables so that 1) no solutions to
the constraints are lost, 2) every constraint whose arcs are labelled “a” is arc consistent,
and 3) every constraint whose arcs are labelled “b” is bounds consistent.
Your algorithm may use REVISEac and REVISEbc without specifying their operation.
REVISEbc is a procedure that takes an arc (x,y) and achieves bounds consistency from
xto y.
1
pf2

Partial preview of the text

Download Constraint Programming: Achieving Arc-Consistency and Bounds Consistency and more Exercises Computer Numerical Control in PDF only on Docsity!

Constraint Programming Problems on consistency

  1. Give an algorithm for achieving bounds consistency on a constraint of the form X 6 = Y , where X and Y are distinct variables with arithmetic domains.
  2. Consider a constraint of the form X = cx → Y = cy, where X and Y are any finite- domain variables, cx and cy are any values, and “→” denotes implication. Consider three algorithms that take a constraint of this form and prune the domains of X and Y. We write Dom(Z) to denote the domain of any variable Z.

Algorithm A1: if Dom(X) = ∅ then set Dom(Y ) to ∅ else if Dom(X) = {cx} then set Dom(Y ) to Dom(Y ) − {v|v 6 = cy}; if cy 6 ∈ Dom(Y ) then set Dom(X) to Dom(X) − {cx}; Algorithm A2: if Dom(X) = ∅ then set Dom(Y ) to ∅ else if Dom(X) = {cx} then set Dom(Y ) to Dom(Y ) − {v|v 6 = cy}; if Dom(Y ) = ∅ then set Dom(X) to ∅ else if cy 6 ∈ Dom(Y ) then set Dom(X) to Dom(X) − {cx}; Algorithm A3: if Dom(X) = ∅ then set Dom(Y ) to ∅ else if Dom(X) = {cx} then set Dom(Y ) to {cy}; if Dom(Y ) = ∅ then set Dom(X) to ∅ else if cy 6 ∈ Dom(Y ) then set Dom(X) to Dom(X) − {cx};

(a) Given a constraint of this form in which X and Y are distinct variables, exactly one of these three algorithms is guaranteed to make the given constraint arc-consistent. Which is it? For each of the other two algorithms argue, through use of an example, that it can fail to make the given constraint arc-consistent. (b) If we assume that in this constraint X and Y are the same variable, then even the correct algorithm goes wrong. Through use of an example, show this. (c) Give an algorithm that takes a constraint of the form X = c 1 → X = c 2 and prunes the domain of X to make the constraint arc consistent without losing any solutions.

  1. Recall the AC-3 algorithm given in class:

algorithm AC-3(G) Let Q be the set of (directed) arcs of G while Q not empty do select and remove any arc (x,y) from Q; REVISEac(x,y); if REVISEac(x,y) changed the domain of x then to Q add all arcs of G that go into x, except (y,x);

The input to the AC-3 algorithm is a directed constraint graph; every binary constraint between variables x and y is represented by an arc from x to y (written (x,y)) and an arc from y to x (written (y,x)). We assume that the graph contains no self arcs, (x,x), and that there is at most one arc from any node to any other node. REVISEac is a procedure that takes an arc (x,y) and achieves arc consistency from x to y. For this question you are to present a new algorithm XC-3 that is to take a graph in the same form as that given to AC-3 except that each edge is labelled with either “a” or “b”. These labels are such that every arc (x,y) has the same label as its inverse arc (y,x). The algorithm is to prune the domains of the variables so that 1) no solutions to the constraints are lost, 2) every constraint whose arcs are labelled “a” is arc consistent, and 3) every constraint whose arcs are labelled “b” is bounds consistent. Your algorithm may use REVISEac and REVISEbc without specifying their operation. REVISEbc is a procedure that takes an arc (x,y) and achieves bounds consistency from x to y.

1

Your algorithm should follow the spirit of AC-3 by not adding more arcs to Q than necessary.