Ant Colony Optimization for Continuous Domains (ACOR)¶
Ant colony optimization for continuous problems. For discrete problems use the classic ant colony algorithms.
ACOR ¶
ACOR(*, sample_count=50, q=0.5, zeta=1.0, **kwargs)
Ant Colony Optimization for Continuous Domains (Socha and Dorigo, 2008).
The archive holds the pop_size best solutions found so far (the paper's k),
sorted from best to worst. Solution l (counted from 1) has the weight
w_l = exp(-(l - 1)^2 / (2 q^2 k^2)) / (q k sqrt(2 pi)). Each new solution picks one
guide l with probability proportional to w_l and samples every component i from a
normal distribution with mean s_l,i and standard deviation
zeta * sum_e |s_e,i - s_l,i| / (k - 1). The new solutions are merged with the archive
and the best k are kept.
Parameters
pop_size: archive size ksample_count: number of new solutions (ants) per iteration (the paper's m)q: intensification factor. Small values favor the best solutions.zeta: deviation distance ratio (the paper's xi). Larger values slow convergence.
The paper's tuned values (k = 50, m = 2, q = 0.0001, xi = 0.85) did no better overall than the defaults on benchmark tests. Unlike the paper, which rotates the coordinate system of each ant, every component is sampled along its own axis, so rotated functions are harder.
Reference: Socha, K. and Dorigo, M. (2008). Ant colony optimization for continuous domains. European Journal of Operational Research, 185(3), 1155 to 1173.
Example¶
import ypea
problem = ypea.Problem(
ypea.Real("x", shape=20, lb=-10, ub=10),
lambda sol: ypea.benchmarks.sphere(sol.x),
vectorized=True,
name="sphere",
)
alg = ypea.ACOR(max_nfe=20_000)
result = alg.solve(problem, seed=1)
print(result.summary())
ACOR on sphere
best objective value: 3.4107
feasible: True (violation 0)
evaluations: 20000, iterations: 398, time: 0.308 s, stopped by: max_nfe
Differs from Python: MATLAB draws its own random numbers, so the best value differs from Python's.
problem = ypea.Problem( ...
vars=ypea.Real("x", shape=20, lb=-10, ub=10), ...
objective=@(sol) ypea.benchmarks.sphere(sol.x), ...
vectorized=true, ...
name="sphere");
alg = ypea.ACOR(max_nfe=20000);
result = alg.solve(problem, seed=1);
disp(result.summary())
ACOR on sphere
best objective value: 4.36762
feasible: true (violation 0)
evaluations: 20000, iterations: 398, time: 0.246 s, stopped by: max_nfe
Search on Rastrigin¶