Package org.encog.neural.neat.training

Examples of org.encog.neural.neat.training.NEATNeuronGene


            lastGenome.setScore(CSVFormat.EG_FORMAT.parse(cols.get(6)));
            result.add(lastGenome);
            genomeMap.put((int) lastGenome.getGenomeID(),
                lastGenome);
          } else if (cols.get(0).equalsIgnoreCase("n") ) {
            NEATNeuronGene neuronGene = new NEATNeuronGene();
            neuronGene.setId(Integer.parseInt(cols.get(1)));
            neuronGene.setNeuronType(PersistNEATPopulation
                .stringToNeuronType(cols.get(2)));
            neuronGene.setEnabled(Integer.parseInt(cols.get(3))>0);
            neuronGene.setInnovationId(Integer.parseInt(cols.get(4)));
            neuronGene.setActivationResponse(CSVFormat.EG_FORMAT
                .parse(cols.get(5)));
            neuronGene
                .setSplitX(CSVFormat.EG_FORMAT.parse(cols.get(6)));
            neuronGene
                .setSplitY(CSVFormat.EG_FORMAT.parse(cols.get(7)));
            lastGenome.getNeurons().add(neuronGene);
          } else if (cols.get(0).equalsIgnoreCase("l")) {
            NEATLinkGene linkGene = new NEATLinkGene();
            linkGene.setId(Integer.parseInt(cols.get(1)));
View Full Code Here


      out.addColumn(neatGenome.getNetworkDepth());
      out.addColumn(neatGenome.getScore());
      out.writeLine();

      for (Gene neuronGene : neatGenome.getNeurons().getGenes()) {
        NEATNeuronGene neatNeuronGene = (NEATNeuronGene) neuronGene;
        out.addColumn("n");
        out.addColumn(neatNeuronGene.getId());
        out.addColumn(PersistNEATPopulation
            .neuronTypeToString(neatNeuronGene.getNeuronType()));
        out.addColumn(neatNeuronGene.isEnabled());
        out.addColumn(neatNeuronGene.getInnovationId());
        out.addColumn(neatNeuronGene.getActivationResponse());
        out.addColumn(neatNeuronGene.getSplitX());
        out.addColumn(neatNeuronGene.getSplitY());
        out.writeLine();
      }
      for (Gene linkGene : neatGenome.getLinks().getGenes()) {
        NEATLinkGene neatLinkGene = (NEATLinkGene) linkGene;
        out.addColumn("l");
View Full Code Here

      afs[i] = neuronsChromosome.get(i).getActivationFunction();
    }

    final Map<Long, Integer> lookup = new HashMap<Long, Integer>();
    for (int i = 0; i < neuronsChromosome.size(); i++) {
      final NEATNeuronGene neuronGene = neuronsChromosome.get(i);
      lookup.put(neuronGene.getId(), i);
    }

    // loop over connections
    for (int i = 0; i < linksChromosome.size(); i++) {
      final NEATLinkGene linkGene = linksChromosome.get(i);
View Full Code Here

    // add the splitting neuron
    final ActivationFunction af = ((NEATPopulation)getOwner().getPopulation())
        .getActivationFunctions().pick(new Random());

    target.getNeuronsChromosome().add(
        new NEATNeuronGene(NEATNeuronType.Hidden, af, innovation
            .getNeuronID(), innovation.getInnovationID()));

    // add the other two sides of the link
    createLink(target, from, innovation.getNeuronID(),
        splitLink.getWeight());
View Full Code Here

    long neuron1ID = -1;
    long neuron2ID = -1;

    // try to add a link
    while ((countTrysToAddLink--) > 0) {
      final NEATNeuronGene neuron1 = chooseRandomNeuron(target, true);
      final NEATNeuronGene neuron2 = chooseRandomNeuron(target, false);

      if (neuron1 == null || neuron2 == null) {
        return;
      }

      // do not duplicate
      // do not go to a bias neuron
      // do not go from an output neuron
      // do not go to an input neuron
      if (!isDuplicateLink(target, neuron1.getId(), neuron2.getId())
          && (neuron2.getNeuronType() != NEATNeuronType.Bias)
          && (neuron2.getNeuronType() != NEATNeuronType.Input)) {

        if ( ((NEATPopulation)getOwner().getPopulation()).getActivationCycles() != 1
            || neuron1.getNeuronType() != NEATNeuronType.Output) {
          neuron1ID = neuron1.getId();
          neuron2ID = neuron2.getId();
          break;
        }
      }
    }
View Full Code Here

   *            is the 2nd best of 2.
   * @return The best neuron genome by id.
   */
  private NEATNeuronGene findBestNeuron(final long nodeID,
      final NEATGenome best, final NEATGenome notBest) {
    NEATNeuronGene result = best.findNeuron(nodeID);
    if (result == null) {
      result = notBest.findNeuron(nodeID);
    }
    return result;
  }
View Full Code Here

            lastSpecies.add(lastGenome);
            if (isLeader) {
              lastSpecies.setLeader(lastGenome);
            }
          } else if (cols.get(0).equalsIgnoreCase("n")) {
            final NEATNeuronGene neuronGene = new NEATNeuronGene();
            final int geneID = Integer.parseInt(cols.get(1));
            neuronGene.setId(geneID);

            final ActivationFunction af = EncogFileSection
                .parseActivationFunction(cols.get(2));
            neuronGene.setActivationFunction(af);

            neuronGene.setNeuronType(PersistNEATPopulation
                .stringToNeuronType(cols.get(3)));
            neuronGene
                .setInnovationId(Integer.parseInt(cols.get(4)));
            lastGenome.getNeuronsChromosome().add(neuronGene);
            nextGeneID = Math.max(geneID + 1, nextGeneID);
          } else if (cols.get(0).equalsIgnoreCase("l")) {
            final NEATLinkGene linkGene = new NEATLinkGene();
View Full Code Here

    if (start > end) {
      return null;
    }

    final int neuronPos = RangeRandomizer.randomInt(start, end);
    final NEATNeuronGene neuronGene = target.getNeuronsChromosome().get(
        neuronPos);
    return neuronGene;

  }
View Full Code Here

   * @return The index.
   */
  public int getElementPos(final NEATGenome target, final long neuronID) {

    for (int i = 0; i < target.getNeuronsChromosome().size(); i++) {
      final NEATNeuronGene neuronGene = target.getNeuronsChromosome()
          .get(i);
      if (neuronGene.getId() == neuronID) {
        return i;
      }
    }

    return -1;
View Full Code Here

  public boolean isNeuronNeeded(final NEATGenome target, final long neuronID) {

    // do not remove bias or input neurons or output
    for (final NEATNeuronGene gene : target.getNeuronsChromosome()) {
      if (gene.getId() == neuronID) {
        final NEATNeuronGene neuron = gene;
        if ((neuron.getNeuronType() == NEATNeuronType.Input)
            || (neuron.getNeuronType() == NEATNeuronType.Bias)
            || (neuron.getNeuronType() == NEATNeuronType.Output)) {
          return true;
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.encog.neural.neat.training.NEATNeuronGene

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.