Ejemplo n.º 1
0
        MutationMemory CreateMemory()
        {
            MutationMemory memory = new MutationMemory();

            memory.Mutate = Mutate;
            return(memory);
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
 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);
     }
 }
Ejemplo n.º 4
0
        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);
                }
            }
        }