FOUNDATIONS OF ARTIFICIAL INTELLIGENCE Foundations of Artificial Intelligence Series Editors J. Hendler H. Kitano B. Nebel Cover picture by Helmut Simonis ELSEVIER AMSTERDAM–BOSTON–HEIDELBERG–LONDON–NEW YORK–OXFORD PARIS–SAN DIEGO–SAN FRANCISCO–SINGAPORE–SYDNEY–TOKYO Handbook of Constraint Programming Edited by Francesca Rossi University of Padova Italy Peter van Beek University of Waterloo Canada Toby Walsh National ICTA Australia & University of New South Wales Australia ELSEVIER AMSTERDAM–BOSTON–HEIDELBERG–LONDON–NEW YORK–OXFORD PARIS–SAN DIEGO–SAN FRANCISCO–SINGAPORE–SYDNEY–TOKYO Elsevier Radarweg 29, PO Box 211, 1000 AE Amsterdam, The Netherlands The Boulevard, Langford Lane, Kidlington, Oxford OX5 1GB, UK First edition 2006 Copyright © 2006 Elsevier B.V. All rights reserved No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means electronic, mechanical, photocopying, recording or otherwise without the prior written permission of the publisher Permissions may be sought directly from Elsevier’s Science & Technology Rights Department in Oxford, UK: phone (+44) (0) 1865 843830; fax (+44) (0) 1865 853333; email: [email protected]. Alternatively you can submit your request online by visiting the Elsevier web site at http://elsevier.com/locate/permissions, and selecting Obtaining permission to use Elsevier material Notice No responsibility is assumed by the publisher for any injury and/or damage to persons or property as a matter of products liability, negligence or otherwise, or from any use or operation of any methods, products, instructions or ideas contained in the material herein. Because of rapid advances in the medical sciences, in particular, independent verification of diagnoses and drug dosages should be made Library of Congress Cataloging-in-Publication Data A catalog record for this book is available from the Library of Congress British Library Cataloguing in Publication Data A catalogue record for this book is available from the British Library ISBN-13: 978-0-444-52726-4 ISBN-10: 0-444-52726-5 ISSN: 1574-6525 For information on all Elsevier publications visit our website at books.elsevier.com Printed and bound in The Netherlands 06 07 08 09 10 10 9 8 7 6 5 4 3 2 1 Foreword Constraints are an ubiquitous concept, which in its broader sense pertains to every day experience: theyrepresenttheconditionswhichrestrictourfreedomofdecision. Infact, howmuchourchoicesareconstrainedbytheexternalworldisabasicphilosophicalques- tion. Intheformalizedreasoningofscientificdisciplines,constraintshavebeenemployed extensively,fromlogictonumericalanalysis,frommathematicalprogrammingtoopera- tionsresearch.Incomputerscience,constraintshavebeenwithusfromtheearlydays,for modeling,representingandreasoning(seetheinterestinghistoricalremarksinChapter2 ofthishandbook,ConstraintSatisfaction:AnEmergingParadigm). I see several good reasons for this ubiquity: one is the conceptually clear separation betweentheperfectlydeclarativeproblemstatementsandtheoftencumbersomeenumera- tiveeffortsforfindingsolutions.Anotherreasonisthecomplexitychallenge:theclassical constraint satisfaction problem is NP-complete and in fact tautology checking in propo- sitionalcalculus(aconstraintproblemonBooleanvariables)hasbeenthetouchstonefor this complexity class. A further reason is that large, complex constraint problems often occurinpractice,theymustbesolvedinonewayoranother,andfast,efficient,systematic solutionshaveanenormouseconomicvalue. WhatIfindsurprisingaboutconstraintsisthatwithinartificialintelligenceandcom- putersciencearelativelyrecent,relativelyuniformbodyofknowledgehasemergedwhich often yields decisive advantages over classical, extensively studied and well developed techniques. Asformanysuccessstorieswithincomputerscience, successislargely due toamixtureofstructures,algorithms,languages,programmingtechniquesandsystemim- plementations. The aim of this handbook is to present this knowledge in all its facets. Differentchaptersarelargelyselfcontainedandallcontributetoputthesubjectintofocus, similarlytotheHawaiiKeckobservatory,wherethemirroriscomposedof36hexagonal segments. Fromtheconceptualpointofview,themaincharacteristicfeaturesofconstraintpro- grammingareconstraintpropagation,andtheidentificationofvariousspecialcaseswhich make complexity tractable. The former (see Chapter 3) is an inference technique which makeslocalconstraintsstrongerwithout changingtheglobalconstraint. The latterissue concernsboththestructure(seeChapter7,TractableStructuresforConstraintSatisfaction Problems)andthekindofconstraints(seeChapter8,TheComplexityofConstraintLan- guages). Lessspecific,butstillveryimportantissuesareasfollows: BacktrackingSearch Algorithms, in Chapter4; LocalSearch, in Chapter 5; Global Constraints, in Chapter6; SymmetryinConstraintProgramming,inChapter10;andModelling,inChapter11. Anothersurprisingfactaboutconstrainttheoryistheincrediblycloserelationshipwith logicprogramming. Inaratherprecisesenselogicprogrammingisawayofexpressing, andsolving, certainclassesofdisjunctive,recursiveconstraints. Furthermore, logicpro- grammingcanbeveryelegantlygeneralizedtoconstraintlogicprogramming(seeChapter v vi Foreword 12),wheretheordinaryHerbrandconstraintsystem,anditsunificationalgorithm,arecom- plementedwithspecificconstraintsolvers.Theinteractionwiththecommittedchoicelan- guagesstudiedintheJapaneseprojectsoftheeightiesalsoyieldedveryinterestingmodels ofcomputationbasedonconstraints. Amalgamationwithmorecommon(andefficiently implemented!) programming languages is also possible (see Chapter 13, Constraints in ProceduralandConcurrentLanguages). Besidesandbeyondthebeautyofitstheoreticalfoundations,whatcontributesthemost tothepracticalconvenienceofconstraintprogrammingare:(i)thedevelopmentofspecific resultsforimportantclassesofconstraints;(ii)theabilityofextendingthebasictheoryto variousadditionalaspectswhichareveryrelevantinpractice; and(iii)theflexibilityand potentialforintegrationwithothermodelingandsolvingmethodologies. Aboutthedevelopmentofspecificresults,thishandbookincludeschaptersaboutcon- straintsonfinite(Chapter14),structured(Chapter17),temporal(Chapter19),continuous andinterval-based(Chapter16)domains. Thepotentialtoextendthebasictheoryinevi- dentinthecaseofsoftconstraints,consideredinChapter9.Ordinaryconstraintsareeither satisfied or not, namely either true or false. Instead soft constraints return a more infor- mativeweight. Interestinglyenough,theproposedextensionsbothaccommodateseveral important cases(fuzzy, hierarchical, optimization, probabilistic constraints), and still of- tenexhibitessentiallythesamesolutionalgorithms. Extensionstorandom,changingand distributed/openconstraintsaretreatedinChapters18,21and20respectively. Aboutthelastissue,inadditiontotheseamlessintegrationwithlogicandimperative programminglanguageswementionedalready,quiteremarkablearetheparadigmsresult- ingfromtheintegrationofconstraintprogrammingwithoperationsresearch(seeChapter 15),withschedulingandplanning(seeChapter22),withvehiclerouting(seeChapter23), withcomponentconfiguration(seeChapter24),with(electricity,water,oil,data)networks (seeChapter25),andwithbioinformatics(seeChapter26). The global scenario based on service-oriented computing which is now under devel- opment offers additional theoretical and practical challenges to constraint programming. Conditionsforservicedeploymentanddiscovery,bothfunctionalandinvolvingdifferent aspectsofqualityofservice,couldbeexpressedintermsofhardandsoftconstraints,and thenegotiationphasesshouldinvolvesubstantialconstraintsolvingabilities. Transactions among the various actors could also require partially backtrackable behavior or at least programmablecompensations.Somelevelofrealtime,distributed,globalconstraintsolv- ingshouldbeimplementedinthemiddleware,sincelotsofhigherlevelapplicationswill beabletotakeadvantageof,andpayforit. Ithinkthatresearchandpracticaldevelopmentintheareaofconstraintprogramming willbeveryactiveforquiteawhileinthefuture,establishingcloserandcloserconnections with a variety of other design methodologies and even other disciplines. I consider this handbooknotonlyaverynicepieceofscientificwork,butalsoacontributionquiteinstru- mental at disseminating advanced knowledge about constraint programming both within theinnerconstraintcommunityandacrossthemuchwideraudienceofpotentialusers. UGOMONTANARI DipartimentodiInformatica Universita`diPisa,Italy Editors FrancescaRossi UniversityofPadova Italy PetervanBeek UniversityofWaterloo Canada TobyWalsh NationalICTAustralia& UniversityofNewSouthWales Australia vii This page intentionally left blank Contributors RolfBackofen EugeneC.Freuder Albert-Ludwigs-Universita¨t CorkConstraintComputationCentre& Germany UniversityCollegeCork,Ireland PhilippeBaptiste ThomFru¨hwirth CNRSLIX&E´colePolytechnique Universita¨tUlm France Germany Fre´de´ricBenhamou IanP.Gent Universite´deNantes UniversityofSt.Andrews France Scotland,UnitedKingdom ChristianBessiere CarmenGervet LIRMM-CNRS BrownUniversity France USA KennethN.Brown DavidGilbert CorkConstraintComputationCentre& UniversityofGlasgow UniversityCollegeCork,Ireland Scotland,UnitedKingdom MatsCarlsson CarlaGomes SICSAB CornellUniversity Sweden USA DavidCohen LaurentGranvilliers RoyalHolloway,UniversityofLondon Universite´deNantes UnitedKingdom France RinaDechter JohnN.Hooker UniversityofCalifornia,Irvine CarnegieMellonUniversity USA USA BoiFaltings HolgerH.Hoos SwissFederalInstituteofTechnology UniversityofBritishColumbia Switzerland Canada ix