Scientific Programming

Volume 2016, Article ID 5102616, 13 pages

http://dx.doi.org/10.1155/2016/5102616

## A Hybrid Programming Framework for Modeling and Solving Constraint Satisfaction and Optimization Problems

Department of Information Systems, Kielce University of Technology, 25-314 Kielce, Poland

Received 2 February 2016; Revised 25 May 2016; Accepted 21 June 2016

Academic Editor: Can Özturan

Copyright © 2016 Paweł Sitek and Jarosław Wikarek. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

#### Abstract

This paper proposes a hybrid programming framework for modeling and solving of constraint satisfaction problems (CSPs) and constraint optimization problems (COPs). Two paradigms, CLP (constraint logic programming) and MP (mathematical programming), are integrated in the framework. The integration is supplemented with the original method of problem transformation, used in the framework as a presolving method. The transformation substantially reduces the feasible solution space. The framework automatically generates CSP and COP models based on current values of data instances, questions asked by a user, and set of predicates and facts of the problem being modeled, which altogether constitute a knowledge database for the given problem. This dynamic generation of dedicated models, based on the knowledge base, together with the parameters changing externally, for example, the user’s questions, is the implementation of the autonomous search concept. The models are solved using the internal or external solvers integrated with the framework. The architecture of the framework as well as its implementation outline is also included in the paper. The effectiveness of the framework regarding the modeling and solution search is assessed through the illustrative examples relating to scheduling problems with additional constrained resources.

#### 1. Introduction

Constraint satisfaction problems (CSPs) and/or constraint optimization problems (COPs) can involve the variables that take values over finite domains (integer, real, binary, etc.) and constraints of all types and characters [1]. By connecting variables, constraints affect the feasible variable domain ranges. Modeling and solving of those problems make up one of the major interest areas of various computer science communities, including operation research, mathematical programming, constraint programming, and artificial intelligence. Problems with constraints like CSP and COP are frequent in production, distribution, transportation, logistics, computer networks, software engineering, project management, planning and scheduling, and so forth. One of the features resulting from the users’ changeable expectations is the need to solve the problem multiple times for variable data instances and parameters. Users express their expectations by asking all kinds of questions. On the one hand, the question is related to the possibility of realizing the task with certain resources at the defined time; on the other hand, it concerns optimal parameters of task realization, and it is about the optimal configuration of the system. Quite often, the questions include logical conditions (e.g., relating to mutual exclusion, dynamic connecting of resources). Because of the changeability of the questions, parameters, and data instances, the idea of autonomous search seems to be the most suitable for solving the problems with constraints. The autonomous search should have the ability to preferably modify and change its internal components when exposed to changing external parameters, requirements, and/or data instances [2].

The underlying motivation for this study was the idea of developing a programming and implementation platform, which would allow effective modeling and solving of CSPs and COPs and solving these problems in an automatic mode (using the autonomous search) despite changes in data instances, parameters, and questions asked by users. The idea was implemented as a hybrid programming framework. To build the framework, the authors used hybridization of various programming paradigms and their own original method of transformation. In addition, the authors proposed a dynamic method for generating dedicated models, based on the knowledge database made up of facts, predicates, and questions asked by users.

#### 2. Backgrounds, Methods, and Structures

Models for problems with constraints need environments that allow modeling and solving the constraints in an easy and effective way. Historically, operations research, in particular, mathematical programming, network programming, and dynamic programming, and so forth, has been used for this purpose. Numerous models (MIP-mixed integer programming, MILP-mixed integer linear programming, IP-integer programming, etc.), algorithms (branch and bound, symplex, branch and cost, etc.), and good practices have been developed to facilitate solving problems with constraints [3]. All these methods and models, however, have some limitations concerning the character of constraints (e.g., only linear constraints) or the character of variables (e.g., only real variables), and so forth. For different types of constraints (nonlinear, logical, etc.) and/or decision variables (integer, binary, etc.), they were either inapplicable or ineffective. For the approach to be most universal and suitable, a given problem must be looked at from the perspective of variables and connecting constraints with the domains of variables taken into account. Constraint logic programming (CLP) paradigm allows this approach. Constraint logic programming (CLP) is a form of constraint programming (CP) paradigm, where logic programming is extended to include CSP (constraint satisfaction problem). CLP programs are built from valid Prolog-based logic data structures. A program is a collection of predicates, and a predicate is a collection of clauses. The idea of a clause is to define that something is true. The simplest form of a clause is the fact. For example, the following two are facts: technology (product, machine, and execution_time) and vehicle (capacity, type, and cost). Syntactically, a fact is just a structure (or an atom) terminated by a full stop [4].

CSP is a triple where represents a set of decision variables, represents the set of associated domains (i.e., possible values for decision variables), and represents a set of constraints. Constraints fall into several types depending on the number of decision variables in a constraint (unary, binary, and -ary). A unary constraint is a constraint on a single decision variable (e.g., , ). A binary constraint is a constraint over a pair of decision variables (e.g., , ). In general, a -ary constraint has a scope of size decision variables [1].

Each constraint binds a set of decision variables and is used to restrict domains of these variables. Solving a CSP means finding the state/condition of a problem, in which the assignment of decision variables satisfies all constraints. The general algorithm for solving a CSP is shown in Figure 1. The algorithm consists of constraint propagation and variable distribution activated in the sequence. If this sequence does not provide a result, backtracking is used and sequence activation is repeated. The algorithm is very effective for solving the problems, in which aryness of constraints does not exceed 2. The CSP algorithm is often ineffective in the case of the problems in which constraints connect more than two decision variables and the optimization problems with constraints (COPs). The effectiveness of propagation is reduced significantly and the number of backtrackings increases. In extreme cases, the algorithm is able to neither find any feasible solution within the allowable time nor ascertain its absence.