6 public class EASPheromoneStrategy
7 extends PheromoneStrategy
{
9 public EASPheromoneStrategy(ACOMediator acom
) {
13 public void pheromoneUpdate(Ant
[] ants
) {
16 for (Ant ant
: ants
) {
17 this.depositPheromone(ant
);
20 int e
= acom
.getNumOfCities();
23 /* enforcement of global best route */
24 for (int i
= 0; i
< acom
.getNumOfCities(); i
++) {
25 j
= acom
.getGlobalBestTour(i
);
26 l
= acom
.getGlobalBestTour(i
+1);
27 acom
.setPheromone( j
, l
, (acom
.getPheromone(j
,l
) +
28 e
/acom
.getGlobalBestTourLength()) );
31 acom
.computeChoiceInformation();
34 protected void depositPheromone(Ant ant
) {
35 double dt
= 1.0/ant
.getTourLength();
38 for (int i
= 0; i
< acom
.getNumOfCities(); i
++) {
41 /* setPheromone will update j,l and l,j */
42 acom
.setPheromone( j
, l
, (acom
.getPheromone(j
,l
) + dt
) );
46 protected void evaporate() {
47 for (int i
= 1; i
< acom
.getNumOfCities(); i
++) {
48 for (int j
= 1; j
< acom
.getNumOfCities(); j
++) {
49 acom
.setPheromone(i
, j
,
50 (1.0 - acom
.getRoh()) * acom
.getPheromone(i
, j
) );