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)); }
public override void Execute(Interpreter inI) { ObjectStack codeStack = inI.CodeStack(); FloatStack fStack = inI.FloatStack(); if (fStack.Size() > 0) { codeStack.Push(fStack.Pop()); } }
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 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); } }
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); }