<<

P. Esquirol, P. Lopez, Hélène Fargier, Thomas Schiex

To cite this version:

P. Esquirol, P. Lopez, Hélène Fargier, Thomas Schiex. Constraint programming. 1995. ￿hal-02850710￿

HAL Id: hal-02850710 https://hal.inrae.fr/hal-02850710 Submitted on 7 Jun 2020

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.

Distributed under a Creative Commons Attribution - ShareAlike| 4.0 International License

Constraint programming

Patrick Esquirol Pierre Lop ez

Lab oratoire dAnalyse et dArchitecture des Systemes du cnrs

avenue du Colonel Ro che

Toulouse Cedex France

email fesquirollop ezglaasfr

Helene Fargier

Universite Paul Sabatier IRIT

route de Narb onne

Toulouse Cedex France

email fargieriritfr

Thomas Schiex

Institut National de la Recherche Agronomique

Chemin de Borde Rouge BP

CastanetTolosan Cedex France

email tschiextoulouseinrafr

Abstract

There has b een a lot of interest lately from p eople solving constrained optimization

problems for Constraint Programming CP Constraint programming cannot b e describ ed

as a technique by itself but p erhaps b etter as a class of computer languages tailored to

the expression and resolution of problems which are nondeterministic in nature with a

fast program development and ecient runtime p erformances

Constraint programming derives from op erational research and

articial intelligence Logic programming oers the general nondeterministic host lan

guage which accommo dates dedicated constraint solvers from OR and AI such as linear

programming or techniques

In this pap er we rst review how pure logic programming languages evolved into Con

straint Logic Programming CLP languages bringing to light the interface b etween logic

programming and constraint solvers Some extra attention is given to a sp ecic class of

constraint solving techniques which have b een develop ed in the Constraint Satisfaction

Problem framework and which are currently used in most CLP languages to solve con

strained problems in nite domains We nally conclude by an overview of some existing

CP languages with some examples taken from scheduling

Keywords Constraint Logic Programming Constraint Satisfaction Scheduling

Intro duction

A large numb er of problems which are considered by op erational research and which have

also b een tackled by articial intelligence techniques such as jobshop scheduling resource

allo cation problems or digital circuit validation are combinatorial problems in nature More

formally such problems are often NPhard GJ and it seems unlikely that with a

reasonable worstcase complexity exist to solve them

A traditional approach to solve such problems is to design a sp ecic computer program

that uses enumerative techniques such as Branch and Bound or lo osing some guarantees lo cal

search techniques Tab o o search simulated annealing This may lead to the utmost eciency

but usually necessitates a lot of work which may rapidly b ecome useless if the mo del evolves

in an unexp ected direction and whose reuse is highly improbable

Another p ossible approach is to cast the problem in a general framework such as integer

linear programming and to use a dedicated solver to solve the linear mo del which has b een

designed Usually the rewriting tends to enlarge the problem size to distort to some extent

the original problem to ignore nice prop erties such as p ossible heuristics or symmetries In

the worst cases the nal eciency may b e p o or and solutions almost meaningless

Ideally one would like a general framework for stating large classes of combinatorial prob

lems with a language which is general enough to limit distortion and op en enough to make it

p ossible to use the sp ecic knowledge ab out the problem in order to enhance eciency

We now try to show the assets of constraint programming languages as general to ols for

representing and solving various classes of constrained problems with illustrations in jobshop

scheduling These assets are inherited from logic programming but also from the underlying

constraint solvers In this pap er we will more sp ecically fo cus on AI techniques for solving

constraint satisfaction problems on nite domains Tsa even if other solvers such as Simplex

for sets of linear inequations are often used in CP languages

From Logic Programming to Constraint Programming

Logic programming languages are general programming languages based on mathematical logic

and more sp ecically rst order logic The language with its numerous dialects is the

main representative of the logic programming languages community The original idea of Prolog

is to let the user sp ecify the prop erties he wants to satisfy using a subset of the rstorder logic

language and to use a general logical inference mechanism the resolution principle Rob to

prove either that these prop erties cannot b e met or to exhibit solutions

Logic programming

Description and go o d prop erties of Prolog programming

Logic Programming will b e presented here through its most representative implementation the

Prolog language This language is a restriction of the rstorder logic language to Horn clauses

It acts as a theorem prover and applies a general inference mechanism based on the resolution

principle To get started with Prolog and the use of logic for problem solving we recommend

the reading of CM CKvC Kow ACM AS

Prolog manipulates ob jects called terms that form the socalled Herbrand universe

A term may b e a constant such as a variable such as X an atom such as a or a

comp ound term such as functional terms fX and lists A Prolog program can b e

viewed as a sequence of declarative statements the clauses each of them stating how a given

relation b etween some terms the head of the clause may b e derived logically from a conjunctive

set of relations the tail of the clause dened somewhere else in the program nary relations

p ossibly n = are all built from a predicate symb ol and a set of terms the arguments of the

relations

In the sequel the chosen syntax to write the clauses will b e the Edinburgh syntax The head

is separated from the tail by if not empty the tail consists of a set of terms separated by

and the clause ends with The character intro duces a comment

A comment next line is an example of a clause

head term term

Moreover a variable is denoted by an upp er case letter AZ a list is represented by HT

where H is the head of the list ie the rst element T its tail the other elements Programs

are clustered into packets of clauses each packet grouping clauses which head refers to the same

relation predicate In each packet one clause represents one alternative to prove the relation

In the following example a pathnding problem a rst packet of clauses describ es the set

of pairs of no des that satisfy the arcrelation of some graph These clauses have an empty tail

no conditions since the graph is given A second packet of clauses states the path relation

recursively dened from the arcrelation a path exists b etween no de X and no de Y either if the

no des are connected directly by an arc rst clause or if a path exists b etween an intermediate

no de Z and no de Y such that no de X is connected to no de Z by an arcrelation second clause

Directed nonreflexive graph

described by its arcs

1 2

arc

arc arc

arc 6 3

arc

arc

Recursive definition of the path

relation between any nodes

5 4

pathXYXY arcXY

pathXYXL arcXZ pathZYL

Prolog programs are launched by writing queries ab out one or more relations that must

simultaneously b e proved The standard strategy of Prolog is based on an emb edded chrono

logical backtrack search that enables to collect all the p ossible solutions for a given

query

If some variables app ear in a query Prolog attempts to give them values or at least returns

a minimal set of variables substitutions equalities constraints that satises the query Values

returned in the answer form one solution to the problem stated by the query The query

pathYL ask for all the paths L and their extremity Y such that path L starts

from no de When the query has no variables answer is Yes if the query is proved to b e

true as for instance for the query path that checks the path

b etween no des and or No when the query is not satisable as for instance for the query

pathXXL which proves that no circuit can b e found in this graph

Let us note that the same program can also answer to queries like pathXL

which returns all the paths terminating on no de or like pathXYL which returns

all the paths of the graph This program is a reversible one since arguments of the path

relation are not forced to have a xed input or output role as opp osed to classical programs in

pro cedural or The relational semantics of logic programming gives its

declarativeness and its genericity The emb edded backtrack and the highlevel

facilities for lists pro cessing play also a ma jor role in the conciseness of Prolog programs

Limitations of logic programming for numerical problem solving

Pure logic programming needs and only allows the statement of relations b etween terms with

out any assumption on numerical prop erties When tackling numerical problems or reasoning

in domains more structured than the domain of syntactic terms Herbrand universe the con

straint solving algorithm on terms the socalled unication algorithm app ears to b e to o weak

for numerical computations in particular when the search space develop ed by the standard

can b e pruned by an active interpretation of the numerical constraints as shows

the next example

Supp ose one wants to determine the pairs XY which satisfy the prop erty X Y numb ers

X and Y b elonging to a given enumerated subset of integers

Definition of a given subset of integers

isnumber

isnumber

isnumber

Definition of the orderedpair relation

orderedpairXY isnumberX isnumberY X Y

Numerical op erations and checks such as X Y are extralogical relations and have b een

added under the form of predened predicates just to make Prolog able to pro duce ele

mentary numerical computations The search tree develop ed in order to answer the query

orderedpairXY which lists all the ordered pairs of numb ers amongst fg is g

ured b elow

?− is_number(X), is_number(Y), X

X=1 X=3 X=2

?− is_number(Y), X

Y=1 Y=3 Y=1 Y=3 Y=1 Y=3 Y=2 Y=2 Y=2

?− X

fail {X=1,Y=2} {X=1,Y=3} fail fail {X=2,Y=3} fail fail fail

Figure Search tree

This program rst generates values for numb ers X and Y and then checks the ordering

relation This approach generateandtest is very inecient considering the failing branches

of the search tree For example X is tried even if it is obvious that no value can b e asso ciated

with Y b ecause X has its maximum value and the order is a strict one For symmetrical reasons

failures due to Y are unnecessarily explored Preferably one could rst restrict the domains of

X and Y b efore enumerating their p ossible values This necessitates that domains b e asso ciated

to variables and that the relation X Y b e actively used to restrict the domains b efore values

have b een prop osed for X and Y constrainandgenerate rather than simply passively checking

it once the variables it involves are assigned

Conclusion

Logic programming and its wellknown implementation through the Prolog language oers sev

eral attractive prop erties for problem solving declarativity genericity conciseness exhaustive

search Facing problems where constraints must actively b e exploited to improve eciency

the unication constraint alone app ears to o weak It has to b e enlarged by other inference

mechanisms based on more structured domains of interpretation such as nite domain vari

ables integers rationals b o oleans for which ecient constraint solving strategies can b e im

plemented The next section lists some of the domains of variables for which constraints can

actively b e interpreted in order to improve the standard strategy of Prolog

Constraint Logic Programming

General principle

Constraint Logic programming CLP is an attempt to overcome the limitations of Logic Pro

gramming by enhancing it with constraint solving mechanisms

The rst ob jective was to replace an explicit co ding of semantic prop erties b etween ob jects

submitted to constraints by an implicit description with primitive constraints This led to

distinguish usual predicates and constraint predicates usual variables and typ ed variables For

example b esides the original predicate isXExpr that binds a variable to the evaluation

of a closed arithmetic expression new equality constraints have b een intro duced which state

equations in typ ed domains This work was concerned with the integration of new computation

domains and their asso ciated constraint solvers In the remainder of this pap er we will denote

by ClpX a CLP system acting on some constraint domain X

The second ob jective was to replace the depthrst search strategy of Prolog and its resulting

generateandtest b ehavior Constraint propagation has b een investigated in the Articial

Intelligence community since late s Mon Mac Ste Techniques like lo cal value

propagation datadriven computation forward checking and lo ok ahead have b een develop ed

Some of these techniques have b een integrated as new inference rules in CLP systems

It is often admitted that the embryonic attempts to intro duce constraints in Prolog are

due to Alain Colmerauer with its design of Prolog II Colb able to solve equations in the

domain of innite trees Cola Prolog II also initiated the use of the difXY primitive

with a coroutining mechanism that p ostp ones the disequality check until b oth arguments

b ecome instantiated and pro duces a backjumping to the clause containing the dif in case of

failure

The core idea of CLP was to replace the computational heart of a logic programming system

namely the unication algorithm by a constraint handling mechanism in a constraint domain

The CLP scheme

A go o d abstract of the theoretical foundations of CLP languages can b e found in Coh

For a deep er analysis the survey of Jaar Maher JM is worth reading For the sake of

simplicity and understandability we prop ose to describ e what a CLP scheme may b e with a

mo del very close to the one of the abstract Prolog III machine This mo del supp oses that

constraints and predicates are syntactically separated in a clause as opp osed to the op erational

mo del given in JM Thus a clause of a logic program will consist of a triplet hh B Ci where

h is the head B a sequence of predicates p ossibly empty and C a set of constraints p ossibly

empty A program clause hh B Ci means that h can b e rewritten as B under the constraints

C Supp ose that the state of the abstract machine at a given time is hG Ri where

G is the ordered set of goals which remain to b e executed

R forms the current constraint store

Initially goals and constraints are those of the query S = hQ Q i One nal state S is

g r f

dened by an empty set of goals S = h R i The nal constraint store R may b e non

f f f

empty In that case the nal answer may dier from a CLP system to another dep ending on

the constraint domains and some prop erties presented b elow

The computation can b e represented by a tree similar to the search tree develop ed by

a pure logic program no des are lab eled by states edges are lab eled by rules primitive or

programdened and leaves are of two typ es fail or answer Fails o ccur when no rule can b e

applied to a state with a non empty set of goals Supp ose g is the next goal to b e executed the

leftmost term of G in the current state hG Ri If a program clause hh B Ci can b e applied

0 0

to g the following state is hG C i where

S

0

G = Gnfgg B

S S

0

R = solve(R fg = hg C)

The equation fg = hg means that g and h have the same predicate symb ol and satisfy

the unication constraints b etween their resp ective arguments When considering numerical

domains unication means equation as for example in the unication of g = foo(X ) and

h = foo(Y Y + ) the result is X = Y = in a CLP system on numerical domains whereas it

fails in pure Prolog as cannot b e made syntactical ly equivalent to Y + The solve function

p erforms a satisability check that if failed entails a backtrack and the selection of another

clause of the program This satisability check may b e complete or not dep ending on the

constraint domains In the following we list some imp ortant prop erties of the CLP systems

relating to the constraint domains they prop ose

Prop erties

The ma jor CLP systems oer in a common Prolog environment several constraint domains

and their attached set of primitives Programmers are generally interested in the expressiveness

of the constraint domains and in the eciency of the solvers It is thus imp ortant to evaluate

the various systems and their computation domains through relevant prop erties such as

Satisfactioncompleteness solutioncompactness of the constraint domain

Incrementality of the constraint satisfaction algorithm

Existence of canonical representations of the constraints set

Simplication ability for the constrainthandling system

A theory on a given domain is satisfactioncomplete if it is always provable that every

constraint is either satisable or not It is the case for example for reals with the set f= =

g of constraints and the set f+ g of functions But it is not the case for integers

with f=g constraint and f+ g functions the satisability of Diophantine equations b eing

undecidable CLP systems answer Maybe or N constraints delayed when this prop erty

is not lled whereas when it is the answer is Yes or No

A theory on a constraint domain is solutioncompact when any value of the domain can b e

represented by a p ossibly innite set of constraints True for the domain of real numb ers with

f= = g constraints and f+ g functions this prop erty is lost for real numb ers with

only f=g constraint and the same functions

Furthermore the set of constraints that is handled at each no de is obtained by adding some

1

constraints to a constraint set which was previously proved satisable Thus the eciency of

the overall language would b enet from some incrementality in the constraint solver once

0

a set R of constraints has b een shown satisable the pro of of satisability of R R should

whenever p ossible b e made more ecient than a pro of from scratch by using some results

from the previous satisability pro of of R

In practice solvers often give a solved form of the initial set of constraints whose satis

ability is obvious and which is equivalent to the original set The solved form given by the

solvers can usually b e directly used instead of the original constraint set when a constraint is

added thus automatically giving some incrementality The solved form may even b e used

for pro jection if it is an explicit representation of the solution space

Simplication is sometimes called a semantic garbage col lection For example the two con

straints X and X can b e rewritten as only one X Another obvious typ e of

simplication is to rewrite the subset of constraints on a given variable as so on as this variable

receives a single value Finally redundancies may also b e eliminated but this feature raises

the more general problem of nding a minimal representative set of constraints for which one

cannot assert that a unique optimal strategy always exists

To that aim the existence of canonical forms of sets of constraints may help A canonical

form can b e used as a solved form which facilitates b oth the satisability tests and simpli

cations for example b ecause constraints are ordered according to their arity andor variables

are lexicographically ordered

Finally for satisfactioncomplete systems queries can receive non ground answers ie each

variable of the query do es not receive a single value the answer is a pro jection of the system

of constraints on these variables The understandability of the answer obviously dep ends on

simplication and canonical representation facilities

Constraint Programming

Although constraint programming derives from logic programming and the ma jor CLP systems

have b een designed as compatible extensions of Prolog which remains the kernel some other

imp ortant systems have b een develop ed indep endently As they keep the nondeterministic

computation principle and their solvers are based on the same constraints domains they

deserve to b e also mentioned in this pap er see Section Constraint programming is the

general framework that covers researches and applications of such constraintbased languages

and systems

1

Or not yet disproved to b e satisable in case of satisfactionincomplete theories

Constraint Solvers

As we have seen CLP needs several services from the underlying constraint solvers a satisa

bility test to avoid useless exploration of space and the ability to pro ject the solution space of

the current constraint set on a subset of the variables involved to b e able to answer the user

query using only the variables that app eared in the query

We now consider several domains with their available constraints solvers to see how these

demands are actually met or relaxed

Equalities in nite and rational trees

The domain of nite trees FT is the original domain of pure logic programming languages

Prolog terms that app ear in Prolog predicates such as f(X) or f(g(X) Z) are simply the

2

syntactic expression of lab eled trees We present this domain for historic reasons even if it may

lo ok somewhat articial to the op eration research community The problem of satisability of

a set of equalities b etween terms with variables is known as the uniability problem A solution

is given by an unier a set of variableterm substitutions which when applied to all the terms

make them identical The problem is easy solvable in linear time PW Furthermore the

algorithms build a most general solution to the constraint set called a most general unier or

mgu which can b e used as a solved form it may easily b e pro jected on a variable subset

and also used as the basis for the next satisability test when new constraints are added

In the domain of FT the terms f(X) and f(g( X)) are not uniable no single FT can

simultaneously match b oth terms However unication algorithms naturally build the substi

tution Xg( X) as a p ossible solution whereas substitutions of the form Xt where t is a term

that contains the variable X cannot dene a solution since they implicitly represent innite

trees Therefore a sp ecic test called the occurcheck should b e inserted in the algorithm to

avoid innite cycles in the solution as ab ove This test yields a b estcase complexity which is

always equal to the worstcase complexity and was therefore omitted for eciency reasons in

most old Prolog dialects

Nowadays in order to sanely avoid the o ccurcheck Prolog languages prefer to solve the

uniability problem in the domain of rational trees RT which may b e innite but which

have a nite representation the nite representation of an innite tree contains cycles In

RT f(X) and f(g( X)) are unied by X = g( X) which implicitly gives the innite tree

f(g( g( g( )))) as the solution Almost linear algorithms are available The language

Prolog II of Marseille Colb has b een the rst Prolog which chose to solve the uniability

problem in the domain of RT

Linear inequations in R or Q

Various CLP languages enable the user to express linear equalities and inequalities in the

domain of R approximated using oating p oint numb ers or Q using innite precision rational

numb ers

For linear equations the usual technique of Gaussian elimination may b e used with a

quadratic worstcase time complexity When inequalities are intro duced p olynomial time al

gorithms are still available Kha Kar but since these algorithms are either less ecient

practically or dicultly made incremental all existing languages have to our knowledge de

cided to rely on variations of the Simplex algorithm despite its exp onential time worst case

2

f(X) represents all trees with a ro ot lab elled f and a single son which may b e any tree

complexity The main variations consist in extending the Simplex to deal with negative num

b ers and strict inequalities LM As it is well known in the integer linear programming

community the Simplex can b e extended to eciently cop e with a growing set of constraints

and some incrementality is p ossible The pro jection of a p olyhedral set on a variable subset

can b e p erformed using a simple algorithm from Fourier which has b een tuned for redundancy

elimination in Imb JMSY

Even if satisability alone is actually needed in the CLP framework the p ossible optimiza

tion p erformed by the Simplex is usually made available at the user level through a sp ecic

predicate

Finite domains

The intro duction of nite domains FD into CLP languages is certainly connected with the

imp ortant growth of the eld of Constraint Satisfaction Problems CSP in the articial

intelligence community Tsa AS The CSP framework is devoted to the problem of

satisfying a set of constraints without any limitation on the constraint typ es in any FD

Denition A CSP (X D C) is dened by

a set X = fx x g of n variables

n

a set D = fd d g of domains Domain d contains the set of values that may be

n i

considered for variable x We note d the size of the largest domain

i

a set of constraints C = fc c g of e constraints Each constraint c is dened by

e i

the set of variables X(c ) X involved in constraint c

i i

a relation R(c ) on the variables of X(c ) ie a subset of the Cartesian product of

i i

the domains of the variables of X(c ) This relation denes the tuples of values which

i

may simultaneously be assigned to the variables involved in the constraint

Example Consider a CSP with variables X = fx x x g al l variables hav

ing the same domain fwhite blackg Three constraints c c and c involve re

spectively fx x g fx x g and fx x g and are dened by the same relation R =

f(white black) (black white)g

An assignment of values to a subset Y X of the variables is said to b e consistent or local ly

consistent i all the constraints c C such that X(c ) Y are satised by the assignment ie

i i

only authorized combinations of values as sp ecied in the relations are used in the assignment

In our example the assignment fx white x black g is lo cally consistent while fx

black x black g is not

A solution of a CSP is simply a consistent assignment of the whole set X of variables A

3

satisable CSP a CSP with at least one solution is also said to b e consistent Our example

CSP has no solution the CSP is inconsistent

In the pure CSP framework the domains d are supp osed to b e nite domains and

i

when their size remains reasonable the relation asso ciated to each constraint can eectively

b e describ ed by the set of tuples of values that corresp ond to authorized combinations The

3

One should not confuse the prop erty of consistency of an assignment which is decidable in p olynomial time

and the prop erty of consistency of a CSP which denes an NPcomplete decision problem

interesting p oint is that any typ e of constraint either linear or not can b e expressed Numb ers

and symb ols may also b e simply mixed together A lot of CSP techniques may b e extended

to the case of relations expressed in intention linear or non linear constraints over N for

example Dav Some of these techniques have also b een extended to the case of innite

domains subsets of R usually and are available in some CLP languages SH Hyv Lho

In the following we only consider FD

An usual restriction in the pure CSP eld is also to restrict oneself to binary constraints

involving only two variables In that case two graphs called resp ectively the constraint graph

and the consistency graph of the CSP may b e dened

The constraint graph has one vertex for each variable and one edge for each constraint

For non binary CSP a similar hyp ergraph can b e dened This graph only describ es the

problem structure

The consistency graph has one vertex for each value of each variable and one edge for

each compatible pair that app ear in a constraint This graph is npartite since no edge

can app ear b etween two values of a given variable It completely denes the problem

x1 x2 x1 x2

x3 x3

Figure The constraint and consistency graphs of a CSP

These two representations are used in Fig to describ e our example CSP In the FD case

an imp ortant dierence with the previous domains of trees and linear programming in R is

that the satisability problem b ecomes NPcomplete This is shown simply by the following

4

observation

Example the graph kcolorability problem can simply be expressed as a CSP

If you consider a graph (V E) one variable x is associated to each vertex v al l

v

the domains are identical and contain k values Final ly one dierence constraint

between x and x is associated to each edge (v w) E Note that our example is

v w

simply the graph colorability problem on a ful ly connected graph of vertices

a clique

The most naive technique that may b e used to solve the satisability problem is the back

track algorithm given an initial consistent assignment A of size k it tries to assign a new

k

variable x If no value in d yields a consistent assignment a backtrack o ccurs on the

k+ k+

previous variable assigned The algorithm starts with an empty and therefore consistent

n

assignment and has a worstcase complexity in O(ed )

Since this algorithm is highly inecient it would b e unreasonable to use it to prove satisa

bility in the frame of a CLP language one satisability test b eing p erformed after each step of

the computation Furthermore it seems dicult to give this algorithm some incrementality

Therefore all existing implementations have chosen to weaken the satisability prop erty by

using the p olynomial worstcase time prop erties dened in Mon Mac

4

This result shows that the satisability problem in the binary CSP restriction is still NPcomplete and this

restriction is made in theory without loss of generality

Lo cal consistency

The notion of lo cal consistency enforcing denes a whole family of techniques which in

practice transform an initial CSP in a hop efully simpler problem with the same solution set

5

This pro cess is also known as a ltering pro cess or as a constraint propagation mechanism

To each typ e of ltering pro cess is asso ciated a socalled lo cal consistency prop erty that

is actually enforced by the ltering The main class of lo cal consistencies has b een dened

in Fre and is called kconsistency

Denition A CSP (X D C) is said to be kconsistent i any consistent assignment of (k - )

variables can be extended to a consistent assignment of k variables on any unassigned variable

A CSP (X D C) is said to be strongly kconsistent i it is jconsistent for al l j = k

It is quite easy to prove that a CSP of n variables which is strongly nconsistent is satis

able and furthermore any consistent assignment can b e extended to a solution However a

6

satisable CSP is not necessarily nconsistent

k k

A p olynomial time algorithm in O(n d ) that enforces strong kconsistency has b een

prop osed in Co o The CSP built is called the kconsistent closure of the CSP Since the

CSP obtained is equivalent to the original CSP we get the following prop erty

Prop erty If a CSP has an empty kconsistent closure a domain is empty then it is un

satisable The converse is natural ly false

Therefore strong kconsistency enforcing oers a p olynomial time relaxation of satisabil

ity The approach followed by most CLP languages is to only enforce some lo cal consistency

prop erty instead of satisability Backtracking o ccurs when an empty closure is obtained

since this actually proves unsatisability Usually only strong consistency also called arc

consistency Ull Wal Mon in the framework of binary CSP is enforced

Denition A binary CSP is said to be arcconsistent i none of its domains is empty this is

consistency and every assignment of one variable can be extended to a consistent assignment

of size on any unassigned variable

Example Our example problem of Fig is unsatisable but it has an non

empty arcconsistent closure and is indeed already arcconsistent enforcing arc

consistency on this problem is completely useless

Basically arcconsistency enforcing works as follows if a value of a given domain d do es

i

not app ear in any of the authorized combinations of one of the constraints that involve x

i

then this value cannot b elong to a solution and can simply b e deleted A single pass on all

variables and constraints is usually not sucient and the pro cess is p erformed iteratively until

quiescence

5

This pro cess can b e related to cutting plane generation in integer linear programming considering the

combined results of Ho o and dK

6

It can b e the case that some consistent assignment of n - variables can not b e consistently extended to

th

the n variable Satisbility simply implies that some consistent assignment of k - variables do extend to a

consistent assignment of all variables

Example The CSP whose consistency graph is il lustrated in Fig simply obtained

by removing the edge (white black) between x and x is a good example of non

consistent CSP which is also non arcconsistent and whose arcconsistent closure is

empty On a rst pass the values numbered wil l be deleted because they are not

connected to any value on an adjacent variable then the values numbered wil l be

deleted for the same reason thanks to the previous deletion until quiescence

here al l the values are deleted Actual ly one could stop on step when the domain

of x becomes empty since it suces to prove inconsistency

1 x1 3 x2 3 1

x3

2 2

Figure A CSP with an empty arcconsistent closure

This simple arcconsistency enforcing algorithm has undergone several optimizations from

AC describ ed in Mon Mac to AC describ ed in BFR With AC we get

optimal time complexity in O(ed ) and AC gives further eciency and a space complexity

in O(ed) However most CLP languages rely on mo died versions of AC vHDT b ecause

it is easily tuned to handle sp ecic classes of constraints more eciently

Actually no CLP language to our knowledge do es enforce lo cal consistency at a level higher

than strong consistency Pragmatically a stronger level would mean earlier unsatisability

detection and therefore less no des explored in the Prolog search tree but it would also mean

more work at each no de Exp erimentally arcconsistency app ears to b e a reasonable tradeo

A last interesting prop erty of all the lo cal consistency enforcing algorithms is their natural

incrementality with resp ect to the addition of constraints in the problem Indeed the CSP

obtained after arcconsistency enforcing if non empty has smaller domains than the initial

CSP and is nevertheless equivalent to the original CSP it may simply b e used instead of the

original CSP

From lo cal consistency to satisfaction

Since CLP languages only enforce arcconsistency the information available at each no de of the

Prolog tree is not a solved form of the CSP which could b e pro jected on the query variables

7

but simply reduced domains with no guarantee of satisability

Since satisfaction is a practically imp ortant problem an additional mechanism must b e used

to solve the satisfaction problem The idea which originates in the CSP eld is to use a hybrid

of backtrack tree search and arcconsistency enforcing Nad vH

8

The algorithm known as Really Full Lo ok Ahead is simply a backtrack tree search

where the assignment consistency test is replaced by arcconsistency enforcing Given an initial

7

The strong nconsistent closure of a CSP would give a solved form but at the cost of an exp onential

amount of memory in the worst case

8

Some CLP languages actually use a weaker level of lo cal consistency enforcing than full arcconsistency

dening algorithms known as Forwardchecking or Partial Lo okAhead See Nad vH

arcconsistent CSP with variables x x assigned it tries to assign a new variable x If

k k+

no value in d yields a CSP with a nonempty arcconsistent closure a backtrack o ccurs on

k+

the previous variable assigned and domains should b e restored to the state they had b efore this

assignment The algorithm starts with an empty and therefore consistent assignment

The algorithm always explores less no des than the simple backtrack algorithm sketched

in Section since a lo cally inconsistent variable assignment of a subset of X will induce an

empty arcconsistent closure In practice the algorithm is often several order of magnitude

more ecient than the backtrack algorithm It b enets from two main typ es of heuristics

variable ordering heuristics decide dynamically during search which will b e the next

variable x that will b e assigned The general principle underlying all these heuristics is

k

the socalled rstfail principle cho ose a variable which is highly constrained so that if a

failure must o ccur it is rapidly detected A go o d choice is to favor variables with a small

actual domain and with a high degree in the constraint graph

value ordering heuristics decide dynamically which value should b e assigned successively

to the variable x that has b een chosen Even if some general purp ose value ordering

k

heuristics have b een prop osed see MJPL the b est results are usually obtained with

heuristics that take into account the precise problem class at hand

See Tsa chapter for further information on variable and value ordering heuristics

In CLP languages the actual tree search is done using the underlying nondeterminism

of the Prolog language A sp ecic predicate usually called indomainX enumerates and

successively assigns each of the values of the domain of the CSP variable X to this variable

Since this mechanism is programmed in Prolog it can actually b e completely mo died and

tuned to exploit heuristics and sp ecic prop erties of the problem at hand

9

Example the fol lowing Chip code solves the graph colorability instance

of Fig using the nite domain solver The predicate color denes the three do

main variables and the three constraints while the labeling predicate is in charge

of the enumeration process The predened predicate deleteXLRfirst fail

chooses a CSP variable X in the list L with a smal lest domain and leaves the re

maining variables in R

colorXXX

labeling

Domain declaration

labelingXY

X

Choice of a variable

X

deleteVarXYRestfirstfail

X

Choice of a value

Three 6= constraints

indomainVar

X n X

labelingRest

X n X

X n X

Look for a solution

labelingXXX

9

See the b eginning of Section for more sp ecic syntax explanations

If the query colorABC is given to the CLP language the tree search wil l

be very smal l since as soon as any of the three variables is assigned and whatever

its value an empty arcconsistent closure is obtained and backtrack occurs The

CSP being unsatisable the answer wil l simply be No

Beyond satisfaction optimization is also p ossible through sp ecic predicates using vari

ants of the Branch and Bound algorithm often related to the Depth First Iterative Deep en

ing Kor

Integrating CSP in CLP

As we said in pure CSP constraints are often supp osed to b e expressed by the set of au

thorized tuples If this language is extremely p owerful since it allows the expression of any

constraint on a nite domain it is also very cumb ersome Therefore all CLP languages have

limited the set of constraints that the user may express to a sp ecic language which usually

contains basic arithmetic constraints often linear inequations with unlimited arity

The traditional arcconsistency enforcing algorithms of general CSP can b e nely tuned to

b etter take into account the nature of these constraints Most languages to our knowledge

essentially p erform a socalled b ound propagation related to interval calculus which can b e

easily extended to real oating p oint domains Dav vH Lho

P

Example for a linear equality a x = al l variables x having a nite integer

i i i

domain and considering for the sake of simplicity that al l the a are positive it

i

is possible to update the domain of x as fol lows Since

j

X

- min(a x )a x

i i j j

i6=j

then al l the values in the domain of x which are larger than the right member can

j

be removed without losing any solution By symmetry an analogous lowerbound

may be built

As in traditional arcconsistency enforcing if the domain of x is modied then

j

the domains of al l the variables connected to x through a constraint should also be

j

updated and so on iteratively until quiescence

For some classes of constraints such simple b ound propagations may suce to enforce arc

consistency vHDT

However the restriction to some arithmetic language is often to o strong to easily express

some natural and useful constraints esp ecially constraints on symb olic domains Therefore

these constraints are usually intro duced in the constraint language using sp ecic predicates

which are naturally called symb olic constraints An example of such a constraint is the

elementILX constraint which involves an integer or a domain integer variable I any

th

nite domain variable X and a list of values L The constraint is satised i the I element

of the list L is equal to the value of X Such constraints are usually handled using adhoc

propagation mechanisms which may or not enforce arcconsistency The imp ortant issue here

is to get the right tradeo b etween the p ower of the lo cal consistency enforcing in terms of

numb er of values deleted and the actual eciency of the algorithm

Since one cannot hop e to extensively intro duce all useful constraint typ es in a xed lan

guage some of the expressive p ower of the CSP framework is lost For example the disjunctive

constraints that naturally app ear in jobshop scheduling see Section cannot b e naturally

expressed as linear inequalities whereas they can b e expressed as a single CSP constraint which

could naturally b e propagated using any arcconsistency algorithm

Other domains

The three previous domains are certainly the most frequent ones in CLP languages We rapidly

review here solvers from other domains that have b een implemented in a CLP language

boolean algebra this domain which only contains the truth values true and false is a

sp ecial case of nite domain and the previous techniques can b e used CD with all their

limitations The usual constraint language is the language of mathematical prop ositional

logic and includes conjunction disjunction implication equivalence The satisability

problem is the general sat problem GJ which is again NPcomplete

A large numb er of techniques have b een prop osed to solve the satisability problem

Enumerative techniques such as Davis and Putnams pro cedure DP which are closely

related to CSP tree search algorithms are not easily made incremental Prolog III uses

a variant of SLresolution describ ed in BB This algorithm requires that formulas b e

translated to clausal form a conjunction of disjuncts which may b e quite costly It is

naturally incremental and yields a simplied form of the constraint set Binary Decision

Diagrams Bry oer an ecient incremental representation of b o olean formulas One

of the b o olean solvers of Chip uses a variable elimination algorithm along with these

BDDs A BDD explicitly represents all the solutions of the constraint set Despite

ecient compression metho ds it may o ccupy an exp onential amount of memory in the

worstcase

An imp ortant dierence with nite domains solvers is that most CLP languages try to

oer the user a legible representation of the current b o olean constraint set whereas

only restricted domains or a solution are available for nite domains This may dene a

very dicult problem

non linear equations in R several approaches exist In a rst approach the expression

of non linear constraints is p ossible but these constraints are simply frozen ignored

until they b ecome eventually linear when enough variables get assigned by the user or

b ecause their value can b e entailed from the constraints These constraints are then

communicated to the linear programming solver The approach is quite simple and al

lows the use of p olynomials or transcendental functions If some nonlinear constraints

remain non linear and frozen when a solution is obtained then the answer given by the

10

CLP language ignore the frozen constraints and may b e meaningless For example a

Z

constraint such as XpowYZ stating that X = Y will b e delayed until either Z is

known to b e equal to and X or and XY or Y is known to b e equal to and

X or two variables among X Y Z have a known value and the remaining one can

b e evaluated

Another approach consists in trying to solve the nonlinear equations using dedicated

+ 11

algorithms Cal ASS uses a sp ecic solver to solve p olynomial equations in C a

relaxation of the original problem in R to eventually prove its inconsistency

A last approach which is not limited to p olynomial equations is to use extensions of the

nite domains lo cal consistency prop erties to oating p oint domains see Dav SH

Hyv Lho

Several other domains including strings sets features trees have received attention from

the CLP community see Coh JM

10

ClpR answers Maybe when some constraints are still frozen and a solution is found

11

Here Buchb ergers Grobner bases algorithm is used with a worstcase doubly exp onential complex

ity Buc

Some existing to ols

In this section we rapidly present the main features of some wellknown CLP language im

plementations Most of these languages are actually commercial pro ducts whose underlying

mechanisms is not precisely do cumented the constraint solvers are black b oxes and the precise

op erational semantics of some constraints may b e unsp ecied A lot of other CLP languages

exist and we invite the reader to fetch JM FAQ to b etter p erceive the variety of available

implementations often for free

As in classical logic programming a constraint logic program is a collection of clauses

p ossibly involving some constraints

Example in Prolog III non standard syntax

cXYZ cR Z XY X Y

cX X

Example in Chip V Edinburgh syntax

cXYZ cR Z XY X Y

cX X

To activate a program one has to express a query ie a sequence of goals and constraints

if no goals are sp ecied the query is simply to solve the constraint system The system then

b ehaves like a classical prolog but each time a clause is used the asso ciated constraints are

added to the current constraint set Constraints solvers are then used to check the consistency

of the current state Backtrack o ccurs when either a goal cannot b e proved or the current set

of constraints b ecomes inconsistent If the goals can b e proved the current substitutions of the

variables are a solution provided that they satisfy the set of constraint Hence the answer is

given under the form of a set of variable bindings and constraints Completeness of the solving

pro cess dep ends on the domain of computation used

CLPR

+

The language ClpR HJM is an implementation of the general CLPX scheme dened

by J Jaar and JL Lassez in JL The rst release was available around and the

12

current release is available for free from IBM for academic and research purp oses only

ClpR is p erhaps the b est system to start with if you want to discover what pure

13

constraint logic programming is The only domain tackled b eyond the usual tree domain is

as the name says real numb ers approximated using oating p oint numb ers This keeps the

system small homogeneous and with a simple syntax

The underlying solver is a Simplexderived solver with a sp ecic Gaussian elimination mo d

ule for linear equalities Because of the oating p oint implementation the strict inequalities

which are available as in Prolog III do not have the precise semantics that can b e obtained

using innite precision rational numb ers

The system contains a mechanism for delaying nonlinear constraints until enough other

numerical constraints make them linear As we said in Section if a solution is found when

a nonlinear constraint is still delayed ClpR simply answers Maybe Anyway a large set of

12

For more information contact Joxan Jaar via email joxanwatsonibmcom

13

However ClpR do es not include a nite domain solver one of the main novelty of constraint programming

People interested in nite domains may try to get clpFD another free system CD available via anonymous

PROGRAMMINGclp fd FTP at ftpinriafrINRIAProjectsChLoELOGIC

primitives is available to express nonlinear constraints eg Z = X Y Y = log(X) and the

language has b een essentially used to deal with partially non linear problems

The system contains facilities for metaprogramming with constraints and allows to ex

plicitly manipulate terms and arithmetical constraints a co ded form b eing available to the

user These facilities are not available in any of the other languages considered here

The initial implementation was interpreted The actual release uses a byteco de compiler

for a b etter eciency of the underlying Prolog It is entirely written in the C language and

runs on most existing Unix workstations and includes MSDOS supp ort ClpR has b een

used to solve various real problems analysis and synthesis of analog circuits HMS sto ck

option analysis HL or problems from computational biology such as DNA sequencing by

restriction site mapping Yap

Prolog III

A Colmerauer and his team rst dened the mo del of a Prolog with constraints around

as an extension of the Prolog II mo del The commercial version of Prolog III has b een

ocially announced in

Compared with other to ols eg Chip Prolog III is very homogeneous providing in

particular a nice uniform syntax A Prolog III program like a Prolog one consists of

a collection of clauses which can p ossibly contain constraints Constraints are syntactically

distinguished from classical Prolog predicates using braces

Prolog III supp orts three domains of computation

rational numbers like Chip Prolog III uses exact precision rational numb er arith

metics The numerical mo dule handles linear inequations where every variable is sup

p osed to b e p ositive It is essentially an incremental Simplexlike solver which checks

that the accumulated numerical constraints can b e satised as so on as the resolution

pro cess triggers a new constrained clause the solver is fed with the attached constraints

it ensures a complete resolution of the constraint system Of course it is also p ossible

to sp ecify some linear criteria to b e optimized Note that in addition to traditional

Simplex techniques much attention has b een paid to strict inequalities

Prolog III also allows the sp ecication of nonlinear constraints They are in fact

delayed until the binding of some variables makes them linear If it is not the case the

solving pro cess may give an inconsistent set of constraints as answer without detecting

the inconsistency

Prolog III do es not naturally handle discrete domains Nevertheless it is p ossible to

express some linear constraints over integers linear arithmetics constraints over integers

are rst solved in Q Enumeration predicates must b e used in order to nd an integer

solution

booleans the b o olean mo dule is based on clausal forms The underlying algorithms

are incremental versions of the SLresolution algorithms They are able to check the

consistency of a set of b o olean constraints moreover they simplify the constraint system

into a set of constraints involving a minimal set of variables

nite lists or nite strings for nite strings there exists a single function to concate

nate two strings denoted by and the only constraint is the equality constraint

Prolog III delays the evaluation of any string constraint until the length of the string is

known Technically the string solver is based on a restricted string unication algorithm

Prolog III is develop ed and distributed by PrologIA France It is an with

p ossible connections to the C language It is available on Unix workstations PC and MacIn

tosh While the other constraintbased to ols fo cus on big industrial accounts Prolog III was

rst successfully distributed to the academic and research elds Let us nevertheless cite two

applications the rst one is an exp ert system analyzing failures in motors used by Daimler

Benz and Bosch Germany The second one for Delacroix France optimizes the cutting of

wo o d panels

CHIP V

Like Prolog III Chip V is a Prologbased constraint to ol It is a direct heir of the ECRC

research prototyp e Chip but diers from the prototyp e in many asp ects notice that the ECRC

continues to develop its own system Eclipse which unlike Chip V is an op en system In

a Chip program constraints are not syntactically distinguished from the other predicates

Chip provides a large numb er of predened constraint predicates on dierent domains of

computation

integers nite domains the most imp ortant feature of the Chip system is the intro

duction of arithmetic constraints over nite domains In addition a rich set of symb olic

constraints is provided for instance the alldifferentVariable List predicate

which sp ecies that all the variables in the list must have dierent values let us also cite

the cumulative constraint dedicated to scheduling applications see Section

Classical constraint propagation metho ds eg arcconsistency enforcing originating

from the CSP eld are used to handle nite domain constraints Since they are of course

incomplete choice predicates are also provided which allow the generation of values for

the nite domain variables

Moreover minimization is done using Branch Bound the predened predicate

min maxGoalC nds a solution which minimizes the maximal value in a list of cost

terms C In practice this is done by nding a rst solution evaluating C and then re

starting the search with a new constraint requiring C to b e lower than this value Never

theless as discussed in vH optimization problems resolution is still to b e enhanced

rationals linear rational constraints are handled by an extended Simplex algorithm as

so ciated with some Gaussian elimination Only linear arithmetic constraints are allowed

in Chip V The rational constraint solver is then obviously complete Note that opti

mization predicates over rational linear constraints are also provided

booleans b o olean constraints are solved by a variable elimination based b o olean uni

cation algorithm which is totally deterministic but still complete Nevertheless since

constraint solving in b o olean algebra is NPcomplete Chip may encounter problems which

cannot b e solved in a reasonable time this is of course a general problem which may

also o ccur in other languages

Finally Chip gives the user the p ossibility to dene its own constraints and control their

execution via the use of demons these have the eect of reevaluating a sp ecied goal each

time a given triggering event such as a change in a variable domain o ccurs This mech

anism implements lo cal consistency algorithms for userdened constraints The declarative

ifthenelse construct also allows a limited way of communicating information b etween

heterogeneous constraints

Chip V is develop ed and distributed by Cosytec France The pro duct also oers

graphic capabilities connections to databases and connections to C language It runs un

der Unix Sun IBM HP Dec and Dos PC Many applications have b een develop ed for

instance the planning application Plane BCF provides year schedules for Dassault

Aviation France and the multiuser scheduling to ol develop ed for Monsanto Belgium

ILOG SolverSchedule

IlogSolver is often describ ed JM as a C library that implements CSP algorithms on

nite and oating p oint domains rather than as a CLP language Presumably this is due to

the fact that Solver do es not use the usual Horn clauses language and do es not include a

solver on rational or nite trees

Anyway this description is somewhat unfair since Solver includes an extension of C

that enables the expression of nondeterminism traditionally oered by Horn clauses in other

languages The domain of niterational trees is not included simply b ecause it do es not seem

useful for the combinatorial problems addressed by Solver

Solver provides several classes of variables each implemented as a Cclass These

classes dene the domains handled by the language

integer variables whose domain is either an interval or an enumeration of integers These

variables can b e involved in linear or non linear arithmetic constraints Non linear con

straints are propagated According to the authors Pug the handling is similar to the

propagation mechanism describ ed in vH

oating point variables whose domain is an interval These variables can b e involved in

linear and nonlinear arithmetic constraints or monotonic op erators such as log The

underlying solver consists of a limited form of arcconsistency enforcing which according

to the authors owes much to Lho

boolean variables domain ftrue false g These are also handled using constraint propa

gation

set variables whose domain is a set of sets Initially the domain of such a variable

contains all the subsets of a given initial set of ob jects The constraints that may b e

expressed state that some elements must b e in the set that other should b e excluded or

can limit the range of the cardinality of the set

All these constraints are handled using a uniform underlying constraint propagation mecha

nism related to arcconsistency enforcing Some additional symb olic constraints are pro

vided and the user has the ability to dene adhoc propagation mechanisms for user dened

constraints

Finally the library tries to oer ob ject oriented features memb ers of userdened classes

may b e CSP variables and the user may dene constraints of classes which are inherited

by instances

Solver is develop ed and distributed by Ilog France The pro duct distributed as a C

library is fully compatible with all other Ilog C software comp onents including connection

to databases graphical interfaces rulebased programming It runs under several Unixbased

systems and under Windows PC Solver has b een used to tackle several real combinatorial

problems from lo comotive scheduling used by the sncf Pug to p ersonnel management in

the French army PPMD

Floating

Finite

Rational

Finite

Rationals

Bo oleans

domains

In

Strings

p oin

tegers

trees trees

Sets

ts

ClpR - - - - -

Prolog III - -

Chip - -

Solver - - - -

constraints are handled on this domain

 authorized variable typ e no constraints

- nonexistent variable typ e

Table Domains addressed in each language

IlogSchedule Pap is a C library of scheduling ob ject classes that automates the

use of Solver for representing nite capacity scheduling problems It oers tuned constraint

propagation mechanisms for the usual constraint typ es that o ccurs in scheduling Typical

classes include activities and various resources typ es renewable or not unary or nite ca

pacity See Section for a rst approach of jobshopscheduling problems using a CLP

language

Summary

Table gives an overview of which domains are addressed by which CLP languages The lan

guage Chip app ears to b e the more general CLP language This judgment should b e somewhat

temp ered Indeed all the languages which handle nite domains can also handle b o oleans and

integers with the ability of handling non convex domains such as f g Prolog III

may also handle integers rationals with a denominator equal to one but it cannot handle non

convex domains Since the Simplex only proves satisability in Q an exp ensive enumerating

pro cess as for nite domains must b e used

Note also that one single problem may often b e formalized using dierent mo dels a schedul

ing date may b e mo deled as integer rational or oating p oint numb ers

More imp ortantly if several constraint solvers exist in the same language it is often im

p ossible to use the solvers simultaneously on mixed problems where more than one typ e of

variable o ccurs in the same constraint b ecause it is usually imp ossible to relate a variable from

one domain to a variable from another domain For instance the relation b etween a rational

and its integer part cannot b e expressed as a constraint in Chip Along the same idea it

is usually not p ossible to asso ciate a b o olean variable to the fact that a given constraint is

satised eg = (x y)

Thanks to its underlying uniform constraint propagation mechanism Solver is quite ad

vanced in this direction and can handle some mixed constraints For example a constraint

of equality exists b etween oating p oint and integer variables

Application to JobShop Scheduling

A scheduling problem arises when a set of interdep endent tasks is to b e organized in time Such

a situation app ears for example in pro ject planning service activities manufacturing shops

computer systems or examination timetabling The problem is to lo cate a set of tasks in time

each task needing one or several resources during its execution The constraints to satisfy may

b e various technological sequencing routing resource limited capacity temp oral lo cation

release dates deadlines Most optimization problems in the scheduling eld are NP

hard GJ To nd solutions to these combinatorial problems op erational research develop ed

exact pro cedures like Branch Bound in order to nd lower and upp er b ounds of the optimal

solution or designed heuristics with some renements sp ecic to the problem at hand for

pruning the search space ML

Scheduling problems have b een widely studied in the literature Bak Gra GOT

Pin Amongst many dierent typ ologies a basic classication may b e based on the resource

environment single machine parallel machines owshop jobshop op enshop or resource

constrained problems

In this section an illustration of the application of CLP to scheduling problems is given

through the jobshop scheduling problem as in Wal The following examples of mo deling

are written in the same language for the sake of unity The Chip language was chosen and more

sp ecically its CSPbased solver over nite domains A domain variable the Chip equivalent

of a CSP variable is dened via ab where is the domain denition op erator and

ab a domain of consecutive set of integers Furthermore constraints on nite domains are

preceded by the sp ecial character to distinguish them from other arithmetical constraint

typ es in Chip

Problem Statement

In the jobshop problem a set of n jobs has to b e pro cessed using a set of m machines Each

job consists of a set of ordered tasks forming a routing each task runs on a separate machine

At any time a machine can pro cess only one task Preemption ie interruption of a started

task b efore completion is not allowed The ob jective is often to nd a schedule that minimizes

the makespan ie the total duration

This section aims at giving information ab out how to simply mo del such problem deriving

b enet from assets of CLP Facing the imp ortant numb er of constraints for large jobshop

scheduling problems an approach using CLP do es not have to solve the constraints involved

but to propagate them by lo cal consistency techniques in order to reduce the search space as

drastically as p ossible

Precedence constraints

The jobs are considered one after the other For each job a list of tasks is given in the order

of the routing Thus task i with start time T and duration D from the list must precede

i i

task i + To satisfy this precedence constraint one must p ost a relative lo cation constraint

b etween tasks i and i +

T + D T

i i i+

To each task of a job is also asso ciated a start domain variable p osting in this way an absolute

lo cation constraint Max corresp onds to a given horizon

jobTTDDMax

T Max Declaration of the first variable

routingTTDDMax

routingTmDmMax

Tm Dm Max Constraint on the latest variable

routingTTTDDDMax

T Max Declaration of other variables

T D T Precedence constraint

routingTTDDMax

Disjunctive constraints

As it is not p ossible to pro cess simultaneously two tasks on the same machine one needs

to generate disjunctive constraints b etween comp eting tasks In a general way a disjunctive

constraint or competition b etween a pair (i j) of tasks states that i precedes j or j precedes

i It yields

(T + D T ) or (T + D T )

i i j j j i

Dierent ways for mo deling this kind of constraint are presented b elow

Choice points

The most natural way to mo del an alternative is made through the intro duction of choice

p oints DSv vH

competitionTiDiTjDj Ti Di Tj i precedes j

competitionTiDiTjDj Tj Dj Ti j precedes i

This implementation is clearly nondeterministic due to its transcription into a disjunction

of constraints one packet of two clauses Hence this way of mo deling a disjunctive

constraint is highly inecient indeed for n comp eting tasks it develops a search space

n

in O( )

Conditional propagation

The conditional propagation of Chip allows the programmer to avoid the aforementioned

choice p oints It uses a demon mechanism to limit the nondeterministic b ehavior of pre

vious implementation by p ostp oning the choices until enough information can b e deduced

from the constraints As so on as the if condition is true for all p ossible values for the

14

Thus the principle of the disjunctive constraint variables the then branch is selected

implementation is the following if the minimal nish time of a task j is larger than the

maximal start time of another task i i must b e scheduled b efore j

competitionTiDiTjDj

if Tj Dj Ti then Ti Di Tj

if Ti Di Tj then Tj Dj Ti

Although more ecient than the previous implementation this metho d keeps the incon

venience to have to wake the demon for pruning the search tree

14

Using ifthenelse the else branch is executed when the condition is always false

Cardinality operator

Using the same principle of conditional propagation van Hentenryck Deville vHD

intro duce the cardinality operator to imp ose the minimum and maximum numb er of con

straints to b e satised among a set of constraints This op erator is a mathematical

abstraction which implements the principle Infer simple constraints from dicult ones

at the op erational level Thus with such an op erator exactly equal to the disjunctive

constraint may b e written as follows

competitionTiTjDiDj

cardinalityTiDi Tj TjDj Ti

Note that in the case of two disjunctive constraints C and C the cardinality op erator

may b e expressed thanks to the conditional propagation Cos

orCC

if C then true else C

if C then true else C

The authors show that nonprimitive constraints built with the cardinality op erator give

comparable or even b etter results to builtin constraints but really improving the exi

bility of utilization and expressiveness of cardinality constraints in order for example to

mo del more general problems than the disjunctive one

The cumulative primitive

The previous implementations concern the socalled b ound propagation also known as

Bconsistency Lho that is to say these rules adjust the extreme b ounds of the

domain variables head and tail of a task However the disjunctive constraints could

also attempt to achieve arcconsistency without p osting any choice p oint or waiting for

a demon to b e awaken

This is the goal of the cumulative constraint of Chip which aims at solving resource

constrained scheduling problems it can also b e used for disjunctive problems such as the

jobshop problem where the amounts of resources intensities or capacity are all equal

to

competitionTiDiTjDj

cumulativeTiTjDiDj

In AB the designers of the cumulative primitive present some results in placement

pro ject management and jobshop scheduling problems In the latter case and for the

famous b enchmark FT it seems that a simple programming using the cu

mulative primitive and a lab eling pro cedure based on rstfail principle allow them to

0

obtain the optimal solution of cost in on a Sun workstation Mb while a rst

00

solution is found with a cost of in

In the examination timetabling framework BDP this kind of implementation did not

realize sucient pruning to get acceptable results The authors improved the eciency

15

by using another builtin predicate distance whose utilization has b een p ossible

due to the presence of symmetries in the problem constraints

While using the cumulative primitive without generating any solution one can notice that

the impact of the constraint propagation may vary with the order in which constraints

15

The predicate distance imp oses an absolute distance b etween two domain variables

are p osted Hence this builtin predicate running as a blackb ox uses adhoc propagation

and do es not seem to achieve arcconsistency

Arcconsistency

The disadvantage raised previously led us to build our own primitive for arcconsistency

and enforcing It satises prop osition T T stand for the earliest and the latest start

i

i

times of i resp ectively

+ D + D + D Prop osition see Fig If T T then T [T T - D ] [T T ]

j i j j i j i i

j i j

Pro of Two sequences are possible between i and j i before j or j before i If i before j

+ D It yields T [T + D T If j before i T T T - D ] [T T ] Thus T + D

j i j j i j i i i i

j j i

T - D T T - D T if both intervals are disjoint T ] + D [ with + D 2

j i j i i j j

j j

j

i

Figure Inconsistent values for start time of i

Prop osition leads to the removal of inconsistent dates of T ie in ] + D [ The T - D T

i j j i

j

implementation uses the notin predicate which allows the removal of values inside a

domain and the conditional propagation where the same domain variable is used in each

hand of the inequality in the lines commented by check proposition in the left

hand the maximum p ossible value of the variable is examined whereas it is the minimum

one in the right hand

reviseTiDiTjDj

D is Di Dj

if Tj Tj D check proposition

then removevaluesTiDiTjDj remove values in Ti

if Ti Ti D check proposition

then removevaluesTjDjTiDi remove values in Tj

removevaluesTiDiTjDj

domaininfoTjTjminTjmax

Min is Tjmax Di

Max is Tjmin Dj

notinTiMinMax

info returns statically the smallest Note that the builtin information predicate domain

and the largest values in the domain of the variable It is then interesting to handle demon

propagation into the remove values predicate not detailed here so as to obtain a

complete dynamic b ehavior

Edge nding

The previous disjunctive constraint whatever its implementation can deduce strong conclu

sions for the global sequencing In practice time windows can b e very large related to pro cessing

times and this rule may b e useless and prune no value It could then b e more promising to

study the extreme p ositions of a single task i relatively to a group S of other ones i S

This technique whose principle is explained through the two following prop ositions arises from

+

constraintbased analysis BBD ERV ERV immediate selections CP and has also

b een studied in Nui It is called edge nding in AC

P

Prop osition see Fig If max ( D + D then S is nonp osterior T + D )- T

s2S s i s s

i

s2S

to i ie i cannot be scheduled before all activities of S

Pro of Suppose i precedes al l activities of S and let z S be the task scheduled last Thus

P

(T + D ) (T + D + D ) (max ( T + D )) (T + D ) which leads to the contradiction

z z i s s2S s s z z

i

s2S

T 2 T

z z

s3

s2

s1

i

Figure Nonp osterior set

If S is nonp osterior to i then at least one task of S must precede i Thus it can b e deduced

a lower b ound of the start time of i it is up dated to the smallest earliest nish time among

the tasks of S the minimum and maximum predened predicates are used

nonposteriorsetTiDiS

setdurationSDS Sum of durations of S

D is Di DS

setendsSEnds List of end variables of S

minimumMinendEnds

maximumMaxendEnds

if Maxend Ti D

then Ti Minend

P

D + D then i is non Prop osition see Fig If max ( T + D ) - min T

s i s2S s s s2S

s

s2S

inserable into S

Pro of Similar to previous one 2

s3

s2

s1

i

Figure Noninserable task

If i is noninserable into S then i must b e scheduled either b efore or after S Moreover if

S has previously b een proved to b e nonp osterior to i then i is necessarily scheduled after all

tasks in S Thus the start time of i can b e adjusted to the earliest nish time of whole set S

value much stronger than with the sole nonp osterior condition

noninserabletaskTiDiS

setdurationSDS D is Di DS setendsSEnds

setstartsSStarts List of start variables of S

minimumMinstartStarts

maximumMaxendEnds

if Maxend Minstart D

then Ti Minstart DS Iff S nonposterior to i

An analogous reasoning symmetrically establishes upp er b ound on the start time of a task

from a nonanterior set condition With noninserability condition one can derive that i pre

cedes all tasks in S and then rene this upp er b ound

Conclusion

The constraint programming framework is mostly known b ecause of noticeable achievement in

solving large combinatorial problems Yap BCF Pug PPMD These results have

b een obtained b oth b ecause of the eciency of the underlying solvers and the extra generality

oered by the host nondeterministic Prolog language

From the end of the eighties to now the CLP scheme has integrated an increasing amount

of solvers and domains There are now CLP languages that use intricate solvers or which are

16

connected to general systems such as Mathematica An imp ortant shortcoming of most

existing systems is the absence of relations b etween domains it is not yet p ossible to think of

hybrid mo dels where constraints are propagated b etween several domains even with incomplete

satisfaction mechanisms For instance a b o olean variable cannot b e usually asso ciated to

the truth of one inequality b etween integer variables achieving by that implicit propagations

b etween b o olean and nite domain solvers

Such hybrid mo dels would however b e promising to mo del b oth numerical time and sym

b olic sequencing constraints of scheduling problems and to derive inferences from a computa

tion domain to another one On the contrary certain languages prop ose global primitives for

the solving of some sp ecic problems eg combinatorial problems and more precisely schedul

ing Surprisingly although their underlying mechanisms are not complete they are often kept

top secret and there is no other way for the user than using these primitives as black b oxes

Economical accounts favors more and more the comp etition b etween constraint program

ming to ols It has the advantage to give rise to the application of metho ds develop ed by

academics but also to bring some new theoretical problems to light Unfortunately it also

leads to the closing of the systems and plays a great part in missing the primary ob jectives

of CLP ie formalizing and integrating general mechanisms of constraint propagation

For these reasons nowadays the only way to exp eriment hybrid solvers or to design user

dened propagation mechanisms is either to build your own system from scratch or from con

straint programming libraries such as IlogSolver which has p erhaps the largest set of

eventhandling primitives or to implement it as metalevel CLP interpretor Bo c

16

See FAQ for an exhaustive lists of existing CLP implementations

On the contrary the authors think that to day there still exist go o d reasons to maintain

Logic Programming as a basic natural framework for constraint programming in particular the

need of highlevel languages for a concise and declarative representation of problems and the

rapid prototyping of constraintoriented applications

These kinds of facilities require a wellfounded generalization of the semantical denition

17

of constraints in CLP languages whereas the trend of improving eciency has led to develop

separately then simply juxtap ose each of the constraint domains their solvers and primitives

References

AB A Aggoun and N Beldiceanu Extending chip in order to solve complex scheduling

and placement problems In Actes des Journees Francophones de Programmation

Logique JFPL pages Lille France

AC D Applegate and W Co ok A computational study of the jobshop scheduling

problem ORSA Journal on Computing

ACM Sp ecial section on logic programming Communications of ACM

AS JeanMarc Alliot and Thomas Schiex Intel ligence Articiel le et Informatique

Theorique in French Cepadues Toulouse France nd edition ISBN

+

ASS A Aiba K Sakai Y Sato DJ Hawley and R Hasegawa Constraint logic pro

gramming language CAL In Proceedings of the International Conference on Fifth

Generation Computer Systems FGCS ICOT Tokyo pages Decem

b er

Bak KR Baker Introduction to sequencing and scheduling John Wiley Sons New

York

BB JM Boi and F Benhamou Boolean Constraints in Prolog III PhD thesis Group e

dIntelligence Articielle Universite dAixMarseille Luminy Novemb er

+

BBD G Bel E Bensana D Dub ois J Erschler and P Esquirol A knowledgebased

approach to industrial jobshop scheduling In A Kusiak editor Know ledgebased

systems in manufacturing pages Taylor Francis

BCF J Bellone A Chamard and A Fishler Constraint logic programming decision

supp ort systems for planning and scheduling aircraft manufacturing at dassault

aviation In Third International Conference on the Practical Application of Prolog

PAP pages Paris France

BDP P Boizumault Y Delon and L Peridy Constraint logic programming for exami

nation timetabling Journal of Logic Programming To app ear

BFR C Bessiere EC Freuder and JC Regin Using inference to reduce arcconsistency

th

computation In Proc of the IJCAI Montreal Canada August

Bo c A Bo ckmayr Logic programming with pseudob o olean constraints In F Ben

hamou A Colmerauer editor Constraint Logic Programming Selected research

Logic Programming Series pages MIT Press

17

Mayb e with the brandnew version of PrologIA PrologIV BT

Bry RE Bryant Symb olic b o olean manipulation with ordered binarydecision dia

grams ACM Computing Surveys Septemb er

BT F Benhamou and Touravane Prolog IV langage et algorithmes In Actes des

Journees Francophones de Programmation en Logique JFPL pages Di

jon France

Buc B Buchb erger Grobner bases An algorithmic metho d in p olynomial ideal theory

In N K Bose editor Multidimensional Systems Theory pages Reidel

Publishing Co

CD P Co dognet and D Diaz Bo olean constraints solving using clpfd In Interna

tional Logic Programming Symposium pages

CKvC A Colmerauer H Kanoui and M van Caneghem Prolog bases theoriques et

developp ements actuels Techniques et Sciences Informatiques

in French

CM WF Clo cksin and CS Mellish Programming in Prolog Springer Verlag rd

edition

Coh J Cohen Constraint logic programming languages Communications of the ACM

July

Cola A Colmerauer Prolog and innite trees In New York Academic Press editor

Logic Programming pages KL Clark and SA Tarnlund

Colb A Colmerauer PROLOG II reference manual and theoretical mo del Technical

rep ort Group e Intelligence Articielle Universite AixMarseille I I Octob er

Co o MC Co op er An optimal kconsistency algorithm Articial Intel ligence

Cos Cosytec Chip Reference Manual June COSYREF

CP J Carlier and E Pinson Adjustment of heads and tails for the jobshop problem

European Journal of Operational Research

Dav E Davis Constraint propagation with interval lab els Articial Intel ligence

July

th

dK J de Kleer A comparison of ATMS and CSP techniques In Proc of the

IJCAI pages Detroit MI August

DP M Davis and H Putnam A computing pro cedure for quantication theory Journal

of the ACM

DSv M Dincbas H Simonis and P van Hentenryck Solving Large Combinatorial

Problems in Logic Programming Journal of Logic Programming

JanuaryMarch

ERV J Erschler F Roub ellat and JP Vernhes Finding some essential characteristics of

the feasible solutions for a scheduling problem

ERV J Erschler F Roub ellat and JP Vernhes Characterizing the set of feasible

sequences for n jobs to b e carried out on a single machine European Journal of

Operational Research

FAQ FAQ of the compconstraints newsgroup Available at URL httpwebcs

cityacukarchiveconst rain t

Fre EC Freuder Synthesizing constraint expressions Communications of the ACM

Novemb er

FT H Fisher and GL Thompson Probabilistic learning combinations of lo cal jobshop

scheduling rules In JF Muth GL Thompson editor Industrial Scheduling

pages Prentice Hall Englewo o d Clis NJ

GJ MR Garey and DS Johnson Computers and Intractability A Guide to the Theory

of NPcompleteness WH Freeman and Company New York

GOT GOThA Les problemes dordonnancement RAIRORO in

French

Gra SC Graves A review of pro duction scheduling Operations Research

+

HJM NC Heintze J Jaar S Michaylov PJ Stuckey and RHC Yap The CLPR

Programmers Manual IBM TJ Watson Research Center PO Box Yorktown

Heights NY Septemb er Version

HL T Huynh and C Lassez A CLPR options trading analysis system In Rob ert A

Kowalski and Kenneth A Bowen editors JICSLP Proceedings th Interna

tional Conference and Symposium on Logic Programming pages Seattle

Washington USA MIT Press

HMS N Heintze S Michaylov and P Stuckey CLPR and some electrical engineering

problems Journal of Automated Reasoning Octob er

Ho o JN Ho oker A quantitative approach to logical inference Decision Support Sys

tems

Hyv E Hyvonen Constraint reasoning based on interval arithmetic the tolerance prop

agation approach Articial Intel ligence Decemb er

Imb JL Imb ert Fouriers elimination Which to cho ose In First Workshop on Princi

ples and Practice of Constraint Programming pages Newp ort April

JL J Jaar and JL Lassez Constraint logic programming In POPL Proceedings

th ACM Symposium on Principles of Programming Languages pages

Munich January ACM

JM J Jaar and MJ Maher Constraint logic programming a survey The Journal of

Logic Programming

JMSY J Jaar MJ Maher PJ Stuckey and R Yap Pro jecting clp constraints

New Generation Computing

Kar N Karmarkar A new p olynomial time algorithm for linear programming Combi

natorica

Kha LG Khachian A p olynomial algorithm in linear programming Soviet Math Dokl

Kor RE Korf Depth rst iterative deep ening An optimal admissible tree search

Articial Intel ligence

Kow RA Kowalski Logic for Problem Solving North Holland

th

Lho O Lhomme Consistency techniques for numeric CSPs In Proc of the IJCAI

pages Chambery France August

LM JL Lassez and K McAllo on A canonical form for generalized constraints J

Symbolic Computation

Mac AK Mackworth Consistency in networks of relations Articial Intel ligence

MJPL S Minton MD Johnston AB Philips and P Laird Solving largescale constraint

satisfaction and scheduling problems using a heuristic repair metho d In Proc of

AAAI pages Boston MA

ML BL McCarthy and J Liu Addressing the gap in scheduling research A review of

optimization and heuristic metho ds in pro duction scheduling International Journal

of Production Research

Mon U Montanari Network of constraints Fundamental prop erties and applications to

picture pro cessing Inf Sci

Nad BA Nadel Constraint satisfaction algorithms Comput Intel l

Novemb er

Nui WPM Nuijten Time and resource constrained scheduling PhD thesis Eindhoven

University of Technology

Pap C Le Pap e Implementation of resource constraints in ilogschedule A library

for the development of constraintbased scheduling systems Intel ligent Systems

Engineering

Pin M Pinedo Scheduling Theory Algorithms and Systems PrenticeHall Englewo o d

Clis NJ

PPMD C Le Pap e JF Puget C Moreau and P Darneau PMFP The use of constraint

st

based programming for predictive p ersonnel management In Proc of the

ECAI Amsterdam The Netherlands

Pug JF Puget Ob ject oriented constraint programming for transp ortation problems

In Proc of ASTAIR

Pug JF Puget A C implementation of CLP Technical Rep ort Ilog

PW MS Paterson and MN Wegman Linear unication JCSS

Rob J Alan Robinson A machineoriented logic based on the resolution principle

Journal of the ACM

SH G Sideb ottom and WS Havens Hierarchical arc consistency applied to numeric

pro cessing in constraint logic programming Technical rep ort Center for Systems

Science Simon Fraser University Burnaby Canada

Ste GL Steele The denition and implementation of a computer programming lan

guage based on constraints Technical rep ort Dept of Electrical Engineering and

Computer Science MIT August

Tsa EPK Tsang Foundations of Constraint Satisfaction Academic Press Ltd Lon

don

Ull JR Ullman Asso ciating parts of patterns Inform Contr

vH P van Hentenryck Constraint Satisfaction in Logic Programming Logic Program

ming Series MIT Press Cambridge MA

vHD P van Hentenryck and Y Deville The cardinality op erator A new logical connec

tive for constraint logic programming In F Benhamou A Colmerauer editor

Constraint Logic Programming Selected research Logic Programming Series pages

MIT Press

vHDT P van Hentenryck Y Deville and C Teng A generic arcconsistency algorithm

and its sp ecializations Articial Intel ligence

Wal D L Waltz Generating semantic descriptions from drawings of scenes with shad

ows Technical Rep ort AI MIT Cambridge MA

Wal M Wallace Applying constraints for scheduling In B Mayoh E Tyugu and

J Penjaam editors Constraint Programming Proceedings NATO ASI Parnu

Estonia NATO Advanced Science Institute Series pages SpringerVerlag

Yap RHC Yap A constraint logic programming framework for constructing DNA

restriction maps Articial Intel ligence in Medicine