Esempio n. 1
0
 public void MergeNewGeneration()
 {
     SortedMeals.UnionWith(Children);
     if (SortedMeals.Count != Count)
     {
         throw new Exception();
     }
     Children = new OrderedBag <IMeal>();
 }
Esempio n. 2
0
 public void RemoveNotFit()
 {
     if (RemovePart <= 0.5)
     {
         var removeKeys = SortedMeals.Skip(KeepCount).ToList(); // first is best
         foreach (var key in removeKeys)
         {
             SortedMeals.Remove(key);
         }
     }
     else
     {
         var keepKeys           = SortedMeals.Take(KeepCount).ToList(); // last is worst
         var newSortedKnapsacks = new OrderedBag <IMeal>();
         foreach (var key in keepKeys)
         {
             newSortedKnapsacks.Add(key);
         }
         SortedMeals = newSortedKnapsacks;
     }
 }
Esempio n. 3
0
 public IMeal GetFittest()
 {
     return(SortedMeals.First());
 }
Esempio n. 4
0
 public IMeal GetRandomMember()
 {
     return(SortedMeals.ElementAt(MyRandom.Next(SortedMeals.Count)));
 }