Esempio n. 1
0
 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)));
 }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
 public static void SetBestSortablePool(this Dictionary <string, object> dictionary,
                                        SortablePool bestSortablePool)
 {
     dictionary[kBestSortablePool] = bestSortablePool;
 }
Esempio n. 4
0
 public static void SetSortablePool(this Dictionary <string, object> dictionary, SortablePool sorterPool)
 {
     dictionary[kSortablePool] = sorterPool;
 }