예제 #1
0
 // Saves a tour
 public void saveTour(int index, Tour tour)
 {
     tours[index] = tour;
 }
예제 #2
0
        public Population(int populationSize, Boolean initialise, Paths pgs, IntPoint m_startPoint, Tour greedtour)
        {
            this.oripaths   = pgs; //保存传入的路劲集合,用来计算适应度,及距离
            this.startPoint = m_startPoint;

            tours = new Tour[populationSize];        //种群路劲集合

            int greedseedsize = 15;

            // If we need to initialise a population of tours do so
            if (initialise)
            {
                for (int j = 0; j < greedseedsize; j++)
                {
                    saveTour(j, greedtour);
                }

                // Loop and create individuals
                for (int i = greedseedsize; i < populationSize; i++)
                {
                    Tour newTour = new Tour(pgs.Count);
                    newTour.generateIndividual();
                    saveTour(i, newTour);
                }
            }
        }