CAPÍTULO IV: DISCUSIÓN Y CONCLUSIONES
4.2. Conclusiones
This section presents a procedure that transforms a COP into an equivalent COP using dual encoding [DP89], as well as empirical results. Since enforcing arc con- sistency (AC) on the dual model is strictly stronger than enforcing generalized arc consistency (GAC) on the original model [SW99], a dual model will be more suit- able when the search explores the O-space and the P-space simultaneously. The
next example demonstrates the whole procedure, and shows more pruning can in- deed be achieved on the dual encoded COP.
Search Space Reduction and Russian Doll Search 113
Example 6.1. Let Q be a COP with five P-vars X = {x1, x2, x3, x4, x5} and
twoO-vars Y = {y1, y2}. Each P-var has a Boolean domain. The domain of y1is {1, 3} and the domain of y2is{0, 2}. The objective function is z = y1+ y2. There are four constraints:
C1(x1, x2, x3, y1) rel= {h0, 0, 1, 1i , h0, 1, 0, 1i , h1, 0, 0, 1i , h1, 1, 1, 3i}, C2(x2, x3, x4, y2) rel= {h0, 0, 0, 2i , h0, 1, 1, 0i , h1, 0, 1, 0i , h1, 1, 0, 0i}, C3(x1, x2, x4) rel= {h0, 0, 0i , h0, 1, 1i , h1, 0, 1i , h1, 1, 0i},
C4(x2, x4, x5) rel= {h0, 0, 1i , h0, 1, 0i , h1, 0, 0i , h1, 1, 1i}.
We transformQ into a new COP Q0 in three steps. First, we introduce a new variable x0
i for each constraint Ci. The domain ofx0iis the set of solutions of Ci projected onX (i.e., on the P-vars alone):
dom(x0
1) = dom(x04) = {h0, 0, 1i , h0, 1, 0i , h1, 0, 0i , h1, 1, 1i}, dom(x0
2) = dom(x03) = {h0, 0, 0i , h0, 1, 1i , h1, 0, 1i , h1, 1, 0i}. If we map each tuple hi, j, ki to the integer 4i + 2j + k via binary encoding, the domains of x01 and x04 become {1, 2, 4, 7} and the domains of x0
2 and x03 become {0, 3, 5, 6}.
In the next step, for everyCithat has variables in bothX and Y , we create a new constraintC0
ithat connectsx0iandyi:
C10(x01, y1) rel= {h1, 1i , h2, 1i , h4, 1i , h7, 3i}, C20(x02, y2) rel= {h0, 2i , h3, 0i , h5, 0i , h6, 0i}.
a new constraintCij0 to preserve the relation:
C120 (x01, x02) rel= {h1, 3i , h2, 5i , h4, 0i , h7, 6i}, C130 (x01, x03) rel= {h1, 0i , h2, 3i , h4, 5i , h7, 6i}, C230 (x02, x03) rel= {h0, 0i , h3, 5i , h5, 3i , h6, 6i}, C340 (x03, x04) rel= {h0, 1i , h3, 7i , h5, 2i , h6, 4i}. For instance, there is a constraint C0
34 because C3 and C4 share the P-vars x2 andx4. h0, 1i is a solution of C340 (x03, x04) because it captures the constraint x2 = 0 ∧ x4 = 0 within the pair h0, 0, 0i and h0, 0, 1i, the solutions of C3(x1, x2, x4) andC4(x2, x4, x5) respectively.
In total,Q0has fourP-vars x0
1, x02, x03, x04and twoO-vars y1, y2. Also there are six constraintsC0
1, C20, C120 , C130 , C230 , C340 . The objective function isz = y1+ y2. Enforcing (G)AC onQ0 gives more pruning than on the originalQ. Let’s say we assignz with 1. This forces the O-vars y1 andy2 to be 1 and 0 respectively. Making the constraints inQ0arc consistent, gives{(x0
1, 2), (x02, 5), (x03, 3), (x04, 7)} without search. This corresponds tox1 = x3 = 0 and x2 = x4 = x5 = 1 in the original problem. On the other hand, the same assignments on theO-vars trigger no propagation inQ.
To describe dual encoding we need the following notations: Let θ be a set of
assignments, X a set of P-vars and y an O-var. Recall θ[y] = b if (y, b) ∈ θ,
and θ[X] = {(x, a) ∈ θ : x ∈ X}.3 Also, two sets of assignments θ and θ0 are compatible iff for every(xi, a) ∈ θ and (xj, a0) ∈ θ0,i = j implies a = a0.
Definition 6.2 (Dual encoding of a COP). The dual encoding of a COPQ =
(X ∪ Y ∪ {z}, C) is another COP Q0 = (X0∪ Y ∪ {z}, C0) constructed as follows:
3
Search Space Reduction and Russian Doll Search 115
• For every C ∈ C, if var (C) intersects X, there is a dual P-var x0 ∈ X0
whose domain is{θ[X] : θ ∈ C}, a set of projected solutions of C, which
are later mapped to distinct integers.
• For every C(x1, . . . , xr, y) ∈ C, where x1, . . . , xr ∈ X and y ∈ Y , there is
a dualO-constraint C0(x0, y) ∈ C0such thathθ[X], θ[y]i is a solution of C0
iffθ is a solution of C.
• For every Ci, Cj ∈ C, if var (Ci) ∩ var (Cj) ∩ X is non-empty, there is a dualP-constraint C0
i,j(x0i, x0j) ∈ C0 such thathθi[X], θj[X]i is a solution of C0
i,j iffθi ∈ Ci,θj ∈ Cj, andθi[X] and θj[X] are compatible.
Q0 is the dual model (of Q) and Q is the primal model (of Q0). BothQ and Q0
have the sameO-vars Y and the same objective function. By construction, there is
a one-to-one mapping between the solutions of the two COPs.
Our transformation is only on theP-vars and the P-constraints; the O-vars and
the objective function are unchanged. This is because each O-constraint and the
objective function share exactly one O-var, and so dual encoding on them is not
useful.
6.3.1 Experimental Results
Our experiment comprises random COPs (pure optimization problems with no
P-constraint). In the problem hn, d, m, e, r, pi, there are n P-vars with domain {0, . . . , d−1}, m O-vars with domain {0, . . . , e−1}, and m O-constraints with ar-
ityr+1 (r P-vars and one O-var). For each solution {(x1, a1), . . . , (xr, ar), (y, b)}
of anO-constraint, with probability p we randomly choose b ∈ {1, . . . , e − 1}, or
else (with probability 1 − p) we set b to zero. Thus for small p most assignments
benchmark contains 10 instances.
We used Gecode 2.1.1 on a MacBook with a 2 GHz Core 2 Duo and 1 GB RAM. Enforcing GAC on the primal O-constraints is by mddc. For the dual constraints, we implemented the arc consistency (AC) algorithm by Samaras and Stergiou [SS05a], which exploits the piecewise functional nature of the dual con- straints. During the depth-first branch-and-bound search, the variables are assigned in a static order, and the largest value in the domain is always tried first. To be more specific, when the primal model is used, theP-var that appears in most constraints
is selected first, i.e., only theP-space is searched. We call this strategy “primal/x.”
When the dual model is used, theO-space is explored before the P-space — the O-
var whose corresponding dualP-var appears in most constraints is assigned first;
after allO-vars are assigned, the dual P-vars are assigned in the same order. We
call this “dual/yx.”
Figure 6.3 plots the number of backtracks and the solving time by dual/yx against primal/x, on h25, 5, {20, 21}, {2, 50}, 4, pi, where p ranges from 0.01 to
0.04. Note that the size of the P-space is always 525 ≈ 3e17 while the size of
the O-space is between 220 ≈ 1e6 and 5021 ≈ 4.77e35. From the graph we
can see using dual/yx often results in 10 to 200 times less backtracks (and never more) than primal/x, although the search space for dual/yx is bigger.4 This is because dual encoding is suitable for sparse problems [SS05a] and exploring the
O-space is more preferred for small p, when the O-vars take the value zero for most
assignments of theP-vars. Figure 6.3b shows the improvement on solving time by
dual/yx is significant for instances which are hard for primal/x (the triangles to the right ofy = x; when a search on the P-vars takes > 10 seconds but on the O-vars
it takes< 10 seconds). Actually, when dual/yx is faster, it has 75.8 (median) times
less backtracks than primal/x; but when it is slower, the ratio is 13.1, and hence the
4
An O-constraint is functional from P-vars to O-var, so that the value of O-var is determined when all P-vars are assigned, but usually not vice versa.
Search Space Reduction and Russian Doll Search 117
cost of the dual constraints outweighs the benefit. Overall, our results indicate the search moves to the optimal value quickly, and during the traversal in theO-space,
the constraint propagation is strong enough to prune many unsatisfiable regions in theP-space.
Finally, no instance were solved within 5 minutes when theP-space was ex-
plored with the dual model. This is because the domains of the dual P-vars are
large and the values are often mapped to the same value (zero, in the worst case) of theO-var. This implies new variable and value ordering heuristics are necessary
for dual encoding to benefit from its strong propagation power.