public Planner( params City[] cities ) { _cities = cities; CurrentTemperature = 100000d; CoolingRate = 0.0005; Generation = 0; CurrentSolution = new Tour(_cities); BestSolution = CurrentSolution; picker = new Random(); }
public bool IsBestThan(Tour other) { return TotalDistance < other.TotalDistance; }
private bool ShouldUse(Tour tour) { return ComputeAcceptanceProbability(tour) > picker.NextDouble(); }
private double ComputeAcceptanceProbability(Tour tour) { return tour.IsBestThan(CurrentSolution) ? 1.0 : Math.Exp((CurrentSolution.TotalDistance - tour.TotalDistance) / CurrentTemperature); }
public bool IsBestThan(Tour other) { return(TotalDistance < other.TotalDistance); }
private double ComputeAcceptanceProbability(Tour tour) { return(tour.IsBestThan(CurrentSolution) ? 1.0 : Math.Exp((CurrentSolution.TotalDistance - tour.TotalDistance) / CurrentTemperature)); }
private bool ShouldUse(Tour tour) { return(ComputeAcceptanceProbability(tour) > picker.NextDouble()); }