private static void TestGA() { TSP tsp = VRPLoader.readTSP(vrps[0]); List <(double, double, double)> stats; List <int> bestSolution; (bestSolution, stats) = GA.Run(tsp, 100, 100, 0.7, 0.1, 5); Console.WriteLine("Solution: " + ListToString(bestSolution)); Console.WriteLine("Distance: " + tsp.Evaluate(bestSolution).ToString()); }
private static void LogStats() { string s = "problem;generation;best;worst;average\n"; foreach (string filename in vrps) { TSP evaluation = VRPLoader.readTSP(filename); List <(double, double, double)> stats; (_, stats) = GA.Run(evaluation, 100, 100, 0.6, 0.3, 10); for (int i = 0; i < stats.Count; i++) { s += filename + ";" + i.ToString() + ";" + stats[i].Item1.ToString() + ";" + stats[i].Item2.ToString() + ";" + stats[i].Item3.ToString() + "\n"; } } File.WriteAllText("stats-test.csv", s); }
private static List <double> TestPopSize(TSP evaluation, int repeats) { List <(double, double, double)> stats; List <int> bestSolution; List <int> range = new List <int>(); List <double> results = new List <double>(); for (int i = 0; i < 10; i++) { range.Add(100 * (i + 1)); } foreach (int prob in range) { List <double> scores = new List <double>(); for (int i = 0; i < repeats; i++) { (bestSolution, stats) = GA.Run(evaluation, prob, 100, 0.7, 0.1, 5); scores.Add(stats[stats.Count - 1].Item1); } results.Add(Median(scores)); } File.WriteAllText(".\\popsize-test.csv", ResultsToString(range, results)); return(results); }