Beispiel #1
0
        public Planner(
            params City[] cities
            )
        {
            _cities = cities;

            CurrentTemperature = 100000d;
            CoolingRate = 0.0005;
            Generation = 0;

            CurrentSolution = new Tour(_cities);
            BestSolution = CurrentSolution;

            picker = new Random();
        }
Beispiel #2
0
 public bool IsBestThan(Tour other)
 {
     return TotalDistance < other.TotalDistance;
 }
Beispiel #3
0
 private bool ShouldUse(Tour tour)
 {
     return ComputeAcceptanceProbability(tour) > picker.NextDouble();
 }
Beispiel #4
0
 private double ComputeAcceptanceProbability(Tour tour)
 {
     return tour.IsBestThan(CurrentSolution) ?
         1.0 :
         Math.Exp((CurrentSolution.TotalDistance - tour.TotalDistance) / CurrentTemperature);
 }
Beispiel #5
0
 public bool IsBestThan(Tour other)
 {
     return(TotalDistance < other.TotalDistance);
 }
Beispiel #6
0
 private double ComputeAcceptanceProbability(Tour tour)
 {
     return(tour.IsBestThan(CurrentSolution) ?
            1.0 :
            Math.Exp((CurrentSolution.TotalDistance - tour.TotalDistance) / CurrentTemperature));
 }
Beispiel #7
0
 private bool ShouldUse(Tour tour)
 {
     return(ComputeAcceptanceProbability(tour) > picker.NextDouble());
 }