示例#1
0
        public override float EvaluateTestCase(GAIndividual inIndividual, object inInput, object inOutput)
        {
            _effort++;
            _interpreter.ClearStacks();
            _currentInput = (float)inInput;
            FloatStack fstack = _interpreter.FloatStack();

            fstack.Push(_currentInput);
            // Must be included in order to use the input stack.
            _interpreter.InputStack().Push(_currentInput);
            _interpreter.Execute(((PushGPIndividual)inIndividual)._program, _executionLimit);
            float result = fstack.Top();

            // System.out.println( _interpreter + " " + result );
            //trh

            /*
             * System.out.println("\nevaluations according to interpreter " +
             * Interpreter.GetEvaluationExecutions());
             * System.out.println("evaluations according to effort " + _effort);
             */
            // Penalize individual if there is no result on the stack.
            if (fstack.Size() == 0)
            {
                return(_noResultPenalty);
            }
            return(result - ((float)inOutput));
        }
示例#2
0
        public override void Execute(Interpreter interpeter)
        {
            FloatStack stack = interpeter.FloatStack();

            if (stack.Size() > 0)
            {
                Console.Error.WriteLine(stack.Top());
            }
            else
            {
                Console.Error.WriteLine("empty");
            }
        }
        public override float EvaluateTestCase(GAIndividual inIndividual, object inInput, object inOutput)
        {
            _interpreter.ClearStacks();
            _currentInput = (float)inInput;
            FloatStack stack = _interpreter.FloatStack();

            stack.Push(_currentInput);
            _interpreter.Execute(((PushGPIndividual)inIndividual)._program, _executionLimit);
            float result = stack.Top();

            // System.out.println( _interpreter + " " + result );
            return(result - ((float)inOutput));
        }
        public override float EvaluateTestCase(GAIndividual inIndividual, object inInput, object inOutput)
        {
            _interpreter.ClearStacks();
            float      currentInput = (float)inInput;
            FloatStack stack        = _interpreter.FloatStack();

            stack.Push(currentInput);
            // Must be included in order to use the input stack.
            _interpreter.InputStack().Push(currentInput);
            _interpreter.Execute(((PushGPIndividual)inIndividual)._program, _executionLimit);
            float result = stack.Top();

            // Penalize individual if there is no result on the stack.
            if (stack.Size() == 0)
            {
                return(_noResultPenalty);
            }
            return(result - ((float)inOutput));
        }
        public virtual float GetIndividualTestCaseResult(GAIndividual inIndividual, GATestCase inTestCase)
        {
            _interpreter.ClearStacks();
            float      currentInput = (float)inTestCase._input;
            FloatStack stack        = _interpreter.FloatStack();

            stack.Push(currentInput);
            // Must be included in order to use the input stack.
            _interpreter.InputStack().Push(currentInput);
            _interpreter.Execute(((PushGPIndividual)inIndividual)._program, _executionLimit);
            float result = stack.Top();

            // If no result, return 0
            if (stack.Size() == 0)
            {
                return(0);
            }
            return(result);
        }