You are on page 1of 10

Quadratic programming and Genetic

algorithms for solving the Binary Constraint


Satisfaction Problems
Mohamed ETTAOUIL, Khalid HADDOUCH and Chakir LOQMAN
Abstract In this paper, we propose a new approach to solve the binary CSP problem using two methods, a quadratic programming (QP)
and genetic algorithms (GA). This approach is divided into two steps: The first step involves filtering and modeling the constraint satisfaction
problem as 0-1 quadratic programming subject to linear constraints. The second step concerns applying the genetic algorithms to solve the
QP problem. Therefore, the proposed algorithm based on the genetic algorithms and the model of CSP problem is well detailed. We show
that the process of resolution is explained by an example of application. Finally, some computational experiments solving the CSP problem
are shown.
Index Terms Constraint satisfaction problem; Consisstancy techniques, Quadratic 0-1 programming; Genetic algorithms.



1 INTRODUCTION
large number of problems in artificial intelligence and
other areas of computer science can be viewed as spe-
cial cases of the constraint satisfaction problem. Some
examples include machine vision, scheduling, temporal
reasoning, graph problems and aircraft conflict [13], [18],
[21], [4]. A constraint satisfaction problem is defined by a
set of variables, a finite and discrete domain for each
variable and a set of constraints. Each constraint restricts
the combination of values that a set of variables may take
simultaneously. Solving the CSP problem requires assign-
ing a value for each variable from each domain in such a
way that all constraints are satisfied. The task is to find
one solution or all solutions. However, a CSP problem
has often a high complexity [14], requiring a combination
of heuristics and combinatorial search methods in order
to solve it in a reasonable time.
Formally speaking, a constraint satisfaction problem is
one of the most difficult and interesting problems for
mathematicians, operational researchers and computa-
tional scientists. Thus, several approaches have been de-
veloped to solve this problem. Some of them use back-
tracking to directly search for possible solutions [7]. Oth-
ers use consistency techniques to simplify the original
problem [2], [3], [22], [24]. Some are a combination of
these two techniques [1], [17]. Moreover, we proposed
different approaches to solve the CSP problem. The first
one consists of modelling a constraint satisfaction prob-
lem as 0-1 quadratic knapsack problem subject to qua-
dratic constraint [9], [10]. The second one is a new model
of the binary CSP problem as 0-1 quadratic programming
which consists of minimizing the quadratic function sub-
ject to linear constraints (QP) [11]. To solve this new mod-
el, many different methods are tried and tested such as
interior point, semi-definite relaxations and lagrangian
relaxations [28]. In this paper, we introduce the genetic
algorithm to solve the QP problem.
Genetic algorithms (GAs) are part of evolutionary
computing, which is a rapidly growing area of artificial
intelligence. These algorithms were invented by John
Holland and developed by him and his students and
colleagues [16]. GAs have been used in science and engi-
neering as adaptive algorithms for solving practical prob-
lems and as computational models of natural evolutio-
nary systems [8], [5], [12]. In order to use the GAs for
solving the problem of science and engineering, we
should define the following six principal elements: En-
coding solution (individual) of the population, generation
of the initial population, function of adaptation or fitness,
mechanism for selection, diversification of population
and sizing parameters. These definitions and representa-
tions are based on specific criteria of the addressed prob-
lem. These Algorithms start with a set of solutions (chro-
mosomes) called population. Solutions from one popula-
tion are used to form a new population. This is motivated
by a hope, that the new population will be better than the
old one. Solutions which are selected to form new solu-
tions according to their fitness. Then, the more suitable
solutions are the more chances to be reproduced.
In this paper, our main objective is to propose a new
approach for solving the constraint satisfaction problems
which combine two techniques: the quadratic program-
A

- Mohamed ETTAOUIL UFR: Scientific Computing and Computer sciences,
Engineering sciences, Modelling and Scientific Computing Laboratory,
Faculty of Science and Technology. University Sidi Mohamed Ben Abdel-
lah, Box 2202, Fez, Morocco.
- Khalid HADDOUCH UFR: Scientific Computing and Computer sciences,
Engineering sciences, Modelling and Scientific Computing Laboratory,
Faculty of Science and Technology. University Sidi Mohamed Ben Abdel-
lah, Box 2202, Fez, Morocco.
- LOQMAN Chakir: of Computer Engineering, High School of technology,
Moulay Ismail University, B. P. 3103, 50000, Toulal, Meknes, Morocco.

JOURNAL OF COMPUTING, VOLUME 4, ISSUE 4, APRIL 2012, ISSN 2151-9617
https://sites.google.com/site/journalofcomputing
WWW.JOURNALOFCOMPUTING.ORG 43


ming and the genetic algorithms. This paper is organized
as follows: In section 2, the arc-consistency technique for
filtering the CSP problem is described and the model of
the binary CSP problem is studied. In section 3, an intro-
duction to GAs is presented. In section 4, the six principal
elements of the genetic algorithms associated to the CSP
problem are defined. The proposed algorithm for solving
CSP problem is proposed and detailed in section 5. In the
last section, the implementation details of the proposed
approach and experimental results are presented.
2 FILTERING AND MODELLING THE CSP
PROBLEM
In general, the constraint satisfaction problem is defined
by a set of variables and a set of constraints [21]. The va-
riables should be instantiated from a discrete domain
while making sure the constraints are satisfied. In This
work, we focus on the binary constraint satisfaction prob-
lem i.e., the CSP with constraints of arity less than or
equal to 2, and each constraint
k
C between the variables
i
y and
j
y is defined by its binary relation
k
R . In fact, a
constraint satisfaction problem is defined by a quadruple
sets ( , , , ) where:
- { }
1
= ,......,
n
y y is a set of n variables,
- { }
1
= ( ),....., ( )
n
D y D y where each ( )
i
D y is a set
of
i
d possible values for
i
y ,
- { }
1
= ,......,
m
C C is a set of m constraints which
restricts the values that the variables can simul-
taneously take.
- { }
1
= ,......,
m
R R is a set of m relationship which
defines the constraint between two variables.
The solution of constraint satisfaction problem requires
assigning each variable a value from its domain satisfying
all constraints. Several methods are used to solve this
problem [18]. In order to use the genetic algorithms for
solving the constraint satisfaction problem, we opte to use
the mathematical model which consists of modeling the
CSP problem as a 0-1 quadratic programming. This mod-
el facilitates the definitions of the six principal elements of
the genetic algorithms. Moreover, before modeling the
CSP problem, we can use the arc consistency technique in
order to reduce the size of CSP problem; thus, reduce the
size of individuals and accelerate the process of resolu-
tion.

2.1 Consistency Techniques
In general, the binary constraint satisfaction problem is
represented as an undirected graph with the vertices
corresponding to the variables and the edges correspond-
ing to the constraints. Hence, the related consistency con-
cepts are named using terminology borrowed from graph
theory. As we know, the binary CSP problem has only
two types of constraints: unary constraints and binary
constraints. The simplest degree of consistency that can
be enforced on a CSP problem is node consistency which
concerns only the unary constraints. However, a stronger
degree of consistency is arc consistency. The latter con-
cerns the binary constraints in a CSP problem and guar-
antees that each value admits at least a support in each
constraint. Many algorithms have been proposed to estab-
lish arc consistency such as (AC1,AC2, ...,AC2000,AC3.1)
[24], [3], [22], [2].

Definition 1
Let
ij
C be a binary constraint between two variables
i
y and
j
y
, with two domains ( )
i
D y and ( )
j
D y . We call
ij
C arc
consistent if
- ( ), ( )
i j
a D y b D y e - e such that ( , ) a b satisfies the
constraint
ij
C ,
- ( ), ( )
j i
b D y a D y e - e such that ( , ) a b satisfies
the constraint
ij
C .
We call a CSP problem arc consistent if all its binary
constraints are arc consistent.

The description of the arc consistency AC3 technique
which is used in this work is the following [19]: Initially,
all arcs ( , )
ij i
C y are put in a set named K. Then, each arc
is revised in turn, and when the revision is effective (at
least one value has been removed), the set K has to be
updated. This revision removes values of ( )
i
D y that have
become inconsistent with respect to constraint
ij
C [19].
The algorithm is stopped when the set K becomes empty.
Therefore, the property of consistency is forced for CSP
problem.
In this paper, The arc consistency algorithm plays an
important role for solving the constraint satisfaction prob-
lem. This consistency technique does not remove all in-
consistent values from domains, but it can still eliminate
many obvious inconsistencies; thus, simplifies the
model of the CSP problem. Each value of the domain is
associated with a variable of decision. Therefore, if any
inconsistent value from domains of each variables is de-
leted, the represented binary variable must be eliminated
from the proposed model and, thus reduces the size of
this model. Finally, this filtering reduce the size of indi-
viduals constructing the population.

2.2 Constraint quadratic programming for solving
constraint satisfaction problem
The constraint satisfaction problem has been recognized
as an efficient model for solving many combinatorial and
complex problems. This problem is formulated as 0-1
quadratic knapsack problem subject to quadratic con-
straint [9]. A branch-and-bound algorithm for solving this
model is proposed, based on solving semidefinite relaxa-
tion [10]. It is well known that this algorithm uses two
bounds, a lower and upper bound, for pruning the search
space. At each node, a lower bound is given by semidefi-
nite relaxation, and an upper bound is computed by satis-
fying the quadratic constraint [10]. On the other hand, we
JOURNAL OF COMPUTING, VOLUME 4, ISSUE 4, APRIL 2012, ISSN 2151-9617
https://sites.google.com/site/journalofcomputing
WWW.JOURNALOFCOMPUTING.ORG 44


have proposed another model of the CSP problem as 0-1
quadratic programming, which consists of minimizing a
quadratic function subject to linear constraints. To solve
this model, we have applied a general method based on
semidefinite relaxations, which concerns reformulating
this problem into an equivalent 0-1 quadratic program-
ming with a convex quadratic objective function[11].
The constraint satisfaction problem is stated as
quadruple sets ( , , , ) . In the following, we want to
present the proposed model of the binary constraint satis-
faction problems. For each variable
i
y of the CSP prob-
lem, we introduce
i
d binary variables
ik
x such that:

1 =
= ( )
0
i k
ik k i
if y v
x v D y
Otherwise

(1)

Where {1,....., }, {1,....., }
i
k d i n e e
This matrix is easily converted to a N-vector:

( ) 11 1 1
1
=
T
d n nd
n
x x x x x

with
=1
=
n
i
i
N d

and =| ( ) |
i i
d D y

Based on this notion of encoding values for each varia-
ble, we can define the objective function and constraints
of our model.

a. Objective function
Each constraint
ij
C between two variables
i
y and
j
y is
defined by its relation
ij
R (
ij
R is a subset of the cartesian
product ( ) ( )
i j
D y D y , specifying the compatible values
between
i
y and
j
y ). Note that, if there is no constraint
between two variables
i
y and
j
y , ( , )
ij r s
R v v holds for any
pair ( , )
r s
v v of ( ) ( )
i j
D y D y . For each couple ( , )
r s
v v
such that ( , )
r s ij
v v R e , we generate a constraint:
= 0
ir js
x x (2)
For each relation
ij
R , the constraints (2) can be
aggregated in a single constraint:

=1 =1
= 0
d
d
j
i
irjs ir js
r s
q x x

(3)


Where
1 ( , )
=
0
r s ij
irjs
if v v R
q
Otherwise
e



and {1,....., }, {1,....., }, < i n j n i j e e

These constraints (3) can be aggregated in a single
constraint:

=1 =1 < =1 =1
( ) = = 0
d
d
j n n i
irjs ir js
i j i j r s
f x q x x

(4)

The later constraint can be written in the following
form:

=1 =1 =1 =1
1
( ) = = 0
2
d
d
j n n i
irjs ir js
i j r s
f x q x x

(5)
Where
- if < i j then
1 ( , )
=
0
r s ij
irjs
if v v R
q
Otherwise
e


- if i = j then = 0 {1,..., }
irjs i
q r d e and
{1,..., }
j
s d e ,
- if > i j then =
irjs jsir
q q ,
- if there is no constraint between variables
i
y
and
j
y then = 0 {1,..., }
irjs i
q r d e and
{1,..., }
j
s d e .
Finally, we can define the objective function ( ) f x in
the following way:


1
( ) =
2
T
f x x Qx

Where the matrix Q is the N N symmetric matrix
and q
irjs
are the elements of this matrix.

b. Constraints
Each variable
i
y must take a unique value from its
domain ( )
i
D y , then the linear constraints of the CSP
problem are defined bellow:

=1
=1 {1,...., }
d
i
ik
k
x i n e

(6)

The latter constraints can be written in the following
matrix form:
= Ax b
Finally, we obtain the following 0-1 quadratic program
( ) QP with a quadratic function subject to linear
constraints [11]:


1
( ) =
2
( )
=
{0,1}
T
N
Min f x x Qx
Subject to
QP
Ax b
x





Where Q is an N N symmetric matrix, A is an
n N matrix and b is an n vector.
The following theorem establishes the links between
the binary CSP problems and an optimization model QP .

Theorem 1 [11]
Let ( ) V QP

be an optimal value of the 0-1 quadratic
programming. The value ( ) V QP is equal to zero if and only if
the binary constraint satisfaction problem has a solution.

Example 1: Job shop scheduling problem
The job shop scheduling problem is a classical problem in
manufacturing, arising daily in factories and workshops [27],
[13]. The JSSP problem involves the temporal synchronization
of the production of l jobs on h machines (resources). Each job
i
J is composed of a sequence of
i
p operations; each operation
ik
op has a fixed processing time (duration)
ik
pr and a variable
start time
ik
st and it requires the exclusive use of a machine for
its duration. Each job
i
J has a release date
i
rd and a due date
i
dd during which it should be accomplished. The solution of
the job shop scheduling problem is a schedule giving the start
time
ik
st for each operation
ik
op that satisfies the two
JOURNAL OF COMPUTING, VOLUME 4, ISSUE 4, APRIL 2012, ISSN 2151-9617
https://sites.google.com/site/journalofcomputing
WWW.JOURNALOFCOMPUTING.ORG 45


following binary constraints:
- A precedence constraint is used to let operation
ik
op be scheduled after all predecessor operations
included in
i
J are finished,
- A capacity constraint is used to restrict the use of
each machine to only one operation at a time.
To solve this problem, different methods have been used
such as shifting bottleneck, simulated annealing and tabu
search.
We consider a sample job shop problem with three machines
(
1 2 3
, , M M M ) and three jobs, so that the objective is to produce
these jobs. The ready times of all jobs are
i
rd . The process
plans, durations
ik
pr and the deadlines
i
dd are given in
Figure 1:












The scheduling task is to assign time and resources for all
operations such that the three jobs can be produced before their
deadlines. From an Artificial Intelligent perspective, the job
shop scheduling problem is a constraint satisfaction problem
[25], [26], i.e. we can formulate a job shop problem as a
constraint satisfaction problem named CSP JSSP [13].
Formally speaking, a CSP JSSP problem is defined by:

1,1 1,2 1,3 2,1 2,2 2,3 3,1 3,2 3,3
={ , , , , , , , , } V st st st st st st st st st is a set of
start times.
={ ( )}
ik
D D st is a set of domains of each start time. The
values of each domain is: ( ) = [ , ]
ik i i ik
D st rd dd pr
+
.
={ , } C CP CC is set of =
CP CC
m n n + constraints where:
-
1,1 1,2 1,2 1,3 2,1 2,2 3,2 3,3
={ ( , ), ( , ), ( , ),..., ( , )} CP CP st st CP st st CP st st CP st st
is a set of = 6
CP
n constraints of operation
precedence. These constraints are defined by linear
inequalities:
ik ik ij
st pr st + s
-
1,1 2,2 1,1 3,3 2,1 3,2 2,3 3,1
={ ( , ), ( , ),..., ( , ),..., ( , )} CC CC st st CC st st CC st st CC st st
is a set of = 9
CC
n constraints resource capacity. The
form of each constraint ( , )
ix jy
C st st between two jobs
i
J and
j
J is: ( , ) ( , )
ix jy
min u pr v pr max u v + + s .
Where ( )
ix
u D st e and ( )
jy
v D st e .
After filtering this problem, we reformulated it as the following
model:





1
( )
2
( )
=
{0,1} =1,..., 27
T
i
Min f x x Qx
Subject to
QP
Ax b
x i






With
9 27
A

e and
9
be .
A general method is used to solve QP problem, which
consists of reformulating it into an equivalent 0-1
quadratic programming with a convex quadratic
objective function [11]. This method is able to determine
whether a CSP problem has a solution or not. Note that, it
is an exact method for solving CSP problem. However,
when the size of this problem is important (A CSP with
variables, constraints and values in every domain become
important), the time of resolution increases exponentially
and creates problems for computer memory. The original
work developed in this paper is to use the model
described in this subsection and apply the genetic
algorithm in order to give a solution to the constraint
satisfaction problem in a reasonable time.
3 GENETIC ALGORITHMS
Genetic algorithms belong to the larger class of evolutio-
nary algorithms (EA), which generate solutions to opti-
mization problems using techniques inspired by natural
evolution, such as crossover, mutation, selection, etc.. .
GAs have a relatively old story since the early work of
John Holland on adaptive systems dates back to 1962 [16].
David Goldbergs book has largely helped to popularize
them [15]. Over the past few decades, GAs have been
successfully applied to solve hard search problems in
science and engineering such as learning robot, aircraft
conflict problem, natural language processing, job shop
scheduling problem and traveling salesman problem.
Significant progress has also been made in understanding
and designing competent genetic algorithms, that solve
hard problems quickly, reliably, and accurately [15]. The
population sizing, convergence time and scalability of
competent GAs are well understood on different classes
of difficult problems. Moreover, a genetic algorithms
research one or several extrema of function defined on the
data space. To use them, the definition of the six follow-
ing elements is obligatory:
1. Encoding solution of the population: This step
associates to each points of the state space a
structure of data. It is usually placed after a
phase of mathematical modeling of the handled
problem. The quality of data encoding deter-
mines the success of genetic algorithms. Several
encoding methods such as binary, gray, real,
permutation, and program codes can be used.
The binary encodings were originally very used;
it is the case in this work.
2. Generation of the initial population: Another im-
portant concept of GAs is the notion of popula-
tion. A mechanism for generating the initial pop-
ulation must be capable of producing a hetero-
geneous population of individuals which will










Fig.1. Example of the job shop problem
JOURNAL OF COMPUTING, VOLUME 4, ISSUE 4, APRIL 2012, ISSN 2151-9617
https://sites.google.com/site/journalofcomputing
WWW.JOURNALOFCOMPUTING.ORG 46


serve as base for the future generations. The
choice of the initial population is important be-
cause it can make the convergence to the global
optimum more or less fast. In the case where
nothing is known of the problem to be resolved,
it is essential that the initial population is distri-
buted on all space of research, i. e., covering the
entire range of possible solutions. Moreover, if
we know any information of the problem to be
resolved, it is likely to generate the initial solu-
tions in the partial space in order to found a good
solution in a short time.
3. Function of adaptation or fitness: In order to
evolve good solutions and to implement natural
selection, the notion of fitness evaluating each
candidate solution is used. The measure could
be:
a. An objective function that is a mathe-
matical model,
b. A computation or a computer simula-
tion,
c. A subjective function where humans
choose better solutions over worse ones,
d. A co-evolved arising out of co-operative
or competitive environments.
In essence, the fitness measure must
determine a candidate solution's relative
fitness, which will subsequently be used by
the GAs to guide the evolution of good
solutions. In each generation, the fitness of
every individual in the population is
evaluated. Based on their fitness, the
multiple individuals are selected from the
current population. Therfore, fitness
measures the quality of the represented
solution.
4. Mechanism for selection: The main idea of selec-
tion is to prefer better solutions to worse ones,
and many selection procedures have been pro-
posed to accomplish this idea, including fitness-
proportionate methods such as roulette-wheel se-
lection, stochastic universal selection, ordinal me-
thods such as tournament selection and trunca-
tion selection. Usually, ordinal selection schemes
are preferred over fitness-proportionate methods
as they are less noisy and are not affected by scal-
ing of fitness measures.
5. Diversification of population: Operators allow to
diversify the population and explore the state
space during the generations. The crossover op-
erator recombines the genes of individuals exist-
ing in the population, the mutation operator aims
to ensure the exploration of state space.
6. Sizing parameters: population size, total number
of generations or stopping criterion, probability
of applying crossover and mutation operators.
The population size, which is usually a user-
specified parameter, is one of the important fac-
tors affecting the performance of genetic algo-
rithms [16]. In general, the population size de-
pends on the nature of the problem.
The process of resolution by genetic algorithms of any
problem is defined in the following way: We begin by
generating a population of individuals in a random way.
To pass from generation i to generation 1 i + , the
following three operations are repeated for all the
elements of the population i . Pairs of parents
1
P and
2
P
are selected according to their adaptations. The crossover
operator is applied to them with a probability pc (usually
around 0.6) and generates pairs of children
1
C and
2
C .
Other elements
i
P are selected for their adaptation. The
mutation operator is applied to them (
i
P ) with probabili-
ty pm (pm is generally much lower than pc) and generates
mutated individual
i
C . The level of adjustment of child-
ren (
1 2
, C C ) and individuals mutated
i
C are then eva-
luated before inclusion in the new population. Different
criteria for stopping algorithm can be selected:
- The number of generations can be fixed at the
brginning. This is what one is tempting to do
when you must find a solution within a limited
time,
- A solution ll br found satisfies all criteria or con-
straints,
- The algorithm can be stopped when the popula-
tion evolves quickly,
- Combinations of the above.
In this work, our objective is to project and use genetic
algorithms in order to find a solution to the constraint
satisfaction problem.
4 CONSTRAINT SATISFACTION PROBLEM SOLVED
BY GENETIC ALGORITHM
The constraint satisfaction problem is modeled as a 0-1
quadratic programming with a quadratic function subject
to linear constraints. In this section, we present a general
approach for solving the CSP problem using the quadrat-
ic programming and genetic algorithms. In order to find a
solution to the constraints satisfaction problems via the
genetic algorithms, the use of the six elements defined in
the last section is obligatory. This definition is based on
the important properties of the QP problem.
Recall that, the model of the CSP problem as 0-1 qua-
dratic programming consists of minimizing the quadratic
function subject to linear constraints. So, the encoding
solution (individual) of the population, generation of the
initial population, function of adaptation, operator of
selection and the diversification of population are defined
bellow.
4.1 Encoding solution of the population
As it is know, the CSP problem can be modeled as a 0-1
quadratic programming. Then, it is normal to use the
binary codes in order to produce all individuals of our
population. The presentation of each individual is the
JOURNAL OF COMPUTING, VOLUME 4, ISSUE 4, APRIL 2012, ISSN 2151-9617
https://sites.google.com/site/journalofcomputing
WWW.JOURNALOFCOMPUTING.ORG 47


following:



Moreover, for each variable
i
y must take a unique
value from its domain ( )
i
D y . So, the encoding individual
of the population must be respecting this constraint. Fi-
nally, each individual of our population is coded in the
following form.





The constraint = Ax b is implicitly verified by this
type of encoding solution.
4.2 Initial population
Recall that, the mechanism for generating the initial pop-
ulation must be capable of producing a hetrogeneous
population of elements which will serve as a base for
future generations. In this context, basing on the type of
encoding solution (respecting constraint (6)), all individu-
als are initialized by "0" and for each size of
i
d
in each
individual, we randomly generate one position in order
to insert "1". Therfore, the initial population is randomly
generated such that the property of constraint (6) is veri-
fied.
When we have one value in D(y
i
) of variable
i
y ( =1
i
d
), the convenable gene take "1" in all different step of reso-
lution. This is logical because the only existing value can
be assigned to the variable
i
y .
4.3 Fitness or function of adaptation
In order to evolve good solutions and to implement natu-
ral selection, the notion of fitness of a candidate solution
is used. In our case, the mathematical model of QP prob-
lem. So, our aim is to define the fitness for each individual
in order to measure the quality of it. This function of
adaptation is based on the objective function and the
optimal value V(QP) of QP problem. Or, when a fitness
measures the quality of the represented solution, we
compute the optimal value
i
OV of each individual and
attribute a value of fitness in function of this optimal
value. In this context, a percentage of adaptation of indi-
vidual
i
IN is calculated using the optimal value
i
OV . The
process of computing this value of fitness is described in
the following:
We consider ps individuals in the population; then,
we must compute
ps
optimal values
i
OV by the following
expression:

1
= =1,...,
2
T
i i i
OV IN QIN i ps (7)

Where ps is the size of population.
Based on the theorem (2.1) which define the relation-
ship between the CSP problem and the optimal value
V(QP) of QP problem. The main property of this theorem
is: the value V(QP) is equal to zero if and only if the bi-
nary constraint satisfaction problem has a solution. Then,
the main idea is to compute the percentage of adaptation
of individual
i
IN . This percentage is calculated by the
following relation and it is a fitness for each individual in
the population:

=100
i
i
m OV
FA
m

(8)

Where m is the number of constraints and
i
OV is the
optimal value for each individual. For example, if the
optimal value of individual
i
IN is equal to zero ( = 0
i
OV
), then all constraints of CSP problem are satisfied
(theorem (2.1)). So, this individual is a solution of CSP
problem, this is equivalent to =100
i
FA . Otherwise, if the
optimal value of individual
k
IN is a great optimal value,
then this individual is not a solution of the CSP problem.
This is equivalent to an unsuitable or no adaptable
individual. To overcome this problem, we distribute a
bad fitness of this individual in order to eliminate it by
the process of selection. Moreover, when = 0
i
FA , all
constraints of CSP problem are violated ( =
i
OV m ). So
this individual is automatically eliminated. Finally,
equation (8) assure a good adaptation for individual if
this later is approximately a solution and assures a bad
adaptation if this individual is further a solution.
4.4 Mechanism of selection
At the level of selection, the main idea is to prefer better
solutions over worse ones. In this work, the type of the
selection used is roulette-wheel selection. This type of
selection guarantees a good luck to the good individual in
order to be selected in the future generation, and a bad
luck to the unsuitable individual targeted to be vanished
in the future generation (Figure 4).












We show that, this type of selection is a convenable
selection because it translates the adapted or no adapted
individual basing its fitness. The part or angle
i
pr
occupied by an individual in roulette is calculated by the
following equation:

= 360
i
i
FA
pr
FT
(9)

Where
=1
=
ps
i
i
FT FA

is the total of the fitness for all


individuals.

4.5 Diversification of the population
The diversification of the population is an important
stage allowing to diversify the population during the
generations and explore the state space. This
0 0 1 0 0 0 0 0 1 0 .... 1 0 0
Fig. 2. The encoding solution (element) of the population
d
1
d
2
d
i
d
n
0 1 0 0 0 1 0 0 1 1 0 0 0
Fig. 3. The encoding solution of the population which respect
the property of equation (6).






Fig. 4. roulette-wheel selection.

NI
i
NI
2
NI
1
NI
ps


JOURNAL OF COMPUTING, VOLUME 4, ISSUE 4, APRIL 2012, ISSN 2151-9617
https://sites.google.com/site/journalofcomputing
WWW.JOURNALOFCOMPUTING.ORG 48


diversification is guaranteed by the crossover operator
and mutation operator:
In this work, a special crossover operator, which
respects the main properties of our model, is defined. In
order to guarantee the specific encoding element of
population and produce the convenable children, the
crossover operator has not been applied to any position
from element, but it must be applied after each size
i
d of
the element (Figure 5 and 6).









In this example, we show that the crossover
recombines the genes of two individuals existing in the
population. This recombination is applied in the specific
position called a point of crossover
k
cp . This point is
randomly generated in the interval
1
[ , ]
n
d d . Note that, the
selection of two parents for producing two children is
realized randomly.
The mutation operator aims to ensure the exploration
of state space. So, to apply this operator we must respect
the characteristic of encoding individual. In this situation,
the special mutation operator is applied. This later change
to a position of alphabet "1" into
i
d position such that this
position is randomly generated between
1
and
i
d (Figure
7).






Finally, we define the specific mutation operator in
order to guarantee the exploration of state space and
respect the main property of encoding solution.

4.6 Sizing parameters
After several experiments, the population size is fixed in
function of the number n of variables. So, the population
size ps is equal to:

= 2 ps n (10)
The stopping criterion is defined in order to give a
solution. Basing on theorem (2.1) which defines the
relationship between the CSP problem and the optimal
value of QP problem, the stopping criterion is the
following: if one individual of population has a fitness
equal to 100, then this individual is a solution. This is
equivalent to:

1
( ) = = 0
2
T
i i
V QP IN QIN .

In general, the probability of applying crossover
operator is equal to 0,6 and the probability of applying
mutation operator is equal to 0,2.
5 ALGORITHM FOR SOLVING CSP PROBLEMS
Recall that, the objective of this approach is to get a
solution to the addressed problem in the reasonable time.
The description of important steps constructing this
solver is represented by the following diagram(Figure 8):












































The important steps of this software are the following:
1. The first step is to read the data of CSP problem
existing int the XML file;
2. The main objective of the second step is to filter
the CSP problem. There are two important roles
of this filtering:
P
1
: 0 0 1 0 0 1 0 0 1 0 0 0 1 0
P
2
: 0 1 0 0 0 0 1 0 0 0 1 0 0 1
Fig. 5. Parents P
1
and P
2
.

C
1
: 0 0 1 0 0 1 0 0 0 0 1 0 0 1
C
2
: 0 1 0 0 0 0 1 0 1 0 0 0 1 0
Fig. 6. Children C1 and C2 with a crossover point = 2
k
cp
(after
2
d )
P
i
: 0 0 1 0 0 1 0 0 0 0 1 0 0 1

C
i
: 0 0 1 0 0 1 0 1 0 0 0 0 0 1
Fig. 7. Operator of mutation with a point of mutation = 3
i
mp (in
3
d ).


















Fig. 8. Diagram of the proposed algorithm.

JOURNAL OF COMPUTING, VOLUME 4, ISSUE 4, APRIL 2012, ISSN 2151-9617
https://sites.google.com/site/journalofcomputing
WWW.JOURNALOFCOMPUTING.ORG 49


a. Reducing the size of the CSP problem,
which result in reducing the size of
individuals;
b. Showing that the CSP problem does not
admit a solution (if one domain after the
filtering is empty).
This filtering is realized by the arc consistency
technique AC3.
3. The role of the third step concerns modeling the
CSP problem as 0-1 quadratic programming
(determining the matrix Q, the matrix A and the
vector b);
4. The next step aims at creating the initial
population in order to apply the process of
resolution by genetic algorithms;
5. The last step concerns computing the fitness for
all individuals such that if one individual has a
fitness equal to 100 then the solution is obtained.
Else the operators of crossover, mutation and
selection are applied in order to research the
solution of CSP problem. In each step, if one
individual
i
IN has a fitness =100
i
FA , then the
algorithm stop. So, the solution is obtained.
Example 2
Go back to the example of application, which consist of
modeling the job shop scheduling problem into a quadratic
problem. This later problem can be solved via the proposed
algorithm. The solution given by this algorithm in the 0.002s
second (time of resolution) is:
1,1 1,2 1,3
= 0 = 3 = 5 st st st

2,1 2,2 2,3
= 0 =1 = 3 st st st

3,1 3,2 3,3
= 0 =1 = 4 st st st

In this result we show that, the job
1
J is produced by the
following process:
- The operation
1,1
op has been executed in the
machine
1
M with the start time
1,1
st which is equal
to 0,
- The operation
1,2
op has been executed in the
machine
2
M with the start time
1,2
st which is equal
to 3,
- And the operation
1,3
op has been executed in the
machine
3
M with the start time
1,3
st which is equal
to 5. Then, we can observe that the job
1
J is
produced between ready times
1
= 0 rd and
deadlines
1
= 6 dd . The production of jobs
2
J
and
3
J is similar to the job
1
J .
6 COMPUTATIONAL EXPQERIMENTS
In order to show the practical interest of the proposed
approach, The experiments are effectuated to solve
problems of different natures (random, academic and
real-world problems). These series represent a large
spectrum of instances (benchmarks). These experiments
are effectuated in personal computer with a 2.0 GHz core
2 duo processor and 4 GB RAM. The performance has
been measured in terms of the CPU time per second. Note
that, this algorithm is implemented by java language.
In this experimentation, some instances used as
benchmarks for the first round of the 2009 CSPs [20]
solver competition are used to test this software (see
Table 1).
The process of experimentation is based on three
components. The first one is the number of run, i. e. the
proposed algorithm is executed number of run times in
order to find the solution. This repetition is imposed by
the notion of heuristics which governs the proposed
approach. The second one is the minimum of CPU time
obtained by the GA. This minimum is the better
resolution time obtained in number of run. Finally, the
mean of the global CPU time which evaluate the
performance of this approach.
We compared our approach to different approaches
proposed in the following link [6]. These results show
that the genetic algorithms are an effective tool to solve
the some instances of constraint satisfaction problem
(CSP). For example, the instance named
" 2 50 23 587 230 32" rand fcd is solved by our
solver in 1395.138s but the best solver solves it in
1411.95s . Yet, it cannot find a solution in a reasonable
time compared to othors. For example " 30 6" geom a
and " 2 4" langford are solved by the proposed
algorithm in bad CPU time (see Table 1). In general, our
approach can get a solution in a short time for difficult
instances. Finally, reasonable results are obtained by this
approach (new solver of CSPs).
JOURNAL OF COMPUTING, VOLUME 4, ISSUE 4, APRIL 2012, ISSN 2151-9617
https://sites.google.com/site/journalofcomputing
WWW.JOURNALOFCOMPUTING.ORG 50


TABLE 1
COMPARISON BETWEEN THE PROPOSED SOLVER AND OTHER SOLVERS




7 CONCLUSION
In this paper, we have proposed a new approach for
solving the binary constraint satisfaction problems. The
interesting steps of this approach are: filtering and
modeling the constraint satisfaction problem as a 0-1
quadratic program subject to linear constraints and using
the genetic algorithms to solve this problem. The most
interesting propriety of this approach is used to give the
solution of the binary CSP. It is also interesting to note
that this method can be used with a non-binary CSP after
converting the latter into a binary CSP [23]. The
experimental results show that our method can find a
solution in a reasonable time compared to other solvers.
Future directions of this research are applying this
approach to get a good solution of real-world problems
such as aircraft conflict, scheduling and planing.

References
[1] F. Bacchus and A. Grove, On the Forward Checking algorithm. In
Principles and Practice of Constraint Programming, in LNCS, Sprin-
ger-Verlag, New York, vol. 976, pp. 292-309, 1995.
[2] C. Bessire and J-C. Rgin, Refining the basic constraint propagation
algorithm, In proceedings of the Seventeeth International Joint confe-
rence on Artificial Intelligence (IJCAI'2001), pp. 309--315, 2001.
[3] C. Bessire, Arc-consistency and arc-consistency again, Artificial
Intelligence, vol. 65, no. 1, pp. 179-190, 1994.
[4] O. S. B. Boubaker and A. Farhat, Intelligent Transport Scheduling,
JOURNAL OF COMPUTING, vol. 2, no. 9, pp. 74-76, 2010.
[5] H. R. Cheshmehgaz, H. Haron, A Novel Job Rotation Schedule Model
Regarding Posture Variety Solving by a Cellular Genetic Algorithm,
JOURNAL OF COMPUTING, vol. 3, no. 6, pp. 67-75, 2011.
[6] CSP 2009 Competition, benchmarks results per solver Result, Avail-
able at www.cril.univ-artois.fr/CPAI09/results/results.php?idev=30,
2009.
[7] Dechter and D. Frost, Backtracking algorithms for constraint satisfac-
tion problems, in Constraints, International Journal, 1998.
[8] S. Dinu, A Novel Genetic Algorithm for Dynamic Economic Dispatch
of Power Generation, JOURNAL OF COMPUTING, vol. 3, no. 4, pp.
198-204, 2011.
[9] M. Ettaouill, A 0-1 quadraric knapsack problem for modelizing and
solving the constraint satisfaction problem, in Lecture Notes in Artifi-
cial Intelligence N1323, Springer Verlag, Berlin, pp. 61-72, 1997.
JOURNAL OF COMPUTING, VOLUME 4, ISSUE 4, APRIL 2012, ISSN 2151-9617
https://sites.google.com/site/journalofcomputing
WWW.JOURNALOFCOMPUTING.ORG 51


[10] M. Ettaouill and C. Loqman, Constraint Satisfaction Problems Solved
by Semidefinite Relaxations, WSEAS TRANSACTIONS on COM-
PUTERS, vol. 7, no. 7, pp. 951-961, 2008.
[11] M. Ettaouill and C. Loqman, A New Optimization Model for Solving
the Constraint Satisfaction Problem, Journal of Advanced Research in
Computer Science, vol. 1, no. 1, pp. 13-31 , 2009.
[12] M. Ettaouill, and Y. Ghanou, , Neural architectures optimization and
genetic algorithms, JWSEAS TRANSACTIONS on COMPUTERS, vol.
8, no. 3 , pp. 526537, 2009.
[13] M. Ettaouil, C. Loqman and K. Haddouch, Job Shop Scheduling
Problem Solved by the Continuous Hopfield Networks, Journal of
Advanced Research in Computer Science, vol. 2, no. 1, pp. 31-47, 2010.
[14] M.R Garey and D.S Johnson, A Guide to the Theory of NP-
Completeness, Computers and Intractability, New York: W.H. Free-
man and Company, 1979.
[15] D.E Goldberg, Genetic Algorithms in Search, Optimization and Ma-
chine Learning, Reading MA Addison Wesley, 1989.
[16] D. E. Goldberg, Design of innovation: Lessons from and for competent
genetic algorithms, Boston, MA: Kluwer Academic Publishers, 2002.
[17] R. M. Haralick and G. L. Elliott, Increasing tree search efficiency for
constraint satisfaction problems, Artificial Intelligence, vol. 14, pp. 263-
313, 1980.
[18] V. Kumar, Algorithms for Constraint Satisfaction Problems, A Survey,
AI Magazine, vol. 13, no. 1, pp. 32-44, 1992.
[19] C. Lecoutre, F. Boussemart and F. Hemery, Revision ordering heuris-
tics for the Constraint Satisfaction Problem, 1st International Work-
shop on Constraint Propagation and Implementation (CPAI'04), pp. 9-
43, 2004.
[20] C. Lecoutre, Benchmarks in XCSP 2.1 XML representation of
CSP/WCSP/QCSP instances, Available at http://www.cril.univ-
artois.fr/lecoutre/research/benchmarks/benchmarks.html, 2008.
[21] C. Lecoutre, Constraint Networks: Techniques and Algorithms,
ISTE/Wiley, ISBN 978-1-84821-106-3, 2009.
[22] N. Mamoulis and K. Stergiou, Solving non-binary CSPs using the
Hidden Variables Encoding, In Proceedings of CP' 2001.
[23] AK. Marckworth, Consistency in networks of relations, Artificial
Intelligence, vol. 8, pp. 99-118, 1977.
[24] R. Mohr and TC. Henderson, Arc and path consistency revisited,
Artificial Intelligence, vol. 28, pp. 225-233, 1986.
[25] R. Mohr and TC. Henderson, Backtracking techniques for the job shop
scheduling constraint satisfaction problem, Artificial Intelligence, vol.
76, pp. 455-480, 1995.
[26] M. A. Salido, A. Garrido and R. Bartk, Introduction: Special issue on
constraint satisfaction techniques for planning and scheduling prob-
lems, Engineering Applications of Artificial Intelligence, 21(2008), pp.
679--682.
[27] D. Smith and S.D. Goodwin, Constraint-based in telligent scheduling,
TR CS-95-02, Dept of Computer Science, University of Regina, 1995.
[28] B. Thiongane, A. Najih and G. Plateau, An Adapted Step Size Algo-
rithm for a 0-1 Biknapsack Lagrangean Dual, Annals of Operations
Research, vol. 139, no. 1, pp. 353373, 2005.



JOURNAL OF COMPUTING, VOLUME 4, ISSUE 4, APRIL 2012, ISSN 2151-9617
https://sites.google.com/site/journalofcomputing
WWW.JOURNALOFCOMPUTING.ORG 52

You might also like