MutationMemory CreateMemory() { MutationMemory memory = new MutationMemory(); memory.Mutate = Mutate; return(memory); }
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 void Feedback(ParameterSet initial, ParameterSet mutated, bool improved) { foreach (MutationMemory memory in Live) { if (memory.IsRelevant(initial, mutated)) { memory.Feedback(improved); return; } } if (improved) { MutationMemory added = Remember(initial, mutated); if (added != null) { Live.Add(added); } } }