public void MergeNewGeneration() { SortedMeals.UnionWith(Children); if (SortedMeals.Count != Count) { throw new Exception(); } Children = new OrderedBag <IMeal>(); }
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; } }
public IMeal GetFittest() { return(SortedMeals.First()); }
public IMeal GetRandomMember() { return(SortedMeals.ElementAt(MyRandom.Next(SortedMeals.Count))); }