public void neighbors_should_have_expected_coordinates() { FlightDatabase db = new FlightDatabase(GetFlightDataPath()); Meeting m = new Meeting(3712, db); SolutionInstance sol = m.GetRandomInstance(); IReadOnlyList <int> originalCoordinates = sol.Coordinates; IEnumerable <SolutionInstance> neighbors = sol.Neighbors; neighbors.Count().Should().BeInRange(18, 36); // If no degenerate case // Check for uniqueness of neighbor List <int[]> coordinatesOfNeighbors = new List <int[]>(); foreach (var neighbor in neighbors) { coordinatesOfNeighbors.Add(neighbor.Coordinates.ToArray()); } // Every set of coordinate should be unique coordinatesOfNeighbors.Distinct().Count().Should().Be(coordinatesOfNeighbors.Count()); // Verifying that the distance is one (we have only moved one point in one of the 18 axes foreach (var coordinates in coordinatesOfNeighbors) { coordinates.Zip(originalCoordinates, (one, two) => Math.Abs(one - two)).Sum().Should().Be(1); } int i = coordinatesOfNeighbors.Count(); }
public void simple_MonteCarlo() { FlightDatabase db = new FlightDatabase(GetFlightDataPath()); Meeting m = new Meeting(3712, db); var x = m.GetRandomInstance(); var b = x.GetBestMonteCarlo(); b.Cost.Should().BeLessOrEqualTo(x.Cost); }
public void run_algo() { FlightDatabase db = new FlightDatabase( GetFlightDataPath() ); Meeting m = new Meeting( 3712, db ); for( int i = 0; i < 1000; i++ ) { m.GetRandomInstance(); } Console.WriteLine( m.BestResult ); }