protected override MutationMemory Remember(ParameterSet initialExample, ParameterSet mutatedExample) { string focusPath = mutatedExample.GetDifference(initialExample).FieldPath; MutationMemory memory = new MutationMemory(); memory.Lifetime = memory.ResetLifetime = 10; memory.Mutate = delegate(ParameterSet initial) { ParameterSet mutated = initial.Clone(); ParameterValue parameter = mutated.Get(focusPath); Mutate(parameter); return mutated; }; memory.IsRelevant = (initial, mutated) => mutated.GetDifference(initial).FieldPath == focusPath; return memory; }
protected override IEnumerable <MutationMemory> InitializeMemory() { foreach (string parameterPath in ParameterPaths) { string parameterPathCopy = parameterPath; MutationMemory memory = new MutationMemory(); memory.Lifetime = memory.ResetLifetime = 20; memory.Mutate = delegate(ParameterSet initial) { ParameterSet mutated = initial.Clone(); ParameterValue parameter = mutated.Get(parameterPathCopy); Mutate(parameter); return(mutated); }; memory.IsRelevant = (initial, mutated) => mutated.GetDifference(initial).FieldPath == parameterPathCopy; yield return(memory); } }
public ParameterSet Mutate(ParameterSet initial) { var advices = (from advisor in Advisors from repeat in Enumerable.Range(0, MultipleAdvices) from advice in advisor.Advise(initial) select advice).ToList(); AdjustExtractorWeight(advices); ParameterSet mutated = PickAdvice(advices).Mutated; string mutatedPath = mutated.GetDifference(initial).FieldPath; if (OnMutation != null) { OnMutation(initial.Get(mutatedPath), mutated.Get(mutatedPath)); } return(mutated); }