示例#1
0
        public virtual void RunTestProgram(Program p, int inTestCaseIndex)
        {
            PushGPIndividual i    = new PushGPIndividual(p);
            GATestCase       test = _testCases[inTestCaseIndex];

            Console.Out.WriteLine("Executing program: " + p);
            EvaluateTestCase(i, test._input, test._output);
            Console.Out.WriteLine(_interpreter);
        }
示例#2
0
        protected internal virtual void EvaluateIndividual(GAIndividual inIndividual, bool duringSimplify)
        {
            List <float> errors = new List <float>();

            if (!duringSimplify)
            {
                _averageSize += ((PushGPIndividual)inIndividual)._program.ProgramSize();
            }
            var sw = Stopwatch.StartNew();

            for (int n = 0; n < _testCases.Count; n++)
            {
                GATestCase test = _testCases[n];
                float      e    = EvaluateTestCase(inIndividual, test._input, test._output);
                errors.Add(e);
            }
            // XXX We measure the time but don't do anything with it.
            var t = sw.ElapsedMilliseconds;

            sw.Stop();
            inIndividual.SetFitness(AbsoluteAverageOfErrors(errors));
            inIndividual.SetErrors(errors);
        }