public GaDualSorter(GenomePool <GenomeSorterDual> genomePoolDualSorter, SortablePool sortablePool, IRando randy) { SortablePool = sortablePool; GenomePoolDualSorter = genomePoolDualSorter; SorterPool = new SorterPool(id: Guid.NewGuid(), sorters: GenomePoolDualSorter.SelectMany( gds => gds.MakePhenotypes(randy, 1))); }
public static GaDualSorter EvolveSortables(this GaDualSorter gaDualSorter, Dictionary <Guid, SortableResult> sortableResults, IRando randy, double replacementRate) { var winSortablesCount = (int)(gaDualSorter.SortablePool.Count() * (1.0 - replacementRate)); var looseSortablesCount = gaDualSorter.SortablePool.Count() - winSortablesCount; var newSortables = Enumerable.Range(0, looseSortablesCount) .Select(i => randy.ToPermutation(gaDualSorter.SorterPool.Order).ToSortable()); var bestSortables = sortableResults.Values .OrderByDescending(r => r.AverageSortedness) .Take(winSortablesCount) .Select(sr => sr.Sortable); var newSortablePool = new SortablePool(Guid.NewGuid(), bestSortables.Concat(newSortables)); return(new GaDualSorter( genomePoolDualSorter: gaDualSorter.GenomePoolDualSorter, sortablePool: newSortablePool, randy: randy)); }
public static void SetBestSortablePool(this Dictionary <string, object> dictionary, SortablePool bestSortablePool) { dictionary[kBestSortablePool] = bestSortablePool; }
public static void SetSortablePool(this Dictionary <string, object> dictionary, SortablePool sorterPool) { dictionary[kSortablePool] = sorterPool; }