some Makefiles
[aco.git] / aco / strategy / as / ASPheromoneStrategy.java
blob51a24238769e1e35e714b0676d7d71af922cd20e
1 package aco.strategy.as;
3 import aco.ant.*;
4 import aco.strategy.*;
5 import aco.mediator.*;
7 public class ASPheromoneStrategy
8 extends PheromoneStrategy {
10 public ASPheromoneStrategy(ACOMediator acom) {
11 super(acom);
14 public void pheromoneUpdate(Ant[] ants) {
15 this.evaporate();
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();
26 int j = 0;
27 int l = 0;
28 for (int i = 0; i < acom.getNumOfCities(); i++) {
29 j = ant.getTour(i);
30 l = ant.getTour(i+1);
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) );