1 package aco
.strategy
.as
;
7 public class ASPheromoneStrategy
8 extends PheromoneStrategy
{
10 public ASPheromoneStrategy(ACOMediator acom
) {
14 public void pheromoneUpdate(Ant
[] ants
) {
17 for (Ant ant
: ants
) {
18 this.depositPheromone(ant
);
21 acom
.computeChoiceInformation();
24 protected void depositPheromone(Ant ant
) {
25 double dt
= 1.0/ant
.getTourLength();
28 for (int i
= 0; i
< acom
.getNumOfCities(); i
++) {
31 /* setPheromone will update j,l and l,j */
32 acom
.setPheromone( j
, l
, (acom
.getPheromone(j
,l
) + dt
) );
36 protected void evaporate() {
37 for (int i
= 0; i
< acom
.getNumOfCities(); i
++) {
38 for (int j
= 0; j
< acom
.getNumOfCities(); j
++) {
39 acom
.setPheromone(i
, j
,
40 (1.0 - acom
.getRoh()) * acom
.getPheromone(i
, j
) );