static void Main(string[] args) { TSP tsp = new TSP(CITIES_NUM, ANTS_NUM, ALPHA, BETA, RHO, PHEROMONE_QUANTITY); double antColonyBestTour = Solve(tsp); tsp.Alpha = 0; tsp.Beta = 0; double bestRandomTour = Solve(tsp); Console.WriteLine("Best distance using Ant Colony: " + antColonyBestTour); Console.WriteLine("Best distance using Random algorithm: " + bestRandomTour); Console.ReadLine(); }
public static double Solve(TSP tsp) { double bestTour = 0; for (int t = 0; t < ITERATION_NUM; t++) { for (int k = 0; k < ANTS_NUM; k++) { for (int i = 0; i < CITIES_NUM; i++) { tsp.Ants[k].VisitNextCity(); } } bestTour = tsp.GetBestTourDistance(); tsp.UpdatePheromoneTrail(); tsp.InitializeAntsTour(); } tsp.BestTourDistance = double.MaxValue; return(bestTour); }