172 Agent-Based Modeling and Simulation with Swarm
Step 4 If t is a multiple of T (T -p e riodical), then execute the GA algorithm
(described below) called BUGS-GA(t), and then go to Step 6.
Step 5 P op(t + 1) := P op(t), t := t + 1, and then go to Step 2.
Step 6 for i := 1 to N do e
i
(t) := 0
t := t + 1. Go to Step 2.
In Step 1, initial bugs are generated on conditions that fo r all i and j,
x
i
j
(0) := Random(a, b) (6.32)
dx
i
j
(0) := Random(−|a − b|, |a − b|) (6.33)
e
i
(0) := 0 (6.34 )
where Random(a,b) is a uniform random genera tor between a and b. The
BUGS-GA period T sp e c ifies the frequency of bug reproductions. In general,
as this value becomes smaller, the perfor mance becomes better, but at the
same time, the converg e nce time is increased.
For real-valued function optimization, real- valued GAs are preferred over
string-based GAs (see [58] for details). Therefore, the real-va lued GA approach
is used in BUGS-GA. The BUGS version of the genetic algorithm, BUGS-
GA(t), is as follows (Table 6.5):
Step 1 n := 1.
Step 2 Select two parent bugs Bug
i
(t) and Bug
j
(t) using a probability dis-
tribution over the energies of all bugs in P op(t) so tha t bugs with hig her
energy are selected more frequently.
Step 3 With probability P
cross
, apply the uniform crossover operation to the
~
DX of copies of Bug
i
(t) and Bug
j
(t), forming two offspring Bug
n
(t+1)
and Bug
n+1
(t + 1) in P op(t + 1). Go to Step 5.
Step 4 If Step 3 is skipped, form two offspring Bug
n
(t+1) and Bug
n+1
(t+1)
in P op(t + 1) by making copies of Bug
i
(t) and Bug
j
(t).
Step 5 With probability P
asex
, a pply the mutation operation to the two off-
spring Bug
n
(t + 1) and Bug
n+1
(t + 1), changing each allele in
~
DX with
probability P
mut
.
Step 6 n := n + 2.
Step 7 If n < N then go to Step 2.
The aim of the BUGS-GA subroutine is to acquire bugs’ behavior adap-
tively. T his subroutine works in much the same way as a real-valued GA,
except that it operates on the directional vector (
~
DX), not on the positional