Minimizing Conflicts: A Heuristic Repair Method For Constraint Satisfaction and Scheduling Problems
Minimizing Conflicts: A Heuristic Repair Method For Constraint Satisfaction and Scheduling Problems
Elsevier
ARTINT 952
Mark D. Johnston
Space Telescope Science Institute, 3700 San Martin Drive, Baltimore, MD 21218, USA
Andrew B. Philips
Sterling Federal Systems, NASA Ames Research Center, AI Research Branch,
Mail Stop: 269-2, Moffett Field, CA 94035, USA
Philip Laird
NASA Ames Research Center, AI Research Branch, Mail Stop: 269-2, Moffett Field,
CA 94035, USA
Abstract
Minton, S., M.D. Johnston, A.B. Philips and P. Laird, Minimizing conflicts: a heuristic
repair method for constraint satisfaction and scheduling problems, Artificial Intelligence 58
(1992) 161-205.
The paper describes a simple heuristic approach to solving large-scale constraint satisfaction
and scheduling problems. In this approach one starts with an inconsistent assignment for a
set of variables and searches through the space of possible repairs. The search can be guided
by a value-ordering heuristic, the min-conflicts heuristic, that attempts to minimize the
number of constraint violations after each step. The heuristic can be used with a variety of
different search strategies.
We demonstrate empirically that on the n-queens problem, a technique based on this
approach performs orders of magnitude better than traditional backtracking techniques. We
also describe a scheduling application where the approach has been used successfully. A
theoretical analysis is presented both to explain why this method works well on certain types
of problems and to predict when it is likely to be most effective.
Correspondence to: S. Minton, Sterling Federal Systems, NASA Ames Research Center, AI
Research Branch, Mail Stop: 269-2, Moffett Field, CA 94035, USA.
1. Introduction
network, and then describe our symbolic method for heuristic repair. Follow-
ing this, we describe empirical results with the n-queens problem, graph-
colorability problems and the Hubble Space Telescope scheduling application.
Finally, we consider a theoretical model identifying general problem charac-
teristics that influence the performance of the method.
J The network, which is programmed in LISP, requires approximately 11 minutes to solve the
1024 queens problem on a TI Explorer II. For larger problems, memory becomes a limiting factor
because the network requires approximately O(n 2) space. (Although the number of connections is
actually O(n3), some connections are computed dynamically rather than stored.)
166 S. M i n t o n et al.
0 = solution
domized search algorithm, called a Las Vegas algorithm [5]. The algorithm
begins by selecting a path from the root to a leaf. To select a path, the
algorithm starts at the root node and chooses one of its children with equal
probability. This process continues recursively until a leaf is encountered. If
the leaf is a solution the algorithm terminates, if not, it starts over again at the
root and selects a path. The same path may be examined more than once, since
no m e m o r y is maintained between successive trials.
The Las Vegas algorithm does, in fact, perform better than simple depth-first
search on n-queens. In fact, this result was already known [5]. However, the
performance of the Las Vegas algorithm is still not nearly as good as that of the
G D S network, and so we concluded that the systematicity hypothesis alone
cannot explain the network's behavior.
Min-Conflicts heuristic:
Given: A set of variables, a set of binary constraints, and an
assignment specifying a value for each variable. Two variables
conflict if their values violate a constraint.
Minimizing conflicts: a heuristic repair method 167
2 In general, the heuristic attempts to minimize the number of other variables that will need to
be repaired. For binary CSPs, this corresponds to minimizing the number of conflicting variables.
For general CSPs, where a single constraint may involve several variables, the exact method of
counting the number of variables that will need to be repaired depends on the particular constraint.
The space telescope scheduling problem is a general CSP, whereas the other tasks described in this
paper are binary CSPs.
168 S. Minton et al.
Begin program
Let VARS-LEFT = list of all variables, each assigned an initial value.
Let VARS-DONE = nil
Call INFORMED-BACKTRACK(VARS-LEFT VARS-DONE)
End program
augmented with the min-conflicts heuristic to order its choice of which variable
and value to attend to. This illustrates an important point. The backtracking
repair algorithm incrementally extends a consistent partial assignment (i.e.,
VARS-DONE), as does a constructive backtracking program, but in addition,
uses information from the initial assignment (i.e., VARS-LEFF) tO bias its
search. Thus, it is a type of i n f o r m e d backtracking. We still characterize it as
repair-based method since its search is guided by a complete, inconsistent
assignment.
4. Experimental results
These strategies provide a starting point for our analysis, although many more
sophisticated search strategies exist. In general, these two strategies have the
following advantages and disadvantages:
(1) Hill climbing. This strategy most closely replicates the behavior of the
GDS network. The disadvantage is that a hill-climbing program can get
caught in local maxima, in which case it will not terminate.
(2) Informed backtracking. As described earlier, this strategy is a standard
backtracking strategy augmented with the min-conflicts heuristic for
ordering the assignment of variables and values; this can be viewed as
backtracking in the space of possible repairs. The advantage of this
strategy is that it is complete--if there is a solution, it will eventually be
found; if not, failure will be reported. Unfortunately, this is of limited
significance for large-scale problems because terminating in a failure can
take a very long time.
repair, the program selects a queen that is in conflict and moves it to the
column (within the same row) where it conflicts with the fewest other queens
(breaking ties randomly). A repair can be accomplished in O(n) time by
maintaining a list of the queens currently in conflict and an array of counters
indicating the number of queens in each column and diagonal.
Interestingly, in our initial experiments we found that the hill-climbing
program performs significantly better than the network. For n ~> 100 the
program has never failed to find a solution. Moreover, the required number of
repairs appears to remain constant as n increases. For comparison, recall that
the required number of repairs for the network increases linearly with n. After
further analysis, we found that this discrepancy can be accounted for by the
network's and the hill-climbing program's different initialization processes. In
particular, whereas the network starts with no queens assigned in the initial
state, the hill-climbing program's preprocessing phase invariably produces an
initial assignment that is "close" to a solution. As shown in Table 1, the
number of conflicting queens in the initial assignment grows extremely slowly,
from a mean of 3.1 for n = 10 to a mean of 12.8 for n = 10~. We found that if
we start the network in an initial state produced by our preprocessing
algorithm, the network and the hill-climbing program perform comparably.
(We note, however, that the network requires O(n 2) space, as compared to the
O(n) space required by the hill-climbing program, which prevented us from
running very large problems on the network.) On the other hand, if we start
the hill-climbing program with a random initial assignment, the required
number of repairs tends to grow linearly. This is not surprising, since the
n u m b e r of conflicts in a random finitialization also tends to grow linearly.
Table 2 compares the efficiency of our hill-climbing program and several
backtracking programs. Each program was run one hundred times for n
increasing from ten to one million. Each entry in the table shows the mean
number of queens moved, where each move is either a backtrack or a repair,
depending on the program. A bound of n x 100 queen movements was
employed so that the experiments could be conducted in a reasonable amount
of time; if the program did not find a solution after moving n x 100 queens, it
was terminated and credited with n x 100 queen movements. For the cases
Table 1
Number of conflicts after initialization.
Conflicts after
n initialization
n = 10 ~ 3,11
n = 102 7,35
n = 10 ~ 9.75
n = 10 4 10,96
n = 105 12,02
n = 10" 12.80
Minimizing conflicts: a heuristic repair method 171
T ab le 2
N u m b e r of b a c k t r a c k s / r e p a i r s for n-queens algorithms.
Constructive Repair-based
when this occurred, the corresponding table entry indicates in parentheses the
percentage of times the program completed successfully. The first column
shows the results for a standard constructive backtracking program. For
n/> 1000, the program was ineffective. The second column in the table shows
the results for informed backtracking using the "most-constrained first" heuris-
tic. This program is a constructive backtracking program that selects the row
that is most constrained when choosing the next row on which to place a
queen. In an empirical study of the n-queens problem, Stone and Stone [39]
found that this was by far the most powerful heuristic for the n-queens problem
out of several described earlier by Bitner and Reingold [4]. The program
exhibited highly variable behavior. At n -- 1000, the program found a solution
on only 81% of the runs, but three-quarters of these successful runs required
fewer than 100 backtracks. Unfortunately, for n > 1000, one hundred runs of
the program required considerably more than 12 hours on a SPARCstationl,
both because the mean number of backtracks grows rapidly and because the
"most-constrained first" heuristic takes O(n) time to select the next row after
each backtrack. Thus we were prevented from generating sufficient data for
n > 1000. The next column in the table shows the results for hill climbing using
the min-conflicts heuristic. As discussed above, this algorithm performed
extremely well, requiring only about 50 repairs irrespective of problem size.
The final column shows the results for an informed backtracking program that
uses the min-conflicts heuristic, backtracking within the space of possible
repairs as described in the previous section. We augmented this program with a
pruning heuristic that would prune a path when the number of constraint
violations began to increase significantly. However, this proved unnecessary for
large n. For n/> 100, this program never backtracked (i.e., no queen had to be
repaired more than once). This last program performs better than the hill-
climbing program (although there is little room for improvement) primarily
because the hill-climbing program may move the same queen repeatedly, which
degrades its performance.
A disadvantage of the min-conflicts heuristic is that the time to accomplish a
172 S. M i n t o n et al.
repair grows with the size of the problem. For n-queens, as noted above, each
repair requires O(n) time in the worst case. Of course, most heuristic methods
require time to determine the best alternative at a choice point. For example,
the "most-constrained" heuristic also requires O(n) time at each choice point•
However, with min-conflicts the tradeoff is clearly cost effective, at least for
n-queens. Since the number of repairs remains approximately constant as n
grows, the program's runtime is approximately linear• This is illustrated by Fig.
3, which shows the average runtime for the hill-climbing program. In terms of
realtime performance, this program solves the million queens problem in less
than four minutes on a SPARCstationl.
The cost of making a repair can be optimized for large problems, in which
case the average solution time for the million-queens problem is reduced to less
than a minute and a half. The program maintains a list of queens that are in
conflict, as well as three arrays of counters indicating the number of queens in
each column, row and diagonal• Rather than scanning a row for the position
with the fewest conflicts, the optimized program maintains a list of empty
columns (which tends to be quite small); it first checks for a zero-conflict
position by looking for an empty column with no conflicts along the diagonals.
If there is no zero-conflict position, the program repeatedly looks for a position
with one conflict by randomly selecting a position and checking the number of
conflicts in that position. Since there tend to be many positions with one
conflict, this technique tends to succeed after just a few tries, so the total
number of positions examined is generally very low.
One obvious conclusion from these results is that n-queens is actually a very
easy problem given the right method. Interesting, two other heuristic methods
that can quickly solve n-queens problems have also recently been invented.
(These two other methods and our method were all developed and published
.•
.t
100
°°"
°•'
-~ 10 ,o
r,-. o"
o
o
03 °o•
O3 1
°
°°•"
0.1
oo•o°°
•°°'
L° o,'"
0.01
1 -~ 3 4 5
10 10 10 10 10 10
Problem Size
must be before task C, then the system will explicitly represent the fact that
task A must be before task C as well. This explicit representation enables the
scheduler to obtain a more accurate assessment of the number of conflicts in a
given schedule.
In searching for a schedule, the GDS network follows the constraint
satisfaction approach outlined in Section 2. In effect, if a task is currently in
conflict then it is removed from the schedule, and if a task is currently
unscheduled then the network schedules it for the time segment that has the
fewest constraint violations. However, the network uses only the hard con-
straints in determining the time segment with the fewest violations. Soft
constraints are consulted when there are two or more "least conflicted" places
to move a task.
The min-conflicts hill-climbing method has been shown to be as effective as
the G D S network on representative data sets used for testing SPIKE, and it
was recently incorporated into the SPIKE system. One advantage in using the
min-conflicts method, as compared to the GDS network, is that much of the
overhead of using the network can be eliminated (particularly the space
overhead). Moreover, because the min-conflicts heuristic is so simple, the
min-conflicts module was quickly coded in C and is extremely efficient. (The
min-conflicts scheduler runs about an order of magnitude faster than the
network, although some of the improvement is due to factors such as program-
ming language differences, making a precise comparison difficult.) While this
may be regarded as just an implementation issue, we believe that the clear and
simple formulation of the method was a significant enabling factor. In addition,
the simplicity of the method makes it easy to experiment with various
modifications to the heuristic and the search strategy. This has significant
practical importance, since SPIKE is currently being used on other types of
telescope scheduling problems where a certain amount of modification and
tuning is required.
In general, scheduling appears to be an excellent application area for
repair-based methods. Supporting evidence comes from recent work on other
real-world scheduling applications by Zweben [44], Biefeld and Cooper [3] and
Kurtzmann [27]. Each of these projects use iterative improvement methods
which can be characterized as repair-based. There are several reasons why
repair-based methods are well-suited to scheduling applications. First, as
Zweben et al. [45] have pointed out, unexpected events may require schedule
revision, in which case dynamic rescheduling is an important issue. Repair-
based methods can be used for rescheduling in a natural manner. Second, most
scheduling applications involve optimization, at least to some degree, and
repair-based methods are also naturally extended to deal with such issues. For
example, in scheduling the Hubble Space Telescope, the goal is to maximize
the amount of observing time and the priority of the chosen observations. The
telescope is expected to remain highly over-subscribed, in that many more
Minimizing conflicts: a heuristic repair method 175
4.3. G r a p h coloring
Johnston and Adorf experimented with two classes of problem instances; one
set with m = 2 n (i.e., average vertex degree of 4) and another with
m = n(n - 1)/4. We will refer to the former as the sparsely-connected graphs,
and the latter as the densely-connected graphs.
Figure 4 compares the results published by Adorf and Johnston with our
results. In Adorf and Johnston's experiments, graphs were tested in the range
from n = 30 to n = 180. For each of the two types of graphs, three different
instances of each size were generated, and the network was run 3000 times per
176 S. M i n t o n et al.
The use of an identical bound for both programs may give the hill-climbing algorithm a slight
advantage. The GDS network requires separate transitions to deassign a variable and to assign a
new value. In the hill-climbing program a single repair, in effect, simulates two transitions by the
network (unless an initial "uncolored" value is being repaired). Additional experimentation has
revealed that this advantage is relatively small, however. In fact, Fig. 4(b) shows that on the sparse
graphs, the hill-climbing program performed a bit worse than the network for small n, although the
significance of this is unclear due to the relatively large statistical variation in the difficulty of the
smaller problems. Unfortunately, the network is no longer running, so additional experiments
cannot be run.
Minimizing conflicts: a heuristic repair method 177
(a) Dense
~ ~..""
Neural Net
200
.2
t,,-
Hill Climbing
I-
r-
m lOO
, m
o ,,I,,I,,I,,I,,I,,I,,
0 30 60 90 120 150 180
N
(b) Sparse
1.0
0
r-
~ 0.8
Hill Climbing
>
C
o 0.6
0
0
~, 0.4
0 ~
.Q
t~ Neura Net
0.2
2
, , I , , ' ~ ' ~ ~ • I ..... J , ,
0 30 60 90 120 150 180
N
Fig. 4. C o m p a r i n g the G D S network to min-conflicts hill climbing on dense and sparse graph-
coloring problems.
Essentially, this is a variable order rule consisting of two criteria. The first
criterion is a preference for the "most-constrained" variable. The tie-breaking
criterion is a preference for the "most-constraining" variable. Thus, this rule is
composed of two generic variable-ordering heuristics. No value-ordering
heuristic is required.
The rule can be incorporated in a standard backtracking algorithm in the
obvious manner. Turner [41] has shown that this algorithm will optimally color
178 s. M i n t o n et al.
Table 3
Probability that initialization alone will solve
the problem.
n Sparse graphs Dense graphs
30 63.19% 100.00%
60 50.13% 100.00%
90 40.37% 100.00%
120 32.75% 100.00%
150 32.87% 100.00%
180 23.75% 100.00%
Minimizing conflicts: a heuristic repair method 179
1.0
G) . \
~ 0.8
Brelaz Backtrack
t-
O
O
"6
0.6
-/ MC Backtrack
~ 0.4
"... MC Hill Climb
.la 0.2
2
".~,~,, %°"%.. °Oo .,o
% °%mll~° %%
%% . . . . . °°%
,, I,, I, , ' r ' , " ; - T ' ; ' . I ~"
0 30 60 90 120 150 180
initialization method (Fig. 5 and Fig. 4) shows that the initialization method
improves performance, but not dramatically.4
The experiments also demonstrate clearly that sparse graphs are much
harder to color than dense graphs, for both the Brelaz method as well as for
the min-conflicts methods. Intuitively, the reason that dense graphs are easy to
color is that they are so overconstrained that a mistake is both unlikely and
easily corrected. For min-conflicts, a mistake is easily corrected because the
choice of color at a vertex is greatly influenced by the colors of all of its
neighbors. For the Brelaz backtracking method, a mistake is easily corrected
since the subsequent choices will be pruned quickly due to the overconstrained
nature of the problem. In a study motivated in part by these experiments,
Cheeseman et al. [7] have shown that as the average connectivity of a
(connected) graph increases, a "phase transition" occurs, and it is at this point
that most of the hard graph colorability problems are found. In other words,
sine a constraint satisfaction problem is easy if it is either underconstrained or
overconstrained, hard problems can be expected to lie within the boundary
between underconstrained and overconstrained problems. Our sparsely-
connected graphs lie within this boundary area.
Figure 6 illustrates how the difficulty of sparsely-connected connected graphs
manifests itself for min-conflicts. The group of nodes on the left of the graph
represents one consistent coloring, and the group on the right represents a
different consistent coloring. But the two colorings are inconsistent with each
other. This situation frequently arises as a result of the initialization process.
On the surface, the assignment would appear to be a good one, since there are
4
Interestingly, the Brelaz initialization method actually degrades performance of the smallest
graphs (where n = 30), This is an anomaly which we cannot as yet explain.
180 S, M i n t o n et al.
there are certain practical advantages to having "extracted" this method from
the network. First, the method is very simple, and so can be programmed
extremely efficiently, especially if done in a task-specific manner. Second, the
heuristic we have identified, that is, choosing the repair which minimizes the
number of conflicts, is very general. It can be used in combination with
different search strategies and task-specific heuristics, an important factor for
most practical applications.
For example, the min-conflicts heuristic can be used in combination with a
variety of variable ordering heuristics. In the previous section, for instance, we
described a hybrid program in which the Brelaz variable ordering heuristic is
adapted for use with min-conflicts value-ordering heuristic. We have also
experimented with a hill-climbing program that uses "max-conflicts" as a
variable ordering heuristic in conjunction with the rain-conflicts value ordering
heuristic. On graph-coloring problems, the resulting program tends to out-
perform min-conflicts alone, although performance is still not as good as the
Brelaz algorithm.
Insofar as the power of our approach is concerned, our experimental results
are encouraging. We have identified two tasks, n-queens and HST scheduling,
which appear more amenable to our repair-based approach than the traditional
constructive approach that incrementally extends a consistent partial assign-
ment. This is not to say that a repair-based approach will do better than any
constructive approach on these tasks, but merely that our simple, repair-based
approach has done relatively well in comparison to the obvious constructive
strategies we tried. We also note that repair-based methods have a special
advantage for scheduling tasks, since they can be used for overconstrained
problems and for rescheduling problems in a natural manner. Thus it seems
likely that there are other applications for which our approach will prove
useful.
5. Analysis
Although a variable is in conflict, its assigned value may actually be the correct valuc. This can
happen when the variable with which it conflicts has an incorrect value. In this paper we have
defined the min-conflicts heuristic so that it can choose any possible value for the variable,
including the variable's current value.
M i n i m i z i n g conflicts: a heuristic repair m e t h o d 183
will not make a mistake if the number of conflicts N b for each incorrect value is
greater than d. We can, therefore, bound the probability of making a mistake
by bounding the probability that N b is less than or equal to d.
To bound N b, we use Hoeffding's inequality, which states that the sum N of
n independent, identically distributed random variables is less than the expec-
-2s2n
ted value ~ / b y more than sn only with probability at most e , for any s >i 0.
In our model, N b is the sum of c potential conflicts, each of which is either 1 or
0, depending on whether there is a conflict. The expected value of N b is pc.
Thus:
-2s2c
Pr(N b ~<p c - sc) <<-e
Since we are interested in the behavior of the min-conflicts heuristic as d
shrinks, let us suppose that d is less than pc. Then, with s = ( p c - d ) / c , we
obtain:
Pr(N b <~ d ) <~ e 2(pc-d)2/c .
T o account for the fact that a mistake can occur if a n y of the k - 1 incorrect
values has d or fewer conflicts, we bound the probability of making a mistake
on any of them by multiplying by k - 1:
P r ( m i s t a k e ) <~ ( k - 1) e - 2(pc-d)z/c .
Note that as c (the number of constraints per variable) becomes large, the
probability of a mistake approaches zero if all other parameters remain fixed.
This analysis thus offers an explanation as to why 3-coloring densely-connected
graphs is relatively easy. We also see that as d becomes small, a mistake is also
less likely, explaining our empirical observation that a " g o o d " initial assign-
ment can be important. (Of course, an assignment with few conflicts does not
necessarily imply small d, as was illustrated by the 3-colorability problem in
Fig. 6.) In a recent paper, Musick and Russell [35] present an analysis which
supports this result. They model heuristic repair algorithms as Markov pro-
cesses, and show that under this model the choice of initial state can have a
significant impact on the expected solution time.
Finally, we note that the probability of a mistake also depends on p, the
probability that an incorrect value conflicts with another variable's value, and
k, the number of values per variable. The probability of a mistake shrinks as p
increases or k decreases.
Pd~d 1 = P~P,.Is ,
= Z
w>o
• Pc~e =-Pe~c is the probability that a correct value for variable V conflicts
with an incorrect value for variable V', and
• Pete is the probability that an incorrect value for variable V conflicts with
an incorrect value for variable V',
Table 4
Summary of notation.
r/ Number of variables
k Values per variable
C Binary constraints per variable
d Distance to solution (number of variables with incorrect values)
Pd ~d I Probability that after a repair step d decreases
Pd~d+ I Probability that after a repair step d increases
Pd ~d Probability that after a repair step d is unchanged
P~ Probability that the variable chosen is currently assigned a
non-solution (i.e., incorrect) value
P,i~ Probability of choosing a correct value, given that a non-solution
value is currently assigned
O (v) For a variable currently assigned a solution value, probability that an
incorrect value has v conflicts
Pc~¢ Probability that a correct value for variable V conflicts with an incorrect
value for variable V'
In general, subscripts s and £ indicate variables assigned solution and non-solution values,
respectively. For a given variable, the subscripts c and 6 refer to correct and incorrect values,
respectively.
I n c o r r e c t values can conflict with the d incorrectly assigned variables, each with
probability p~, a n d with the o t h e r n - d - 1 correctly assigned variables,
each with p r o b a b i l i t y Pc~,~. T h e d i s t r i b u t i o n is:
O~(v) = B ( v , p , . ~ , d - 1 ) .
Oe~(v) = ~ B ( k , P e t e , d - 1 ) B ( v - k, P ~ . e , n - d ) .
k=O
c k'
Pete- n-1 k-1 "
Values for P c . e and Pe.e are given in Table 5 for some illustrative problem
types, including sparse and dense graph 3-colorability problems. For com-
parison, the table also shows the corresponding values for the random problem
described by Dechter and Pearl [8].
Table 5
Probabilities of conflicts between solution and non-solution values Pc,e, and between non-solution
and non-solution values Pe,e, for some CSPs that can be treated as " r a n d o m " . For graph
3-colorability problems the m e a n vertex degree (VD) of the problem graph is indicated. T h e
D e c h t e r - P e a r l problem, shown for comparison, has probability p~ of a constraint between
variables, and P2 that a constraint permits any specific pair of values, c is the m e a n n u m b e r of
variables constrained by any variable, k' is the m e a n n u m b e r of values prohibited by a constraint
b e t w e e n two variables and k is the domain size.
D e n s e graph 2 1 n l n
3-colorability ~ -n 1 3
3 n-1 6"n-1
V D = 2n/3
Dechter-Pearl p,(1 - pz)kn p,(1 - pz)k(k - 2)n
general case p~n (1 - p E ) k k
(k - 1)(n - 1) (k - l)2(n - 1)
Dechter-Pearl
k=5 1 1 n 3 n
pI=0.5, p~=0.6 ~.n 2 U n- a 16 n-1
188 S. Minton et al.
Note that with this rule there need be no change in the assignment.
conflicts, the probability of choosing the correct value is 1/(m + 1). Thus the
total probability of choosing the correct value, given that it has v conflicts, is:
The probability of v conflicts on the correct value, given that it has > 0
conflicts, is O,,~(v)/[1 - 0c~(0)]. Combining these yields the total probability that
the heuristic will leave the assignment unchanged:
= o~.~(~)
(1) o > w. The correct value will not be chosen since the current value has
fewer conflicts, so P~°'(v, w)lv> w = 0.
(2) v = w. In this case we have to consider the other k - 2 incorrect values.
Summing over configurations where m have exactly v conflicts, and the
remaining k - 2 - m have > v conflicts, yields:
(3) v < w. Similar to case (2) except that in this case the heuristic will
certainly not leave the assignment unchanged, so the probability of
choosing the correct value increases from 1/(m + 2) to l / ( m + 1):
k-2
=- =
,,=0 m + 1 "
The total probability of choosing the correct value is
P,b~ = ,,-,
~ a-,
~ O,=,.(v) O~(w) p~O,(v' w),
~=1 o=,1 1 -00)
using the fact that the probability of v conflicts on an incorrect value, given that
the value has > 0 conflicts, is Oe~(v)/[1- 0cs(0)].
whether or not there are any conflicts on values. This approach is captured by
the "random-conflicts" rule:
If one or more values has no conflicts, select one of these values (at
random). If all values have conflicts, select one at random.
P,ls = 0,-~(>0) k i 1
~ k
and
= 0 ( > 0 ) k-2 1
,s, .
psolz
£v, w) is the probability of choosing the correct value for a variable with v
conflicts on the correct value and w > 0 conflicts on an incorrect value.
With this rule, the probability of choosing the correct value is independent of
the variable's currently assigned value:
P,I~ = P,~I.~ = 1 / k .
Select for repair a variable at random from the set of all variables
that are currently in conflict.
N~..... f = d [ 1 - Oe~(O)].
Minimizing conflicts: a heuristic repair method 191
Now consider a variable that is assigned a correct value. The probability that
there are one or more conflicts on its assigned value is 1 - 0c~(0). Since there
are a total of n - d such variables, the expected number with conflicts is
Ns.conf
P" = N~.... f + N~.... f '
while the probability that is currently assigned an incorrect value is:
N~,conf
pC = 1 - P~ = Ns . . . . f -[" N . . . . . f
5.6. I. R a n d o m CSPs
We have taken two graph 3-colorability problems for comparison of the
heuristics:
The relevant conflict probabilities for these two problems are given in Table 5.
Probabilities were calculated for both problem types for n = 90. Value selection
heuristics are labelled as follows in Figs. 8-10: MC rain-conflicts (Section
5.4.1); RC random-conflicts (Section 5.4.2); and R random (Section 5.4.3).
Variable selection
Figure 7 shows P~ vs, d/n, the probability that a variable currently assigned
an incorrect value will be chosen for repair. The probability is lower for the
densely-connected E3C problem, since even a small number of incorrectly
assigned variables can introduce a large number of conflicts.
192 S. Minton et al.
::.~0.81
....... ~..............!...........':,,'i-~...
i 1
0.2...........>;Ti,.'\
.J
.......E3C
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.*.
o 0.2 0.4 0.6 0.8
d/N
Fig. 7. Probability of selecting a variable that is assigned an incorrect value for H3C and E3C
random problems.
Value selection
Figure 8 compares value selection for the two problems. Here it is desirable
that both P,+ (Figs. 8(a), (b)) and P, is (Figs. 8(c), (d)) be as large as possible.
Random value selection (labelled R in the figures) has uniform probability 31
making the correct choice in both problems. For H3C variables with correct
values assigned (Fig. 8(a)), RC does worse than random, and MC does better
only for small d/n. In contrast, for variables that have incorrect values (Fig.
8(c)), the probability is fairly high for both MC and RC that the correct value
will be selected, with MC showing slightly better performance. For E3C (Figs.
8(b), (d)), MC has probability near unity of choosing the correct value,
whether or not the current value is correct. RC does no better than random
except for variables currently assigned incorrect values and d/n < 0 . 2 (Fig.
8(d)).
o: 0
0.2 0.4 0.6 0.8 o.2 0.4 o:6 ole 1'
diN diN
1 [',~., i Pcli
0.8. '- ............ i .............. ~............. ÷ ......
i Mei
0 0
0 0.2 0.4 0.6 0.8 0.2 0.4 0.6 0.8 1
diN din
Fig. 8. Probability of choosing correct values for variables currently assigned correct or incorrect
values.
more likely to improve the state than to worsen it. Figure 10 plots this ratio on
a logarithmic scale vs. d/n for each of the three value selection methods. For
H3C (Fig. 10(a)), MC is best (for d ~ n), followed by RC and R, but in all
cases the ratio is <1. For E3C (Fig. 10(b)) the results are very different: MC
shows a much higher chance of improving the state, while both RC and R
worsen it. RC is significantly better than R only for very small d/n.
!Pd~d.li
0.8 ........................................................................ 0.8 .............
............. ~.............. i .............. ~ d:!
o.8 ............... i .............. i .............. i .............. i .............
0 . 0 ............................. i ..........................................
0,4'
MC
0.4 .............. ,.............. ~.............. ' .............. ;'.............
0.2, "LAI°" l
ol i i I 0
0.2 0.4 0.6 0.8 1
0 0.2 0.4 0.6 0.0 1
d/N d/N
. ~ ~.-\
o I 0
0 0.2 0.4 0.6 0.8 0 0.2 "0:4 0:6 0:8
diN diN
lOOOt
,ool
! !
1000
IO0
\i '/'MC :
10-
............. "i....... i N . i i / :
1-
i ~c,~ i\_...i"
RC ~............ ~ .............
............. ~ i ~~ .......T.............
lated empirically the same probabilities that are predicted by the statistical
model. Fig. 11 shows the comparison for MC value selection: the empirical
data points, indicated by the + and × symbols, show the results of averaging
200 states for each value of d. The agreement with the model probability
calculations is excellent.
5.6.2. n-queens
We have evaluated the simplified n-queens model of Section 5.3.2 and
Appendix A for min-conflicts value selection. Figure 12 shows the quantities
Pd-~d-1, Pd~d+], and the ratio Pd-u ]/Pd~d+1 for small d for n = 64, 96, 128,
and 256. As n increases, the relative probability of moving towards the solution
increases as well. While this is in accordance with the experimental results, the
0.0, 0,
i
1i . . . . :r". . . . . . . . . . . i i i
. . . . . . . . . . . . . ! ~ . . . . . . . . . . . L. . . . . . . . . . . . . . i . . . . . . . . . . . . . + .............
".4 . IN
o: . . . . . . . :'''1'''I'' 0
0.2 0,4 0.6 0.8 0 0.2 0,4 0.6 0.8
d/N diN
Fig. 11. Comparison of predicted results with empirical results for min-conflicts value selection.
(a) (b)
,256
0.01 .........................................................,...........
. . . . . m 1
10 I0
d
model does not permit more quantitative comparison due to the simplifying
assumption that the mean conflicts on incorrect values is 3 (instead of the
actual ~2.5). The situation for n-queens is further complicated by the fact that
solutions appear to be relatively numerous, violating the model assumption
that there is a unique solution.
There are two interesting limiting cases of the model for random CSPs,
corresponding to limiting forms of the conflict probability distribution functions
0 (see Section 5.3.1). These limits are discussed in this section.
(e-")/(f/z) v
o~,,(v) ~ o,~(v) ~-
v!
h e r e / x = np,. The result is independent of n, and thus we have the important
conclusion that the performance of value selection heuristics depends only on
d/n in the Poisson limit Pc ~ 1/n for small npc. This is also true of the variable
selection method used in the model (which depends only on 0 , ( 0 ) and 0,,(0)).
Figure 13(a) illustrates this dependence on d/n for the H3C problem for
n = 30, 60, and 90: the differences are already nearly indistinguishable.
0.3-
°"t.............
il! ...........
! i .~" ii .............
0.2. ............
0.1. ....
O.
0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.0 0.8
d/N d/N
Fig. 13. Scaling behavior with n for variable selection method.
Minimizing conflicts: a heuristic repair method 197
d0
tct°~° = = t
/.tV~ exp -
for large t. The important point is the predicted exponential decline in the
probability of reaching the solution as the number of hill-climbing steps in-
creases. This result provides an explanation for the observed behavior of the
G D S network and of min-conflicts hill climbing on sparse 3-colorable graphs as
described above in Section 4.3: when the number of steps is limited to t ~ n,
there is an exponential decline with problem size n of the probability of finding
the solution.
Two other limitations are worth noting, since we have analyzed the min-
conflicts heuristic independent of the initialization process and search strategy.
First, the model permits no conclusions about the assignment being repaired,
yet the construction of a good initial guess (i.e. an assignment such that d is
small) is a key problem for repair methods. Second, since the model ignores all
fine structure in the problem, the possibility of pathological configurations is
not considered. This can manifest itself in hill-climbing techniques as "cycles",
where the same variables are repaired again and again, but no progress is made
towards the solution. To model the performance of the min-conflicts heuristic
in conjunction with a particular search strategy, such as hill-climbing a more
detailed analysis is required. For example, in a recent paper, Morris [33]
examines the structure of the n-queens problem, and shows analytically that,
for min-conflicts hill-climbing, almost all local minima are solutions.
6. Discussion
In part, this is due to the way the problems are represented. For example, in
the HST problem, as described earlier, the transitive closure of temporal
constraints is explicitly represented. For example, if task A must precede task
B, then all tasks that precede A must also precede B, and all such constraints
are explicitly represented. This improves performance because the min-
conflicts heuristic is less likely to violate a set of constraints than a single
constraint. In some cases, we expect that more sophisticated techniques will be
necessary to identify critical constraints [11]. To this end, we arc currently
evaluating explanation-based learning techniques [9] as a method for identify-
ing critical constraints.
The algorithms described in this paper also have an important relation to
previous work in AI. In particular, there is a long history of AI programs that
use repair or debugging strategies to solve problems, primarily in the areas of
planning and design [37, 40]. This approach has recently had a renaissance with
the emergence of case-based [14,26] and analogical [17, 24,42] problem
solving. To solve a problem, a case-based system will retrieve the solution from
a previous, similar problem and repair the old solution so that it solves the new
problem.
The fact that the min-conflicts approach performs well on n-queens, a
well-studied, "standard" constraint-satisfaction problem, suggests that AI re-
pair-based approaches may be more generally useful than previously thought.
Additional evidence also comes from a very recent study by Selman, Levesque
and Mitchell [36], in which they showed that a repair-based algorithm (very
similar to the hill-climbing algorithms investigated here) performs well on hard
satisfiability problems. However, as we have pointed out, in some cases it can
be more time-consuming to repair a solution than to construct a new one from
scratch. It may be that our analysis of min-conflicts for CSP problems can be
extended to repair methods for other tasks, such as case-based planning
methods. We conjecture that for each of the factors affecting the performance
of min-conflicts, such as the expected "distance" from the initial assignment to
the solution and the degree that each variable is constrained, there are
analogous factors for other tasks.
There are many possible extensions to the work reported here, but three are
particularly worth mentioning. First, we expect that there are other applica-
tions for which the min-conflicts approach will prove useful. Conjunctive
matching, for example, is an area where preliminary results appear promising.
This is particularly true for matching problems that require only that a good
partial-match be computed. Second, we expect that there are interesting ways
in which the min-conflicts heuristic could be combined with other heuristics.
For example, as mentioned earlier, when a "most-conflicted" variable ordering
strategy is used together with min-conflicts, the resulting program outperforms
min-conflicts alone on graph 3-colorability problems. Finally, there is the
possibility of employing the min-conflicts heuristics with other search tech-
Minimizing conflicts: a heuristic repair method 201
niques. In this paper, we only considered two very basic methods, hill climbing
and backtracking. However, more sophisticated techniques such as best-first
search are obvious candidates for investigation, since the number of conflicts in
an assignment can serve as a heuristic evaluation function. Another possibility
is Tabu search [16], a hill-climbing technique that maintains a list of forbidden
moves in order to avoid cycles. Morris [31,32] has also proposed a hill-
climbing method which can break out of local maxima by systematically
altering the cost function. The work by Morris and much of the work on Tabu
search bears a close relation to our approach.
7. Conclusions
8. Acknowledgement
pq _ 3i
(n - 1) 2 "
w h e r e P2 = 3i(n - 1) 2.
References
[1] B. Abramson and M. Yung, Divide and conquer under global constraints: a solution to the
n-queens problem, J. Parallel Distrib. Comput. 61 (1989) 649-662.
[2] H.M. Adorf and M.D. Johnston, A discrete stochastic neural network algorithm for con-
straint satisfaction problems, in: Proceedings International Joint Conference on Neural Net-
works, San Diego, CA (1990).
[3] E. Biefeld and L. Cooper, Bottleneck identification using process chronologies, in: Proceed-
ings IJCAI-91, Sydney, Australia (1991).
[4] J. Bitner and E.M. Reingold, Backtrack programming techniques, Commun. ACM 18 (1975)
651-655.
[5] G. Brassard and P. Bratley, Algorithmics--Theory and Practice (Prentice Hall, Englewood
Cliffs, N J, 1988).
[6] D. Brelaz, New methods to color the vertices of a graph, Commun. ACM 22 (1979) 251-256.
[7] P. Cheeseman, B. Kanefsky and W.M. Taylor, Where the really hard problems are, in:
Proceedings IJCAI-91, Sydney, Australia (1991).
[8] R. Dechter and J. Pearl, Network-based heuristics for constraint-satisfaction problems, Artif.
Intell. 34 (1988) 1-38.
[9] M. Eskey and M. Zweben, Learning search control for constraint-based scheduling, in:
Proceedings AAAI-90, Boston, MA (1990).
[10] M.S. Fox, Constraint-Directed Search: A Case Study of Job-Shop Scheduling (Morgan
Kaufmann, San Mateo, CA, 1987).
[11] M.S. Fox, N. Sadeh and C. Baykan, Constrained heuristic search, in: Proceedings IJCAI-89,
Detroit, MI (1989).
[12] E.C. Freuder, Partial constraint satisfaction, in: Proceedings IJCAI-89, Detroit, MI (1989);
also: Artif. Intell. 58 (1992) 21-70 (this volume).
[13] M.L. Ginsberg and W.D. Harvey, Iterative broadening, in: Proceedings AAA1-90, Boston,
MA (1990).
[14] K.J. Hammond, Case-based planning: an integrated theory of planning, learning and mem-
ory, Ph.D. Thesis, Yale University, Department of Computer Science, New Haven, CT
(1986).
[15] R.M. Haralick and G.L. Elliot, Increasing tree search efficiency for constraint satisfaction
problems, Artif. Intell. 14 (1980) 263-313.
[16] A. Hertz and D. de Werra, Using tabu search techniques for graph coloring, Computing 39
(1987) 345-351.
[17] A.K. Hickman and M.C. Loven, Partial match and search control via internal analogy, in:
204 S. Minton et al.
derivation analogy in prodigy, in: S. Minton, ed., Machine Learning Methods for Planning
and Scheduling (Morgan Kaufmann, San Mateo, CA, 1992).
[43] M. Waldrop, Will the Hubble space telescope compute?, Science 243 (1989) 1437-1439.
[44] M. Zweben, A framework for iterative improvement search algorithms suited for constraint
satisfaction problems, Tech. Rept. RIA-90-05-03-1, NASA Ames Research Center, AI
Research Branch (1990).
[45] M. Zweben, M. Deale and R. Gargan, Anytime rescheduling, in: Proceedings Workshop on
Innovative Approaches to Planning, Scheduling and Control (Morgan Kaufmann, San Mateo,
CA, 1990).