A Satisfiability Modulo Theories Approach to Constraint Programming
Total Page:16
File Type:pdf, Size:1020Kb
A SATISFIABILITY MODULO THEORIES APPROACH TO CONSTRAINT PROGRAMMING Josep SUY FRANCH Dipòsit legal: GI. 150-2013 http://hdl.handle.net/10803/98302 A satisfiability modulo theories approach to constraint programming està subjecte a una llicència de Reconeixement 3.0 No adaptada de Creative Commons ©2013, Josep Suy Franch PHDTHESIS A Satisfiability Modulo Theories Approach to Constraint Programming Author: Josep SUY FRANCH 2012 Programa de Doctorat en Tecnologia Advisors: Dr. Miquel BOFILL ARASA Dr. Mateu VILLARET AUSELLE Memoria` presentada per optar al t´ıtol de doctor per la Universitat de Girona Abstract Satisfiability Modulo Theories (SMT) is an active research area mainly focused on for- mal verification of software and hardware. The SMT problem is the problem of deter- mining the satisfiability of ground logical formulas with respect to background theories expressed in classical first-order logic with equality. Examples of theories include linear real or integer arithmetic, arrays, bit vectors, uninterpreted functions, etc., or combina- tions of them. Modern SMT solvers integrate a Boolean satisfiability (SAT) solver with specialized solvers for a set of literals belonging to each theory. On the other hand, Constraint Programming (CP) is a programming paradigm de- voted to solve Constraint Satisfaction Problems (CSP). In a CSP, relations between vari- ables are stated in the form of constraints. Each constraint restricts the combination of values that a set of variables may take simultaneously. The constraints are stated over specific domains, typically: Booleans, integers, rationals, reals, finite domains, or com- binations of them. The problem consists in finding an assignment to the variables that satisfy all constraints. Many CP solving algorithms are based on systematic search, but in the last years there have been many other successful approaches to solve CSPs: SAT, Mixed Integer Linear Programming (MILP), Lazy Clause Generation (Lazy fd), genetic algorithms, tabu search, . In this thesis we focus on solving CSPs using SMT. Essentially, what we do is reformulating CSPs into SMT. There are already promising results in this direction, but there does not exist a generic approach and there are no available tools to extensively explore the adequacy of this approach. We intend to fill this gap with a complete encoding of an standard CP language. We provide extensive performance comparisons between state-of-the-art SMT solvers and most of the available CP solvers on a large collection of problems. The obtained results allow us to conclude that state-of-the-art SMT solvers are a robust tool to solve CSPs. We tackle not only decisional CSPs, but also Constraint Optimization Problems (COP), where the objective is to find a solution that is optimal with respect to some given objective function. We also address the Weighted Constraint Satisfiability Prob- lem (WCSP), where there are constraints with an associated weight (cost) and where the goal is to minimize the sum of the costs of the unsatisfied constraints. For solving COP i ii and WCSP we have used SMT in conjunction with appropriated algorithms: search algo- rithms and UNSAT core based algorithms borrowed from the MaxSAT area. We have developed the fzn2smt system for encoding instances of the MINIZINC standard (CSP and COP) specification language into SMT. With this system we have obtained the golden medal in the par division and the silver medal in the free division of the MINIZINC challenge 2010, and the silver medal in the same divisions of the MINIZINC challenge 2011. We have also developed a new specification language, called Simply, and its ex- tension WSimply, for programming in the three CP paradigms (CSP, COP and WCSP), and a compiler from this language to SMT. WSimply provides support for meta-constraints that is, constraints on constraints. Meta-constraints can be very helpful in the modelling process, since they allow us to abstract to a higher level, expressing, e.g., priorities be- tween a set of soft constraints, different levels of preference (multi-objective optimiza- tion), etc. As far as we know, WSimply is the first declarative CP language allowing to model WCSP instances intensionally and supporting meta-constraints. Once seen that SMT is a very good approximation for CP, we have tried to test whether algorithms built on top of an SMT solver can have equal or better performance than ad hoc programs designed specifically for a given problem, based on other ap- proaches. We concentrate on scheduling problems. Scheduling problems consist in de- ciding how to commit resources and time of execution to a set of activities. They are well suited to SMT because have a strong Boolean component and also an important arith- metic component. To test our approach we have chosen the resource-constrained project scheduling problem (RCPSP), and its generalizations RPCPSP/max and MRCPSP, since this is the most widely studied scheduling problem in the literature. We provide exten- sive performance comparisons between our approach and state-of-the-art RCPSP solvers. We remark that our system outperforms all other approaches described in the literature to solve MRCPSP and it is competitive in RCPSP and RCPSP/max. Resum La Satisfactibilitat Modul` Teories (SMT) es´ una area` de recerca activa centrada principal- ment en la verificacio´ formal de programari i maquinari. Un problema SMT consisteix en determinar la satisfactibilitat de formules´ logiques` sense quantificadors, respecte a teories de fons expressades en logica` classica` de primer ordre amb igualtat. Alguns exemples d’aquestes teories son:´ l’aritmetica` lineal real o entera, les matrius, els vectors de bits, les funcions no interpretades, . , o combinacions d’elles. Els solucionadors SMT moderns integren un solucionador de Satisfactibilitat Booleana (SAT) amb solucionadors especial- itzats per al conjunt de literals que pertanyen a cada teoria. D’altra banda, la Programacio´ amb Restriccions (CP) es´ un paradigma de progra- macio´ dedicat a resoldre els problemes de satisfaccio´ de restriccions (CSP). En un CSP, les relacions entre les variables s’expressen en forma de restriccions. Cada restriccio´ limita la combinacio´ de valors que poden prendre a la vegada un conjunt de variables. Les restriccions s’expressen a traves´ de dominis espec´ıfics com ara: Booleans, enters, racionals, reals, dominis finits, o combinacions d’aquests. Aquest problema consisteix en trobar una assignacio´ a les variables que satisfaci totes les restriccions. Molts algorismes de resolucio´ de CSPs es basen en la cerca sistematica,` tot i que en els ultims´ anys han aparegut molts altres metodes` per resoldre CSPs amb exit:` SAT, Mixed Integer Linear Programming (MILP), Lazy Clause Generation (Lazy fd ), algorismes genetics,` recerca tabu,´ . Aquesta tesi es centra en la resolucio´ de CSPs utilitzant SMT. En esencia,` es re- formulen els CSPs a formules´ SMT. Ja existeixen alguns resultats prometedors en aquest sentit, pero` sense un enfocament generic.` Tampoc existeixen eines disponibles per explo- rar exhaustivament la idone¨ıtat d’aquest enfocament. Es preten omplir aquest buit amb una codificacio´ completa d’un llenguatge estandard` de CP. Tambe´ es proporcionen com- paracions exhaustives de rendiment entre els millors solucionadors actuals d’SMT i la majoria dels solucionadors de CP disponibles en una amplia` col·leccio´ de problemes. Els resultats obtinguts permeten concloure que els millors solucionadors actuals d’SMT son´ una eina solida` per a resoldre CSPs. No nomes´ s’aborden els CSP decisionals, sino´ tambe´ problemes d’optimitzacio´ de restriccions (COP), on l’objectiu es´ trobar una solucio´ que sigui optima` respecte a una iii iv funcio´ objectiu donada. Tambe´ tractem el problema de restriccions de satisfacibilitat amb pesos (WCSP), on hi ha restriccions amb un pes associat (cost) i on l’objectiu es´ minim- itzar la suma dels costos de les restriccions insatisfetes. Per a resoldre COP i WCSP s’ha utilitzat SMT juntament amb els algorismes apropiats: algorismes de cerca i algorismes basats en nuclis d’insatisfactibilitat provinents de l’area` de MaxSAT. S’ha desenvolupat el sistema fzn2smt per a la codificacio´ de les instancies` del llenguatge d’especificacio´ estandard MINIZINC a SMT. Amb aquest sistema s’ha obtingut la medalla d’or en la divisio´ “par” i la medalla de plata en la divisio´ “free” de la MINIZINC Challenge 2010, i la medalla de plata en les mateixes divisions de la MINIZINC Challenge 2011. Tambe´ s’ha desenvolupat un nou llenguatge d’especificacio,´ anomenat Simply, i la seva extensio´ WSimply, per a la programacio´ dels tres paradigmes de CP (CSP, COP i WCSP), i un compilador d’aquests llenguatges a SMT. WSimply dona´ suport a meta- restriccions, es´ a dir, restriccions sobre restriccions. Les meta-restriccions poden ser de gran ajuda en el proces´ de modelatge, ates` que ens permeten abstreure’ns a un nivell superior, per expressar, per exemple, les prioritats entre un conjunt de restriccions amb pes, diferents nivells de preferencia` (optimitzacio´ multiobjectiu), etc. Pel que sabem, WSimply es´ el primer llenguatge declaratiu de CP que permet modelar WCSPs inten- sionalment i alhora donar suport a meta-restriccions. Un cop comprovat que SMT es´ una molt bona aproximacio´ per a CP, s’ha trac- tat de comprovar si els algorismes basats en SMT (amb ajuda d’un solucionador SMT directament o utilitzant-lo com un oracle) poden tenir un rendiment igual o millor que els programes dissenyats espec´ıficament per a un problema donat, desenvolupats so- bre la base d’altres enfocaments. Ens concentrem en els problemes de programacio´ d’activitats (scheduling). Els problemes de programacio´ d’activitats consisteixen en de- cidir com assignar recursos i temps d’execucio´ a un conjunt d’activitats. Aquest prob- lemes s’adapten be´ a SMT ja que tenen una forta component Booleana i tambe´ una compo- nent aritmetica` important. Per comprovar el nostre enfocament s’ha escollit el Problema del Projecte de Programacio´ amb Recursos Limitats (RCPSP), i les seves generalitzacions RPCPSP/max i MRCPSP, ates` que aquest es´ el problema de programacio´ d’activitats mes´ ampliament` estudiat en la literatura.