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
| public class Main { public static void main(String[] args) { int[][] distanceMatrix = new int[][]{{0, 1, 3, 1}, {1, 0, 3, 2}, {3, 3, 0, 2}, {1, 2, 2, 0}}; double[][] pheromoneMatrix = new double[4][4]; for(int i=0; i<distanceMatrix.length; i++) { for(int j=0; j<distanceMatrix.length; j++) { pheromoneMatrix[i][j] = 0.1; } } List<Integer> citys = new ArrayList<Integer>(); for(int i=0; i<4; i++) { citys.add(i+1); } ACO aco = new ACO(citys, pheromoneMatrix, distanceMatrix, 50, 6); aco.run(); System.out.println(aco.getBestRoute()); System.out.println(aco.getBestLength()); } }
|