Activity-Based Search for Black-Box Contraint-Programming Solvers
Robust search procedures are a central component in the design of black-box constraint-programming solvers. This paper proposes activity-based search, the idea of using the activity of variables during propagation to guide the search. Activity-based search was compared experimentally to impact-based search and the wdeg heuristics. Experimental results on a variety of benchmarks show that activity-based search is more robust than other heuristics and may produce significant improvements in performance.
Historically, the constraint-programming (CP) community has focused on developing open, extensible optimization tools, where the modeling and the search procedure can be specialized to the problem at hand. This focus stems partially from the roots of CP in programming languages and partly from the rich modeling language typically found in CP systems. While this flexibility is appealing for experts in the field, it places significant burden on practitioners, reducing its acceptance across the wide spectrum of potential users. In recent years however, the constraint-programming community devoted increasing attention to the development of black-box constraint solvers. This new focus was motivated by the success of Mixed-Integer Programming (MIP) and SAT solvers on a variety of problem classes. MIP and SAT solvers are typically black-box systems with automatic model reformulations and general-purpose search procedures. As such, they allow practitioners to focus on modeling aspects and may reduce the time to solution significantly.
This research is concerned with one important aspect of black-box solvers: the implementation of a robust search procedure. In recent years, various proposals have addressed this issue. Impact-based search (Ibs)  is motivated by concepts found in MIP solvers such as strong branching and pseudo costs. Subsequent work about solution counting can be seen as an alternative to impacts  that exploits the structure of CP constraints. The weighted-degree heuristic (wdeg)  is a direct adaptation of the SAT heuristic Vsids to CSPs that relies on information collected from failures to define the variable ordering.
This paper proposes Activity-Based Search (Abs), a search heuristic that recognizes the central role of constraint propagation in constraint-programming systems. Its key idea is to associate with each variable a counter which measures the activity of a variable during propagation. This measure is updated systematically during search and initialized by a probing process. Abs has a number of advantages compared to earlier proposals. First, it does not deal explicitly with variable domains which complicates the implementation and runtime requirements of Ibs. Second, it does not instrument constraints which is a significant burden in solution-counting heuristics. Third, it naturally deals with global constraints, which is not the case of wdeg since all variables in a failed constraint receive the same weight contribution although only a subset of them is relevant to the conflict. Abs was compared experimentally to Ibs and wdeg on a variety of benchmarks. The results show that Abs is the most robust heuristic and can produce significant improvements in performance over Ibs and wdeg, especially when the problem complexity increases.
2 Impact-Based Search
Impact-based search was motivated by the concept of pseudo-cost in MIP solvers. The idea is to associate with a branching decision a measure of how effectively it shrinks the search space. This measure is called the impact of the branching decision.
Let be a CSP defined over variables , domains , and constraints . Let denote the domain of variable and denote the size of this domain. A trivial upper-bound on the size of the search space of is given by the product of the domain sizes:
At node , the search procedure receives a CSP , where and is the constraint posted at node . Labeling a variable with value adds a constraint to to produce, after propagation, the CSP .
The contraction of the search space induced by a labeling is defined as
when the assignment produces a failure since and whenever , i.e., whenever there is almost no domain reduction. An estimate of the impact of the labeling constraint over a set of search tree nodes can then be defined as
Actual implementations (e.g., ) rely instead on
where is a parameter of the engine and the subscripts in and denote the impact before and after the update. Clearly, yields a forgetful strategy, gives a running average that progressively decays past impacts, while a choice favors past information over most recent observations.
The (approximate) impact of a variable at node is defined as
To obtain suitable estimates of the assignment and variable impacts at the root node, Ibs simulates all the possible assignments. For large domains, domain values are partitioned in blocks. Namely, for a variable , let with . The impact of a value () is then set to . With partitioning, the initialization costs drop from propagations to propagations (one per block). The space requirement for Ibs is , since it stores the impacts of all variable/value pairs.
The Search Procedure
Ibs defines a variable and a value selection heuristic. Ibs first selects a variable with the largest impact, i.e., . It then selects a value with the least impact, i.e., . Neither nor are guaranteed to be a singleton and, in case of ties, Ibs breaks the ties uniformly at random.
As any randomized search procedure, Ibs can be augmented with a restart strategy. A simple restarting scheme limits the number of failures in round to and increases the limit between rounds to where .
3 The Wdeg Heuristic
wdeg maintains, for each constraint, a counter (weight) representing the number of times a variable appears in a failed constraint, i.e., a constraint whose propagation removes all values in the domain of a variable. The weighted degree of variable is defined as
where is the set of uninstantiated variables in .
wdeg only defines a variable selection heuristic: It first selects a variable with the smallest ratio . All the weights are initialized to 1 and, when a constraint fails, its weight is incremented. The space overhead of wdeg is for a CSP .
4 Activity-Based Search
Abs is motivated by the key role of propagation in constraint-programming solvers. Contrary to SAT solvers, CP uses sophisticated filtering algorithms to prune the search space by removing values that cannot appear in solutions. Abs exploits this filtering information and maintains, for each variable , a measure of how often the domain of is reduced during the search. The space requirement for this statistic is . Abs can optionally maintain a measure of how much activity can be imputed to each assignments in order to drive a value-selection heuristic. If such a measure is maintained, the space requirement is proportional to the number of distinct assignments performed during the search and is bounded by . Abs relies on a decaying sum to forget the oldest statistics progressively, using an idea from Vsids. It also initializes the activity of the variables by probing the search space.
Abs is simple to implement and does not require sophisticated constraint instrumentation. It scales to large domains without special treatment and is independent of the domain sizes when the value heuristic is not used. Also, Abs does not favor variables appearing in failed constraints, since a failure in a CP system is typically the consequence of many filtering algorithms.
Given a CSP , a CP solver applies a constraint-propagation algorithm after a labeling decision. produces a new domain store enforcing the required level of consistency. Applying to identifies a subset of affected variables defined by
The activity of , denoted by , is updated at each node of the search tree by the following two rules:
where is the subset of affected variables and be an age decay parameter satisfying . The aging only affects free variables since otherwise it would quickly erase the activity of variables labeled early in the search.
The activity of an assignment at a search node is defined as the number of affected variables in when applying on , i.e.,
As for impacts, the activity of over the entire tree can be estimated by an average over all the tree nodes seen so far, i.e., over the set of nodes . The estimation is thus defined as
Once again, it is simpler to favor a weighted sum instead
where the subscripts on capture the estimate before and after the update. When the value heuristic is not used, it is not necessary to maintain which reduces the space requirements without affecting variable activities.
The Search Procedure
Abs defines a variable ordering and possibly a value ordering. It selects the variable with the largest ratio , i.e., the most active variable per domain value. Ties are broken uniformly at random. When a value heuristic is used, Abs selects a value with the least activity, i.e., . The search procedure can be augmented with restarts. The activities can be used “as-is” to guide the search after a restart. It is also possible to reinitialize activities in various ways, but this option was not explored so far in the experimentations.
Abs uses probing to initialize the activities. Consider a path going from the root to a leaf node in a search tree for the CSP . This path corresponds to a sequence of labeling decisions in which the decision labels variable with . If is the subset of variables whose domains are filtered as a result of applying after decision , the activity of variable along path is defined as where
if was never involved in any propagation along and if the domain of was filtered by each labeling decision in . Also, when (no aging) and path is followed.
Now let us now denote the set of all paths in some search tree of . Each such path defines an activity for each variable . Ideally, we would want to initialize the activities of as the average over all paths in , i.e.,
Abs initializes the variables activities by sampling to obtain an estimate of the mean activity from a sample . More precisely, Abs repeatedly draws paths from . These paths are called probes and the assignment in a probe is selected uniformly at random as follows: (1) is a free variable and (2) value is picked from . During the probe execution, variable activities are updated normally but no aging is applied in order to ensure that all probes contribute equally to . Observe that some probes may terminate prematurely since a failure may be encountered; others may actually find a solution if they reach a leaf node. Moreover, if if a failure is discovered at the root node, singleton arc-consistency  has been established and the value is removed from the domain permanently.
The number of probes is chosen to provide a good estimate of the mean activity over the paths. The probing process delivers an empirical distribution of the activity of each variable with mean and standard deviation . Since the probes are iid, the distribution can be approximated by a normal distribution and the probing process is terminated when the 95% confidence interval of the t-distribution, i.e., when
is sufficiently small (e.g., within of the empirical mean) for all variables with being the number of probes,
Observe that this process does not require a separate instrumentation. It uses the traditional activity machinery with . In addition, the probing process does not add any space requirement: the sample mean and the sample standard deviation are computed incrementally, including the activity vector for each probe as it is completed. If a value heuristic is used the sampling process also maintains for every labeling decision attempted during the probes.
5 Experimental Results
5.1 The Experimental Setting
All the experiments were done on a Macbook Pro with a core i7 at 2.66Ghz running MacOS 10.6.7. Ibs, wdeg, and Abs were were all implemented in the Comet system . Since the search algorithms are in general randomized, the empirical results are based on 50 runs and the tables report the average () and the standard deviation of the running times in seconds. Unless specified otherwise, a timeout of 5 minutes was used and runs that timeout were assigned a runtime. The following parameter values were used for the experimental results: in both Ibs and Abs, (slow aging), and . Experimental results on the sensitivities of these parameters will also be reported. For every heuristic, the results are given for three strategies: no restarts (), fast restarting () or slow restarting (). depending on which strategy is best across the board. The initial failure limit is set to .
The search algorithms were run on the exact same models, with a single line changed to select the search procedure. In our experiments, Ibs does not partition the domains when initializing the impacts and always computes the impacts exactly. Both the variable and value heuristics break ties randomly. In wdeg, no value heuristic is used: The values are tried in the sequential order of the domain. Ties in the variable selection are broken randomly. All the instances are solved using the same parameter values as explained earlier. No comparison with model-counting heuristic is provided, since these are not available in publicly available CP solvers.
The experimental evaluation uses benchmarks that have been widely studied, often by different communities. The multi-knapsack and magic square problems both come from the Ibs paper . The progressive party has been a standard benchmark in the local search, mathematical-programming, and constraint-programming communities, and captures a complex, multi-period allocation problem. The nurse rostering problem  originated from a mathematical-programming paper and constraint programming was shown to be a highly effective and scalable approach. The radiation problem is taken from the 2008 MiniZinc challenge  and has also been heavily studied. These benchmarks typically exploit many features of constraint-programming systems including numerical, logical, reified, element, and global constraints.
5.2 The Core Results
This benchmark is from  and our implementation follows Refalo’s informal description. The satisfaction model uses an arithmetic encoding of the binary knapsacks (not a global constraint) where the objective is replaced by a linear equality with a right-hand-side set to the known optimal value. All the constraints use traditional bound-consistency algorithms for filtering linear constraints. A second set of experiments considers the optimization variant. The COP uses global binary knapsack constraints (binaryKnapsackAtmost in Comet) based on the filtering algorithm in . These benchmarks contain up to variables.
Figure 1 is a pictorial depiction of the behavior of the three search algorithms with no restarts. The chart on the left gives the absolute running time (in seconds) with a logarithmic scale. The stacked bar chart on the right reports the same data using a relative scale instead where the height of the bar is the normalized sum of the running time of all three algorithms and the length of each segment is its normalized running time. Note that, since this view is not logarithmic, adjacent bars correspond to different totals. The results clearly show that, as the difficulty of the problem increases, the quality of wdeg sharply decreases and the quality of Abs significantly improves. On the harder instances, Abs is clearly superior to Ibs and vastly outperforms wdeg. Figure 2 conveys the same information for the optimization variant with similar observations.
Table 1 gives the numerical results for instances to . The first column specifies the instance, while the remaining columns report the average run times, the standard deviations, and the number of runs that did not time-out. The results are given for no-restart and slow-restart strategies for all heuristics. On the decision instance , wdeg often fails to find a solution within the time limit and, in general, takes considerable time. Abs always finds solutions and is about 5 times faster than Ibs for the no-restart strategy which is most effective on the decision variant. On the optimization variant, wdeg cannot solve instance in any of the 50 runs and Ibs does not always find a solution. Abs, in contrast, finds a solution in all 50 runs well within the time limit.
In summary, on this benchmark, wdeg is vastly outperformed by Ibs and Abs as soon as the instances are not easy. Abs is clearly the most robust heuristic and produces significant improvements in performance on the most difficult instances, both in the decision and optimization variants.
This benchmark is also from  and the model is based on a direct algebraic encoding with linear equations for the rows and columns (the square side is ), 2 linear equations for the diagonals, one alldifferent constraint (not enforcing domain consistency) for the entire square, binary inequalities to order the elements in the diagonals, and two binary inequalities to order the top-left corner against the bottom-left and top-right corners. Table 2 report results for squares of size to size . The column in Table 2 reports the number of successful runs (no timeout).
On magic squares, wdeg is completely dominated by Ibs and Abs: It has poor performance and is not robust even on the simpler instances. The best performance for Ibs and Abs is obtained using a fast restart, in which case Abs provides a slight improvement over Ibs. Ibs is more effective than Abs with slow or no restarts.
The progressive party problem  is a constraint satisfaction problem featuring a mix of global constraint and has been used frequently for benchmarking CP, LS, and MIP solvers. The instance considered here is the instance with 29 guests, 8 periods and 13 hosts, i.e., 232 variables with domains of size 13. The goal is to find a schedule for a social event taking place over time periods subject to constraints on the sizes of the venues (the boats), sizes of the group, and social constraints (two groups cannot meet more than once and one group cannot go back to the same boat more than once). The model relies on multiple global alldifferent, multi-knapsacks and arithmetic constraints with reifications. This model breaks the search in phases (one per period) and uses the black-box heuristic within each period.
The results are given in Table 3. Abs clearly dominates Ibs on this benchmark for all restarting strategies. Abs is also clearly superior to wdeg when no restarts are used but is slightly slower than wdeg when slow or fast restarts are used.
This benchmark is taken from  and is a rostering problem assigning nurses to infants in an hospital ward, while balancing the workload. The multi-zone model can be found in Listing 1.2 in . The custom search procedure is removed and replaced by a call to one of the generic searches (Ibs,Abs,wdeg). Table 4 reports the performance results for the three heuristics and 3 restarting strategies on the one-zone instances (z1-z5,z8). Note that the custom procedure in  relies on a dynamic-symmetry breaking on values and sophisticated variable/value ordering. Results for wdeg beyond z5 are not reported as it times out systematically. As before, column reports the number of runs that finish (out of 50), reports the number of choice points and the columns reports the mean and standard deviation of the running time.
wdeg exhibits extremely poor performance and robustness on this benchmark. Abs is clearly the most robust procedure as it solves all instances in all its runs for all the restarting strategies. It is also significantly faster than Ibs on z4 and z8. Ibs behaves well in general, except on z4 and z8 for which it sometimes fails to find solutions and takes significantly more time than Abs. It is faster than Abs on z3 and z5.
|6||1x144 + 10x37 + 296x37|
|7||1x178 + 10x37 + 333x37|
|8||1x149 + 10x37 + 333x37|
|9||1x175 + 10x37 + 333x37|
|10||1x233 + 10x50 + 441x50|
This last benchmark is a constrained optimization problem for
radiation therapy taken from the 2008 MiniZinc challenge
. The objective is to find a setup of a
radiation therapy machine to deliver a desired radiation intensity to
a tumor. The problem uses algebraic constraint and the formulation can
be found in the mini-zinc repository 
Table 6 reports the results for 5 instances. Abs clearly dominates Ibs on all instances and Ibs cannot solve the largest instance within the time limit for any restarting strategy. wdeg performs well in general on this benchmark. It is slightly faster than Abs on the largest instance for the slow and fast restarts, but is slower with no restarts. On instance 9, it is faster with no restart and slower when slow or fast restart are used. Both wdeg and Abs are effective on this problem and clearly superior to Ibs.
On this collection of benchmarks, Abs is clearly the most robust and effective heuristic. It is robust across all benchmarks and restarting strategies and is, in general, the fastest heuristic. wdeg has significant robustness and performance issues on the multi-knapsack, magic square, and nurse rostering benchmarks. Ibs has some robustness issues on radiation, some rostering instances, and the optimization variant of the large knapsack problems. It is in general significantly less efficient than Abs on the knapsack, rostering, and radiation benchmarks.
5.3 Sensitivity Analysis
Criticality of the Variable Ordering
Table 7 reports the performance of activity-based search when no value ordering is used. The value heuristic simply tries the value in increasing order as in wdeg. The results indicate that the value selection heuristic of Abs does not play a critical role and is only marginally faster/more robust on the largest instances.
Sensitivity to the Sample Size
Figure 3 illustrates graphically the sensitivy of Abs to the confidence interval parameter used to control the number of probes in the initialization process. The statistics are based on 50 runs of the non-restarting strategy. The boxplots show the four main quartiles for the running time (in seconds) of Abs with ranging from 0.8 down to 0.05. The blue line connects the medians whereas the red line connects the means. The circles beyond the extreme quartiles are outliers. The left boxplot shows results on msq-10 while the right one shows results on the optimization version of knap1-4.
The results show that, as the number of probes increases (i.e., becomes smaller), the robustness of the search heuristic improves and the median and the mean tend to converge. This is especially true on knap1-4, while msq-10 still exhibits some variance when . Also, the mean decreases with more probes on msq-10, while the mean increases on knap1-4 as the probe time becomes more important. The value used in the core experiments seem to be a reasonable compromise.
Sensitivity to (Aging)
Figure 4 illustrates the sensitivity to the aging parameter. The two boxplots are once again showing the distribution of running times in seconds for 50 runs of msq-10 (left) and knap1-4 (right). What is not immediately visible on the figure is that the number of timeouts for msq-10 increases from for to for . Overall, the results seem to indicate that the slow aging process is desirable.
5.4 Some Behavioral Observations
Figure 5 depicts the behavior of Abs and Ibs on radiation #9 under all three restarting strategies. The axis is the running time in a logarithmic scale and the axis is the objective value each time a new upper bound is found. The three red curves depict the performance of activity-based search, while the three blue curves correspond to impact-based search. What is striking here is the difference in behavior between the two searches. Abs quickly dives to the optimal solution and spends the remaining time proving optimality. Without restarts, activity-based search hits the optimum within 3 seconds. With restarts, it finds the optimal solution within one second and the proof of optimality is faster too. Ibs slowly reaches the optimal solution but then proves optimality quickly. Restarts have a negative effect on Ibs. We conjecture that the reduction of large domains may not be such a good indicator of progress and may bias the search toward certain variables.
Figure 6 provide interesting data about activities on radiation #9. In particular, Figure 6 gives the frequencies of activity levels at the root, and plots the activity levels for all the variables. (Only the variables not fixed by singleton arc-consistency are shown in the figures). The two figures highlight that the probing process has isolated a small subset of the variables with very high activity levels, indicating that, on this benchmark, there are relatively few very active variables. It is tempting to conjecture that this benchmark has backdoors  or good cycle-cutsets  and that activity-based search was able to discover them, but more experiments are needed to confirm or disprove this conjecture.
Robust search procedures is a central component in the design of black-box constraint-programming solvers. This paper proposed activity-based search, the idea of using the activity of variables during propagation to guide the search. A variable activity is incremented every time the propagation step filters its domain and is aged otherwise. A sampling process is used to initialize the variable activities prior to search. Activity-based search was compared experimentally to the Ibs and wdeg heuristics on a variety of benchmarks. The experimental results have shown that Abs was significantly more robust than both Ibs and wdeg on these classes of benchmarks and often produces significant performance improvements.
- In this model, the time that the beam is on is a variable and must be optimized alongside the number of patterns.
- F. Boussemart, F. Hemery, C. Lecoutre, and L. Sais. Boosting systematic search by weighting constraints. In R. L. de Mántaras and L. Saitta, editors, ECAI, pages 146–150. IOS Press, 2004.
- R. Dechter and J. Pearl. The cycle-cutset method for improving search performance in ai applications. In Proceedings of IEEE conference on AI Applications, Orlando, FL, 1987.
- I. Dynadec. Comet v2.1 user manual. Technical report, Providence, RI, 2009.
- G12. http://www.g12.cs.mu.oz.au/minizinc/, 2008.
- M. W. Moskewicz, C. F. Madigan, Y. Zhao, L. Zhang, and S. Malik. Chaff: engineering an efficient sat solver. In Proceedings of the 38th annual Design Automation Conference, DAC ’01, pages 530–535, New York, NY, USA, 2001. ACM.
- N. Nethercote, P. J. Stuckey, R. Becket, S. Brand, G. J. Duck, and G. Tack. Minizinc: Towards a standard cp modelling language. In In: Proc. of 13th International Conference on Principles and Practice of Constraint Programming, pages 529–543. Springer, 2007.
- L. Perron. http://code.google.com/p/or-tools/, 2010.
- G. Pesant. Counting and estimating lattice points: Special polytopes for branching heuristics in constraint programming. Optima Newsletter, 81:9–14, 2009.
- P. Prosser, K. Stergiou, and T. Walsh. Singleton consistencies. In CP’02, pages 353–368, London, UK, 2000. Springer-Verlag.
- P. Refalo. Impact-based search strategies for constraint programming. In M. Wallace, editor, CP, volume 3258 of Lecture Notes in Computer Science, pages 557–571. Springer, 2004.
- P. Schaus, P. Van Hentenryck, and J.-C. RÃgin. Scalable load balancing in nurse to patient assignment problems. In W.-J. van Hoeve and J. Hooker, editors, Integration of AI and OR Techniques in Constraint Programming for Combinatorial Optimization Problems, volume 5547 of Lecture Notes in Computer Science, pages 248–262. Springer Berlin / Heidelberg, 2009.
- B. Smith, S. Brailsford, P. Hubbard, and H. Williams. The Progressive Party Problem: Integer Linear Programming and Constraint Programming Compared. Constraints, 1:119–138, 1996.
- M. A. Trick. A dynamic programming approach for consistency and propagation for knapsack constraints. In Annals of Operations Research, pages 113–124, 2001.
- R. Williams, C. P. Gomes, and B. Selman. Backdoors to typical case complexity. In Proceedings of the 18th international joint conference on Artificial intelligence, 1173–1178, San Francisco, CA, USA, 2003.