Package jcgp.backend.function

Examples of jcgp.backend.function.Function


  }

  @Test
  public void functionTest() {
    // make a new function and assign to node
    Function f = new Function() {

      @Override
      public Object run(Object... connections) {
        // blank
        return 0;
View Full Code Here


        // blank
        return 0;
      }
    };
   
    Function function = new Function() {
      @Override
      public Object run(Object... connections) {
        // blank
        return null;
      }
View Full Code Here

   * function.
   *
   * @return a random allowed function.
   */
  public Function getRandomFunction() {
    Function f = functionSet.getAllowedFunction(numberGenerator.nextInt(functionSet.getAllowedFunctionCount()));
    return f;
  }
View Full Code Here

public class TestFunctionSet extends FunctionSet {
 
  public TestFunctionSet() {
   
    registerFunctions(
      new Function() {
        @Override
        public Integer run(Object... args) {
          return (Integer) args[0] + (Integer) args[1];
        }
        @Override
        public int getArity() {
          return 2;
        }
      },
      new Function() {
        @Override
        public Integer run(Object... args) {
          return (Integer) args[0] - (Integer) args[1];
        }
        @Override
        public int getArity() {
          return 2;
        }
      },
      new Function() {
        @Override
        public Integer run(Object... args) {
          return (Integer) args[0] * (Integer) args[1];
        }
        @Override
        public int getArity() {
          return 2;
        }
      },
      new Function() {
        @Override
        public Integer run(Object... args) {
          return (Integer) args[0] / (Integer) args[1];
        }
        @Override
View Full Code Here

TOP

Related Classes of jcgp.backend.function.Function

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.