Download PDF

Functional Programming Abstractions for CP Modeling (CP modellering met functionele abstracties)

Publication date: 2011-12-06

Author:

Wuille, Pieter
Demoen, Bart ; Schrijvers, Tom

Abstract:

The field of Constraint Programming (CP) provides problem-independent technology for solving combinatorial problems.The programmer describes his problem in a model, which is processed by a problem-independent solver to produce a solution. Solver implementations arean active topic of research, and many efficient solvers exist. Specific languages werecreated that provide CP modeling facilities, but these domain-specificlanguages (DSL) run behind on features and abstractions, compared to modern general purpose languages. On the other hand, using CPlibraries in such a language requires boilerplate code, and is often farless declarative in nature.Functional Programming (FP) is a programming paradigm that is based on the concept of functionsas they are defined in mathematics, i.e., without side effects beyond their return value. Functionallanguages are declarative, offer very high level abstractions, and are easy to analyze. Furthermore,they can be used for general purposes.The existing Monadic Constraint Programming (MCP) framework offers interesting high-level abstractions forCP in thestate-of-the-art functional programming language Haskell. In the first part of this thesis, we study how to build upon it to create a practical, concise, and declarative modeling DSL for constraint problems.Our language allows Finite Domain (FD) problems to be written using high-level expressions, whilethe underlying framework performs optimized translation to specific solver back-ends. Implementedback-ends include a proof-of-concept solver in Haskell, and bindings to the constraint solvinglibrary Gecode. For solving with low overhead, an extra mode is provided that generates C++ codefor performing the solving at a later stage.In the second part, we provide declarative modeling of search. Controlling the search heuristicemployed by a constraint solver is often essential for good performance, but existing systems areeither limited in possibilities or imperative in nature. Again, we choose to provide a DSL todo better. The Search Combinators language is declarative, concise and captures many advanced search heuristics.We implement an efficient code generator for these search heuristics, avoiding the pitfalls encountered.