コード例 #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
ファイル: Instructions.cs プロジェクト: lulzzz/BraneCloud
        public override void Execute(Interpreter inI)
        {
            ObjectStack codeStack = inI.CodeStack();
            FloatStack  fStack    = inI.FloatStack();

            if (fStack.Size() > 0)
            {
                codeStack.Push(fStack.Pop());
            }
        }
コード例 #3
0
ファイル: Print.cs プロジェクト: lulzzz/BraneCloud
        public override void Execute(Interpreter interpeter)
        {
            FloatStack stack = interpeter.FloatStack();

            if (stack.Size() > 0)
            {
                Console.Error.WriteLine(stack.Top());
            }
            else
            {
                Console.Error.WriteLine("empty");
            }
        }
コード例 #4
0
ファイル: Atan.cs プロジェクト: lulzzz/BraneCloud
        public override void Execute(Interpreter interpeter)
        {
            FloatStack stack = interpeter.FloatStack();

            if (stack.Size() >= 1)
            {
                // we're good
                float slope = stack.Pop();
                stack.Push((float)Math.Atan(slope));
            }
            else
            {
                stack.Push(0);
            }
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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);
        }