Beispiel #1
0
        public override double Evaluate(IBlackBox net)
        {
            if (net.InputCount != 2 || net.OutputCount != 1)
            {
                throw new IndexOutOfRangeException();
            }
            var    inputs = MutationService.Shuffle(Inputs, RandomizationProvider.Current);
            double error  = 0;

            foreach (var ins in inputs)
            {
                net.Reset();
                net.SetInputs(ins);
                net.Activate(3);
                double output   = net.GetOutput(0);
                double expected = (ins[0] == ins[1]) ? 0 : 1;
                double diff     = output - expected;
                error += (diff >= 0) ? diff : -diff;
            }
            return(4 - error);
        }