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