Examples of Population


Examples of jcgp.backend.population.Population

    setEvolutionaryStrategy(0);
    setMutator(0);
    setProblem(0);

    // create a new population
    population = new Population(resources);
  }
View Full Code Here

Examples of jcgp.backend.population.Population

    if (resources.arity() < 1) {
      resources.println("[CGP] Error: arity is smaller than 1. Check that at least one function is enabled");
      return;
    }
    finished = false;
    population = new Population(resources);
    resetStatisticsValues();
    resources.setCurrentGeneration(1);
    resources.setCurrentRun(1);
    resources.println("*********************************************************");
    resources.println("[CGP] New experiment: " + problem.toString());
View Full Code Here

Examples of org.apache.commons.math3.genetics.Population

        GeneticAlgorithm ga = new GeneticAlgorithm(new OnePointCrossover<Character>(), CROSSOVER_RATE,
                                                   new RandomCharacterMutation(), MUTATION_RATE,
                                                   new TournamentSelection(TOURNAMENT_ARITY));

        // initial population
        Population initial = getInitialPopulation();

        // stopping condition
        StoppingCondition stoppingCondition = new StoppingCondition() {
           
            int generation = 0;
           
            @Override
            public boolean isSatisfied(Population population) {
                Chromosome fittestChromosome = population.getFittestChromosome();
               
                if (generation == 1 || generation % 10 == 0) {
                    System.out.println("Generation " + generation + ": " + fittestChromosome.toString());
                }
                generation++;

                double fitness = fittestChromosome.fitness();
                if (Precision.equals(fitness, 0.0, 1e-6)) {
                    return true;
                } else {
                    return false;
                }
            }
        };

        System.out.println("Starting evolution ...");
       
        // run the algorithm
        Population finalPopulation = ga.evolve(initial, stoppingCondition);

        // Get the end time for the simulation.
        long endTime = System.currentTimeMillis();

        // best chromosome from the final population
        Chromosome best = finalPopulation.getFittestChromosome();
        System.out.println("Generation " + ga.getGenerationsEvolved() + ": " + best.toString());
        System.out.println("Total execution time: " + (endTime - startTime) + "ms");
  }
View Full Code Here

Examples of org.encog.ml.ea.population.Population

    return (NEATPopulation)train.getPopulation();
  }
 
  public void testPersistEG()
  {
    Population pop = generate();

    EncogDirectoryPersistence.saveObject((EG_FILENAME), pop);
    NEATPopulation pop2 = (NEATPopulation)EncogDirectoryPersistence.loadObject((EG_FILENAME));
   
    validate(pop2);
View Full Code Here

Examples of org.encog.ml.ea.population.Population

    training1.iteration();
    // enough training for now, backup current population
    final ByteArrayOutputStream serialized1 = new ByteArrayOutputStream();
    new PersistNEATPopulation().save(serialized1, training1.getPopulation());

    final Population population2 = (Population)new PersistNEATPopulation().read(new ByteArrayInputStream(
      serialized1.toByteArray()));
    final ByteArrayOutputStream serialized2 = new ByteArrayOutputStream();
    new PersistNEATPopulation().save(serialized2, population2);
    Assert.assertEquals(serialized1.size(), serialized2.size());   
  }
View Full Code Here

Examples of org.encog.ml.ea.population.Population

  public MLMethodGeneticAlgorithm(final MethodFactory phenotypeFactory,
      final CalculateScore calculateScore, final int populationSize) {
    super(TrainingImplementationType.Iterative);

    // Create the population
    final Population population = new BasicPopulation(populationSize, null);
    final Species defaultSpecies = population.createSpecies();

    for (int i = 0; i < population.getPopulationSize(); i++) {
      final MLEncodable chromosomeNetwork = (MLEncodable) phenotypeFactory
          .factor();
      final MLMethodGenome genome = new MLMethodGenome(chromosomeNetwork);
      defaultSpecies.add(genome);
    }
    defaultSpecies.setLeader(defaultSpecies.getMembers().get(0));
   
    population.setGenomeFactory(new MLMethodGenomeFactory(phenotypeFactory,
        population));
   
    // create the trainer
    this.genetic = new MLMethodGeneticAlgorithmHelper(population,
        calculateScore);
View Full Code Here

Examples of org.encog.ml.genetic.population.Population

    return (NEATPopulation)train.getPopulation();
  }
 
  public void testPersistEG()
  {
    Population pop = generate();

    EncogDirectoryPersistence.saveObject((EG_FILENAME), pop);
    NEATPopulation pop2 = (NEATPopulation)EncogDirectoryPersistence.loadObject((EG_FILENAME));
   
    validate(pop2);
View Full Code Here

Examples of org.encog.ml.genetic.population.Population

      final int populationSize, final double mutationPercent,
      final double percentToMate) {
    super(TrainingImplementationType.Iterative);
    this.genetic = new NeuralGeneticAlgorithmHelper();
    this.genetic.setCalculateScore(new GeneticScoreAdapter(calculateScore));
    final Population population = new BasicPopulation(populationSize);
    getGenetic().setMutationPercent(mutationPercent);
    getGenetic().setMatingPopulation(percentToMate * 2);
    getGenetic().setPercentToMate(percentToMate);
    getGenetic().setCrossover(
        new Splice(network.getStructure().calculateSize() / 3));
    getGenetic().setMutate(new MutatePerturb(4.0));
    getGenetic().setPopulation(population);
    for (int i = 0; i < population.getPopulationSize(); i++) {
      final BasicNetwork chromosomeNetwork = (BasicNetwork) network
          .clone();
      randomizer.randomize(chromosomeNetwork);

      final NeuralGenome genome = new NeuralGenome(chromosomeNetwork);
      genome.setGeneticAlgorithm(getGenetic());
      getGenetic().calculateScore(genome);
      getGenetic().getPopulation().add(genome);
    }
    population.sort();
  }
View Full Code Here

Examples of org.encog.ml.genetic.population.Population

 
  private void initPopulation(GeneticAlgorithm ga)
  {
    CalculateGenomeScore score =  new TSPScore(cities);
    ga.setCalculateScore(score);
    Population population = new BasicPopulation(POPULATION_SIZE);
    ga.setPopulation(population);

    for (int i = 0; i < POPULATION_SIZE; i++) {

      final TSPGenome genome = new TSPGenome(ga, cities);
      ga.getPopulation().add(genome);
      ga.calculateScore(genome);
    }
    population.claim(ga);
    population.sort();
  }
View Full Code Here

Examples of org.encog.ml.genetic.population.Population

 
  private static void initPopulation(GeneticAlgorithm ga)
  {
    ScorePlayer score =  new ScorePlayer();
    ga.setCalculateScore(score);
    Population population = new BasicPopulation(POPULATION_SIZE);
    ga.setPopulation(population);

    for (int i = 0; i < POPULATION_SIZE; i++) {

      Player player = new Player(1000);
      player.randomize();
      final PlayerGenome genome = new PlayerGenome(ga, player);
      ga.getPopulation().add(genome);
      ga.calculateScore(genome);
    }
    population.sort();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.