コード例 #1
0
        void InitializeValues()
        {
            totalCities = SharedMethods.TotalCities;

            tourOrder     = new int[totalCities];
            tourLocations = new Vector2[totalCities];

            (tourLocations, tourOrder) = SharedMethods.InitializeLocations(totalCities, random);

            SharedMethods.Order.CopyTo(tourOrder, 0);
            SharedMethods.Locations.CopyTo(tourLocations, 0);

            SharedMethods.DrawPoints(pointsGrid);

            initialDistance = SharedMethods.RoundTripDistance(tourLocations, tourOrder);

            populationSize = SharedMethods.PopulationSize;
            mutationRate   = SharedMethods.MutationRate;
            elitism        = SharedMethods.Elitism;

            count = 0;

            ga = null;
            ga = new GAClass(populationSize, totalCities, elitism, random, mutationRate);
        }
コード例 #2
0
        void InitializeValues()
        {
            totalCities = SharedMethods.TotalCities;

            tourOrder     = new int[totalCities];
            tourLocations = new Vector2[totalCities];
            bestTourOrder = new int[totalCities];

            (tourLocations, tourOrder) = SharedMethods.InitializeLocations(totalCities, random);

            SharedMethods.Order.CopyTo(tourOrder, 0);
            SharedMethods.Locations.CopyTo(tourLocations, 0);

            SharedMethods.DrawPoints(pointsGrid);

            initialDistance = SharedMethods.RoundTripDistance(tourLocations, tourOrder);

            bestTourDistance = float.PositiveInfinity;
            swaps            = 0;
        }
コード例 #3
0
        void InitializeValues()
        {
            totalCities = SharedMethods.TotalCities;

            tourOrder     = new int[totalCities];
            tourLocations = new Vector2[totalCities];
            bestTourOrder = new int[totalCities];

            (tourLocations, tourOrder) = SharedMethods.InitializeLocations(totalCities, random);

            SharedMethods.Order.CopyTo(tourOrder, 0);
            SharedMethods.Locations.CopyTo(tourLocations, 0);

            SharedMethods.DrawPoints(pointsGrid);

            initialDistance = SharedMethods.RoundTripDistance(tourLocations, tourOrder);
            totalIterations = SharedMethods.Factorial(totalCities);

            currentIteration = 0;
            bestTourDistance = double.PositiveInfinity;
        }
コード例 #4
0
        void InitializeValues()
        {
            totalCities = SharedMethods.TotalCities;

            tourOrder     = new int[totalCities];
            tourLocations = new Vector2[totalCities];

            (tourLocations, tourOrder) = SharedMethods.InitializeLocations(totalCities, random);

            SharedMethods.Order.CopyTo(tourOrder, 0);
            SharedMethods.Locations.CopyTo(tourLocations, 0);

            SharedMethods.DrawPoints(pointsGrid);

            initialDistance = SharedMethods.RoundTripDistance(tourLocations, tourOrder);

            Temperature     = SharedMethods.Temperature;
            TemperatureRate = SharedMethods.TemperatureRate;

            count = 0;
        }