Пример #1
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;
        }
Пример #2
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);
     }
 }
Пример #3
0
        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);
        }