// Run an algorithm a specified number of times, returning the shortest route length found and the average. public static double[] RunTrials(Algorithm toRun) { double shortest = double.PositiveInfinity; double total = 0.0; for (int i = 0; i < Trials; i++) { toRun.Reset(); Route result = toRun.Run(); if (result.Count != City.Count) { throw new BadRouteException(result.Count, toRun); } shortest = result.Length < shortest ? result.Length : shortest; total += result.Length; } return(new double[] { shortest, total / (double)Trials }); }