Hello! Thanks very much for the interesting paper and especially for providing the reference implementation in Python! It's made it possible for a hobbyist like myself to try the algorithm out.
I'm trying to reproduce the results in another paper (or rather, apply the methods to my own problem) which used COA to optimize the placement of $n$ wireless routers in 2D space1. While testing the algorithm, I noticed that it seemed a bit too difficult to get the minimum cost to converge to satisfactory values - it was taking me around $10^5$ iterations ("function evaluations") to start reaching even the ballpark of the results in the paper, plateauing around 0.2 (I'm using 0..1 for my cost) They got their results with $10^3$ iterations!
So I started stepping through the implementation, and noticed that the initial random values generated for the coyotes were actually out of the VarMin, VarMax
range. I was initially using negative values in VarMin
, which made this pop out.
The possible error
I believe that there are parentheses missing in this statement, which generates the initial random values for each coyote:
|
coyotes = np.tile(VarMin, [pop_total, 1]) + np.random.rand(pop_total, D) * np.tile(VarMax, [pop_total, 1]) - \ |
|
np.tile(VarMin, [pop_total, 1]) |
Due to the missing parentheses, this gets evaluated essentially as min + (random() * max) - min
, instead of the intended min + random() * (max - min)
. This causes the initial random values to be biased towards the maximum, depending on min
and max
.
The latter (min + random() * (max - min)
) is also used when generating the puppies:
|
pup = p1*coyotes_aux[parents[0], :] + \ |
|
p2*coyotes_aux[parents[1], :] + \ |
|
n*(VarMin + np.random.rand(1, D) * (VarMax - VarMin)) |
After changing that line like the following, I started instantly receiving much better results (first sub-0.1 min cost with 20k function evaluations!)
-coyotes = np.tile(VarMin, [pop_total, 1]) + np.random.rand(pop_total, D) * np.tile(VarMax, [pop_total, 1]) - np.tile(VarMin, [pop_total, 1])
+coyotes = np.tile(VarMin, [pop_total, 1]) + np.random.rand(pop_total, D) * (np.tile(VarMax, [pop_total, 1]) - np.tile(VarMin, [pop_total, 1]))