public static ISgMutantProfile ToSgMutantProfile ( this ISorterGenomeEval parentGenomeEval, ISorterMutateParams sorterMutateParams ) { var rando = Rando.Fast(sorterMutateParams.Seed); var layer = SorterLayer.Make(new[] { parentGenomeEval.SorterGenome }, 0) .Reproduce( seed: rando.NextInt(), newGenomeCount: sorterMutateParams.MutantCount, mutationRate: sorterMutateParams.SorterMutationRate, insertionRate: sorterMutateParams.SorterInsertionRate, deletionRate: sorterMutateParams.SorterDeletionRate ); var compPool = CompPool.MakeEmpty(parentGenomeEval.SorterGenome.KeyCount) .AddSorterEvalsParallel(layer.Genomes.Select(g => g.ToSorter())); return(new SgMutantProfileImpl( parentGenomeEval: parentGenomeEval, sorterGenomeEvals: compPool.SorterEvals.Where(ev => ev.SwitchUseCount <= sorterMutateParams.MaxScore) .Select(ev => SorterGenomeEval.Make ( sorterGenome: layer.GetGenome(ev.Sorter.Guid), parentGenomeEval: parentGenomeEval, sorterEval: ev, generation: 1, success: ev.Success )), scores: compPool.SorterEvals.Select(ev => (double)ev.SwitchUseCount), sorterMutateParams: sorterMutateParams )); }
public SgMutantProfileImpl( ISorterGenomeEval parentGenomeEval, IEnumerable <ISorterGenomeEval> sorterGenomeEvals, IEnumerable <double> scores, ISorterMutateParams sorterMutateParams ) { _parentGenomeEval = parentGenomeEval; _sorterGenomeEvals = sorterGenomeEvals.ToList(); _scores = scores.ToList(); _sorterMutateParams = sorterMutateParams; }
public static SorterGenomeEvalToJson ToJsonAdapter(this ISorterGenomeEval sorterGenomeEval) { var chromosomeUintToJson = new SorterGenomeEvalToJson { SorterGenomeToJson = sorterGenomeEval.SorterGenome.ToJsonAdapter(), SorterEvalToJson = sorterGenomeEval.SorterEval.ToJsonAdapter(), ParentScores = sorterGenomeEval.Ancestors, Generation = sorterGenomeEval.Generation, Score = sorterGenomeEval.Score }; return(chromosomeUintToJson); }
public static ISorterGenomeEval Make( ISorterGenome sorterGenome, ISorterGenomeEval parentGenomeEval, ISorterEval sorterEval, int generation, bool success ) { return(Make ( sorterGenome: sorterGenome, ancestors: (parentGenomeEval == null) ? ImmutableStack <int> .Empty : parentGenomeEval.Ancestors.Push ( sorterEval.SwitchUseCount ), sorterEval: sorterEval, generation: generation, success: success )); }
public static ISorterGenomeEvalVm ToSorterGenomeEvalVm(this ISorterGenomeEval sorterGenomeEval) { return(new SorterGenomeEvalVmImpl(sorterGenomeEval)); }
public SorterGenomeEvalVmImpl(ISorterGenomeEval sorterGenomeEval) { _sorterGenomeEval = sorterGenomeEval; }
public static string ToJsonString(this ISorterGenomeEval sorterGenome) { return(JsonConvert.SerializeObject(sorterGenome.ToJsonAdapter(), Formatting.None)); }