Package jcgp.backend.population

Examples of jcgp.backend.population.Node


     
      resources.println("[Parser] Parsing file: " + file.getAbsolutePath() + "...");
     
      int gene;
      Connection newConnection;
      Node changingNode;
      // for all nodes, columns first
      for (int c = 0; c < resources.columns(); c++) {
        for (int r = 0; r < resources.rows(); r++) {
          // store the changing node
          changingNode = chromosome.getNode(r, c);

          // for every connection
          for (int i = 0; i < resources.arity(); i++) {
            // get connection number from the .chr file
            gene = in.nextInt();
            if (gene < resources.inputs()) {
              // connection was an input
              newConnection = chromosome.getInput(gene);
            } else {
              // connection was another node, calculate which from its number
              newConnection = chromosome.getNode((gene - resources.inputs()) % resources.rows(),
                  (gene - resources.inputs()) / resources.rows());
            }
            changingNode.setConnection(i, newConnection);
          }

          // set the function, straight indexing should work - this is not entirely
          // safe, but it is not viable to check for functionset compatibility
          changingNode.setFunction(resources.getFunction(in.nextInt()));
        }
      }

      // outputs
      for (int o = 0; o < resources.outputs(); o ++) {
View Full Code Here


    chromosome = new Chromosome(resources);
  }

  @Before
  public void setUp() throws Exception {
    node = new Node(chromosome, 0, 0);
    // make node with addition function and hard-coded value connections
    node.initialise(resources.getFunction(0),
        new Connection[]{new Connection() {

          @Override
View Full Code Here

    for (int r = 0; r < getResources().rows(); r++) {
      for (int c = 0; c < getResources().columns(); c++) {
        // go through all connections
        for (int a = 0; a < getResources().arity(); a++) {
          if (mutateGene()) {
            Node n = chromosome.getNode(r, c);
           
            if (report.get()) getResources().report("[Mutator] Mutating " + n +
                ", changed connection " + a + " from " + n.getConnection(a) + " ");
           
            n.setConnection(a, chromosome.getRandomConnection(c));
           
            if (report.get()) getResources().reportln("to " + n.getConnection(a));
           
          }
        }
        // deal with node function next
        if (mutateGene()) {
          Node n = chromosome.getNode(r, c);
          if (report.get()) getResources().report("[Mutator] Mutating " + n +
              ", changed function from " + n.getFunction());
         
          n.setFunction(getResources().getRandomFunction());
         
          if (report.get()) getResources().reportln(" to " + n.getFunction());
        }
      }
    }
    // finally, mutate outputs
    for (int o = 0; o < getResources().outputs(); o++) {
View Full Code Here

      // if the source is a node, all inputs and some nodes are valid
      if (target instanceof GUIInput) {
        return true;
      } else if (target instanceof GUINode) {
        // target and source are nodes, let's look at levels back
        Node t = ((GUINode) target).getNode(), s = ((GUINode) source).getNode();
        if (s.getColumn() - t.getColumn() > 0 && s.getColumn() - t.getColumn() <= resources.levelsBack()) {
          return true;
        }
        return false;
      } else if (target instanceof GUIOutput) {
        return false;
View Full Code Here

TOP

Related Classes of jcgp.backend.population.Node

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.