Constraint logic programming emerged in the late 80's as a highly declarative class of programming languages based on first-order logic and theories with decidable constraint languages, thereby subsuming Prolog restricted to equality constraints over the Herbrand's term domain. This approach has proven extremely successfull in solving combinatorial problems in the industry which quickly led to the development of a variety of constraint solving libraries in standard programming languages. Later came the design of a purely declarative front-end constraint-based modeling language, MiniZinc, independent of the constraint solvers, in order to compare their performances and create model benchmarks. Beyond that purpose, the use of a high-level modeling language such as MiniZinc to develop complete applications, or to teach constraint programming, is limited by the impossibility to program search strategies, or new constraint solvers, in a modeling language, as well as by the absence of an integrated development environment for both levels of constraint-based modeling and constraint solving. In this paper, we propose to solve those issues by taking Prolog with its constraint solving libraries, as a unified relation-based modeling and programming language. We present a Prolog library for high-level constraint-based mathematical modeling, inspired by MiniZinc, using subscripted variables (arrays) in addition to lists and terms, quantifiers and iterators in addition to recursion, together with a patch of constraint libraries in order to allow array functional notations in constraints. We show that this approach does not come with a significant computation time overhead, and presents several advantages in terms of the possibility of focussing on mathematical modeling, getting answer constraints in addition to ground solutions, programming search or constraint solvers if needed, and debugging models within a unique modeling and programming environment.
翻译:约束逻辑编程兴起于20世纪80年代末,作为一类基于一阶逻辑与可判定约束语言理论的高度声明式编程语言,其将Prolog限制于Herbrand项域上的等式约束。该方法在工业界解决组合优化问题方面取得了显著成功,迅速催生了标准编程语言中多种约束求解库的开发。随后,独立于约束求解器的纯声明式前端约束建模语言MiniZinc被设计出来,用于比较不同求解器的性能并创建模型基准。然而,MiniZinc这类高级建模语言在开发完整应用或教学约束编程时存在局限性——无法在建模语言中编程搜索策略或实现新型约束求解器,且缺乏同时支持约束建模与约束求解的集成开发环境。本文提出通过将Prolog及其约束求解库作为统一的基于关系的建模与编程语言来解决上述问题。我们受MiniZinc启发,开发了一个用于高级约束数学建模的Prolog库:该库在列表和项的基础上引入下标变量(数组),在递归的基础上引入量词与迭代器,同时修补约束库以支持约束中的数组函数式记法。实验表明,该方法不仅未引入显著的计算时间开销,还具备以下优势:聚焦数学建模的能力、除基解外获取答案约束的能力、按需编程搜索策略或约束求解器的能力,以及在统一建模与编程环境中调试模型的能力。