Constraint Programming P

Constraint Programming P

<p> <a href="/tags/Constraint_programming/" rel="tag">Constraint programming</a> P. Esquirol, P. Lopez, Hélène Fargier, Thomas Schiex</p><p>To cite this version:</p><p>P. Esquirol, P. Lopez, Hélène Fargier, Thomas Schiex. Constraint programming. 1995. ￿hal-02850710￿</p><p>HAL Id: hal-02850710 https://hal.inrae.fr/hal-02850710 Submitted on 7 Jun 2020</p><p>HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés.</p><p>Distributed under a Creative Commons Attribution - ShareAlike| 4.0 International License</p><p>Constraint programming</p><p>Patrick Esquirol� Pierre Lop ez</p><p>Lab oratoire d�Analyse et d�Architecture des Syst�emes du cnrs</p><p>�� avenue du Colonel Ro che</p><p>����� Toulouse Cedex �France�</p><p> e�mail� fesquirol�lop ezg�laas�fr</p><p>H�el�ene Fargier</p><p>Universit�e Paul Sabatier �IRIT�</p><p>���� route de Narb onne</p><p>����� Toulouse Cedex �France�</p><p> e�mail� fargier�irit�fr</p><p>Thomas Schiex</p><p>Institut National de la Recherche Agronomique</p><p>Chemin de Borde Rouge� BP ��</p><p>����� Castanet�Tolosan Cedex �France�</p><p> e�mail� tschiex�toulouse�inra�fr</p><p>Abstract</p><p>There has b een a lot of interest lately from p eople solving constrained optimization</p><p> problems for Constraint Programming �CP�� Constraint programming cannot b e describ ed</p><p> as a technique by itself but p erhaps b etter as a class of computer languages tailored to</p><p> the expression and resolution of problems which are non�deterministic in nature� with a</p><p> fast program development and e�cient runtime p erformances�</p><p>Constraint programming derives from <a href="/tags/Logic_programming/" rel="tag">logic programming</a>� op erational research and</p><p> arti�cial intelligence� Logic programming o�ers the general non�deterministic host lan�</p><p> guage which accommo dates dedicated constraint solvers from OR and AI such as linear</p><p> programming or <a href="/tags/Constraint_satisfaction/" rel="tag">constraint satisfaction</a> techniques�</p><p>In this pap er� we �rst review how pure logic programming languages evolved into Con�</p><p> straint Logic Programming �CLP� languages� bringing to light the interface b etween logic</p><p> programming and constraint solvers� Some extra attention is given to a sp eci�c class of</p><p> constraint solving techniques which have b een develop ed in the Constraint Satisfaction</p><p>Problem framework and which are currently used in most CLP languages to solve con�</p><p> strained problems in �nite domains� We �nally conclude by an overview of some existing</p><p>CP languages� with some examples taken from scheduling�</p><p>Keywords� Constraint Logic Programming� Constraint Satisfaction� Scheduling�</p><p>� Intro duction</p><p>A large numb er of problems which are considered by op erational research and which have</p><p> also b een tackled by arti�cial intelligence techniques� such as job�shop scheduling� resource</p><p> allo cation problems or digital circuit validation are combinatorial problems in nature� More</p><p> formally� such problems are often NP�hard �GJ��� and it seems unlikely that <a href="/tags/Algorithm/" rel="tag">algorithms</a> with a</p><p> reasonable worst�case complexity exist to solve them�</p><p>A traditional approach to solve such problems is to design a sp eci�c computer program</p><p> that uses enumerative techniques such as Branch and Bound or� lo osing some guarantees� lo cal</p><p> search techniques �Tab o o search� simulated annealing�� This may lead to the utmost e�ciency</p><p> but usually necessitates a lot of work� which may rapidly b ecome useless if the mo del evolves</p><p> in an unexp ected direction and whose reuse is highly improbable�</p><p>Another p ossible approach is to cast the problem in a general framework such as integer</p><p> linear programming and to use a dedicated solver to solve the linear mo del which has b een</p><p> designed� Usually� the rewriting tends to enlarge the problem size� to distort �to some extent�</p><p> the original problem� to ignore nice prop erties such as p ossible heuristics or symmetries� � � In</p><p> the worst cases� the �nal e�ciency may b e p o or and solutions almost meaningless�</p><p>Ideally� one would like a general framework for stating large classes of combinatorial prob�</p><p> lems� with a language which is general enough to limit distortion and op en enough to make it</p><p> p ossible to use the sp eci�c knowledge ab out the problem� in order to enhance e�ciency�</p><p>We now try to show the assets of constraint programming languages as general to ols for</p><p> representing and solving various classes of constrained problems� with illustrations in job�shop</p><p> scheduling� These assets are inherited from logic programming but also from the underlying</p><p> constraint solvers� In this pap er� we will more sp eci�cally fo cus on AI techniques for solving</p><p> constraint satisfaction problems on �nite domains �Tsa���� even if other solvers� such as Simplex</p><p> for sets of linear inequations are often used in CP languages�</p><p>� From Logic Programming to Constraint Programming</p><p>Logic programming languages are general programming languages based on mathematical logic�</p><p> and more sp eci�cally �rst order logic� The language <a href="/tags/Prolog/" rel="tag">Prolog</a>� with its numerous dialects� is the</p><p> main representative of the logic programming languages community� The original idea of Prolog</p><p> is to let the user sp ecify the prop erties he wants to satisfy using a subset of the �rst�order logic</p><p> language and to use a general logical inference mechanism� the resolution principle �Rob���� to</p><p> prove either that these prop erties cannot b e met or to exhibit solutions�</p><p>��� Logic programming</p><p>����� Description and go o d prop erties of Prolog programming</p><p>Logic Programming will b e presented here through its most representative implementation� the</p><p>Prolog language� This language is a restriction of the �rst�order logic language to Horn clauses�</p><p>It acts as a theorem prover� and applies a general inference mechanism based on the resolution</p><p> principle� To get started with Prolog and the use of logic for problem solving� we recommend</p><p> the reading of �CM��� CKvC�� � Kow��� ACM�� � AS����</p><p>Prolog manipulates ob jects� called terms� that form the so�called �Herbrand universe��</p><p>A term may b e a constant such as ���� a variable such as �X�� an atom such as �a�� or a</p><p> comp ound term such as functional terms ��f�X����� and lists� A Prolog program can b e</p><p> viewed as a sequence of declarative statements� the clauses� each of them stating how a given</p><p> relation b etween some terms �the head of the clause� may b e derived logically from a conjunctive</p><p> set of relations �the tail of the clause�� de�ned somewhere else in the program� n�ary relations</p><p>�p ossibly n = �� are all built from a predicate symb ol and a set of terms� the arguments of the</p><p> relations�</p><p>In the sequel� the chosen syntax to write the clauses will b e the Edinburgh syntax� The head</p><p> is separated from the tail by ����� if not empty� the tail consists of a set of terms separated by</p><p>���� and the clause ends with ���� The character ��� intro duces a comment�</p><p>� A comment� next line is an example of a clause</p><p> head �� term�� term��</p><p>Moreover a variable is denoted by an upp er case letter �A�Z�� a list is represented by �H�T�</p><p> where H is the head of the list �i�e�� the �rst element�� T its tail �the other elements�� Programs</p><p> are clustered into packets of clauses� each packet grouping clauses which head refers to the same</p><p> relation predicate� In each packet� one clause represents one alternative to prove the relation�</p><p>In the following example �a path��nding problem�� a �rst packet of � clauses describ es the set</p><p> of pairs of no des that satisfy the arc�relation of some graph� These clauses have an empty tail</p><p>�no conditions� since the graph is given� A second packet of clauses states the path relation�</p><p> recursively de�ned from the arc�relation� a path exists b etween no de X and no de Y� either if the</p><p> no des are connected directly by an arc ��rst clause� or if a path exists b etween an intermediate</p><p> no de Z and no de Y� such that no de X is connected to no de Z by an arc�relation �second clause��</p><p>� Directed non�reflexive graph</p><p>� described by its arcs</p><p>1 2</p><p> arc������</p><p> arc������ arc������</p><p> arc������ 6 3</p><p> arc������</p><p> arc������</p><p>� Recursive definition of the path</p><p> relation between any � nodes</p><p>� 5 4</p><p> path�X�Y��X�Y�� �� arc�X�Y��</p><p> path�X�Y��X�L�� �� arc�X�Z�� path�Z�Y�L��</p><p>Prolog programs are launched by writing queries ab out one or more relations that must</p><p> simultaneously b e proved� The standard strategy of Prolog is based on an emb edded chrono�</p><p> logical backtrack search <a href="/tags/Algorithm/" rel="tag">algorithm</a>� that enables to collect all the p ossible solutions for a given</p><p> query�</p><p>If some variables app ear in a query� Prolog attempts to give them values� or at least returns</p><p> a minimal set of variables substitutions �equalities constraints�� that satis�es the query� Values</p><p> returned in the answer form one solution to the problem stated by the query� The query�</p><p>���path���Y�L��� ask for all the paths L and their extremity Y� such that path L starts</p><p> from no de �� When the query has no variables� answer is �Yes� if the query is proved to b e</p><p> true� as for instance for the query ���path��������������� that checks the path �������</p><p> b etween no des � and �� or �No� when the query is not satis�able� as for instance for the query</p><p>���path�X�X�L���� which proves that no circuit can b e found in this graph�</p><p>Let us note that the same program can also answer to queries like ���path�X���L���</p><p> which returns all the paths terminating on no de �� or like ���path�X�Y�L��� which returns</p><p> all the paths of the graph� This program is a reversible one� since arguments of the path</p><p> relation are not forced to have a �xed input or output role� as opp osed to classical programs in</p><p> pro cedural or <a href="/tags/Functional_programming/" rel="tag">functional programming</a>� The relational semantics of logic programming gives its</p><p> declarativeness and its genericity� The emb edded backtrack <a href="/tags/Search_algorithm/" rel="tag">search algorithm</a> and the high�level</p><p> facilities for lists pro cessing play also a ma jor role in the conciseness of Prolog programs�</p><p>����� Limitations of logic programming for numerical problem solving</p><p>Pure logic programming needs and only allows the statement of relations b etween terms� with�</p><p> out any assumption on numerical prop erties� When tackling numerical problems or reasoning</p><p> in domains more structured than the domain of syntactic terms �Herbrand universe�� the con�</p><p> straint solving algorithm on terms �the so�called uni�cation algorithm� app ears to b e to o weak</p><p> for numerical computations� in particular when the search space develop ed by the standard</p><p> <a href="/tags/Backtracking/" rel="tag">backtracking</a> can b e pruned by an active interpretation of the numerical constraints� as shows</p><p> the next example�</p><p>Supp ose one wants to determine the pairs �X�Y� which satisfy the prop erty X � Y� numb ers</p><p>X and Y b elonging to a given enumerated subset of integers�</p><p>� Definition of a given subset of integers</p><p> is�number����</p><p> is�number����</p><p> is�number����</p><p>� Definition of the ordered�pair relation</p><p> ordered�pair�X�Y� �� is�number�X�� is�number�Y�� X � Y�</p><p>Numerical op erations and checks �such as X � Y� are extra�logical relations and have b een</p><p> added under the form of prede�ned predicates just to make Prolog able to pro duce ele�</p><p> mentary numerical computations� The search tree develop ed in order to answer the query</p><p>���ordered�pair�X�Y��� which lists all the ordered pairs of numb ers amongst f�����g is �g�</p><p> ured b elow�</p><p>?− is_number(X), is_number(Y), X<Y.</p><p>X=1 X=3 X=2</p><p>?− is_number(Y), X<Y. ?− is_number(Y), X<Y. ?− is_number(Y), X<Y.</p><p>Y=1 Y=3 Y=1 Y=3 Y=1 Y=3 Y=2 Y=2 Y=2</p><p>?− X<Y. ?− X<Y. ?− X<Y. ?− X<Y. ?− X<Y. ?− X<Y. ?− X<Y. ?− X<Y. ?− X<Y.</p><p> fail {X=1,Y=2} {X=1,Y=3} fail fail {X=2,Y=3} fail fail fail</p><p>Figure �� Search tree</p><p>This program �rst generates values for numb ers X and Y and then checks the ordering</p><p> relation� This approach �generate�and�test� is very ine�cient considering the failing branches</p><p> of the search tree� For example� X�� is tried even if it is obvious that no value can b e asso ciated</p><p> with Y b ecause X has its maximum value and the order is a strict one� For symmetrical reasons�</p><p> failures due to Y�� are unnecessarily explored� Preferably� one could �rst restrict the domains of</p><p>X and Y b efore enumerating their p ossible values� This necessitates that domains b e asso ciated</p><p> to variables and that the relation X � Y b e actively used to restrict the domains b efore values</p><p> have b een prop osed for X and Y �constrain�and�generate�� rather than simply passively checking</p><p> it once the variables it involves are assigned�</p><p>����� Conclusion</p><p>Logic programming and its well�known implementation through the Prolog language o�ers sev�</p><p> eral attractive prop erties for problem solving �declarativity� genericity� conciseness� exhaustive</p><p> search�� Facing problems where constraints must actively b e exploited to improve e�ciency�</p><p> the uni�cation constraint alone app ears to o weak� It has to b e enlarged by other inference</p><p> mechanisms based on more structured domains of interpretation� such as �nite domain vari�</p><p> ables� integers� rationals� b o oleans� for which e�cient constraint solving strategies can b e im�</p><p> plemented� The next section lists some of the domains of variables for which constraints can</p><p> actively b e interpreted in order to improve the standard strategy of Prolog�</p><p>��� Constraint Logic Programming</p><p>����� General principle</p><p>Constraint Logic programming �CLP� is an attempt to overcome the limitations of Logic Pro�</p><p> gramming by enhancing it with constraint solving mechanisms�</p><p>The �rst ob jective was to replace an explicit co ding of semantic prop erties b etween ob jects</p><p> submitted to constraints by an implicit description with primitive constraints� This led to</p><p> distinguish usual predicates and constraint predicates� usual variables and typ ed variables� For</p><p> example� b esides the original predicate �is�X�Expr�� that binds a variable to the evaluation</p><p> of a closed arithmetic expression� new equality constraints have b een intro duced� which state</p><p> equations in typ ed domains� This work was concerned with the integration of new computation</p><p> domains and their asso ciated constraint solvers� In the remainder of this pap er we will denote</p><p> by Clp�X � a CLP system acting on some constraint domain X �</p><p>The second ob jective was to replace the depth��rst search strategy of Prolog and its resulting</p><p> generate�and�test b ehavior� Constraint propagation has b een investigated in the Arti�cial</p><p>Intelligence community since late ���s �Mon��� Mac��� Ste���� Techniques like lo cal value</p><p> propagation� data�driven computation� forward checking and lo ok ahead have b een develop ed�</p><p>Some of these techniques have b een integrated as new inference rules in CLP systems�</p><p>It is often admitted that the embryonic attempts to intro duce constraints in Prolog are</p><p> due to Alain Colmerauer with its design of Prolog II �Col��b�� able to solve equations in the</p><p> domain of in�nite trees �Col��a�� Prolog II also initiated the use of the �dif�X�Y�� primitive</p><p> with a co�routining mechanism that p ostp ones the disequality check until b oth arguments</p><p> b ecome instantiated and pro duces a backjumping to the clause containing the dif in case of</p><p> failure�</p><p>The core idea of CLP was to replace the computational heart of a logic programming system�</p><p> namely the uni�cation algorithm� by a constraint handling mechanism in a constraint domain�</p><p>��� The CLP scheme</p><p>A go o d abstract of the theoretical foundations of CLP languages can b e found in �Coh����</p><p>For a deep er analysis� the survey of Ja�ar � Maher �JM��� is worth reading� For the sake of</p><p> simplicity and understandability we prop ose to describ e what a CLP scheme may b e with a</p><p> mo del very close to the one of the abstract Prolog III machine� This mo del supp oses that</p><p> constraints and predicates are syntactically separated in a clause� as opp osed to the op erational</p><p> mo del given in �JM���� Thus� a clause of a logic program will consist of a triplet hh� B� Ci where</p><p> h is the head� B a sequence of predicates �p ossibly empty� and C a set of constraints �p ossibly</p><p> empty�� A program clause hh� B� Ci means that h can b e rewritten as B under the constraints</p><p>C� Supp ose that the state of the abstract machine at a given time is hG� Ri� where�</p><p>� G is the �ordered� set of goals which remain to b e executed�</p><p>� R forms the current constraint store�</p><p>Initially� goals and constraints are those of the query� S = hQ � Q i� One �nal state S is</p><p>� g r f</p><p> de�ned by an empty set of goals� S = h�� R i� The �nal constraint store R may b e non</p><p> f f f</p><p> empty� In that case� the �nal answer may di�er from a CLP system to another� dep ending on</p><p> the constraint domains and some prop erties presented b elow�</p><p>The computation can b e represented by a tree� similar to the search tree develop ed by</p><p> a pure logic program� no des are lab eled by states� edges are lab eled by rules �primitive or</p><p> program�de�ned�� and leaves are of two typ es� fail or answer� Fails o ccur when no rule can b e</p><p> applied to a state with a non empty set of goals� Supp ose g is the next goal to b e executed �the</p><p> left�most term of G� in the current state hG� Ri� If a program clause hh� B� Ci can b e applied</p><p>0 0</p><p> to g� the following state is hG � C i where�</p><p>S</p><p>0</p><p>� G = Gnfgg B</p><p>S S</p><p>0</p><p>� R = solve(R fg = hg C)�</p><p>The equation fg = hg means that g and h have the same predicate symb ol and satisfy</p><p> the uni�cation constraints b etween their resp ective arguments� When considering numerical</p><p> domains� uni�cation means equation� as for example in the uni�cation of g = foo(X� �) and</p><p> h = foo(Y� Y + �)� the result is X = Y = � in a CLP system on numerical domains whereas it</p><p> fails in pure Prolog �as � cannot b e made syntactical ly equivalent to Y + ��� The solve function</p><p> p erforms a satis�ability check� that� if failed� entails a backtrack and the selection of another</p><p> clause of the program� This satis�ability check may b e complete or not� dep ending on the</p><p> constraint domains� In the following� we list some imp ortant prop erties of the CLP systems</p><p> relating to the constraint domains they prop ose�</p><p>����� Prop erties</p><p>The ma jor CLP systems o�er� in a common Prolog environment� several constraint domains</p><p> and their attached set of primitives� Programmers are generally interested in the expressiveness</p><p> of the constraint domains and in the e�ciency of the solvers� It is thus imp ortant to evaluate</p><p> the various systems and their computation domains through relevant prop erties such as�</p><p>� Satisfaction�completeness� solution�compactness of the constraint domain�</p><p>� Incrementality of the constraint satisfaction algorithm�</p><p>� Existence of canonical representations of the constraints set�</p><p>� Simpli�cation ability for the constraint�handling system�</p><p>A theory on a given domain is satisfaction�complete if it is always provable that every</p><p> constraint is either satis�able or not� It is the case for example for reals with the set f=� �=</p><p>� �� �� �� �g of constraints and the set f+� �g of functions� But it is not the case for integers</p><p> with f=g constraint and f+� �g functions �the satis�ability of Diophantine equations b eing</p><p> undecidable�� CLP systems answer �Maybe�� or �N constraints delayed� when this prop erty</p><p> is not �lled� whereas when it is� the answer is �Yes� or �No��</p><p>A theory on a constraint domain is solution�compact when any value of the domain can b e</p><p> represented by a �p ossibly in�nite� set of constraints� True for the domain of real numb ers with</p><p> f=� �=� �� �� �� �g constraints and f+� �g functions� this prop erty is lost for real numb ers with</p><p> only f=g constraint and the same functions�</p><p>Furthermore� the set of constraints that is handled at each no de is obtained by adding some</p><p>1</p><p> constraints to a constraint set which was previously proved satis�able � Thus� the e�ciency of</p><p> the overall language would b ene�t from some �incrementality� in the constraint solver� once</p><p>0</p><p> a set R of constraints has b een shown satis�able� the pro of of satis�ability of R � R should�</p><p> whenever p ossible� b e made more e�cient than a pro of from scratch� by using some results</p><p> from the previous satis�ability pro of of R�</p><p>In practice� solvers often give a �solved form� of the initial set of constraints whose satis��</p><p> ability is �obvious� and which is equivalent to the original set� The �solved form� given by the</p><p> solvers can usually b e directly used instead of the original constraint set when a constraint is</p><p> added� thus automatically giving some �incrementality�� The �solved form� may even b e used</p><p> for pro jection if it is an explicit representation of the solution space�</p><p>Simpli�cation is sometimes called a semantic garbage col lection� For example the two con�</p><p> straints X � � and X � � can b e rewritten as only one� X � �� Another obvious typ e of</p><p> simpli�cation is to rewrite the subset of constraints on a given variable as so on as this variable</p><p> receives a single value� Finally redundancies may also b e eliminated� but this feature raises</p><p> the more general problem of �nding a minimal representative set of constraints� for which one</p><p> cannot assert that a unique optimal strategy always exists�</p><p>To that aim� the existence of canonical forms of sets of constraints may help� A canonical</p><p> form can b e used as a �solved form� which facilitates b oth the satis�ability tests and simpli��</p><p> cations� for example b ecause constraints are ordered according to their arity� and�or variables</p><p> are lexicographically ordered�</p><p>Finally� for satisfaction�complete systems� queries can receive non ground answers �i�e�� each</p><p> variable of the query do es not receive a single value�� the answer is a pro jection of the system</p><p> of constraints on these variables� The understandability of the answer obviously dep ends on</p><p> simpli�cation and canonical representation facilities�</p><p>��� Constraint Programming</p><p>Although constraint programming derives from logic programming and the ma jor CLP systems</p><p> have b een designed as compatible extensions of Prolog �which remains the kernel�� some other</p><p> imp ortant systems have b een develop ed indep endently� As they keep the non�deterministic</p><p> computation principle� and their solvers are based on the same constraints domains� they</p><p> deserve to b e also mentioned in this pap er �see Section ����� Constraint programming is the</p><p> general framework that covers researches and applications of such constraint�based languages</p><p> and systems�</p><p>1</p><p>Or not yet disproved to b e satis�able in case of satisfaction�incomplete theories�</p><p>� Constraint Solvers</p><p>As we have seen� CLP needs several services from the underlying constraint solvers� a satis�a�</p><p> bility test to avoid useless exploration of space and the ability to pro ject the solution space of</p><p> the current constraint set on a subset of the variables involved �to b e able to answer the user</p><p> query using only the variables that app eared in the query��</p><p>We now consider several domains� with their available constraints solvers to see how these</p><p> demands are actually met or relaxed�</p><p>��� Equalities in �nite and rational trees</p><p>The domain of �nite trees �FT� is the original domain of pure logic programming languages�</p><p>Prolog terms that app ear in Prolog predicates� such as f(X) or f(g(X)� �� Z)� are simply the</p><p>2</p><p> syntactic expression of lab eled trees � We present this domain for historic reasons� even if it may</p><p> lo ok somewhat arti�cial to the op eration research community� The problem of satis�ability of</p><p> a set of equalities b etween terms with variables is known as the uni�ability problem� A solution</p><p> is given by an uni�er � a set of variable�term substitutions which� when applied to all the terms�</p><p> make them identical� The problem is easy� solvable in linear time �PW���� Furthermore� the</p><p> algorithms build a most general solution to the constraint set �called a most general uni�er or</p><p> mgu � which can b e used as a �solved form�� it may easily b e pro jected on a variable subset</p><p> and also used as the basis for the next satis�ability test when new constraints are added�</p><p>In the domain of FT� the terms f(X) and f(g(�� X)) are not uni�able� no single FT can</p><p> simultaneously match b oth terms� However� uni�cation algorithms naturally build the substi�</p><p> tution X�g(�� X) as a p ossible solution whereas substitutions of the form X�t� where t is a term</p><p> that contains the variable X cannot de�ne a solution since they implicitly represent in�nite</p><p> trees� Therefore� a sp eci�c test� called the occur�check should b e inserted in the algorithm to</p><p> avoid in�nite cycles in the solution as ab ove� This test yields a b est�case complexity which is</p><p> always equal to the worst�case complexity and was therefore omitted� for e�ciency reasons� in</p><p> most old Prolog dialects�</p><p>Nowadays� in order to sanely avoid the o ccur�check� Prolog languages prefer to solve the</p><p> uni�ability problem in the domain of rational trees �RT�� which may b e in�nite� but which</p><p> have a �nite representation �the �nite representation of an in�nite tree contains cycles�� In</p><p>RT� f(X) and f(g(�� X)) are uni�ed by X = g(�� X)� which implicitly gives the in�nite tree</p><p> f(g(�� g(�� g(�� � � �)))) as the solution� Almost linear algorithms are available� The language</p><p>Prolog II of Marseille �Col��b� has b een the �rst Prolog which chose to solve the uni�ability</p><p> problem in the domain of RT�</p><p>��� Linear �in�equations in R or Q</p><p>Various CLP languages enable the user to express linear equalities and inequalities in the</p><p> domain of R �approximated using �oating p oint numb ers� or Q � using in�nite precision rational</p><p> numb ers�</p><p>For linear equations� the usual technique of Gaussian elimination may b e used� with a</p><p> quadratic worst�case time complexity� When inequalities are intro duced� p olynomial time al�</p><p> gorithms are still available �Kha��� Kar���� but since these algorithms are either less e�cient</p><p> practically or di�cultly made incremental� all existing languages have� to our knowledge� de�</p><p> cided to rely on variations of the Simplex algorithm� despite its exp onential time worst case</p><p>2</p><p> f(X) represents all trees with a ro ot lab elled f and a single son� which may b e any tree�</p><p> complexity� The main variations consist in extending the Simplex to deal with negative num�</p><p> b ers and strict inequalities �LM���� As it is well known in the integer linear programming</p><p> community� the Simplex can b e extended to e�ciently cop e with a growing set of constraints</p><p> and some incrementality is p ossible� The pro jection of a p olyhedral set on a variable subset</p><p> can b e p erformed using a simple algorithm from Fourier� which has b een tuned for redundancy</p><p> elimination in �Imb��� JMSY����</p><p>Even if satis�ability alone is actually needed in the CLP framework� the p ossible optimiza�</p><p> tion p erformed by the Simplex is usually made available at the user level through a sp eci�c</p><p> predicate�</p><p>��� Finite domains</p><p>The intro duction of �nite domains �FD� into CLP languages is certainly connected with the</p><p> imp ortant growth of the �eld of �Constraint Satisfaction Problems� �CSP� in the arti�cial</p><p> intelligence community �Tsa��� AS���� The CSP framework is devoted to the problem of</p><p> satisfying a set of constraints� without any limitation on the constraint typ es� in any FD�</p><p>De�nition � A CSP � (X� D� C) is de�ned by�</p><p>� a set X = fx � � � � � x g of n variables�</p><p>� n</p><p>� a set D = fd � � � � � d g of domains� Domain d contains the set of values that may be</p><p>� n i</p><p> considered for variable x � We note d the size of the largest domain�</p><p> i</p><p>� a set of constraints C = fc � � � � � c g of e constraints� Each constraint c is de�ned by�</p><p>� e i</p><p>� the set of variables X(c ) � X involved in constraint c �</p><p> i i</p><p>� a relation R(c ) on the variables of X(c )� i�e�� a subset of the Cartesian product of</p><p> i i</p><p> the domains of the variables of X(c )� This relation de�nes the tuples of values which</p><p> i</p><p> may simultaneously be assigned to the variables involved in the constraint�</p><p>Example� Consider a CSP with � variables �X = fx � x � x g�� al l variables hav�</p><p>� � �</p><p> ing the same domain fwhite� blackg� Three constraints� c � c � and c involve re�</p><p>� � �</p><p> spectively fx � x g� fx � x g and fx � x g and are de�ned by the same relation R =</p><p>� � � � � �</p><p> f(white� black)� (black� white)g�</p><p>An assignment of values to a subset Y � X of the variables is said to b e consistent �or local ly</p><p> consistent� i� all the constraints c � C such that X(c ) � Y are satis�ed by the assignment� i�e��</p><p> i i</p><p> only authorized combinations of values� as sp eci�ed in the relations are used in the assignment�</p><p>In our example� the assignment fx � white � x � black g is lo cally consistent while fx �</p><p>� � �</p><p> black � x � black g is not�</p><p>�</p><p>A solution of a CSP is simply a consistent assignment of the whole set X of variables� A</p><p>3</p><p> satis�able CSP �a CSP with at least one solution� is also said to b e consistent � Our example</p><p>CSP has no solution� the CSP is inconsistent�</p><p>In the �pure� CSP framework� the domains d are supp osed to b e �nite domains and�</p><p> i</p><p> when their size remains reasonable� the relation asso ciated to each constraint can e�ectively</p><p> b e describ ed by the set of tuples of values that corresp ond to authorized combinations� The</p><p>3</p><p>One should not confuse the prop erty of consistency of an assignment� which is decidable in p olynomial time�</p><p> and the prop erty of consistency of a CSP� which de�nes an NP�complete decision problem�</p><p> interesting p oint is that any typ e of constraint� either linear or not� can b e expressed� Numb ers</p><p> and symb ols may also b e simply mixed together� A lot of CSP techniques may b e extended</p><p> to the case of relations expressed in intention �linear or non linear constraints over N for</p><p> example� �Dav���� Some of these techniques have also b een extended to the case of in�nite</p><p> domains �subsets of R usually� and are available in some CLP languages �SH��� Hyv��� Lho����</p><p>In the following� we only consider FD�</p><p>An usual restriction in the �pure� CSP �eld is also to restrict oneself to binary constraints�</p><p> involving only two variables� In that case� two graphs� called resp ectively the constraint graph</p><p> and the consistency graph of the CSP� may b e de�ned�</p><p>� The constraint graph has one vertex for each variable and one edge for each constraint�</p><p>For non binary CSP� a similar hyp er�graph can b e de�ned� This graph only describ es the</p><p> problem structure�</p><p>� The consistency graph has one vertex for each value of each variable and one edge for</p><p> each compatible pair that app ear in a constraint� This graph is n�partite since no edge</p><p> can app ear b etween two values of a given variable� It completely de�nes the problem�</p><p> x1 x2 x1 x2</p><p> x3 x3</p><p>Figure �� The constraint and consistency graphs of a CSP</p><p>These two representations are used in Fig� � to describ e our example CSP� In the FD case�</p><p> an imp ortant di�erence with the previous domains of trees and linear programming in R is</p><p> that the satis�ability problem b ecomes NP�complete� This is shown simply by the following</p><p>4</p><p> observation� �</p><p>Example� the graph k�colorability problem can simply be expressed as a CSP�</p><p>If you consider a graph (V� E)� one variable x is associated to each vertex v� al l</p><p> v</p><p> the domains are identical and contain k values� Final ly� one di�erence constraint</p><p> between x and x is associated to each edge (v� w) � E� Note that our example is</p><p> v w</p><p> simply the graph ��colorability problem on a ful ly connected graph of � vertices</p><p>�a ��clique��</p><p>The most naive technique that may b e used to solve the satis�ability problem is the back�</p><p> track algorithm� given an initial consistent assignment A of size k� it tries to assign a new</p><p> k</p><p> variable x � If no value in d yields a consistent assignment� a backtrack o ccurs on the</p><p> k+� k+�</p><p> previous variable assigned� The algorithm starts with an empty �and therefore consistent�</p><p> n</p><p> assignment and has a worst�case complexity in O(ed )�</p><p>Since this algorithm is highly ine�cient� it would b e unreasonable to use it to prove satis�a�</p><p> bility in the frame of a CLP language �one satis�ability test b eing p erformed after each step of</p><p> the computation�� Furthermore� it seems di�cult to give this algorithm some incrementality�</p><p>Therefore� all existing implementations have chosen to weaken the �satis�ability� prop erty by</p><p> using the p olynomial worst�case time <a href="/tags/Local_consistency/" rel="tag">local consistency</a> prop erties de�ned in �Mon��� Mac����</p><p>4</p><p>This result shows that the satis�ability problem in the binary CSP restriction is still NP�complete and this</p><p> restriction is made� in theory� �without loss of generality��</p><p>����� Lo cal consistency</p><p>The notion of �lo cal consistency enforcing� de�nes a whole family of techniques which� in</p><p> practice� transform an initial CSP in a �hop efully� simpler problem� with the same solution set�</p><p>5</p><p>This pro cess is also known as a ��ltering� pro cess� or as a �constraint propagation� mechanism �</p><p>To each typ e of �ltering pro cess is asso ciated a so�called �lo cal consistency� prop erty that</p><p> is actually enforced by the �ltering� The main class of lo cal consistencies has b een de�ned</p><p> in �Fre��� and is called k�consistency�</p><p>De�nition � A CSP (X� D� C) is said to be k�consistent i� any consistent assignment of (k - �)</p><p> variables can be extended to a consistent assignment of k variables on any unassigned variable�</p><p>A CSP (X� D� C) is said to be strongly k�consistent i� it is j�consistent for al l j = �� � � � � k�</p><p>It is quite easy to prove that a CSP of n variables which is strongly n�consistent is satis��</p><p> able �and furthermore� any consistent assignment can b e extended to a solution�� However� a</p><p>6</p><p> satis�able CSP is not necessarily n�consistent �</p><p> k k</p><p>A p olynomial time algorithm �in O(n �d )� that enforces strong k�consistency has b een</p><p> prop osed in �Co o���� The CSP built is called the k�consistent closure of the CSP� Since the</p><p>CSP obtained is equivalent to the original CSP� we get the following prop erty�</p><p>Prop erty � If a CSP has an empty k�consistent closure �a domain is empty�� then it is un�</p><p> satis�able� The converse is natural ly false�</p><p>Therefore� strong k�consistency enforcing o�ers a p olynomial time relaxation of satis�abil�</p><p> ity� The approach followed by most CLP languages is to only enforce some lo cal consistency</p><p> prop erty instead of satis�ability� Backtracking o ccurs when an empty closure is obtained�</p><p> since this actually proves unsatis�ability� Usually� only strong ��consistency� also called arc�</p><p> consistency �Ull��� Wal��� Mon��� in the framework of binary CSP� is enforced�</p><p>De�nition � A binary CSP is said to be arc�consistent i� none of its domains is empty �this is</p><p>��consistency� and every assignment of one variable can be extended to a consistent assignment</p><p> of size � on any unassigned variable�</p><p>Example� Our example problem of Fig� � is unsatis�able� but it has an non</p><p> empty arc�consistent closure� and is indeed already arc�consistent �enforcing arc�</p><p> consistency on this problem is completely useless��</p><p>Basically� arc�consistency enforcing works as follows� if a value of a given domain d do es</p><p> i</p><p> not app ear in any of the authorized combinations of one of the constraints that involve x �</p><p> i</p><p> then this value cannot b elong to a solution and can simply b e deleted� A single pass on all</p><p> variables and constraints is usually not su�cient and the pro cess is p erformed iteratively until</p><p> quiescence�</p><p>5</p><p>This pro cess can b e related to cutting plane generation in integer linear programming considering the</p><p> combined results of �Ho o��� and �dK����</p><p>6</p><p>It can b e the case that some consistent assignment of n - � variables can not b e consistently extended to</p><p> th</p><p> the n variable� Satis�bility simply implies that some consistent assignment of k - � variables do extend to a</p><p> consistent assignment of all variables�</p><p>Example� The CSP whose consistency graph is il lustrated in Fig� �� simply obtained</p><p> by removing the edge (white� black) between x and x � is a good example of non</p><p>� �</p><p> consistent CSP which is also non arc�consistent and whose arc�consistent closure is</p><p> empty� On a �rst pass� the values numbered � wil l be deleted because they are not</p><p> connected to any value on an adjacent variable� then the values numbered � wil l be</p><p> deleted� for the same reason �thanks to the previous deletion�� � � until quiescence�</p><p> here� al l the values are deleted� Actual ly� one could stop on step �� when the domain</p><p> of x becomes empty� since it su�ces to prove inconsistency� �</p><p>1 x1 3 x2 3 1</p><p> x3</p><p>2 2</p><p>Figure �� A CSP with an empty arc�consistent closure</p><p>This simple arc�consistency enforcing algorithm has undergone several optimizations� from</p><p>AC�� �describ ed in �Mon��� Mac���� to AC�� �describ ed in �BFR����� With AC��� we get</p><p>�</p><p> optimal time complexity in O(ed ) and AC�� gives further e�ciency and a space complexity</p><p> in O(ed)� However� most CLP languages rely on mo di�ed versions of AC�� �vHDT���� b ecause</p><p> it is easily tuned to handle sp eci�c classes of constraints more e�ciently�</p><p>Actually� no CLP language� to our knowledge� do es enforce lo cal consistency at a level higher</p><p> than strong ��consistency� Pragmatically� a stronger level would mean earlier unsatis�ability</p><p> detection� and therefore less no des explored in the Prolog search tree� but it would also mean</p><p> more work at each no de� Exp erimentally� arc�consistency app ears to b e a reasonable tradeo��</p><p>A last interesting prop erty of all the lo cal consistency enforcing algorithms is their natural</p><p> incrementality with resp ect to the addition of constraints in the problem� Indeed� the CSP</p><p> obtained after arc�consistency enforcing� if non empty� has smaller domains than the initial</p><p>CSP and is nevertheless equivalent to the original CSP� it may simply b e used instead of the</p><p> original CSP�</p><p>����� From lo cal consistency to satisfaction</p><p>Since CLP languages only enforce arc�consistency� the information available at each no de of the</p><p>Prolog tree is not a �solved form� of the CSP which could b e pro jected on the query variables�</p><p>7</p><p>� but simply reduced domains with no guarantee of satis�ability</p><p>Since satisfaction is a practically imp ortant problem� an additional mechanism must b e used</p><p> to solve the satisfaction problem� The idea� which originates in the CSP �eld� is to use a hybrid</p><p> of backtrack tree search and arc�consistency enforcing �Nad��� vH�� ��</p><p>8</p><p>The algorithm� known as �Really Full Lo ok Ahead� � is simply a backtrack tree search</p><p> where the assignment consistency test is replaced by arc�consistency enforcing� Given an initial</p><p>7</p><p>The strong n�consistent closure of a CSP would give a �solved form�� but at the cost of an exp onential</p><p> amount of memory in the worst case�</p><p>8</p><p>Some CLP languages actually use a weaker level of lo cal consistency enforcing than full arc�consistency�</p><p> de�ning algorithms known as �Forward�checking� or �Partial Lo ok�Ahead�� See �Nad��� vH����</p><p> arc�consistent CSP with variables x � � � � � x assigned� it tries to assign a new variable x � If</p><p>� k k+�</p><p> no value in d yields a CSP with a non�empty arc�consistent closure� a backtrack o ccurs on</p><p> k+�</p><p> the previous variable assigned and domains should b e restored to the state they had b efore this</p><p> assignment� The algorithm starts with an empty �and therefore consistent� assignment�</p><p>The algorithm always explores less no des than the simple backtrack algorithm sketched</p><p> in Section ��� since a lo cally inconsistent variable assignment of a subset of X will induce an</p><p> empty arc�consistent closure� In practice� the algorithm is often several order of magnitude</p><p> more e�cient than the backtrack algorithm� It b ene�ts from two main typ es of heuristics�</p><p>� variable ordering heuristics decide dynamically� during search� which will b e the next</p><p> variable x that will b e assigned� The general principle underlying all these heuristics is</p><p> k</p><p> the so�called �rst�fail principle� cho ose a variable which is highly constrained so that if a</p><p> failure must o ccur� it is rapidly detected� A go o d choice is to favor variables with a small</p><p> actual domain and with a high degree in the constraint graph�</p><p>� value ordering heuristics decide dynamically which value should b e assigned successively</p><p> to the variable x that has b een chosen� Even if some �general purp ose� value ordering</p><p> k</p><p> heuristics have b een prop osed �see �MJPL�� ��� the b est results are usually obtained with</p><p> heuristics that take into account the precise problem class at hand�</p><p>See �Tsa�� �� chapter � for further information on variable and value ordering heuristics�</p><p>In CLP languages� the actual tree search is done using the underlying non�determinism</p><p> of the Prolog language� A sp eci�c predicate� usually called indomain�X�� enumerates and</p><p> successively assigns each of the values of the domain of the CSP variable X to this variable�</p><p>Since this mechanism is programmed in Prolog� it can actually b e completely mo di�ed and</p><p> tuned to exploit heuristics and sp eci�c prop erties of the problem at hand�</p><p>9</p><p>Example� the fol lowing Chip code solves the graph ��colorability instance</p><p> of Fig� � using the �nite domain solver� The predicate ��color de�nes the three do�</p><p> main variables and the three constraints� while the labeling predicate is in charge</p><p> of the enumeration process� The prede�ned predicate delete�X�L�R�first fail�</p><p> chooses a CSP variable X in the list L with a smal lest domain and leaves the re�</p><p> maining variables in R�</p><p>��color�X��X��X�� ��</p><p> labeling�����</p><p>� Domain declaration</p><p> labeling��X�Y�� ��</p><p>X� �� �����</p><p>� Choice of a variable</p><p>X� �� �����</p><p> delete�Var��X�Y��Rest�first�fail��</p><p>X� �� �����</p><p>� Choice of a value</p><p>� Three 6= constraints</p><p> indomain�Var��</p><p>X� �n� X��</p><p> labeling�Rest��</p><p>X� �n� X��</p><p>X� �n� X��</p><p>� Look for a solution</p><p> labeling��X��X��X����</p><p>9</p><p>See the b eginning of Section � for more sp eci�c syntax explanations�</p><p>If the query ��color�A�B�C� is given to the CLP language� the tree search wil l</p><p> be very smal l� since as soon as any of the three variables is assigned� and whatever</p><p> its value� an empty arc�consistent closure is obtained and backtrack occurs� The</p><p>CSP being unsatis�able� the answer wil l simply be �No��</p><p>Beyond satisfaction� optimization is also p ossible through sp eci�c predicates using vari�</p><p> ants of the Branch and Bound algorithm� often related to the �Depth First Iterative Deep en�</p><p> ing� �Kor����</p><p>����� Integrating CSP in CLP</p><p>As we said� in �pure� CSP� constraints are often supp osed to b e expressed by the set of au�</p><p> thorized tuples� If this language is extremely p owerful� since it allows the expression of any</p><p> constraint on a �nite domain� it is also very cumb ersome� Therefore� all CLP languages have</p><p> limited the set of constraints that the user may express to a sp eci�c language which usually</p><p> contains basic arithmetic constraints� often linear �in�equations with unlimited arity�</p><p>The traditional arc�consistency enforcing algorithms of general CSP can b e �nely tuned to</p><p> b etter take into account the nature of these constraints� Most languages� to our knowledge�</p><p> essentially p erform a so�called �b ound propagation�� related to interval calculus� which can b e</p><p> easily extended to real ��oating p oint� domains �Dav��� vH��� Lho����</p><p>P</p><p>Example� for a linear equality a �x = �� al l variables x having a �nite integer</p><p> i i i</p><p> domain� and considering� for the sake of simplicity� that al l the a are positive� it</p><p> i</p><p> is possible to update the domain of x as fol lows� Since</p><p> j</p><p>X</p><p>- min(a �x )�a x �</p><p> i i j j</p><p> i6=j</p><p> then al l the values in the domain of x which are larger than the right member can</p><p> j</p><p> be removed� without losing any solution� By symmetry� an analogous lower�bound</p><p> may be built�</p><p>As in traditional arc�consistency enforcing� if the domain of x is modi�ed� then</p><p> j</p><p> the domains of al l the variables connected to x through a constraint should also be</p><p> j</p><p> updated �and so on� iteratively� until quiescence��</p><p>For some classes of constraints� such simple b ound propagations may su�ce to enforce arc�</p><p> consistency �vHDT����</p><p>However� the restriction to some arithmetic language is often to o strong to easily express</p><p> some natural and useful constraints� esp ecially constraints on symb olic domains� Therefore�</p><p> these constraints are usually intro duced in the constraint language using sp eci�c predicates</p><p> which are naturally called �symb olic constraints�� An example of such a constraint is the</p><p>�element�I�L�X�� constraint which involves an integer or a domain integer variable I� any</p><p> th</p><p>�nite domain variable X and a list of values L� The constraint is satis�ed i� the I element</p><p> of the list L is equal to the value of X� Such constraints are usually handled using ad�hoc</p><p> propagation mechanisms� which may or not� enforce arc�consistency� The imp ortant issue here</p><p> is to get the right tradeo� b etween the p ower of the lo cal consistency enforcing �in terms of</p><p> numb er of values deleted� and the actual e�ciency of the algorithm�</p><p>Since one cannot hop e to extensively intro duce all �useful� constraint typ es in a �xed lan�</p><p> guage� some of the expressive p ower of the CSP framework is lost� For example� the disjunctive</p><p> constraints that naturally app ear in job�shop scheduling �see Section �� cannot b e naturally</p><p> expressed as linear inequalities whereas they can b e expressed as a single CSP constraint� which</p><p> could naturally b e propagated using any arc�consistency algorithm�</p><p>��� Other domains</p><p>The three previous domains are certainly the most frequent ones in CLP languages� We rapidly</p><p> review here solvers from other domains that have b een implemented in a CLP language�</p><p>� boolean algebra � this domain� which only contains the � truth values �true and false� is a</p><p> sp ecial case of �nite domain and the previous techniques can b e used �CD���� with all their</p><p> limitations� The usual constraint language is the language of mathematical prop ositional</p><p> logic and includes conjunction� disjunction� implication� equivalence� � � The satis�ability</p><p> problem is the general sat problem �GJ���� which is again NP�complete�</p><p>A large numb er of techniques have b een prop osed to solve the satis�ability problem�</p><p>Enumerative techniques such as Davis and Putnam�s pro cedure �DP���� which are closely</p><p> related to CSP tree search algorithms� are not easily made incremental� Prolog III uses</p><p> a variant of SL�resolution describ ed in �BB���� This algorithm requires that formulas b e</p><p> translated to clausal form �a conjunction of disjuncts�� which may b e quite costly� It is</p><p> naturally incremental and yields a �simpli�ed� form of the constraint set� Binary Decision</p><p>Diagrams �Bry��� o�er an e�cient� incremental representation of b o olean formulas� One</p><p> of the b o olean solvers of Chip uses a variable elimination algorithm along with these</p><p>BDDs� A BDD explicitly represents all the solutions of the constraint set� Despite</p><p> e�cient compression metho ds� it may o ccupy an exp onential amount of memory in the</p><p> worst�case�</p><p>An imp ortant di�erence with �nite domains solvers is that most CLP languages try to</p><p> o�er the user a �legible� representation of the current b o olean constraint set �whereas</p><p> only restricted domains or a solution are available for �nite domains�� This may de�ne a</p><p> very di�cult problem�</p><p>� non linear equations in R � several approaches exist� In a �rst approach� the expression</p><p> of non linear constraints is p ossible� but these constraints are simply �frozen� �ignored�</p><p> until they b ecome eventually linear� when enough variables get assigned �by the user or</p><p> b ecause their value can b e entailed from the constraints�� These constraints are then</p><p> communicated to the linear programming solver� The approach is quite simple and al�</p><p> lows the use of p olynomials or transcendental functions� If some non�linear constraints</p><p> remain non linear �and frozen� when a solution is obtained� then the answer given by the</p><p>10</p><p>CLP language ignore the frozen constraints and may b e meaningless � For example� a</p><p>Z</p><p> constraint such as �X�pow�Y�Z�� stating that X = Y � will b e delayed until either ��� Z is</p><p> known to b e equal to � �and X��� or � �and X�Y� or ��� Y is known to b e equal to � �and</p><p>X��� or ��� two variables among X� Y� Z have a known value and the remaining one can</p><p> b e evaluated�</p><p>Another approach consists in trying to solve the non�linear equations using dedicated</p><p>+ 11</p><p> algorithms� Cal �ASS ��� uses a sp eci�c solver to solve p olynomial equations in C �a</p><p> relaxation of the original problem in R � to eventually prove its inconsistency�</p><p>A last approach� which is not limited to p olynomial equations� is to use extensions of the</p><p>�nite domains lo cal consistency prop erties to �oating p oint domains �see �Dav��� SH���</p><p>Hyv�� � Lho�����</p><p>Several other domains� including strings� sets� features trees� � � have received attention from</p><p> the CLP community �see �Coh��� JM�����</p><p>10</p><p>Clp�R� answers �Maybe� when some constraints are still frozen and a solution is found�</p><p>11</p><p>Here� Buchb erger�s Gr�obner bases algorithm is used� with a worst�case doubly exp onential complex�</p><p> ity �Buc����</p><p>� Some existing to ols</p><p>In this section� we rapidly present the main features of some well�known CLP language im�</p><p> plementations� Most of these languages are actually commercial pro ducts whose underlying</p><p> mechanisms is not precisely do cumented� the constraint solvers are black b oxes and the precise</p><p> op erational semantics of some constraints may b e unsp eci�ed� A lot of other CLP languages</p><p> exist and we invite the reader to fetch �JM�� � FAQ��� to b etter p erceive the variety of available</p><p> implementations �often for free��</p><p>As in classical logic programming� a constraint logic program is a collection of clauses�</p><p> p ossibly involving some constraints�</p><p>� Example in Prolog III �non standard syntax�</p><p> c��X�Y�Z� �� c��R�� �Z � �X�Y� X���� Y��� �</p><p> c��X� �� �X � �� �</p><p>� Example in Chip V� �Edinburgh syntax�</p><p> c��X�Y�Z� �� c��R�� Z �� �X�Y� X ��� �� Y �� ��</p><p> c��X� �� X �� ��</p><p>To activate a program� one has to express a query� i�e�� a sequence of goals and constraints�</p><p> if no goals are sp eci�ed� the query is simply to solve the constraint system� The system then</p><p> b ehaves like a classical prolog� but each time a clause is used� the asso ciated constraints are</p><p> added to the current constraint set� Constraints solvers are then used to check the consistency</p><p> of the current state� Backtrack o ccurs when either a goal cannot b e proved or the current set</p><p> of constraints b ecomes inconsistent� If the goals can b e proved� the current substitutions of the</p><p> variables are a solution� provided that they satisfy the set of constraint� Hence the �answer� is</p><p> given under the form of a set of variable bindings and constraints� Completeness of the solving</p><p> pro cess dep ends on the domain of computation used�</p><p>��� CLP�R�</p><p>+</p><p>The language Clp�R � �HJM ��� is an implementation of the general CLP�X � scheme de�ned</p><p> by J� Ja�ar and J�L� Lassez in �JL���� The �rst release was available around ���� and the</p><p>12</p><p> current release ��� is available for free from IBM for academic and research purp oses only �</p><p>Clp�R � is p erhaps the b est system to start with if you want to discover what �pure�</p><p>13</p><p> constraint logic programming is � The only domain tackled� b eyond the usual tree domain� is�</p><p> as the name says� real numb ers� approximated using �oating p oint numb ers� This keeps the</p><p> system small� homogeneous and with a simple syntax�</p><p>The underlying solver is a Simplex�derived solver� with a sp eci�c Gaussian elimination mo d�</p><p> ule for linear equalities� Because of the �oating p oint implementation� the strict inequalities�</p><p> which are available as in Prolog III� do not have the precise semantics that can b e obtained</p><p> using in�nite precision rational numb ers�</p><p>The system contains a mechanism for delaying non�linear constraints until enough other</p><p> numerical constraints make them linear� As we said in Section ���� if a solution is found when</p><p> a non�linear constraint is still delayed� Clp�R � simply answers �Maybe�� Anyway� a large set of</p><p>12</p><p>For more information� contact Joxan Ja�ar via e�mail �joxan�watson�ibm�com��</p><p>13</p><p>However� Clp�R� do es not include a �nite domain solver� one of the main novelty of constraint programming�</p><p>People interested in �nite domains may try to get clp�FD�� another free system �CD��� available via anonymous</p><p>PROGRAMMING�clp fd� FTP at ftp�inria�fr��INRIA�Projects�ChLoE�LOGIC</p><p> primitives is available to express non�linear constraints �e�g�� Z = X � Y � Y = log(X)� and the</p><p> language has b een essentially used to deal with partially non linear problems�</p><p>The system contains facilities for �meta�programming� with constraints and allows to ex�</p><p> plicitly manipulate terms and arithmetical constraints� a co ded form b eing available to the</p><p> user� These facilities are not available in any of the other languages considered here�</p><p>The initial implementation was interpreted� The actual release uses a byte�co de compiler</p><p> for a b etter e�ciency of the underlying Prolog� It is entirely written in the C language and</p><p> runs on most existing Unix workstations and includes MS�DOS supp ort� Clp�R � has b een</p><p> used to solve various real problems� analysis and synthesis of analog circuits �HMS���� sto ck</p><p> option analysis �HL��� or problems from computational biology such as DNA sequencing by</p><p> restriction site mapping �Yap����</p><p>��� Prolog III</p><p>A� Colmerauer and his team �rst de�ned the mo del of a Prolog with constraints around �����</p><p> as an extension of the Prolog II mo del� The commercial version of Prolog III has b een</p><p> o�cially announced in �����</p><p>Compared with other to ols �e�g�� Chip�� Prolog III is very homogeneous� providing� in</p><p> particular� a nice uniform syntax� A Prolog III program� like a Prolog one� consists of</p><p> a collection of clauses� which can p ossibly contain constraints� Constraints are syntactically</p><p> distinguished from classical Prolog predicates using braces�</p><p>Prolog III supp orts three domains of computation�</p><p>� rational numbers � like Chip� Prolog III uses exact precision rational numb er arith�</p><p> metics� The numerical mo dule handles linear inequations �where every variable is sup�</p><p> p osed to b e p ositive�� It is essentially an incremental Simplex�like solver� which checks</p><p> that the accumulated numerical constraints can b e satis�ed �as so on as the resolution</p><p> pro cess triggers a new constrained clause� the solver is fed with the attached constraints�</p><p> it ensures a complete resolution of the constraint system�� Of course� it is also p ossible</p><p> to sp ecify some �linear� criteria to b e optimized� Note that in addition to traditional</p><p>Simplex techniques� much attention has b een paid to strict inequalities�</p><p>Prolog III also allows the sp eci�cation of non�linear constraints� They are in fact</p><p> delayed until the binding of some variables makes them linear� If it is not the case� the</p><p> solving pro cess may give an inconsistent set of constraints as answer� without detecting</p><p> the inconsistency�</p><p>Prolog III do es not naturally handle discrete domains� Nevertheless� it is p ossible to</p><p> express some linear constraints over integers� linear arithmetics constraints over integers</p><p> are �rst solved in Q � Enumeration predicates must b e used in order to �nd an integer</p><p> solution�</p><p>� booleans � the b o olean mo dule is based on clausal forms� The underlying algorithms</p><p> are incremental versions of the SL�resolution algorithms� They are able to check the</p><p> consistency of a set of b o olean constraints� moreover� they simplify the constraint system</p><p> into a set of constraints involving a minimal set of variables�</p><p>� �nite lists �or �nite strings� � for �nite strings� there exists a single function to concate�</p><p> nate two strings� denoted by ��� and the only constraint is the equality constraint�</p><p>Prolog III delays the evaluation of any string constraint until the length of the string is</p><p> known� Technically� the string solver is based on a restricted string uni�cation algorithm�</p><p>Prolog III is develop ed and distributed by PrologIA �France�� It is an <a href="/tags/Interpreter_(computing)/" rel="tag">interpreter</a> with</p><p> p ossible connections to the C language� It is available on Unix workstations� PC and MacIn�</p><p> tosh� While the other constraint�based to ols fo cus on big industrial accounts� Prolog III was</p><p>�rst successfully distributed to the academic and research �elds� Let us nevertheless cite two</p><p> applications� the �rst one is an exp ert system analyzing failures in motors �used by Daimler�</p><p>Benz and Bosch� Germany�� The second one �for Delacroix� France�� optimizes the cutting of</p><p> wo o d panels�</p><p>��� CHIP V�</p><p>Like Prolog III� Chip V� is a Prolog�based constraint to ol� It is a direct heir of the ECRC</p><p> research prototyp e Chip� but di�ers from the prototyp e in many asp ects �notice that the ECRC</p><p> continues to develop its own system� Eclipse� which� unlike Chip V�� is an op en system�� In</p><p> a Chip program� constraints are not syntactically distinguished from the other predicates�</p><p>Chip provides a large numb er of pre�de�ned constraint predicates� on di�erent domains of</p><p> computation�</p><p>� integers � �nite domains � the most imp ortant feature of the Chip system is the intro�</p><p> duction of arithmetic constraints over �nite domains� In addition� a rich set of symb olic</p><p> constraints is provided �for instance� the �alldifferent�Variable List�� predicate�</p><p> which sp eci�es that all the variables in the list must have di�erent values� let us also cite</p><p> the cumulative constraint� dedicated to scheduling applications� see Section ���</p><p>Classical constraint propagation metho ds �e�g�� arc�consistency enforcing� originating</p><p> from the CSP �eld are used to handle �nite domain constraints� Since they are of course</p><p> incomplete� choice predicates are also provided which allow the generation of values for</p><p> the �nite domain variables�</p><p>Moreover� minimization is done using Branch � Bound� the prede�ned predicate</p><p>�min max�Goal�C�� �nds a solution which minimizes the maximal value in a list of cost</p><p> terms C� In practice� this is done by �nding a �rst solution� evaluating C and then re�</p><p> starting the search with a new constraint requiring C to b e lower than this value� Never�</p><p> theless� as discussed in �vH�� �� optimization problems resolution is still to b e enhanced�</p><p>� rationals � linear rational constraints are handled by an extended Simplex algorithm as�</p><p> so ciated with some Gaussian elimination� Only linear arithmetic constraints are allowed</p><p> in Chip V�� The rational constraint solver is then obviously complete� Note that opti�</p><p> mization predicates over rational linear constraints are also provided�</p><p>� booleans � b o olean constraints are solved by a variable elimination based b o olean uni�</p><p>�cation algorithm� which is totally deterministic but still complete� Nevertheless� since</p><p> constraint solving in b o olean algebra is NP�complete� Chip may encounter problems which</p><p> cannot b e solved in a reasonable time �this is of course a general problem� which may</p><p> also o ccur in other languages��</p><p>Finally� Chip gives the user the p ossibility to de�ne its own constraints and control their</p><p> execution� via the use of demons� these have the e�ect of re�evaluating a sp eci�ed goal each</p><p> time a given triggering event �such as a change in a variable domain� o ccurs� This mech�</p><p> anism implements lo cal consistency algorithms for user�de�ned constraints� The declarative</p><p>�if�then�else� construct also allows a �limited� way of communicating information b etween</p><p> heterogeneous constraints�</p><p>Chip V� is develop ed and distributed by Cosytec �France�� The pro duct also o�ers</p><p> graphic capabilities� connections to databases and connections to C language� It runs un�</p><p> der Unix �Sun� IBM� HP� Dec� and Dos �PC�� Many applications have b een develop ed� for</p><p> instance� the planning application �Plane� �BCF��� provides ��year schedules for Dassault�</p><p>Aviation �France� and the multi�user scheduling to ol develop ed for Monsanto �Belgium��</p><p>��� ILOG Solver�Schedule</p><p>Ilog�Solver is often describ ed �JM��� as a C�� library that implements CSP algorithms on</p><p>�nite and �oating p oint domains rather than as a CLP language� Presumably� this is due to</p><p> the fact that Solver do es not use the usual Horn clauses language and do es not include a</p><p> solver on rational or �nite trees�</p><p>Anyway� this description is somewhat unfair� since Solver includes an extension of C��</p><p> that enables the expression of non�determinism� traditionally o�ered by Horn clauses in other</p><p> languages� The domain of �nite�rational trees is not included simply b ecause it do es not seem</p><p> useful for the combinatorial problems addressed by Solver�</p><p>Solver provides several classes of variables� each implemented as a C���class� These</p><p> classes de�ne the domains handled by the language�</p><p>� integer variables� whose domain is either an interval or an enumeration of integers� These</p><p> variables can b e involved in linear or non linear arithmetic constraints� Non linear con�</p><p> straints are propagated� According to the authors �Pug���� the handling is similar to the</p><p> propagation mechanism describ ed in �vH����</p><p>� �oating point variables� whose domain is an interval� These variables can b e involved in</p><p> linear and nonlinear arithmetic constraints� or monotonic op erators such as �log�� The</p><p> underlying solver consists of a limited form of arc�consistency enforcing which� according</p><p> to the authors� owes much to �Lho����</p><p>� boolean variables �domain ftrue � false g�� These are also handled using constraint propa�</p><p> gation�</p><p>� set variables� whose domain is a set of sets� Initially� the domain of such a variable</p><p> contains all the subsets of a given initial set of ob jects� The constraints that may b e</p><p> expressed state that some elements must b e in the set� that other should b e excluded� or</p><p> can limit the range of the cardinality of the set�</p><p>All these constraints� are handled using a uniform underlying constraint propagation mecha�</p><p> nism� related to arc�consistency enforcing� Some additional �symb olic constraints� are pro�</p><p> vided and the user has the ability to de�ne ad�hoc propagation mechanisms for user de�ned</p><p> constraints�</p><p>Finally� the library tries to o�er �ob ject oriented� features� memb ers of user�de�ned classes</p><p> may b e �CSP� variables and the user may de�ne �constraints of classes�� which are inherited</p><p> by instances�</p><p>Solver is develop ed and distributed by Ilog �France�� The pro duct� distributed as a C��</p><p> library� is fully compatible with all other Ilog C�� software comp onents� including connection</p><p> to databases� graphical interfaces� rule�based programming� � � It runs under several Unix�based</p><p> systems and under Windows �PC�� Solver has b een used to tackle several real combinatorial</p><p> problems� from lo comotive scheduling used by the sncf �Pug��� to p ersonnel management in</p><p> the French army �PPMD����</p><p>Floating</p><p>Finite</p><p>Rational</p><p>Finite</p><p>Rationals</p><p>Bo oleans</p><p> domains</p><p>In</p><p>Strings</p><p> p oin</p><p> tegers</p><p> trees trees</p><p>Sets</p><p> ts</p><p>Clp�R � - � � - - - � � -</p><p>Prolog III � � � - � � � � -</p><p>Chip - � � � � � � � -</p><p>Solver - - - � � - � � �</p><p>�� constraints are handled on this domain</p><p>� authorized variable typ e� no constraints</p><p>-� non�existent variable typ e</p><p>Table �� Domains addressed in each language</p><p>Ilog�Schedule �Pap��� is a C�� library of scheduling ob ject classes that automates the</p><p> use of Solver for representing �nite capacity scheduling problems� It o�ers tuned constraint</p><p> propagation mechanisms for the usual constraint typ es that o ccurs in scheduling� Typical</p><p> classes include activities and various resources typ es �renewable or not� unary or �nite ca�</p><p> pacity� � � �� See Section � for a �rst approach of job�shop�scheduling problems using a CLP</p><p> language�</p><p>��� Summary</p><p>Table � gives an overview of which domains are addressed by which CLP languages� The lan�</p><p> guage Chip app ears to b e the more general CLP language� This judgment should b e somewhat</p><p> temp ered� Indeed� all the languages which handle �nite domains can also handle b o oleans and</p><p> integers� with the ability of handling non convex domains such as f�� �� �� �� �� �g� Prolog III</p><p> may also handle integers �rationals with a denominator equal to one�� but it cannot handle non</p><p> convex domains� Since the Simplex only proves satis�ability in Q � an exp ensive enumerating</p><p> pro cess� as for �nite domains� must b e used�</p><p>Note also that one single problem may often b e formalized using di�erent mo dels� a schedul�</p><p> ing date may b e mo deled as integer� rational or �oating p oint numb ers�</p><p>More imp ortantly� if several constraint solvers exist in the same language� it is often im�</p><p> p ossible to use the solvers simultaneously on �mixed� problems� where more than one typ e of</p><p> variable o ccurs in the same constraint� b ecause it is usually imp ossible to relate a variable from</p><p> one domain to a variable from another domain� For instance� the relation b etween a rational</p><p> and its integer part cannot b e expressed as a constraint in Chip� Along the same idea� it</p><p> is usually not p ossible to asso ciate a b o olean variable to the fact that a given constraint is</p><p> satis�ed� e�g�� � = (x � y)�</p><p>Thanks to its underlying uniform constraint propagation mechanism� Solver is quite ad�</p><p> vanced in this direction and can handle some �mixed� constraints� For example� a constraint</p><p> of equality exists b etween �oating p oint and integer variables�</p><p>� Application to Job�Shop Scheduling</p><p>A scheduling problem arises when a set of interdep endent tasks is to b e organized in time� Such</p><p> a situation app ears for example in pro ject planning� service activities� manufacturing shops�</p><p> computer systems or examination timetabling� The problem is to lo cate a set of tasks in time�</p><p> each task needing one or several resources during its execution� The constraints to satisfy may</p><p> b e various� technological �sequencing� routing�� resource �limited capacity�� temp oral lo cation</p><p>�release dates� deadlines�� � � � Most optimization problems in the scheduling �eld are NP�</p><p> hard �GJ���� To �nd solutions to these combinatorial problems� op erational research develop ed</p><p> exact pro cedures like Branch � Bound� in order to �nd lower and upp er b ounds of the optimal</p><p> solution� or designed heuristics with some re�nements sp eci�c to the problem at hand for</p><p> pruning the search space �ML����</p><p>Scheduling problems have b een widely studied in the literature �Bak��� Gra��� GOT���</p><p>Pin���� Amongst many di�erent typ ologies� a basic classi�cation may b e based on the resource</p><p> environment� single machine� parallel machines� �ow�shop� job�shop� op en�shop or resource�</p><p> constrained problems�</p><p>In this section� an illustration of the application of CLP to scheduling problems is given</p><p> through the job�shop scheduling problem� as in �Wal���� The following examples of mo deling</p><p> are written in the same language for the sake of unity� The Chip language was chosen and more</p><p> sp eci�cally its CSP�based solver over �nite domains� A domain variable �the Chip equivalent</p><p> of a CSP variable� is de�ned via ��� a��b� where ���� is the domain de�nition op erator and</p><p>�a��b� a domain of consecutive set of integers� Furthermore� constraints on �nite domains are</p><p> preceded by the sp ecial character ��� to distinguish them from other arithmetical constraint</p><p> typ es in Chip�</p><p>��� Problem Statement</p><p>In the job�shop problem a set of n jobs has to b e pro cessed using a set of m machines� Each</p><p> job consists of a set of ordered tasks forming a routing� each task runs on a separate machine�</p><p>At any time a machine can pro cess only one task� Preemption i�e�� interruption of a started</p><p> task b efore completion� is not allowed� The ob jective is often to �nd a schedule that minimizes</p><p> the makespan� i�e�� the total duration�</p><p>This section aims at giving information ab out how to simply mo del such problem� deriving</p><p> b ene�t from assets of CLP� Facing the imp ortant numb er of constraints for large job�shop</p><p> scheduling problems� an approach using CLP do es not have to solve the constraints involved</p><p> but to propagate them by lo cal consistency techniques� in order to reduce the search space as</p><p> drastically as p ossible�</p><p>��� Precedence constraints</p><p>The jobs are considered one after the other� For each job a list of tasks is given in the order</p><p> of the routing� Thus task i �with start time T and duration D � from the list must precede</p><p> i i</p><p> task i + �� To satisfy this precedence constraint� one must p ost a relative lo cation constraint</p><p> b etween tasks i and i + ��</p><p>T + D � T �</p><p> i i i+�</p><p>To each task of a job is also asso ciated a start domain variable� p osting in this way an absolute</p><p> lo cation constraint �Max corresp onds to a given horizon��</p><p> job��T��T���D��D��Max� ��</p><p>T� �� ���Max� � Declaration of the first variable</p><p> routing��T��T���D��D��Max��</p><p> routing��Tm���Dm��Max� ��</p><p>Tm � Dm ��� Max� � Constraint on the latest variable</p><p> routing��T��T��T���D��D��D��Max� ��</p><p>T� �� ���Max� � Declaration of other variables</p><p>T� � D� ��� T�� � Precedence constraint</p><p> routing��T��T���D��D��Max��</p><p>��� Disjunctive constraints</p><p>As it is not p ossible to pro cess simultaneously two tasks on the same machine� one needs</p><p> to generate disjunctive constraints b etween comp eting tasks� In a general way� a disjunctive</p><p> constraint �or competition� b etween a pair (i� j) of tasks states that i precedes j or j precedes</p><p> i� It yields�</p><p>(T + D � T ) or (T + D � T )�</p><p> i i j j j i</p><p>Di�erent ways for mo deling this kind of constraint are presented b elow�</p><p>�� Choice points</p><p>The most natural way to mo del an alternative is made through the intro duction of choice</p><p> p oints �DSv��� vH����</p><p> competition�Ti�Di�Tj�Dj� �� Ti � Di ��� Tj� � i precedes j</p><p> competition�Ti�Di�Tj�Dj� �� Tj � Dj ��� Ti� � j precedes i</p><p>This implementation is clearly nondeterministic due to its transcription into a disjunction</p><p> of constraints �one packet of two clauses�� Hence this way of mo deling a disjunctive</p><p> constraint is highly ine�cient� indeed� for n comp eting tasks� it develops a search space</p><p> n</p><p> in O(� )�</p><p>�� Conditional propagation</p><p>The conditional propagation of Chip allows the programmer to avoid the aforementioned</p><p> choice p oints� It uses a demon mechanism to limit the nondeterministic b ehavior of pre�</p><p> vious implementation by p ostp oning the choices until enough information can b e deduced</p><p> from the constraints� As so on as the if condition is true for all p ossible values for the</p><p>14</p><p>� Thus the principle of the disjunctive constraint variables� the then branch is selected</p><p> implementation is the following� if the minimal �nish time of a task j is larger than the</p><p> maximal start time of another task i� i must b e scheduled b efore j�</p><p> competition�Ti�Di�Tj�Dj� ��</p><p> if Tj � Dj �� Ti then Ti � Di ��� Tj�</p><p> if Ti � Di �� Tj then Tj � Dj ��� Ti�</p><p>Although more e�cient than the previous implementation� this metho d keeps the incon�</p><p> venience to have to wake the demon for pruning the search tree�</p><p>14</p><p>Using �if�then�else�� the else branch is executed when the condition is always false�</p><p>�� Cardinality operator</p><p>Using the same principle of conditional propagation� van Hentenryck � Deville �vHD���</p><p> intro duce the cardinality operator to imp ose the minimum and maximum numb er of con�</p><p> straints to b e satis�ed among a set of constraints� This op erator is a mathematical</p><p> abstraction which implements the principle �Infer simple constraints from di�cult ones��</p><p> at the op erational level� Thus with such an op erator exactly equal to �� the disjunctive</p><p> constraint may b e written as follows�</p><p> competition�Ti�Tj�Di�Dj� ��</p><p> cardinality������Ti�Di ��� Tj� Tj�Dj ��� Ti���</p><p>Note that in the case of two disjunctive constraints C� and C�� the cardinality op erator</p><p> may b e expressed thanks to the conditional propagation �Cos�� ��</p><p> or�C��C�� ��</p><p> if C� then true else C��</p><p> if C� then true else C��</p><p>The authors show that non�primitive constraints built with the cardinality op erator give</p><p> comparable �or even b etter� results to builtin constraints� but really improving the �exi�</p><p> bility of utilization and expressiveness of cardinality constraints �in order for example to</p><p> mo del more general problems than the disjunctive one��</p><p>�� The cumulative primitive</p><p>The previous implementations concern the so�called b ound propagation also known as</p><p>��B�consistency� �Lho���� that is to say these rules adjust the extreme b ounds of the</p><p> domain variables �head and tail of a task�� However� the disjunctive constraints could</p><p> also attempt to achieve arc�consistency� without p osting any choice p oint or waiting for</p><p> a demon to b e awaken�</p><p>This is the goal of the cumulative constraint of Chip which aims at solving resource�</p><p> constrained scheduling problems� it can also b e used for disjunctive problems such as the</p><p> job�shop problem where the amounts of resources �intensities or capacity� are all equal</p><p> to ��</p><p> competition�Ti�Di�Tj�Dj� ��</p><p> cumulative��Ti�Tj���Di�Dj�����������</p><p>In �AB���� the designers of the cumulative primitive present some results in placement�</p><p> pro ject management and job�shop scheduling problems� In the latter case and for the</p><p> famous �� � �� b enchmark �FT���� it seems that a simple programming using the cu�</p><p> mulative primitive and a lab eling pro cedure based on �rst�fail principle� allow them to</p><p>0</p><p> obtain the optimal solution of cost ��� in �� on a Sun� workstation ���Mb� while a �rst</p><p>00</p><p> solution is found with a cost of ���� in � �</p><p>In the examination timetabling framework �BDP���� this kind of implementation did not</p><p> realize su�cient pruning to get acceptable results� The authors improved the e�ciency</p><p>15</p><p> by using another builtin predicate ��distance� � whose utilization has b een p ossible</p><p> due to the presence of symmetries in the problem constraints�</p><p>While using the cumulative primitive without generating any solution� one can notice that</p><p> the impact of the constraint propagation may vary with the order in which constraints</p><p>15</p><p>The predicate �distance� imp oses an absolute distance b etween two domain variables�</p><p> are p osted� Hence this builtin predicate� running as a black�b ox� uses ad�hoc propagation</p><p> and do es not seem to achieve arc�consistency�</p><p>�� Arc�consistency</p><p>The disadvantage raised previously led us to build our own primitive for arc�consistency</p><p> and enforcing� It satis�es prop osition � �T T stand for the earliest and the latest start</p><p> i</p><p> i</p><p> times of i� resp ectively��</p><p>+ D + D � � + D � Prop osition � �see Fig� �� If T T then T � [T T - D ] � [T T ]�</p><p> j i j j i j i i</p><p> j i j</p><p>Pro of� Two sequences are possible between i and j� i before j or j before i� If i before j�</p><p>+ D � It yields� T � [T + D � � T � If j before i� T � T T - D ] � [T T ]� Thus T + D �</p><p> j i j j i j i i i i</p><p> j j i</p><p>T - D � T T - D � T if both intervals are disjoint T �� ] + D [ with + D � 2</p><p> j i j i i j j</p><p> j j</p><p> j</p><p> i</p><p>Figure �� Inconsistent values for start time of i</p><p>Prop osition � leads to the removal of inconsistent dates of T � i�e�� in ] + D [� The T - D � T</p><p> i j j i</p><p> j</p><p> implementation uses the �notin� predicate which allows the removal of values inside a</p><p> domain� and the conditional propagation where the same domain variable is used in each</p><p> hand of the inequality� in the lines commented by � check proposition �� in the left</p><p> hand the maximum p ossible value of the variable is examined whereas it is the minimum</p><p> one in the right hand�</p><p> revise�Ti�Di�Tj�Dj� ��</p><p>D is Di � Dj�</p><p> if Tj �� Tj � D � check proposition �</p><p> then remove�values�Ti�Di�Tj�Dj�� � remove values in Ti</p><p> if Ti �� Ti � D � check proposition �</p><p> then remove�values�Tj�Dj�Ti�Di�� � remove values in Tj</p><p> remove�values�Ti�Di�Tj�Dj� ��</p><p> domain�info�Tj�Tjmin�Tjmax��</p><p>Min is Tjmax � Di � ��</p><p>Max is Tjmin � Dj � ��</p><p> notin�Ti�Min�Max��</p><p> info� returns statically the smallest Note that the builtin information predicate �domain</p><p> and the largest values in the domain of the variable� It is then interesting to handle demon�</p><p> propagation into the �remove values� predicate �not detailed here�� so as to obtain a</p><p> complete dynamic b ehavior�</p><p>��� Edge �nding</p><p>The previous disjunctive constraint �whatever its implementation� can deduce strong conclu�</p><p> sions for the global sequencing� In practice� time windows can b e very large related to pro cessing</p><p> times� and this rule may b e useless and prune no value� It could then b e more promising to</p><p> study the extreme p ositions of a single task i relatively to a group S of other ones �i �� S��</p><p>This technique whose principle is explained through the two following prop ositions� arises from</p><p>+</p><p> constraint�based analysis �BBD ��� ERV��� ERV���� immediate selections �CP��� and has also</p><p> b een studied in �Nui���� It is called edge �nding in �AC����</p><p>P</p><p>Prop osition � �see Fig� �� If max ( � D + D then S is non�p osterior T + D )- T</p><p> s2S s i s s</p><p> i</p><p> s2S</p><p> to i� i�e�� i cannot be scheduled before all activities of S�</p><p>Pro of� Suppose i precedes al l activities of S and let z � S be the task scheduled last� Thus</p><p>P</p><p>(T + D ) � (T + D + D ) � (max ( T + D )) � (T + D ) which leads to the contradiction</p><p> z z i s s2S s s z z</p><p> i</p><p> s2S</p><p>T � 2 T �</p><p> z z</p><p> s3</p><p> s2</p><p> s1</p><p> i</p><p>Figure �� Non�p osterior set</p><p>If S is non�p osterior to i then at least one task of S must precede i� Thus it can b e deduced</p><p> a lower b ound of the start time of i� it is up dated to the smallest earliest �nish time among</p><p> the tasks of S �the minimum and maximum prede�ned predicates are used��</p><p> non�posterior�set�Ti�Di�S� ��</p><p> set�duration�S�DS�� � Sum of durations of S</p><p>D is Di � DS�</p><p> set�ends�S�Ends�� � List of end variables of S</p><p> minimum�Min�end�Ends��</p><p> maximum�Max�end�Ends��</p><p> if Max�end �� Ti � D</p><p> then Ti ��� Min�end�</p><p>P</p><p>� D + D then i is non� Prop osition � �see Fig� �� If max ( T + D ) - min T</p><p> s i s2S s s s2S</p><p> s</p><p> s2S</p><p> inserable into S�</p><p>Pro of� Similar to previous one� 2</p><p> s3</p><p> s2</p><p> s1</p><p> i</p><p>Figure �� Non�inserable task</p><p>If i is non�inserable into S then i must b e scheduled either b efore or after S� Moreover� if</p><p>S has previously b een proved to b e non�p osterior to i then i is necessarily scheduled after all</p><p> tasks in S� Thus the start time of i can b e adjusted to the earliest �nish time of whole set S�</p><p> value much stronger than with the sole non�p osterior condition�</p><p> non�inserable�task�Ti�Di�S� ��</p><p> set�duration�S�DS�� D is Di � DS� set�ends�S�Ends��</p><p> set�starts�S�Starts�� � List of start variables of S</p><p> minimum�Min�start�Starts��</p><p> maximum�Max�end�Ends��</p><p> if Max�end �� Min�start � D</p><p> then Ti ��� Min�start � DS� � Iff S non�posterior to i</p><p>An analogous reasoning symmetrically establishes upp er b ound on the start time of a task</p><p> from a non�anterior set condition� With non�inserability condition� one can derive that i pre�</p><p> cedes all tasks in S and then re�ne this upp er b ound�</p><p>� Conclusion</p><p>The constraint programming framework is mostly known b ecause of noticeable achievement in</p><p> solving large combinatorial problems �Yap��� BCF��� Pug��� PPMD���� These results have</p><p> b een obtained b oth b ecause of the e�ciency of the underlying solvers and the extra generality</p><p> o�ered by the host non�deterministic Prolog language�</p><p>From the end of the eighties to now� the CLP scheme has integrated an increasing amount</p><p> of solvers and domains� There are now CLP languages that use intricate solvers or which are</p><p>16</p><p> connected to general systems such as Mathematica � An imp ortant shortcoming of most</p><p> existing systems is the absence of relations b etween domains� it is not yet p ossible to think of</p><p> hybrid mo dels where constraints are propagated b etween several domains� even with incomplete</p><p> satisfaction mechanisms� For instance� a b o olean variable cannot b e usually asso ciated to</p><p> the truth of one inequality b etween integer variables� achieving by that implicit propagations</p><p> b etween b o olean and �nite domain solvers�</p><p>Such hybrid mo dels would however b e promising to mo del b oth numerical �time� and sym�</p><p> b olic �sequencing� constraints of scheduling problems� and to derive inferences from a computa�</p><p> tion domain to another one� On the contrary� certain languages prop ose �global� primitives for</p><p> the solving of some sp eci�c problems �e�g�� combinatorial problems and more precisely schedul�</p><p> ing�� Surprisingly� although their underlying mechanisms are not complete� they are often kept</p><p> top secret and there is no other way for the user than using these primitives as black b oxes�</p><p>Economical accounts favors more and more the comp etition b etween constraint program�</p><p> ming to ols� It has the advantage to give rise to the application of metho ds develop ed by</p><p> academics but also to bring some new theoretical problems to light� Unfortunately� it also</p><p> leads to the �closing� of the systems� and plays a great part in missing the primary ob jectives</p><p> of CLP� i�e�� formalizing and integrating general mechanisms of constraint propagation�</p><p>For these reasons� nowadays� the only way to exp eriment hybrid solvers or to design user�</p><p> de�ned propagation mechanisms is either to build your own system from scratch or from con�</p><p> straint programming libraries such as Ilog�Solver �which has p erhaps the largest set of</p><p> event�handling primitives�� or to implement it as meta�level CLP interpretor �Bo c����</p><p>16</p><p>See �FAQ��� for an exhaustive lists of existing CLP implementations�</p><p>On the contrary� the authors think that to day there still exist go o d reasons to maintain</p><p>Logic Programming as a basic natural framework for constraint programming� in particular the</p><p> need of high�level languages for a concise and declarative representation of problems� and the</p><p> rapid prototyping of constraint�oriented applications�</p><p>These kinds of facilities require a well�founded generalization of the semantical de�nition</p><p>17</p><p> of constraints in CLP languages whereas the trend of improving e�ciency has led to develop</p><p> separately then simply juxtap ose each of the constraint domains� their solvers and primitives�</p><p>References</p><p>�AB��� A� Aggoun and N� Beldiceanu� Extending chip in order to solve complex scheduling</p><p> and placement problems� In Actes des Journ�ees Francophones de Programmation</p><p>Logique �JFPL����� pages ������ Lille� France� �����</p><p>�AC��� D� Applegate and W� Co ok� A computational study of the job�shop scheduling</p><p> problem� ORSA Journal on Computing� ������������� �����</p><p>�ACM��� Sp ecial section on logic programming� Communications of ACM� ����� ������</p><p>�AS��� Jean�Marc Alliot and Thomas Schiex� Intel ligence Arti�ciel le et Informatique</p><p>Th�eorique �in French�� Cepadues� Toulouse� France� �nd edition� ����� ISBN �</p><p>���������������</p><p>+</p><p>�ASS ��� A� Aiba� K� Sakai� Y� Sato� D�J� Hawley� and R� Hasegawa� Constraint logic pro�</p><p> gramming language CAL� In Proceedings of the International Conference on Fifth</p><p>Generation Computer Systems �FGCS����� ICOT� Tokyo� pages �������� Decem�</p><p> b er �����</p><p>�Bak��� K�R� Baker� Introduction to sequencing and scheduling� John Wiley � Sons� New�</p><p>York� �����</p><p>�BB��� J�M� Boi and F� Benhamou� Boolean Constraints in Prolog III� PhD thesis� Group e</p><p> d�Intelligence Arti�cielle� Universit�e d�Aix�Marseille� Luminy� Novemb er �����</p><p>+</p><p>�BBD ��� G� Bel� E� Bensana� D� Dub ois� J� Erschler� and P� Esquirol� A knowledge�based</p><p> approach to industrial job�shop scheduling� In A� Kusiak� editor� Know ledge�based</p><p> systems in manufacturing� pages �������� Taylor � Francis� �����</p><p>�BCF��� J� Bellone� A� Chamard� and A� Fishler� Constraint logic programming decision</p><p> supp ort systems for planning and scheduling aircraft manufacturing at dassault</p><p> aviation� In Third International Conference on the Practical Application of Prolog</p><p>�PAP����� pages ������ Paris� France� �����</p><p>�BDP��� P� Boizumault� Y� Delon� and L� P�eridy� Constraint logic programming for exami�</p><p> nation timetabling� Journal of Logic Programming� ����� To app ear�</p><p>�BFR��� C� Bessi�ere� E�C� Freuder� and J�C� R�egin� Using inference to reduce arc�consistency</p><p> th</p><p> computation� In Proc� of the �� IJCAI� Montreal� Canada� August �����</p><p>�Bo c��� A� Bo ckmayr� Logic programming with pseudo�b o olean constraints� In F� Ben�</p><p> hamou � A� Colmerauer� editor� Constraint Logic Programming� Selected research�</p><p>Logic Programming Series� pages �������� MIT Press� �����</p><p>17</p><p>Mayb e with the brand�new version of PrologIA� PrologIV �BT����</p><p>�Bry��� R�E� Bryant� Symb olic b o olean manipulation with ordered binary�decision dia�</p><p> grams� ACM Computing Surveys� �������������� Septemb er �����</p><p>�BT��� F� Benhamou and Toura��vane� Prolog IV � langage et algorithmes� In Actes des</p><p>Journ�ees Francophones de Programmation en Logique �JFPL����� pages ������ Di�</p><p> jon� France� �����</p><p>�Buc��� B� Buchb erger� Gr�obner bases� An algorithmic metho d in p olynomial ideal theory�</p><p>In N� K� Bose� editor� Multidimensional Systems Theory� pages �������� Reidel</p><p>Publishing Co�� �����</p><p>�CD��� P� Co dognet and D� Diaz� Bo olean constraints solving using clp�fd�� In Interna�</p><p> tional Logic Programming Symposium� pages �������� �����</p><p>�CKvC��� A� Colmerauer� H� Kanoui� and M� van Caneghem� Prolog� bases th�eoriques et</p><p> d�evelopp ements actuels� Techniques et Sciences Informatiques� ������������� �����</p><p>�in French��</p><p>�CM��� W�F� Clo cksin and C�S� Mellish� Programming in Prolog� Springer Verlag� �rd</p><p> edition� �����</p><p>�Coh��� J� Cohen� Constraint logic programming languages� Communications of the ACM�</p><p>������������ July �����</p><p>�Col��a� A� Colmerauer� Prolog and in�nite trees� In New York Academic Press� editor�</p><p>Logic Programming� pages �������� K�L� Clark and S�A� Tarnlund� �����</p><p>�Col��b� A� Colmerauer� PROLOG II reference manual and theoretical mo del� Technical</p><p> rep ort� Group e Intelligence Arti�cielle� Universit�e Aix�Marseille I I� Octob er �����</p><p>�Co o��� M�C� Co op er� An optimal k�consistency algorithm� Arti�cial Intel ligence� ���������</p><p>�����</p><p>�Cos��� Cosytec� Chip Reference Manual� June ����� COSY�REF�����</p><p>�CP��� J� Carlier and E� Pinson� Adjustment of heads and tails for the job�shop problem�</p><p>European Journal of Operational Research� ����������� �����</p><p>�Dav��� E� Davis� Constraint propagation with interval lab els� Arti�cial Intel ligence�</p><p>�������������� July �����</p><p> th</p><p>�dK��� J� de Kleer� A comparison of ATMS and CSP techniques� In Proc� of the ��</p><p>IJCAI� pages �������� Detroit� MI� August �����</p><p>�DP��� M� Davis and H� Putnam� A computing pro cedure for quanti�cation theory� Journal</p><p> of the ACM� ������������� �����</p><p>�DSv��� M� Dincbas� H� Simonis� and P� van Hentenryck� Solving Large Combinatorial</p><p>Problems in Logic Programming� Journal of Logic Programming� �������������</p><p>January�March �����</p><p>�ERV��� J� Erschler� F� Roub ellat� and J�P� Vernhes� Finding some essential characteristics of</p><p> the feasible solutions for a scheduling problem� <a href="/tags/Operations_research/" rel="tag">Operations Research</a>� �������������� �����</p><p>�ERV��� J� Erschler� F� Roub ellat� and J�P� Vernhes� Characterizing the set of feasible</p><p> sequences for n jobs to b e carried out on a single machine� European Journal of</p><p>Operational Research� ������������� �����</p><p>�FAQ��� FAQ of the comp�constraints newsgroup� Available at URL http���web�cs��</p><p> city�ac�uk�archive�const rain t�� �����</p><p>�Fre��� E�C� Freuder� Synthesizing constraint expressions� Communications of the ACM�</p><p>����������� Novemb er �����</p><p>�FT��� H� Fisher and G�L� Thompson� Probabilistic learning combinations of lo cal job�shop</p><p> scheduling rules� In J�F� Muth � G�L� Thompson� editor� Industrial Scheduling�</p><p> pages �������� Prentice Hall� Englewo o d Cli�s� NJ� �����</p><p>�GJ��� M�R� Garey and D�S� Johnson� Computers and Intractability� A Guide to the Theory</p><p> of NP�completeness� W�H� Freeman and Company� New York� �����</p><p>�GOT��� GOThA� Les probl�emes d�ordonnancement� RAIRO�RO� ������������� ����� �in</p><p>French��</p><p>�Gra��� S�C� Graves� A review of pro duction scheduling� Operations Research� �����������</p><p>�����</p><p>+</p><p>�HJM ��� N�C� Heintze� J� Ja�ar� S� Michaylov� P�J� Stuckey� and R�H�C� Yap� The CLP�R�</p><p>Programmer�s Manual� IBM T�J� Watson Research Center� PO Box ���� Yorktown</p><p>Heights� NY ������ Septemb er ����� �Version �����</p><p>�HL��� T� Huynh and C� Lassez� A CLP�R� options trading analysis system� In Rob ert A�</p><p>Kowalski and Kenneth A� Bowen� editors� JICSLP���� Proceedings �th Interna�</p><p> tional Conference and Symposium on Logic Programming� pages ������ Seattle�</p><p>Washington� U�S�A�� ����� MIT Press�</p><p>�HMS��� N� Heintze� S� Michaylov� and P� Stuckey� CLP�R� and some electrical engineering</p><p> problems� Journal of Automated Reasoning� ���������� Octob er �����</p><p>�Ho o��� J�N� Ho oker� A quantitative approach to logical inference� Decision Support Sys�</p><p> tems� ����������� �����</p><p>�Hyv��� E� Hyv�onen� Constraint reasoning based on interval arithmetic� the tolerance prop�</p><p> agation approach� Arti�cial Intel ligence� ���������� Decemb er �����</p><p>�Imb��� J�L� Imb ert� Fourier�s elimination� Which to cho ose� In First Workshop on Princi�</p><p> ples and Practice of Constraint Programming� pages �������� Newp ort� April �����</p><p>�JL��� J� Ja�ar and J�L� Lassez� Constraint logic programming� In POPL���� Proceedings</p><p>��th ACM Symposium on Principles of Programming Languages� pages ��������</p><p>Munich� January ����� ACM�</p><p>�JM��� J� Ja�ar and M�J� Maher� Constraint logic programming� a survey� The Journal of</p><p>Logic Programming� ��������������� �����</p><p>�JMSY��� J� Ja�ar� M�J� Maher� P�J� Stuckey� and R� Yap� Pro jecting clp��� constraints�</p><p>New Generation Computing� ����������� �����</p><p>�Kar��� N� Karmarkar� A new p olynomial time algorithm for linear programming� Combi�</p><p> natorica� ���������� �����</p><p>�Kha��� L�G� Khachian� A p olynomial algorithm in linear programming� Soviet Math� Dokl��</p><p>�������������� �����</p><p>�Kor��� R�E� Korf� Depth �rst iterative deep ening � An optimal admissible tree search�</p><p>Arti�cial Intel ligence� ���������� �����</p><p>�Kow��� R�A� Kowalski� Logic for Problem Solving� North Holland� �����</p><p> th</p><p>�Lho��� O� Lhomme� Consistency techniques for numeric CSPs� In Proc� of the �� IJCAI�</p><p> pages �������� Chamb�ery� France� August �����</p><p>�LM��� J�L� Lassez and K� McAllo on� A canonical form for generalized constraints� J�</p><p>Symbolic Computation� �������� �����</p><p>�Mac��� A�K� Mackworth� Consistency in networks of relations� Arti�cial Intel ligence� �����</p><p>���� �����</p><p>�MJPL��� S� Minton� M�D� Johnston� A�B� Philips� and P� Laird� Solving large�scale constraint</p><p> satisfaction and scheduling problems using a heuristic repair metho d� In Proc� of</p><p>AAAI���� pages ������ Boston� MA� �����</p><p>�ML��� B�L� McCarthy and J� Liu� Addressing the gap in scheduling research� A review of</p><p> optimization and heuristic metho ds in pro duction scheduling� International Journal</p><p> of Production Research� ������������ �����</p><p>�Mon��� U� Montanari� Network of constraints� Fundamental prop erties and applications to</p><p> picture pro cessing� Inf� Sci�� ��������� �����</p><p>�Nad��� B�A� Nadel� Constraint satisfaction algorithms� Comput� Intel l�� �������������</p><p>Novemb er �����</p><p>�Nui��� W�P�M� Nuijten� Time and resource constrained scheduling� PhD thesis� Eindhoven</p><p>University of Technology� �����</p><p>�Pap��� C� Le Pap e� Implementation of resource constraints in ilog�schedule� A library</p><p> for the development of constraint�based scheduling systems� Intel ligent Systems</p><p>Engineering� �������� �����</p><p>�Pin��� M� Pinedo� Scheduling� Theory� Algorithms and Systems� Prentice�Hall� Englewo o d</p><p>Cli�s� NJ� �����</p><p>�PPMD��� C� Le Pap e� J�F� Puget� C� Moreau� and P� Darneau� PMFP� The use of constraint�</p><p> st</p><p> based programming for predictive p ersonnel management� In Proc� of the ��</p><p>ECAI� Amsterdam� The Netherlands� �����</p><p>�Pug��� J�F� Puget� Ob ject oriented constraint programming for transp ortation problems�</p><p>In Proc� of ASTAIR���� �����</p><p>�Pug��� J�F� Puget� A C�� implementation of CLP� Technical Rep ort ������ Ilog� �����</p><p>�PW��� M�S� Paterson and M�N� Wegman� Linear uni�cation� JCSS� ����������� �����</p><p>�Rob��� J� Alan Robinson� A machine�oriented logic based on the resolution principle�</p><p>Journal of the ACM� ��������� �����</p><p>�SH��� G� Sideb ottom and W�S� Havens� Hierarchical arc consistency applied to numeric</p><p> pro cessing in constraint logic programming� Technical rep ort� Center for Systems</p><p>Science� Simon Fraser University� Burnaby� Canada� �����</p><p>�Ste��� G�L� Steele� The de�nition and implementation of a computer programming lan�</p><p> guage based on constraints� Technical rep ort� Dept� of Electrical Engineering and</p><p>Computer Science� M�I�T�� August �����</p><p>�Tsa��� E�P�K� Tsang� Foundations of Constraint Satisfaction� Academic Press Ltd�� Lon�</p><p> don� �����</p><p>�Ull��� J�R� Ullman� Asso ciating parts of patterns� Inform� Contr�� ���������� �����</p><p>�vH��� P� van Hentenryck� Constraint Satisfaction in Logic Programming� Logic Program�</p><p> ming Series� MIT Press� Cambridge� MA� �����</p><p>�vHD��� P� van Hentenryck and Y� Deville� The cardinality op erator� A new logical connec�</p><p> tive for constraint logic programming� In F� Benhamou � A� Colmerauer� editor�</p><p>Constraint Logic Programming� Selected research� Logic Programming Series� pages</p><p>�������� MIT Press� �����</p><p>�vHDT��� P� van Hentenryck� Y� Deville� and C� Teng� A generic arc�consistency algorithm</p><p> and its sp ecializations� Arti�cial Intel ligence� ����������� �����</p><p>�Wal��� D� L� Waltz� Generating semantic descriptions from drawings of scenes with shad�</p><p> ows� Technical Rep ort AI���� M�I�T�� Cambridge MA� �����</p><p>�Wal��� M� Wallace� Applying constraints for scheduling� In B� Mayoh� E� Tyugu� and</p><p>J� Penjaam� editors� Constraint Programming� Proceedings ���� NATO ASI Parnu�</p><p>Estonia� NATO Advanced Science Institute Series� pages �������� Springer�Verlag�</p><p>�����</p><p>�Yap��� R�H�C� Yap� A constraint logic programming framework for constructing DNA</p><p> restriction maps� Arti�cial Intel ligence in Medicine� ���������� �����</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    0 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us