*/
public void solve() {
StringBuilder builder = new StringBuilder();
initCities();
DiscreteACO aco = new DiscreteACO(this, 50);
int sameSolutionCount = 0;
int iteration = 1;
double lastSolution = Double.MAX_VALUE;
while (sameSolutionCount < MAX_SAME_SOLUTION) {
aco.iteration();
double thisSolution = aco.getBestCost();
builder.setLength(0);
builder.append("Iteration: ");
builder.append(iteration++);
builder.append(", Best Path Length = ");
builder.append(thisSolution);
System.out.println(builder.toString());
if (Math.abs(lastSolution - thisSolution) < 1.0) {
sameSolutionCount++;
} else {
sameSolutionCount = 0;
}
lastSolution = thisSolution;
}
System.out.println("Good solution found:");
int[] best = aco.getBestTour();
displaySolution(best);
}