Exemplo n.º 1
0
 public Mypermutation(Mypermutation item)
 {
     this.permutation       = item.permutation;
     this.permutationLength = item.permutationLength;
     this.utility           = item.utility;
     rnd = new Random();
 }
Exemplo n.º 2
0
        private Mypermutation[] Populate(int permutationLength, int populationsize)
        {
            Mypermutation[] population = new Mypermutation[populationsize];

            for (int i = 0; i < populationsize; i++)
            {
                population[i] = new Mypermutation(permutationLength);
            }
            return(population);
        }
Exemplo n.º 3
0
        private void CrossOver(Mypermutation first, Mypermutation second)
        {
            int crosspoint = rnd.Next(0, first.permutationLength);

            int[] temp = new int[first.permutationLength];

            Array.Copy(second.permutation, 0, temp, 0, first.permutationLength);

            Array.Copy(first.permutation, 0, second.permutation, 0, crosspoint);

            Array.Copy(temp, 0, first.permutation, 0, crosspoint);
        }