-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAntColonyOptimization.java
35 lines (26 loc) · 1.11 KB
/
AntColonyOptimization.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
public class AntColonyOptimization {
public static void main(String[] args) {
Methods m= new Methods();
DataSet ds=new DataSet();
boolean initialized = false;
for(int i=0;i<3;i++){
if(initialized==false){
ds.setDistance(m.initDistance(ds.getDistance()));
m.initTau(ds.getTau());
initialized=true;
}else{
ds.setDistance(m.initDistance(ds.getDistance()));
}
ds.setEta(m.initEta(ds.getDistance()));
System.out.println("\nMatrix visibility (H):");
m.printMatrix(ds.getEta());
ds.setRouteAnt(m.calculateProbability(ds.getTau(),ds.getEta()));
System.out.printf("Route ant %d: ",i+1);
m.printRoute(ds.getRouteAnt());
m.pheromoneMatrix(m.calculateTotalDistance(ds.getRouteAnt()), ds.getTau(),ds.getRouteAnt());
System.out.println("New Tau Matrix:");
m.printMatrix(ds.getTau());
System.out.println(m.convertToString(ds.getRouteAnt()));
}
}
}