or entailment checking. Propagation is done using the arc-consistency algorithm. AC-3, adapted for non-binary constraints. At the heart of the algorithm is an.
Towards an Open Finite Domain Constraint Solver Mats Carlsson12 , Bjorn Carlson3, Greger Ottosson1 1
Computing Science Dept., Uppsala University PO Box 311, S-751 05 UPPSALA, Sweden 2 SICS, PO Box 1263, S-164 28 KISTA, Sweden 3 Xerox PARC, 3333 Coyote Hill Road, Palo Alto, CA, 94304-9960
1 Summary We describe the design and implementation of a nite domain constraint solver embedded in SICStus Prolog system using an extended uni cation mechanism via attributed variables as a generic constraint interface. The solver is based on indexicals, i.e. reactive functional rules performing incremental constraint solving or entailment checking. Propagation is done using the arc-consistency algorithm AC-3, adapted for non-binary constraints. At the heart of the algorithm is an evaluator for indexicals. The solver provides the usual prede ned search strategies ( xed order, fail rst principle, branch and bound for minimization or maximization). Access predicates for the relevant variable attributes (domain value, bounds and size etc.) are also provided, making customized search strategies easily programmable. A design goal has been to keep the solver open-ended and extendible as well as to keep a substantial part written in Prolog, partly contradicting conventional wisdom in implementing constraint solvers.
2 Design Overview The solver has an open-ended design in several senses: (1) The user can de ne new elementary constraints in terms of indexicals. (2) Non-local constraint propagation is available via global constraints de ned by the user via a programming interface. Such constraints may use specialized algorithms for application speci c constraint solving. (3) An elementary constraint can be linked to a 0/1 variable denoting its truth value. Indexicals are used to de ne both the constraint solving and the entailment checking aspects of a constraint. Arithmetic expressions and symbolic constraints are compiled to elementary ones or to indexicals (see e.g. [2]). Constraints can also be arbitrarily combined using the propositional connectives. The interface between the SICStus Prolog engine and the solver is provided in part by the attributed variables mechanism [3], which has been used previously to add several constraint solvers to SICStus and ECLi PSe Prologs. This
mechanism associates solver-speci c information with variables, and provides hooks for extended uni cation and projection of answer constraints. The generality and exibility of the indexical approach comes with a cost. Indexicals have small grain size; the ratio of useful invocations is low for many problems; they prune only one variable at a time, and incur high scheduling overhead since they produce many suspensions (O(n2 ) for a n-ary constraint). Global constraints, on the other hand, maintain consistency over an arbitrary amount of variables, are resumed when needed (under certain constraint speci ed conditions), and use speci c, incremental algorithms for each constraint, e.g. graph algorithms and OR techniques. In our framework, we mix indexicals and global constraints by having separate scheduling queues for the two; a global constraint is only resumed when no indexicals are scheduled for execution. Thus, global constraints can be seen as having lesser priority than indexicals. This is reasonable, since indexicals (per invocation) are cheap, while specialized algorithms for global consistency are often expensive. Global constraints are de ned via a programming interface, making it possible to incorporate problem speci c algorithms to enhance propagation power. For an occurrence of a global constraint c, the interface provides services to suspend and resume c on a collection of variables, to maintain a private state containing information used by incremental algorithms, and to prune variables and propagate the eects. The constraint speci c algorithm is responsible for determining (dis)entailment, and for computing the new domains of any variables to be pruned.
References 1. B. Carlson, M. Carlsson, and D. Diaz. Entailment of nite domain constraints. In Proceedings of the Eleventh International Conference on Logic Programming. MIT Press, 1994. 2. D. Diaz and P. Codognet. A Minimal Extension of the WAM for CLP(FD). In Proceedings of the International Conference on Logic Programming, pages 774{790, Budapest, Hungary, 1993. MIT Press. 3. C. Holzbaur. Speci cation of Constraint Based Inference Mechanism through Extended Uni cation. PhD thesis, Dept. of Medical Cybernetics and AI, University of Vienna, 1990. 4. Pascal Van Hentenryck, Vijay Saraswat, and Yves Deville. Design, implementation and evaluation of the constraint language cc(FD). In A. Podelski, editor, Constraints: Basics and Trends, volume 910 of Lecture Notes in Computer Science. Springer-Verlag, 1995.
This article was processed using the LATEX macro package with LLNCS style