On the Hybridization of Constraint Programming and Local Search Techniques: Models and Software Tools
Total Page:16
File Type:pdf, Size:1020Kb
UNIVERSITA` DEGLI STUDI DI UDINE DIPARTIMENTO DI MATEMATICA E INFORMATICA DOTTORATO DI RICERCA IN INFORMATICA CICLO XXII PHDTHESIS On the Hybridization of Constraint Programming and Local Search Techniques: Models and Software Tools Raffaele Cipriano Supervisors: Agostino Dovier Luca Di Gaspero ANNO ACCADEMICO 2010/2011 Dipartimento di Matematica e Informatica Universita` degli Studi di Udine Via delle Scienze, 206 33100 Udine Italia Contents I Preliminary Concepts1 1 Constraint Satisfaction and Optimization Problems3 1.1 Formal definitions for CSP and COP......................3 1.2 Example.....................................4 2 Constraint Programming9 2.1 Constraint Propagation.............................9 2.2 Variable Assignment.............................. 11 2.3 Search Engines................................. 12 2.3.1 Depth first............................... 12 2.3.2 Branch and bound........................... 13 2.3.3 Depth first with restart......................... 13 2.4 Example..................................... 15 3 Local Search 19 3.1 Local Search Entities.............................. 20 3.2 Basic Local Search Algorithms......................... 20 3.2.1 Hill Climbing.............................. 22 3.2.2 Simulated annealing.......................... 23 3.2.3 Monte Carlo.............................. 23 3.2.4 Tabu Search............................... 23 3.3 Advanced Local Search Techniques...................... 24 3.4 Other Meta-heuristics.............................. 25 3.4.1 Population-based methods....................... 25 3.4.2 Hybrid meta-heuristics......................... 26 3.5 Examples.................................... 27 4 Hybridization of CP and LS 31 4.1 Consolidated Hybrid Techniques........................ 31 4.2 Large Neighborhood Search.......................... 32 4.3 New Hybrid Techniques............................ 34 4.4 The Comet language.............................. 34 II Software Tools 37 5 Gecode 39 5.1 Gecode Overview................................ 39 ii Contents 5.2 Gecode Architecture.............................. 40 5.3 Modeling with Gecode............................. 41 5.3.1 Model Head............................... 42 5.3.2 Constraints............................... 42 5.3.3 Objective Function and Branching................... 43 5.3.4 Setting up a Branch and Bound search engine............. 44 6 EasyLocal++ 47 6.1 EasyLocal++ Overview............................. 47 6.2 EasyLocal++ Architecture........................... 48 6.3 Modeling with EasyLocal++.......................... 50 6.3.1 State.................................. 50 6.3.2 Move.................................. 51 6.3.3 Constraints and Objective Function.................. 52 6.3.4 NeighborhoodExplorer......................... 53 6.3.5 StateManager.............................. 56 6.3.6 Main.................................. 56 7 GELATO hybrid solver 59 7.1 GELATO Overview............................. 60 7.2 GELATO Internal Core........................... 61 7.2.1 Data................................... 61 7.2.2 Helpers................................. 68 7.3 GELATO External Interface......................... 71 7.3.1 GELATO Large Neighborhood Search Engines........... 72 7.3.2 Calling the external interface from the main program........ 74 7.4 Modeling with GELATO ........................... 74 7.4.1 A Gecode model for GELATO ................... 75 7.4.2 The main................................ 77 8 GELATO Meta-Tool 79 8.1 SICStus language................................ 79 8.1.1 CSPs and COPs in SICStus...................... 80 8.2 FlatZinc language................................ 81 8.2.1 CSPs and COPs in FlatZinc ...................... 82 8.2.2 Annotation in FlatZinc ......................... 83 8.3 Translation from Prolog to FlatZinc ...................... 84 8.3.1 Compiling a FlatZinc Generator.................... 84 8.3.2 Generating the FlatZinc code..................... 87 8.4 A Meta-heuristic modeling language...................... 88 8.5 Architecture of the GELATOMeta-Tool................... 91 Contents iii 9 Installing GELATO 93 9.1 Installing Gecode ............................... 93 9.2 Installing EasyLocal++ ............................ 94 9.3 Installing GELATO ............................. 94 III Applications 95 10 Asymmetric Traveling Salesman Problem 97 10.1 Modeling the ATSP............................... 97 10.2 Experiments................................... 98 10.2.1 Solving approaches........................... 98 10.2.2 Parameters tuning and data analysis.................. 99 10.3 Results...................................... 100 11 The Minimum Energy Broadcast Problem 103 11.1 Modeling the MEB............................... 103 11.2 Experiments................................... 104 11.2.1 Solving approaches........................... 104 11.2.2 Parameters tuning and data analysis.................. 105 11.3 Results...................................... 105 12 The Course Time Tabling Problem 107 12.1 Modeling the CTT............................... 108 12.2 Experiments................................... 108 12.2.1 Solving approaches........................... 109 12.2.2 Parameters tuning and data analysis.................. 109 12.3 Results...................................... 109 Conclusions 113 Bibliography 115 iv Contents List of Figures 1.1 Solution for the given instance of SCTT....................6 1.2 Assignment for the given instance of SCTT, violating constraints C2 and C3.6 1.3 Optimum solution for the given instance of SCTT...............7 2.1 Example of Branch and Bound search..................... 14 2.2 Example of Depth First with Restart search.................. 14 2.3 Ineffective exploration of the search space for the SCTT problem....... 17 2.4 Effective exploration of the search space for the SCTT problem........ 18 3.1 LS exploration on the search tree: (a) Initial solution s0. (b) Exploration of the neighborhood of s0. (c) Moving to a neighbor. (d) The process is iterated. 21 4.1 A step of LS (a) and LNS (b) applied to a initial solution obtained by CP... 33 4.2 LNS move for a solution of SCTT....................... 34 5.1 Gecode Architecture.............................. 40 6.1 The levels of abstraction in EasyLocal++ ................... 48 6.2 EasyLocal++main classes........................... 50 7.1 Structure of GELATO and interactions with Gecode and EasyLocal++ . 60 7.2 GelatoState class................................ 62 7.3 Gelato Move class hierarchy.......................... 64 7.4 GelatoInput class................................ 65 7.5 GelatoOutput class............................... 65 7.6 GelatoSpace class................................ 67 7.7 GelatoNeighborhoodExplorer class....................... 69 7.8 Main Gelato Helpers classes.......................... 70 7.9 GelatoOutputManager class........................... 72 7.10 LNS Engines classes.............................. 73 7.11 main code that calls the HillClimbingRandom engine.......... 75 8.1 SICStus Prolog model for the SCTT problem................. 81 8.2 Objective function of the SCTT model..................... 82 8.3 The overall GELATO tool and the translation process............ 85 8.4 Example of generator head........................... 85 8.5 Example of generator utilities.......................... 86 8.6 Pseudo code for the compilation of the generator body............ 87 8.7 Excerpt of SCTT FlatZinc model obtained................... 89 8.8 The overall GELATO tool.......................... 92 vi List of Figures 10.1 Methods comparison on the ATSP instances.................. 101 11.1 Methods comparison on the MEB instances.................. 106 12.1 Methods comparison on the CTT instances................... 111 List of Tables 3.1 Differences between the Basics Local Search Techniques........... 22 8.1 Examples of translation from clp(FD) predicates to output predicates and then to FlatZinc statements............................. 88 viii List of Tables Introduction Combinatorial problems such as planning, scheduling, timetabling, and, in general, resource management problems, are encountered daily by industries, corporations, hospitals, and uni- versities. The ability to get quickly good solutions for these problems is essential for such organizations, since it impacts business and overall customer and employee satisfaction. This allows for increasing of profit margins, proper use and employment of materials and re- sources, optimized utilization of machines and employees, the scheduling of work shifts, and so on. These problems can be encoded with a mathematical approach that considers multiple elements such as, connections and relationships of entities, prohibited situations, all while working to obtain the main objective that is desired. This mathematical approach is fun- damental in the characterization of Constraint Satisfaction Problems (CSPs) and Constraint Optimization Problems (COPs). A CSP is defined as the problem of associating values, taken from a set of domains, to variables subject to a set of constraints. A solution is an assignment of values to all the variables that satisfies all the constraints. In COPs a cost function is asso- ciated to the variable assignments and a solution that (without loss of generality) minimizes the cost value searched. Unfortunately, these problems typically belong to the class of NP- hard (or worse) problems. Thus, in non trivial instances it is extremely unlikely that someone could find an efficient method (i.e., a polynomial algorithm) for solving