/// <summary> /// A method called when a new common path is created /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void OnNewBestFound(object sender, BestFoundEventArgs args) { BestDistance = args.NewBest.GetDistance(); BestPathSeries.Points.Clear(); foreach (City stop in args.NewBest.Stops) { BestPathSeries.Points.Add(new DataPoint(stop.XPosition, stop.YPosition)); } BestPathInfo.InvalidatePlot(true); NotifyOfPropertyChange(nameof(BestDistance)); }
/// <summary> /// A method triggered by the NewBestTrip event that updates the new best path /// </summary> /// <param name="sender">The solver that sent the event</param> /// <param name="args">The event arguments</param> private void OnNewBestTrip(object sender, BestFoundEventArgs args) { PathSeries.Points.Clear(); foreach (City point in args.NewBest.Stops) { PathSeries.Points.Add(new DataPoint(point.XPosition, point.YPosition)); } ChangeSeries.Points.Add(new DataPoint(args.Generation, 1 / (args.NewBest.Fitness) + 1)); BestDistance = (int)args.NewBest.GetDistance(); NotifyOfPropertyChange(nameof(BestDistance)); PlotInfo.InvalidatePlot(true); ChangeInfo.InvalidatePlot(true); }