Page 1
An Adaptive Quantuminspired Differential Evolution Algorithm
for 01 Knapsack Problem
Ashish Ranjan Hota
Department of Electrical Engineering
Indian Institute of Technology
Kharagpur, India
hota.ashish@acm.org
Ankit Pat
Department of Mathematics
Indian Institute of Technology
Kharagpur, India
ankitpat.iitkgp@gmail.com
Abstract — Differential evolution (DE) is a population based
evolutionary algorithm widely
multidimensional global optimization
continuous spaces. However, the design of its operators makes
it unsuitable for many reallife constrained combinatorial
optimization problems which operate on binary space. On the
other hand, the quantum inspired evolutionary algorithm
(QEA) is very well suitable for handling such problems by
applying several quantum computing techniques such as Qbit
representation and rotation gate operator, etc. This paper
extends the concept of differential operators with adaptive
parameter control to the quantum paradigm and proposes the
adaptive quantuminspired differential evolution algorithm
(AQDE). The performance of AQDE is found to be
significantly superior as compared to QEA and a discrete
version of DE on the standard 01 knapsack problem for all the
considered test cases.
used for solving
over problems
Keywords
evolutionary algoithm; 01 knapsack problem; quantum
computing
differential evolution; quantum inspired
I.
INTRODUCTION
Differential Algorithm (DE), introduced by Storn and
Price [1,2] has been shown to give significantly better
performance in terms of efficiency and robustness on many
benchmark multimodal continuous functions than other
population based evolutionary algorithms. For exploration of
the search space and to introduce diversity, it employs two
simple mutation and crossover operators respectively
followed by a greedy replacement strategy. The performance
is found to be very sensitive to the mutation and crossover
parameters chosen and the best combination of both the
parameters changes from one function to another. Thus, a
large number of modifications have been proposed to make
the selection of control parameters adaptive and free from
function dependency [37].
Because of its superior performance on continuous
optimization problems, several modifications have been
introduced in the past, so that it operates on binary space.
Pampara, Engelbrecht and Franken [8] proposed an angle
modulation scheme (AMDE) to map the continuous space to
binary. On similar lines, binary differential evolution
(binDE) and normalization DE (normDE) were proposed
based on sigmoid function mapping and normalization of
continuous space respectively [9] giving better results as
compared to AMDE. A discrete binary version of differential
evolution (DBDE) for solving 01 knapsack problem was
also proposed [10].
To solve various optimization problems better than the
conventional evolutionary algorithms, a broad class of
algorithms have been proposed by applying several concepts
of quantum computing in the past decade. Quantum
computing uses the quantum mechanical phenomena like
superposition, entanglement, interference, decoherence, etc
to develop quantum algorithms. Many quantum algorithms
have been shown to be exponentially faster and massively
parallel as compared to classical algorithms [11, 12]. Thus
quantum inspired genetic algorithms with interference as
crossover operator [13], quantum inspired evolutionary
algorithms (QEA) [14], quantum behaved particle swarm
optimization [15] etc has been developed for both continuous
and binary spaces.
QEA uses superposition of binary bits known as Qbit for
representation of individuals and updates the individuals
depending on their values with respect to the global best
solution by suitably deciding the parameter of the rotation
gate operator. Broadly it comes under the class of estimation
of distribution algorithms (EDA) [23]. QEA has
demonstrated quite significant results on binary optimization
problems and some improvements on QEA have also been
proposed [16, 17]. QEAs have been extended by differential
operators to solve flow shop scheduling problems [18], N
queen’s problem [19], for classification rule discovery [20]
and some benchmark functions [21].
In this paper, an adaptive quantuminspired differential
evolution algorithm (AQDE) is proposed with adaptive
control of mutation and crossover parameters and the
operators acting directly on the superposition states of the
individual. The proposed AQDE outperforms QEA and
DBDE under different conditions of population size and item
size of the 01 knapsack problem.
The rest of this paper is organized as follows: Section II
gives a brief introduction of knapsack problem, DE, DBDE
and QEA. The proposed AQDE is explained in detail in
section III. Experimental settings and the results obtained are
mentioned under section IV. Finally, section V concludes the
paper.
Page 2
II.
BACKGROUND
A. 0  1 Knapsack Problem:
The 01 knapsack problem is a classical problem in
combinatorial optimization.
Problem Description:
In a given set of m items each item has an integer weight
wj and an integer profit pj. The problem is to select a subset
from the set of m items such that the overall profit is
maximized without exceeding a given weight capacity W. It
is an NPHard problem and hence doesn’t have a polynomial
time algorithm. The problem may be mathematically
modeled as follows:
m
p x
Maximize:
1
ii
i
=∑
(1)
Subject to the constraint:
1
, {0,1}
m
iii
i
w x W x
=
≤∈
∑
(2)
where xi takes values of either 1 or 0 representing the
selection or rejection of the ith item.
B. Differential Evolution :
In classical DE, each member of the population is
represented by a real valued Ddimensional vector. A typical
iteration of the DE algorithm consists of three major
operations – mutation, crossover and selection, which are
carried out for each member of the population (called as
target vector). Mutation on each target vector of the
population generates a new mutant vector uniquely
associated with it. Then the crossover operation generates a
new trial vector using the mutant vector and the target vector
itself. In selection phase the fitness of the trial vector is
compared with the target vector and the vector with higher
fitness replaces the target vector in the population for the
next iteration. The three operations – mutation, crossover and
selection, are discussed in detail below.
Mutation: The mutant Vt
generated by adding a randomly selected vector Xt
population, with a weighted difference of two other
randomly selected vectors Xt
12
.(
irr
VX F X
=+
where r1,r2 and r3 are all distinct and different from i. The
parameter t denotes the generation. F is a control parameter
whose value is typically chosen between 0 and 2.
Crossover: The crossover operation generates a trial
vector Ui from its corresponding target vector Xi and mutant
vector Vi, by using the following relation:
, ( (0,1)
, ((0,1)
j ij
xif rand
⎪ ⎩
where j=1,2,…..D, Ui = (ut
jth evaluation of a random number generator in [0,1] from a
uniform distribution. Irand is a randomly chosen dimension
index from {1,2,…..,D} which ensures that the new trail
vector is different from the target vector. CR is a control
i vector on a target vector Xt
i is
r1 from the
r2, Xt
t
r3 from the population.
)
r
X
3
ttt
−
(3)
,
,
,
)()
)()
t
j ij rand
I
t
j i
t
rand
v if randCR or j
CR and j
I
u
⎧
⎪
≤=
=⎨
>≠
(4)
1,i , ut
2,i , …….. , ut
D,i), randj is the
parameter which decides the crossover rate and its value is
typically chosen in the range of 0 to 1.
Selection: If the trial vector Ui has a better fitness value
compared to the target vector, then it replaces the target
vector in the population in the next iteration. Otherwise, the
target vector remains unchanged in the population.
C. Discrete Binary version of Differential evolution
The discrete binary version of differential evolution
(DBDE) [10] was an attempt to develop an algorithm which
worked on similar lines as DE but on a binary Ddimensional
space. DBDE has its roots in DE and a discrete binary
version of particle swarm optimization (DPSO) [22].
Here the individuals are initialized as a binary string.
The mutation operator is exactly similar to that of DE, but
the resultant mutant vector is no longer binary because of
the difference operator and the control parameter. Therefore
the discretization process from a real continuous space to a
binary space is done according to the following equation:
1, (0,1)
0,(0,1)
ifrand
>
⎪ ⎩
where rand is a random number in the range [0,1] selected
uniformly at random. sig() is a sigmoid limiting
transformation function and vt
the ith mutated vector in generation t. The crossover and
selection operations in DBDE, are same as in DE.
,
t
i d
,
,
(
(
)
)
t
i d
t
i d
if randsig v
sig v
v
⎧
⎪
≤
=⎨
(5)
i,d is dth dimensional value of
D. Quantum Inspired Evolutionary Algorithm
Quantuminspired Evolutionary Algorithm (QEA), as its
name indicates, is inspired from the principles of quantum
computing, but it is designed to run on a classical computer.
In QEA, the smallest unit of information is called Qbit
and is defined as [α,β]T, where α and β are complex
numbers that specify the probability amplitude of the
respective Qbit states such that  α 2+ β 2 =1.  α 2
represents the probability that the Qbit will be in state ‘0’
and  β2 represents the probability that the Qbit will be in
state ‘1’. The representation for an individual q of QEA with
mbit is given as follows:
...

...
ββ
⎣
where  αi 2+ βi 2 =1, i=1,2,…..m
Algorithm Description: In the beginning, the population
is initialized with the α and β of all bits of all individuals set
to1/2 . In each generation, binary strings are generated
from the respective Qbit strings by observing the Qbit
states using the following criteria:
⎧
⎪
=⎨
⎪⎩
where Pi,j is the jth bit of ith individual in the population.
Once the population consisting of the binary strings has been
generated, the fitness value of these strings is evaluated and
the best solutions are stored separately in a global pool B.
12
12

m
m
q
α
β
α α
⎡
=⎢
⎤
⎥
⎦
(6)
2
,
,
1, ()
0,
i j
i j
if rand
P
otherwise
β
<
(7)
Page 3
The global best solution b among all the solutions in B is
determined. Then, a quantum rotation gate U(θ) is used to
update the values of the Qbits of each individual as follows:
cos()
()
sin() cos(
i
θΔ
⎝
where Δθi, i=1,2,….m is the rotation angle of each Qbit
towards either 0 or 1 depending on its sign. The parameter
Δθi is decided by comparing the value of the bit in the
individual and the corresponding bit in the global best
individual as per Table I (reproduced from [14]).
Then the global pool is updated with fitness based
replacement by better individuals of the present generation
and the previous global pool. The global best individual is
also updated accordingly. A global and local migration is
invoked with a definite frequency, in which all or some of
the individuals of the global pool are replaced by the global
best or the local best individuals respectively.
The detailed procedure of QEA [14] is provided below
for better understanding.
sin()
)
ii
i
i
U
θθ
θΔ
θ
Δ−Δ
⎛⎞
⎟
⎠
Δ=⎜
(8)
III.
This section describes the adaptive quantuminspired
differential evolution algorithm (AQDE).
ADAPTIVE QUANTUM DIFFERENTIAL EVOLUTION
A. Representation
Instead of using [α,β]T like QEA as the representation of
Qbits, AQDE uses the variable θ for reasons discussed later.
Since  α 2+ β 2 =1, it basically represents the equation of a
unit circle and each point on its perimeter can be represented
by a single variable θ with the Cartesian coordinates given
by cosθ and sinθ where θ is defined in [0,2π]. In AQDE, the
Qbits (θ) are initialized uniformly at random in [0, 2π] for
all the bits for all the individuals in the population. The
binary population is derived as follows:
1, (0,1)
0,
⎩
where Pj,i is the jth bit of the ith individual in the
population and θj,i is the corresponding Qbit.
2
,
,
sin (
otherwise
)
j i
j i
ifrand
P
θ
⎧
<
=⎨
(9)
Figure 1. QEA pseudo code
B. Mutation Operator
Mutation operator in AQDE is similar to that of classical
DE, but instead of operating on the individual directly, it is
applied on the Qbit (θ). Since θ contains information about
both α and β, it is more appropriate to generate the mutant
vector in terms of θ. Moreover, unlike the case of classical
DE, it inherently avoids the problem of constraint violation,
i.e. the mutant vector exceeding the prescribed domain. This
is because both cosine and sine functions are periodic with
period 2π. The representation of Qbits was changed to θ
keeping this in mind. The mutant Qbits θm are generated for
all the individuals in the population in every generation.
Mutant Qbits of the i
determined as follows:
.(
irrr
F
θθθθ
=+−
where r1,r2,r3 and i are mutually distinct and F
mutation control parameter which is determined in every
generation as per the following equation,
12
. .(0.1)F rand rand
=
where rand1, rand2 are random numbers generated from a
uniform distribution on [0,1]. The purpose of multiplying
one random number is to take values for F on the interval
[0,0.1]. One more independent random number is further
multiplied to probabilistically generate more values close to
zero. This is because, the quality of solution is found to be
highly sensitive towards radical perturbation of the Qbit.
th individual in generation t are
123
)
mttttt
(10)
t is the
(11)
C. Crossover Operator
The crossover operation operates on the original Qbits
and the respective mutant Qbits in the following
Procedure QEA
begin
t ? 0
initialize Q(t);
make P(t) from Q(t) by (7)
evaluate P(t)
B(t) ? P(t)
b? best solution among B(t)
while t<T do
t?t+1
make P(t) from Q(t) by (7)
evaluate P(t)
update Q(t) using (8)
store best solutions among B(t1)
and P(t)in B(t)
store best solution b among B(t)
if (migration condition)
migrate b or bt
or locally respectively
endif
end while
end
j to B(t) globally
Table I. Look up Table for Δθi
(f(.) is the profit and bi and xi are ith bit of best solution
b and binary solution x)
xi
bi
f(x)≥f(b)
0 0 false
0 0 true
0 1 false
0 1 true
1 0 false
1 0 true
1 1 false
1 1 true
Δθi
0
0
0.01π
0
0.01π
0
0
0
Page 4
manner:
,
,
,
, (
, ( if rand
(0,1)
(0,1)
)()
)()
mt
j i
t
j rand
I
ct
j i
t
j i
t
j rand
if randCR or j
CR and j
I
θ
θ
⎪ ⎩
θ
⎧
⎪
≤=
=⎨
>≠
(12)
where θc
crossover operation. Irand is a number randomly chosen from
{1,2,…D} which ensures at least one Qbit is different from
the original set in each individual. CR
parameter which is determined in every iteration as follows:
(0.5,0.0375)
rand
CRG
=
where Grand generates a random number from the
Gaussian distribution with mean 0.5 and standard deviation
0.0375. As a result, CR lies in a 0.15 neighborhood of 0.5
with a probability of 0.998. Thus the value of CR is selected
very close to 0.5 in almost all the cases, which is found to the
best value experimentally.
ji is the jth Qbit of ith individuals after the
t is the control
t
(13)
D. Selection
The population and the Qbits are updated in a greedy
fashion. By observing the state of the newly obtained Qbits
(θc
replace the corresponding individual in the population if their
fitness values are higher. The replacement is done using the
following equations:
, ( ()
,
i
P
⎩
and
, ( ()
,
j i
θ
⎪ ⎩
where P
modified after crossover (θc
corresponding individual.
ji), by (9), a new set of individuals are obtained which
1
( ))
ctctt
t
i
t
ii
i
P if f Pf P
P
otherwise
+
⎧
>
=⎨
(14a)
,
1
,
,
( ))
ct
j i
t
ctt
ii
t
j i
if f P f P
otherwise
θ
⎧
⎪
θ
+
>
=⎨
(14b)
c
i is the ith individual by observing the Qbits
ji). f(Pi) is the fitness value of the
Thus AQDE is an adaptive algorithm, which employs
differential operators on the superposition state of Qbits and
can be applied to binary optimization problems directly. The
pseudo code of AQDE applied to 01 knapsack problem is
given in Fig. 2.
IV. EXPERIMENTAL SETTINGS AND RESULTS
To test the performance of AQDE, it was compared with
both QEA and DBDE on the 01 knapsack problem. In all
test cases, strongly correlated sets of data were considered.
The weights wi, respective prices pi and the knapsack
capacity W were calculated as follows [14].
[1,10]
5,1,2,.....
1
2
i
=
where rand[1,10] generates an integer in {1,2,….,10}
uniformly at random.
For satisfying the constraint of the knapsack problem, the
repair method given in [14] is applied to all the algorithms. If
the constraint is violated, the repair method randomly
chooses an item and removes it from the collection until the
constraint is just satisfied. After that it starts adding items
randomly again. When the constraint is just violated, it
removes the last added item and stops.
Three knapsack problems with 100, 250, and 500 items
were considered with unsorted data obtained as above. For
each knapsack problem, the algorithm was tested for a
population size of 30 and 50. The maximum number of
generations in all cases was chosen as 1000. The mean best
profits of 30 runs and the respective standard deviations
were tabulated (Table I).The variation of mean best profit
with no. of generations were plotted (Fig. 38).
1
i
ii
m
i
w
p
rand
wim
Ww
=
=+=
= ∑
(15)
Table II. Performance comparison on 01 Knapsack
problem
QEA DBDE
Item
size
AQDE
30 50 30 50 30 50
100
600.5
(4.615)
601.8
(3.333)
612.9
(3.208)
614.0
(2.936)
625.6
(3.301)
629.1
(3.147)
250
1423.9
(8.758)
1428.3
(5.427)
1448.1
(5.708)
1452.5
(6.301)
1502.7
(6.834)
1519.4
(5.469)
500
2693.8
(10.77)
2703.3
(3.282)
2735.2
(10.54)
2740.6
(8.204)
2855.2
(14.93)
2898.7
(11.27)
Procedure AQDE for knapsack
begin
t ? 0
initialize Q(t);
make P(t) from Q(t) by (9)
repair P(t)
evaluate fitness of P(t)
while t<T do
t?t+1
determine F and CR by (11) and (13)
apply mutation on Q(t) using (10)
obtain Q’(t) by crossover using (12)
make P’(t) from Q’(t) using (9)
repair P’(t)
evaluate fitness of P(t)
update P(t+1) and Q(t+1) by (14)
end while
end
Figure 2. AQDE pseudo code
Page 5
Figure 3. Population Size= 30, Item Size = 100
Figure 5. Population Size= 30, Item Size = 250
Figure 7. Population Size= 30, Item Size = 500
Figure 4. Population Size= 50, Item Size = 100
Figure 6. Population Size= 50, Item Size = 250
Figure 8. Population Size= 50, Item Size = 500