@Override
	public void run(int iterations) {
		// Do iterations
		for (int i = 0; i < iterations; i++) {
			// Find the best 5 paths of the generated paths

			LimitedPriorityQueue lpq = new LimitedPriorityQueue(queueLimit,
					new Double(1));

			// shortestPathLength.
			ArrayList<int[][]> chromosomes = getChromosomes();

			for (int j = 0; j < chromosomes.size(); j++) {
				double length = fitness(chromosomes.get(j));
				lpq.push(j, new Double(length));
			}
			if (i % 1000 == 0) {
				lpq.printArray(i);
				//System.out.println("ZeroDeltaIterations: " + zeroDeltaIterations);
				System.out.println("Best path: " + fitness(bestPath));
			}

			int[] indices = lpq.getIndices();

			// Cross the values over to form new paths
			// System.out.println("Iterations without change: " +
			// zeroDeltaIterations + ". Swapping with probability: " +
			// (probability + zeroDeltaIterations * zeroDeltaAddition));
			pmx(indices);

			if (fitness(chromosomes.get(indices[0])) < fitness(bestPath))
				bestPath = chromosomes.get(indices[0]);
			
			// If iterations > 1000 then we keep the first 2 and scrap the rest.
			if (zeroDeltaIterations == 5000) {
				// If we've had 10,000 iterations with no change. Scrap all
				// (keep the best?)
				// We're probably stuck in a local minima

				randomise();
				//for (int k = 0; k < 30; k++) {
				//	chromosomes.add(generateRandomPath());
				//}
				zeroDeltaIterations = 0;
			} else if (zeroDeltaIterations % 300 == 0 && zeroDeltaIterations >= 300) {
				// We've probably hit a local minima, so generate a lot more
				// random ones
				int[][] pathA = chromosomes.get(indices[0]);
				// int[][] pathB = chromosomes.get(1);
				chromosomes.clear();
				chromosomes.add(pathA);
				// chromosomes.add(pathB);
				for (int k = 0; k < 200; k++) {
					chromosomes.add(generateRandomPath());
				}

			} /*else if (zeroDeltaIterations % 500 == 0) {
				int[][] pathA = chromosomes.get(indices[0]);
				int[][] pathB = chromosomes.get(indices[1]);
				chromosomes.clear();
				chromosomes.add(pathA);
				chromosomes.add(pathB);
				for (int k = 0; k < 15; k++) {
					// Add a copy of the existing path
					chromosomes.add(pathA);
				}
			}*/

			double delta = fitness(chromosomes.get(indices[0])) - prevWeight;
			if (Math.abs(delta) < 0.2) {
				zeroDeltaIterations++;
			} else {
				zeroDeltaIterations = 0;
			}

			prevWeight = fitness(chromosomes.get(indices[0]));
			weights.add(new Double(fitness(bestPath)));
		}

	}