Esempio n. 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();
        }
Esempio n. 2
0
 public bool IsBestThan(Tour other)
 {
     return TotalDistance < other.TotalDistance;
 }
Esempio n. 3
0
 private bool ShouldUse(Tour tour)
 {
     return ComputeAcceptanceProbability(tour) > picker.NextDouble();
 }
Esempio n. 4
0
 private double ComputeAcceptanceProbability(Tour tour)
 {
     return tour.IsBestThan(CurrentSolution) ?
         1.0 :
         Math.Exp((CurrentSolution.TotalDistance - tour.TotalDistance) / CurrentTemperature);
 }
Esempio n. 5
0
 public bool IsBestThan(Tour other)
 {
     return(TotalDistance < other.TotalDistance);
 }
Esempio n. 6
0
 private double ComputeAcceptanceProbability(Tour tour)
 {
     return(tour.IsBestThan(CurrentSolution) ?
            1.0 :
            Math.Exp((CurrentSolution.TotalDistance - tour.TotalDistance) / CurrentTemperature));
 }
Esempio n. 7
0
 private bool ShouldUse(Tour tour)
 {
     return(ComputeAcceptanceProbability(tour) > picker.NextDouble());
 }