1% BEGIN LICENSE BLOCK 2% Version: CMPL 1.1 3% 4% The contents of this file are subject to the Cisco-style Mozilla Public 5% License Version 1.1 (the "License"); you may not use this file except 6% in compliance with the License. You may obtain a copy of the License 7% at www.eclipse-clp.org/license. 8% 9% Software distributed under the License is distributed on an "AS IS" 10% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 11% the License for the specific language governing rights and limitations 12% under the License. 13% 14% The Original Code is The ECLiPSe Constraint Logic Programming System. 15% The Initial Developer of the Original Code is Cisco Systems, Inc. 16% Portions created by the Initial Developer are 17% Copyright (C) 2006 Cisco Systems, Inc. All Rights Reserved. 18% 19% Contributor(s): 20% 21% END LICENSE BLOCK 22 23\chapter{Introduction} 24%HEVEA\cutdef[1]{section} 25 26This manual documents the major \eclipse\ libraries. 27They are enabling tools for the development and delivery 28of planning and scheduling applications. 29Since this is an area of active research and new developments, 30these libraries are subject to technical improvements, addition 31of new features and redesign as part of our ongoing work. 32 33In this section we shall briefly summarize the constraint solvers that 34are available as \eclipse\ libraries. 35No examples are given here - each solver has its own documentation 36with examples for the interested reader. 37 38\section{Suspended Goals: {\em suspend}} 39The constraint solvers of \eclipse\ are all implemented using suspended 40goals. 41In fact the simplest implementation of any constraint is to suspend it 42until all its variables are sufficiently instantiated, and then test it. 43 44The library {\em suspend} contains versions of 45the mathematical constraints \verb0>=0, \verb0>0, 46\verb0=:=0, \verb0=\=0, \verb0=<0, \verb0<0 47which behave like this\footnote{ 48Note that the global flag {\em coroutine} has a similar effect: 49it causes the arithmetic comparisons as well as many other 50built-in predicates to delay until they are sufficiently instantiated}. 51 52\section{Finite Domains: {\em ic}} 53\subsection{{\em Integer Domain}} 54The standard constraint solver offered by most constraint programming 55systems is the {\em finite domain} solver, which applies constraint 56propagation techniques developed in the AI community 57\cite{VanHentenryck}. 58\eclipse\ supports finite domain constraints via the {\em ic} 59library\footnote{There is also an older implementation, the {\em fd} library, 60whose use is deprecated}. 61This library implements finite domains of integers, and the usual 62functions and constraints on variables over these domains. 63 64\subsection{Symbolic Domain: {\em ic_symbolic}} 65In addition to integer domains, \eclipse\ offers finite domains of 66ordered non-numeric values, for example ${red, green, blue}$. 67These are implemented by the {\em ic_symbolic} library. 68 69Whilst there is a standard set of constraints supported by the 70{\em ic} library in \eclipse\ and in 71most constraint programming systems, many more finite domain 72constraints have been introduced which have uses in specific 73applications and do not belong in a generic constraint programming 74library. 75The behaviour of these constraints is to prune the finite domains of 76their variables, in just the same way as the standard 77constraints. 78Therefore \eclipse\ offers several further libraries which implement more 79constraints using the {\em ic} library. 80 81\subsection{Global Constraints: {\em ic\_global}} 82One such library is {\em ic\_global}. 83It supports a variety of constraints, each of which takes as an argument 84a list of finite domain variables, of unspecified length. 85Such constraints are called ``global'' constraints \cite{beldiceanu}. 86Examples of such constraints, available from the {ic\_global} library 87are 88\verb0alldifferent/10, \verb0maxlist/20, \verb0occurrences/30 and 89\verb0sorted/20. 90 91\subsection{Scheduling Constraints} 92There are several \eclipse\ libraries implementing global constraints for 93scheduling applications. The constraints have the same semantics, 94but different propagation. The constraints take a list 95of tasks (start times, durations and resource needs), and a maximum 96resource level. They reduce the finite domains of the task start times 97by reasoning on resource bottlenecks \cite{lepape}. Three \eclipse\ libraries 98implementing scheduling constraints are 99{\em cumulative}, {\em edge\_finder} and {\em edge\_finder3}. 100 101\section{Sets} 102\eclipse\ offers constraint solving over the domain of finite sets of 103integers. The {\em ic\_sets} library works together with the {\em ic} library 104to reason about sets and set cardinality \cite{gervet}\footnote{ 105There is also an older implementation, the {\em conjunto} library, which 106is generally less efficient, but implements sets of symbolic elements as 107well as integer sets}. 108 109\section{Intervals} 110Besides finite domains, \eclipse\ also offers continuous domains in the 111form of numeric intervals. 112These are also implemented by the {\em ic} library, which is an integration 113of an 114integer finite domain solver and interval reasoning over continuous 115intervals\footnote{ 116The {\em ic} library replaces the old {\em ria} interval solver, and 117covers most of the functionality of the finite domain solver {\em fd}}. 118It solves equations and inequations between 119general arithmetic expressions over continuous or integral variables. 120The expressions can include non-linear functions such as $sin$, built-in 121constants such as $pi$. Piecewise linear unary functions are also available. 122 123In addition to constraints, {\em ic} offers search techniques 124({\em splitting} \cite{VanHentenryck:95} and {\em squashing} 125\cite{lhomme96boosting}) 126for solving problems involving continuous numeric variables. 127 128 129\section{User-Defined Constraints} 130\subsection{Generalised Propagation: {\em propia}} 131The predicate {\em infers} takes as one argument 132any user-defined predicate, and as a second argument a form of 133propagation to be applied to that predicate. 134 135This functionality enables the user to turn any predicate into a 136constraint \cite{LeProvost93b}. The forms of propagation include finite 137domains and intervals. 138 139\subsection{Constraint Handling Rules} 140The user can also specify predicates using rules with guards 141\cite{Fruehwirth}. 142They delay until the guard is entailed or disentailed, and then 143execute or terminate accordingly. 144 145This functionality enables the user to implement constraints in a way 146that is clearer than directly using the underlying {\em suspend} 147library. 148 149\section{Repair} 150The {\em repair} library allows a {\em tentative} value to be 151associated with any variable \cite{cp99wkshoptalk}. 152This tentative value may violate constraints on the variable, in which 153case the constraint is recorded in a list of violated constraints. 154The repair library also supports propagation {\em invariants} 155\cite{Localizer}. 156Using invariants, if a variable's tentative 157value is changed, the consequences of this change can be propagated to 158any variables whose tentative values depend on the changed one. 159The use of tentative values in search is illustrated in the \eclipse\ 160``Tutorial on Search Methods''. 161 162\section{Linear Constraints} 163There are two libraries supporting linear constraint solving. The 164first {\em eplex} provides an interface to external linear 165programming packages. 166It offers flexibility and scalability, but may 167require a license for the external software. 168The second {\em clpqr} can support infinite precision, but is less 169efficient and scalable and offers fewer facilities. 170 171\subsection{External Linear Solvers: {\em eplex}} 172{\em eplex} supports a tight integration \cite{Bockmayr} between 173external linear solvers (CPLEX \cite{ILOG} and XPRESS \cite{Dash}) 174and \eclipse. 175Constraints as well as variables can appear in both the external 176linear solver and other \eclipse\ solvers. 177Variable bounds are automatically passed from the \eclipse\ {\em range} 178solver to the external solver. 179Optimal solutions and other solutions can be returned to \eclipse\ as 180required. 181Search can be carried out either in \eclipse\ or in the external solver. 182 183\subsection{{\em clpqr}} 184The {\em clpqr} library offers two implementations of the Simplex 185method for solving linear constraints \cite{Holzbauer}. 186One version uses rationals and 187is exact. The other version uses floats. 188This library employs public domain software, and can be used for small 189problems (with less than 100 variables). 190 191\subsection{Piecewise Linear: {\em eplex\_relax}} 192This library handles any user-defined piecewise linear function as a 193constraint closely integrated with {\em eplex}. It offers better 194pruning than the standard handling of piecewise linear constraints 195in the external solvers \cite{Ajili}. 196 197%\section{Combining Linear and Finite Domain Propagation} 198%\subsection{{\em fdplex}} 199%A simple way to achieve maximum propagation is to send all numeric 200%constraints both to {\em fd} and to {\em eplex} \cite{RWH99}. 201%This requirement is automatically supported by the {\em fdplex} 202%library. 203 204\subsection{Probing for Scheduling} 205For scheduling applications where the cost is dependent on each start 206time, a combination of solvers can be very powerful. 207For example, we can use finite domain 208propagation to reason on 209resources and linear constraint solving to reason on cost \cite{HaniProbe}. 210 211The {\em probing\_for\_scheduling} library supports such a combination, 212via a similar user interface to the {\em cumulative} constraint mentioned 213above. 214 215 216\section{Other Libraries} 217The solvers described above are just a few of the many libraries 218available in ECLiPSe and listed in the \eclipse\ library directory. 219 220Libraries are not only for constraint solvers -- for example, the 221{\em \eclipse\ SQL Database Interface} library provides an interface to 222external Database Management Systems, allowing users to add and retrieve data 223from the database within an \eclipse\ program. 224 225Any \eclipse\ user who has implemented a constraint solver is welcome to 226send the code to the \eclipse\ team so that it can be added to 227the available libraries. 228Comments and suggestions on the existing libraries are also welcome! 229 230%HEVEA\cutend 231