Package org.encog.ml.ea.genome

Examples of org.encog.ml.ea.genome.Genome


    adjustCompatibilityThreshold();

    // assign genomes to species (if any exist)
    for (final Genome g : genomes) {
      Species currentSpecies = null;
      final Genome genome = g;

      if (!Double.isNaN(genome.getAdjustedScore())
          && !Double.isInfinite(genome.getAdjustedScore())) {
        maxScore = Math.max(genome.getAdjustedScore(), maxScore);
      }

      for (final Species s : speciesCollection) {
        final double compatibility = getCompatibilityScore(genome,
            s.getLeader());

        if (compatibility <= this.compatibilityThreshold) {
          currentSpecies = s;
          addSpeciesMember(s, genome);
          genome.setSpecies(s);
          break;
        }
      }

      // if this genome did not fall into any existing species, create a
View Full Code Here


      // Add elite genomes directly
      if (species.getMembers().size() > 5) {
        final int idealEliteCount = (int) (species.getMembers().size() * getEliteRate());
        final int eliteCount = Math.min(numToSpawn, idealEliteCount);
        for (int i = 0; i < eliteCount; i++) {
          final Genome eliteGenome = species.getMembers().get(i);
          if (getOldBestGenome() != eliteGenome) {
            numToSpawn--;
            if (!addChild(eliteGenome)) {
              break;
            }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  public Genome factor() {
    final Genome result = new MLMethodGenome(
        (MLEncodable) this.factory.factor());
    result.setPopulation(this.population);
    return result;
  }
View Full Code Here

    while (speciesNum < getSpecies().size()) {
      Species species = getSpecies().get(speciesNum);

      int genomeNum = 0;
      while (genomeNum < species.getMembers().size()) {
        Genome genome = species.getMembers().get(genomeNum);
        if (Double.isInfinite(genome.getScore())
            || Double.isInfinite(genome.getAdjustedScore())
            || Double.isNaN(genome.getScore())
            || Double.isNaN(genome.getAdjustedScore())) {
          species.getMembers().remove(genome);
        } else {
          genomeNum++;
        }
      }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  public MLMethod getMethod() {
    final Genome best = this.genetic.getBestGenome();
    return this.genetic.getCODEC().decode(best);
  }
View Full Code Here

   * {@inheritDoc}
   */
  @Override
  public int performAntiSelection(final Random rnd, final Species species) {
    int worstIndex = rnd.nextInt(species.getMembers().size());
    Genome worst = species.getMembers().get(worstIndex);
    BasicEA.calculateScoreAdjustment(worst,
        this.trainer.getScoreAdjusters());

    for (int i = 0; i < this.rounds; i++) {
      final int competitorIndex = rnd.nextInt(species.getMembers().size());
      final Genome competitor = species.getMembers().get(competitorIndex);

      // force an invalid genome to lose
      if (Double.isInfinite(competitor.getAdjustedScore())
          || Double.isNaN(competitor.getAdjustedScore())) {
        return competitorIndex;
      }

      BasicEA.calculateScoreAdjustment(competitor,
          this.trainer.getScoreAdjusters());
View Full Code Here

   * {@inheritDoc}
   */
  @Override
  public int performSelection(final Random rnd, final Species species) {
    int bestIndex = rnd.nextInt(species.getMembers().size());
    Genome best = species.getMembers().get(bestIndex);
    BasicEA.calculateScoreAdjustment(best, this.trainer.getScoreAdjusters());

    for (int i = 0; i < this.rounds; i++) {
      final int competitorIndex = rnd.nextInt(species.getMembers().size());
      final Genome competitor = species.getMembers().get(competitorIndex);

      // only evaluate valid genomes
      if (!Double.isInfinite(competitor.getAdjustedScore())
          && !Double.isNaN(competitor.getAdjustedScore())) {
        BasicEA.calculateScoreAdjustment(competitor,
            this.trainer.getScoreAdjusters());
        if (this.trainer.getSelectionComparator().isBetterThan(
            competitor, best)) {
          best = competitor;
View Full Code Here

TOP

Related Classes of org.encog.ml.ea.genome.Genome

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.