1 package aco
.strategy
.eas
;
6 import aco
.mediator
.eas
.*;
8 public class EASPheromoneStrategy
9 extends PheromoneStrategy
{
11 protected EASMediator acom
;
13 public EASPheromoneStrategy(ACOMediator acom
) {
17 public void pheromoneUpdate(Ant
[] ants
) {
20 for (Ant ant
: ants
) {
21 this.depositPheromone(ant
);
26 acom
.computeChoiceInformation();
29 protected void enforceGlobalBest() {
30 /* enforcement of global best route */
32 for (int i
= 0; i
< acom
.getNumOfCities(); i
++) {
33 j
= acom
.getGlobalBestTour(i
);
34 l
= acom
.getGlobalBestTour(i
+1);
35 acom
.setPheromone( j
, l
, (acom
.getPheromone(j
,l
) +
36 acom
.getE()/(double)acom
.getGlobalBestTourLength()) );
40 protected void depositPheromone(Ant ant
) {
41 double dt
= 1.0/(double)ant
.getTourLength();
44 for (int i
= 0; i
< acom
.getNumOfCities(); i
++) {
47 /* setPheromone will update j,l and l,j */
48 acom
.setPheromone( j
, l
, (acom
.getPheromone(j
,l
) + dt
) );
52 protected void evaporate() {
53 for (int i
= 1; i
< acom
.getNumOfCities(); i
++) {
54 for (int j
= 1; j
< acom
.getNumOfCities(); j
++) {
55 acom
.setPheromone(i
, j
,
56 (1.0 - acom
.getRoh()) * acom
.getPheromone(i
, j
) );