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

Authors: Paweł Sitek; Jarosław Wikarek
Journal: Scientific Programming
 (2016)

---

## 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.


---

## Body

## 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(
X
,
D
o
m
,
C
s
t
) where X
=
{
X
1
,
X
2
,
…
,
X
m
} represents a set of m decision variables, D
o
m
=
{
D
o
m
1
,
D
o
m
2
,
…
,
D
o
m
m
} represents the set of associated domains (i.e., possible values for decision variables), and C
s
t
=
{
C
s
t
1
,
C
s
t
2
,
…
,
C
s
t
n
} represents a set of n constraints. Constraints fall into several types depending on the number of decision variables in a constraint (unary, binary, and n-ary). A unary constraint is a constraint on a single decision variable (e.g., X
≠
6, Y
<
6). A binary constraint is a constraint over a pair of decision variables (e.g., X
>
Y, X
+
Y
<
8). In general, a n-ary constraint has a scope of size n decision variables [1].Each constraintC
s
t
i 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.Figure 1
The general scheme of the algorithm to solve CSP.In order to overcome this shortcoming, suggestions of integrating the CP/CLP paradigms with other paradigms occurred. Since the areas are similar, constraints and decision variables, the integration usually relates to the paradigm of mathematical programming [5–9].Several scenarios of CP/CLP and MP integration have been reported in the literature [10]:(i)
Double modeling uses both CP and MP models and exchanges information while solving.
(ii)
Search-inference duality views CP and MP methods as special cases of a search/inference duality.
(iii)
Decomposition decomposes problems into a CP part and an MP part using a Benders scheme.In the approach proposed in this paper, the scenario for the integration of both paradigms is supplemented with the authors’ own method of problem transformation [11–13] and the idea of autonomous search [12]. All these components are connected and integrated into the programming hybrid framework (Section 3).The method of problem transformation [11, 13] proposed by authors (Section 3.2) is briefly speaking, the transformation of the search space performed by removing all points and areas in which decision variables cannot occur, thus reducing the size of this space. Transformations are usually performed through changing the problem specification and adding the transformed model (with reduced and transformed decision variables and constraints). The transformation is conducted on the basis of facts, attributes, and constraints. The idea of autonomous search (Section 3.3) is implemented through the transformation method and automatic model generation. The models are generated dynamically using adequate CLP predicates, based on the current set of input facts (data instances), knowledge database (with facts and predicates describing a given problem), and question(s) asked by users. Both the input facts and the questions can change dynamically, which leads to new model generation/formation.The main contribution of this study is the concept and implementation of the hybrid programming framework, which joins the ideas of (i) hybridization in the form of integration of MP and CLP, (ii) presolving in the form of transformation and constraint propagation, and (iii) autonomous search in the form of automatic generation of dedicated models to solve. Additionally, formal models of the scheduling problems for the illustrative examples before and after transformation are included.


## 3. The Concept of Hybrid Programming Framework Using Idea of an Autonomous Search

Based on the experience of hybridization and integration of CP/CLP/MP [5–8, 11, 13], the hybrid programing framework to modeling and solving CSPs and COPs has been proposed.The main assumptions used in the concept and implementation of the hybrid programming framework were as follows:(i)
Integration of CLP and MP environments.
(ii)
Introducing the framework presolving methods in the form of transformation and constraint propagation.
(iii)
Knowledge base, which contains predicates for constraints, questions, methods, tools, and so forth and facts for data instances.
(iv)
Implementation autonomous search in the form of automatic models generation for CSPs and COPs as the MP/MIP/MILP models based on knowledge base (constraints, questions, and data facts).
(v)
The ability to solve MIP/MILP/MP models by internal and external solvers (LINGO [14] or SCIP [15] in this version of framework).
(vi)
Replacing the variable distribution methods (Figure1) through MP methods and algorithms (e.g., branch and bound, cutting plane, relaxation, etc.).
(vii)
Implementation of the framework using the CLP environment (E
C
L
i
P
S
e system [16]).


### 3.1. Architecture of Hybrid Programming Framework

Figure2 shows a context scheme of the framework. The framework communicates with the knowledge database, the user, and the external MP solver(s). The knowledge database, which de facto is a part of the framework, consists of a set of various types of predicates, including those most simple facts. The data instances of a given problem are saved as facts. Relationships between individual facts define the information structure of the problem. Predicates and facts may concern different problems modeled and solved using the framework and for this reason they are identified through the problem index (id_pro). The set of facts can be logically divided into two subsets: the subset of constant facts describing the problem and the subset changing the input facts. A user communicates with the framework by sending an inquiry/question in a suitable format and structure: (1)
Q
u
e
s
t
i
o
n
t
y
p
e
,
p
a
r
a
m
e
t
e
r
s
,
I
D
_
p
r
o
.The question determines what problem will be solved, with what parameters (i.e., which facts will be used), and defines the type of the question (which evaluation criterion will be used). An appropriate dedicated model will be generated depending on the formalization of this question, in particular, on its type.Figure 2
The concept of hybrid programming framework and its environment.Predicates can be logically divided into several groups. Particular groups of predicates (except for facts) that create the knowledge base are shown in Description of the Group Predicates.A simplified functional scheme of the framework is shown in Figure3; Algorithm 1 depicts the underlying/basic scenario of the framework operation, in the form of a pseudocode.Algorithm 1:The basic scenario of the framework operation.
While  new question
Determining the type of the problem (based of questions)
Determining the parameters of the question
Determining the size of the problem (based on facts)
Initiate basic variables
Load data about the problem from set of facts
Basic constraints (load predicates)
while
additional conditions resulting from question
Initiate additional variables
Additional constraints (load predicates)
Starting
constraint propagation
if  transformation of the problem  then
Transformation
Starting
constraint propagation
Determining the type of the MP Solver
Generation of the MP model in the Solver format or MPS
Start SolverFigure 3
The functional diagram of hybrid programming framework.The user’s question initiates the framework operation. The structure of the question in (1) defines the type of the question (general, wh-question, logical, etc.) and type of the problem and its detailed parameters (time, number of resources, size, etc.). Depending on the question, adequate information is extracted about the problem, data instances, problem size, and so forth.Based on this information, the framework downloads suitable facts and predicates from the knowledge database. The facts are converted into lists. The reference model is built in CLP for a CSP or COP (variables and constraints). The model can be supplemented with additional constraints, including logic constraints if necessary. In the next step, the model is subjected to presolving. Two presolving methods are used in the framework, usually alternately: constraint propagation and transformation. After presolving, the model is the basis for generating the final implementation model in the form of an MP model (usually MILP). The MP model is then solved using an MP solver.


### 3.2. Transformation

Transformation has been studied by the authors [11, 13]. It consists in changing the specification of a problem to eliminate unacceptable/nonfeasible points from the solution space prior to solving the problem. As a result, the number of decision variables is reduced and aggregated and the constraints are simplified and also the numbers of constraints is reduced, which leads to a smaller search space and, hence, shorter search time and the possibility to solve problems of larger size within allowable time limits. Facts and problem constraints are used in the process of transformation. Transformation and constraint propagation are presolving methods applied in the framework. In real practical problems, the transformation may involve the removal of unacceptable transportation routes in SCM problems [13] and the change of the problem specification from operational to resource type in task group scheduling [17], and so forth. For the illustration example (Section 4), the transformation relies on the change problem representation through the appropriate aggregation of indices. For allowable values of indices of machines and products, an aggregated implementation index is created, the values of which are determined based on feasible values of base indices ((2a), (2b)). Details of the transformation in terms of indices, decision variables, constraints, and facts for the illustration example are presented in Section 4 and Appendices D.1 and D.2.


### 3.3. Autonomous Search

Autonomous search, as used in the framework, is the narrowing of the search space through the implementation of presolving methods and automatic generation of dedicated implementation models. Both the presolving methods (constraint propagation and transformation) and model generation are based on current data instances. Users’ questions are also taken into account while constructing the model. The questions may be related only to some of the aspects and constraints of the problem. Based on the current data, instances and users’ questions ensure that the automatically generated models are dedicated and fit the specific situation. Such dedicated models have fewer decision variables and constraints.This shortens the search time (the search space is considerably reduced relative to that in universal models). A change of the question and/or data instance results in a new model adjusted to new parameters.


## 3.1. Architecture of Hybrid Programming Framework

Figure2 shows a context scheme of the framework. The framework communicates with the knowledge database, the user, and the external MP solver(s). The knowledge database, which de facto is a part of the framework, consists of a set of various types of predicates, including those most simple facts. The data instances of a given problem are saved as facts. Relationships between individual facts define the information structure of the problem. Predicates and facts may concern different problems modeled and solved using the framework and for this reason they are identified through the problem index (id_pro). The set of facts can be logically divided into two subsets: the subset of constant facts describing the problem and the subset changing the input facts. A user communicates with the framework by sending an inquiry/question in a suitable format and structure: (1)
Q
u
e
s
t
i
o
n
t
y
p
e
,
p
a
r
a
m
e
t
e
r
s
,
I
D
_
p
r
o
.The question determines what problem will be solved, with what parameters (i.e., which facts will be used), and defines the type of the question (which evaluation criterion will be used). An appropriate dedicated model will be generated depending on the formalization of this question, in particular, on its type.Figure 2
The concept of hybrid programming framework and its environment.Predicates can be logically divided into several groups. Particular groups of predicates (except for facts) that create the knowledge base are shown in Description of the Group Predicates.A simplified functional scheme of the framework is shown in Figure3; Algorithm 1 depicts the underlying/basic scenario of the framework operation, in the form of a pseudocode.Algorithm 1:The basic scenario of the framework operation.
While  new question
Determining the type of the problem (based of questions)
Determining the parameters of the question
Determining the size of the problem (based on facts)
Initiate basic variables
Load data about the problem from set of facts
Basic constraints (load predicates)
while
additional conditions resulting from question
Initiate additional variables
Additional constraints (load predicates)
Starting
constraint propagation
if  transformation of the problem  then
Transformation
Starting
constraint propagation
Determining the type of the MP Solver
Generation of the MP model in the Solver format or MPS
Start SolverFigure 3
The functional diagram of hybrid programming framework.The user’s question initiates the framework operation. The structure of the question in (1) defines the type of the question (general, wh-question, logical, etc.) and type of the problem and its detailed parameters (time, number of resources, size, etc.). Depending on the question, adequate information is extracted about the problem, data instances, problem size, and so forth.Based on this information, the framework downloads suitable facts and predicates from the knowledge database. The facts are converted into lists. The reference model is built in CLP for a CSP or COP (variables and constraints). The model can be supplemented with additional constraints, including logic constraints if necessary. In the next step, the model is subjected to presolving. Two presolving methods are used in the framework, usually alternately: constraint propagation and transformation. After presolving, the model is the basis for generating the final implementation model in the form of an MP model (usually MILP). The MP model is then solved using an MP solver.


## 3.2. Transformation

Transformation has been studied by the authors [11, 13]. It consists in changing the specification of a problem to eliminate unacceptable/nonfeasible points from the solution space prior to solving the problem. As a result, the number of decision variables is reduced and aggregated and the constraints are simplified and also the numbers of constraints is reduced, which leads to a smaller search space and, hence, shorter search time and the possibility to solve problems of larger size within allowable time limits. Facts and problem constraints are used in the process of transformation. Transformation and constraint propagation are presolving methods applied in the framework. In real practical problems, the transformation may involve the removal of unacceptable transportation routes in SCM problems [13] and the change of the problem specification from operational to resource type in task group scheduling [17], and so forth. For the illustration example (Section 4), the transformation relies on the change problem representation through the appropriate aggregation of indices. For allowable values of indices of machines and products, an aggregated implementation index is created, the values of which are determined based on feasible values of base indices ((2a), (2b)). Details of the transformation in terms of indices, decision variables, constraints, and facts for the illustration example are presented in Section 4 and Appendices D.1 and D.2.


## 3.3. Autonomous Search

Autonomous search, as used in the framework, is the narrowing of the search space through the implementation of presolving methods and automatic generation of dedicated implementation models. Both the presolving methods (constraint propagation and transformation) and model generation are based on current data instances. Users’ questions are also taken into account while constructing the model. The questions may be related only to some of the aspects and constraints of the problem. Based on the current data, instances and users’ questions ensure that the automatically generated models are dedicated and fit the specific situation. Such dedicated models have fewer decision variables and constraints.This shortens the search time (the search space is considerably reduced relative to that in universal models). A change of the question and/or data instance results in a new model adjusted to new parameters.


## 4. Illustrative Example and Computational Experiments

Practical use of framework for modeling and solving problems will be presented for illustrative example. As an illustrative example was selected job-shop scheduling problem with additional resources [18, 19]. Problems of this type can be found in manufacturing, logistics, computer networks, software engineering, and so forth.Formally, the illustrative example is an extension variant of job-shop scheduling problem and can be defined as follows. A set ofL
I jobs/orders/products I
=
{
I
1
,
I
2
,
…
,
I
L
I
} are given which require, for their processing, a set of L
M machines M
=
{
M
1
,
M
2
,
…
,
M
L
M
} and a set of L
R additional resources R
=
{
R
1
,
R
2
,
…
,
R
L
R
}. Each additional resource R
r has a specified limit k
o
r (number of units of the resource R
k). Each job/order I
l is a sequence of k operations. The kth operation of job/order I
i has to be executed by a specific machine M
k
∈
M for time units (t
r
i
,
k is integer). Generally, in job-shop problems, a feasible schedule is such that (a) at any time each machine can execute at most one operation, (b) the operations of the same job/order are totally ordered, and (c) no preemption is allowed. Moreover, in our example, any time, each operation can be assisted by additional resources R
r where d
i
,
m
,
r determines how much additional resources R
r are used to execute job/order I
i on machine M
k
∈
M. Additional resources can be operators, tools, memory, transportation units, and so forth while basic resources are the machines/processors/workstations. A formal model of a scheduling problem for illustrative example, containing constraints, decision variables, and parameters, is shown in Appendix D.1. The collection of facts together with their structure for this model is included in Figure 4 (as the lowest layer of the information structure).Figure 4
The information structure for illustrative example implemented in hybrid programming framework.Both the proposed model and the structure of facts constitute a significant extension of the classical job-shop scheduling problem (JSSP) [18, 19]. Firstly, they allow accounting for additional resources R, as described above. Secondly, the structure of constraints of the model, decision variables, and facts is universal and can describe not only job-shop scheduling problems but also those in other environments including flow-shop, open-shop, project, multiproject, and so forth.Modeling starts with loading the set of facts for illustrative example to the knowledge base. Then, the facts are converted into lists using a general predicate (P1). In the next step, the set of predicates (P2) is created. This set implements the basic and additional/logic constraints for illustrative example. Then, the built or expanded set of predicates (P3) implements various types of questions (e.g., as in the exemplified questions asked to the illustrative example) for illustrative example. In the next step, predicates to transform modeled problem (P4) are taken from the knowledge base. Transformation for illustrative example involves the aggregation of the relevant facts (indexes of these facts) and building a list of only the feasible combinations of facts. The principle of the transformation of the facts for illustrative example is shown in Figure5.Figure 5
The principle of the transformation of the facts for illustrative example.Exemplified questions asked to the illustrative example are as follows(Q1)
What is the minC
m
a
x (makespan)?
(Q
2
A)
What is the minC
m
a
x if the set of additional resources is k
o
1
=
k
o
2
=
k
o
3
=
k
o
4
=
2?
(Q
2
B)
What is the minC
m
a
x if the set of additional resources is k
o
1
=
k
o
2
=
k
o
3
=
k
o
4
=
3?
(Q3)
What is the minimum set of resourcesR
1 at C
m
a
x
′?
(Q4)
Is it possible to schedule orders inC
m
a
x
′ and what are the sets of resources R
1
,
R
2
,
R
3
,
R
4?
(Q5)
Is it possible to schedule orders inC
m
a
x
′ if resources R
1 and R
4 cannot be used simultaneously?
(Q6)
Is it possible to schedule orders inC
m
a
x
′ if machines M
7 and M
9 cannot be used simultaneously?
(Q7)
What is the minC
m
a
x if resources R
1 and R
4 cannot be used simultaneously?
(Q
8
A)
What is the minC
m
a
x if machines M
1 and M
2 cannot be used simultaneously?
(Q
8
B)
What is the minC
m
a
x if machines M
7 and M
9 cannot be used simultaneously?The resulting list L_index for facts from AppendixB.1 are presented in the Appendix B.2. Indices (the dimensions of the problem), decision variables, and constraints of the model are also subject to transformation. The transformation of indices (2a) stems from the fact that not every product i has to be manufactured on every machine m. Thus, if product i is made on a specific machine m, the existing values of index pair (
i
,
m
) are replaced with the values of aggregated/transformed index z. In the next step, the decision variables are subjected to transformation as a result of the aggregation of some of their indexes (2b). The set of all decision variables of the model before and after transformation are presented in Appendices D.1 and D.2, respectively. In the final stage, the constraints of the model transformed through the change (reduction) of summations and “for” phrase for the individual constraints. The constraints for model before and after the transformation are included in Appendices D.1 and D.2, respectively: (2a)
i
,
m
⟶
z
(2b)
X
i
,
m
,
r
,
t
⟶
X
z
,
r
,
t
∣
K
p
i
,
m
⟶
K
p
z
∣
Y
i
,
m
,
r
,
t
⟶
Y
z
,
r
,
t
.The final step is the generation of a dedicated MILP model (files in the appropriate solver format or Mathematical Programming System (MPS)) using universal set of predicates for automatic generation (P5). Schematic structure of information for illustrative example in the form of facts, lists, and files is shown in Figure 4 and the description is shown in Table 3.The scenario of computational experiments was as follows. For any questions from the exemplified questions asked to the illustrative example and a given set of data instances (AppendixB.1), the generation of dedicated MILP models have been made using a hybrid programming framework. After that, the automatically generated models were solved using the external MP solvers like “LINGO” [14] or “SCIP” [15]. Choosing solver “SCIP” was due to its high efficiency and the use of the built-in powerful presolving methods [15]. As for the efficiency and effectiveness in the area of MP and CP, SCIP is the best option of all noncommercial solvers [15]. CPLEX and Gurobi are certainly faster in solving the same benchmarks, but being commercial solvers, they mean higher costs (licenses, etc.).Obtained results are shown in Table1. The scope of the exemplified questions asked to the illustrative example shows the flexibility and capabilities of a hybrid programming framework. These are general questions (Q4, Q5, and Q6) and specified questions (Q1, Q
2
A, Q
2
B, and Q3), which require both optimal and feasible solutions. In addition, questions can be logical (Q7, Q8), whose modeling directly in an MP environment is not obvious and simple. To determine the effectiveness of the proposed framework for questions Q1, Q
2
A, and Q
2
B (for the most demanding computing), models were generated using the framework (Table 1) and modeled using only the classical mathematical programming (Table 2). Then, both groups of models were solved using LINGO and SCIP solvers. The answers to these questions using the framework are obtained 10 to 20 times faster than using just the pure MP solvers. In each case, the use of “SCIP” solver accelerated calculations twofold in comparison with the “LINGO” solver, with the “LINGO” solver (see columns T
1 and T
2 of Tables 1 and 2).Table 1
Results for asked questions to the illustrative example (framework implementation).
Questions
V
C
Parameters
Answer
T
1
T
2
Q1
3070
16377
—
min
⁡
C
m
a
x
=
22
7
6
Q
2
A
3070
16377
ko1 = ko2 = ko3 = ko4 = 2
min
⁡
C
m
a
x
=
26
316
146
Q
2
B
3070
16377
ko1 = ko2 = ko3 = ko4 = 3
min
⁡
C
m
a
x
=
22
60
28
Q3
3070
16377
C
m
a
x
′
=
24
k
o
1
m
i
n
=
2,
2
2
Q4
3270
16678
C
m
a
x
′
=
24
Yes ko1 = 3, ko2 = 4, ko3 = 4, ko4 = 2
2
2
C
m
a
x
′
=
20
No
1
1
C
m
a
x
′
=
23
Yes ko1 = 4, ko2 = 4, ko3 = 3, ko4 = 2
2
1
Q5
3266
16623
C
m
a
x
′
=
24
NO
2
2
C
m
a
x
′
=
30
YES
12
6
Q6
3560
16917
C
m
a
x
′
=
24
NO
3
2
C
m
a
x
′
=
26
YES
6
2
Q7
3266
16623
min
⁡
C
m
a
x
=
27
16
8
Q
8
A
3560
16917
min
⁡
C
m
a
x
=
22
6
5
Q
8
B
3560
16917
min
⁡
C
m
a
x
=
26
4
3Table 2
Results for asked questions to the illustrative example (MP implementation).
Questions
V
C
Parameters
Answer
T
1
T
2
Q1
70604
75343
—
C
m
a
x
=
22
128
67
Q
2
A
70604
75343
ko1 = ko2 = ko3 = ko4 = 2
C
m
a
x
=
26
3756
1546
Q
2
B
70604
75343
ko1 = ko2 = ko3 = ko4 = 3
C
m
a
x
=
22
546
234
min
⁡
C
m
a
x: optimal makespan.
C
m
a
x
′: given makespan.
V: the number of decision variables.
C: the number of constraints.
T
1: time of finding solution (in seconds) in LINGO.
T
2: time of finding solution (in seconds) in SCIP.Table 3
Description of the facts, lists, and parameters for the illustrative example.
Facts
Keys
Parameters
Facts about structure of the problem
F_product(#id_pro, #id_wer, #i)
#id_pro: problem ID#id_wer: version of the data instances#i: product ID
F_machine(#id_pro, #id_wer, #m)
#id_pro: problem ID#id_wer: version of the data instances #m: machine ID
F_technology(#id_pro, #id_wer, #i, #m, parameters)
#id_pro: problem ID#id_wer: version of the data instances#i: product ID #m: machine ID
t
r
i
,
m: the execution time of the product i on the machine m
F_precedence(#id_pro, #id_we, #i, #m, #m)
#id_pro: problem ID#id_wer: version of the data instances#i: product ID #m: machine ID
F_resources(#id_pro, #id_we, #r, parameters)
#id_pro: problem ID#id_wer: version of the data instances#r: additional resource ID
k
o
r: the total number of additional resources r
F_allocation(#id_pro, #id_we, #r, #m, #i, parameters)
#id_pro: problem ID#id_wer: version of the data instances#r: additional resource ID#m: machine ID#i: product ID
d
i
,
m
,
r: the number of additional resources r needed to execute a product i on the machine m
F_model(#id_pro, #id_wer, #n
r, parameters)
#id_pro: problem ID#id_wer: version of the data instances#n
r: model ID
l
i
n
e
n
r: line of code for model ID
F_order(#id_pro, #id_we, #i, parameters)
#id_pro: problem ID#id_wer: version of the data instances#i: product ID
o
r
i: the size of the order for product i
Lists
L_precedence(#i, #m, #m)
#m: machine ID #i: product ID
L_technology(#i, #m, parameters)
#i: product ID#m: machine ID
t
r
i
,
m: the execution time of the product i on the machine m; w
i
,
m: if the product i is executed on the machine m,  w
i
,
m = 1; otherwise, w
i
,
m = 0; o
r
i: the size of the order for product i
L_allocation(#r, #m, #i, parameters)
#r: additional resource ID#m: machine ID#i: product ID
d
i
,
m
,
r: the number of additional resources r needed to execute a product i on the machine m; k
o
r: the total number of additional resources r
L_model(#n
r, parameters)
#n
r: model ID
l
i
n
e
n
r: line of code for model ID
L_index_z (#i, #m, parameters)
#i: product ID#m: machine ID
z: the new index after transformation
L_data_t (#z, parameters)
#z: the new index after transformation (combination of #i and #m)
t
r
z: the execution time of the product i on the machine m; w
z: if the product i is executed on the machine, w
z
=
1; otherwise, w
z
=
0; o
r
z: the size of the order for product i
L_precedence_t (#z, #z)
#z: the new index after transformation (combination of #i and #m)The models generated using the framework, respectively, have 20 times smaller number of decision variables and 3 times smaller number of constraints in relation to the models created only in MP environments.The model file for Q1 questions in a format compatible with the “LINGO” is shown in AppendixC.The file was generated by group predicates P5 on the basis of the information structure (Figure5).


## 5. Conclusions

The proposed hybrid framework can be used in two modes. Firstly, it can be a platform for the end user to solve the COP and the CSP, which are generated and solved on the basis of existing knowledge base, but also the questions asked by the user. Secondly, it is a programming framework for modeling and solving the COP and the CSP. In this case, the user must know the environment CLP. For each new problem, users supplement the knowledge base of relevant predicates in P2 and P3 sets (see Description of the Group Predicates).The concept of hybrid programming framework that combines (a) two programming paradigms (CLP/MP); (b) the presolving methods (transformation and constraint propagation); (c) autonomous search; and (d) the automatic generation of dedicated implementation models is the flexible and efficiency solution. Flexibility and easiness of modeling problems are caused by CLP-based approach which by nature is declarative. Efficiency is the result of applying the presolving methods, dedicated implementation models, and mathematical programming for solving. The idea of autonomous search is implemented mainly through the mechanism of automatic generation of implementation models based on current data instances and the requirements of users (in the form of frequently asked questions) which means that models are better suited to current requirements and conditions and their solution requires less space search. The knowledge base of the framework, which is built from predicates and facts, provides scalability because knowledge base can be updated with new facts relating to existing models, predicates, and facts of new models and the facts resulting in answers to user questions and so on.Further research will focus on two directions/areas. The first is to use a framework for modeling and solving other problems in the area of widely understood computer science. The second is the integration framework with other paradigms such as fuzzy logic and concurrent programming.A new remotely accessible (e.g., in the cloud [20]) version of the framework is going to be developed. For licensing reasons, LINGO solver will be replaced by SCIP in this version.



---

*Source: 5102616-2016-08-03.xml*