Exemple #1
0
        public EAAlgorithm(int populationSize = 10, int elitesNumber = 2, int crossoverNumber = 5, double mutationPr = 0.2)
        {
            Festival       = DataLoader.LoadData("test");
            BestSolution   = new Solution(Festival);
            PopulationSize = populationSize;
            Population     = new List <Solution>(PopulationSize);
            NewPopulation  = new List <Solution>(PopulationSize);

            _ElitesNumber    = elitesNumber;
            _CrossoverNumber = crossoverNumber;
            _MutationPr      = mutationPr;

            for (int i = 0; i < PopulationSize; ++i)
            {
                Population.Add(new Solution(Festival, RandomGen));
            }
        }
Exemple #2
0
 public Solution(Festival festival, Random randomGen = null)
 {
     Ppl        = festival.People;
     Shifts     = festival.Shifts;
     Loc        = festival.Locations;
     Assignment = new Dictionary <Person, List <Shift> >();
     if (randomGen != null)
     {
         RandomGen = randomGen;
     }
     else
     {
         RandomGen = new Random();
     }
     Fitness = null;
     foreach (var person in Ppl)
     {
         Assignment.Add(person, new List <Shift>());
     }
     CreateRandom();
 }