Examples of Population


Examples of com.heatonresearch.aifh.evolutionary.population.Population

     * Create the initial random population.
     *
     * @return The population.
     */
    private Population initPopulation() {
        Population result = new BasicPopulation(PlantUniverse.POPULATION_SIZE, null);

        BasicSpecies defaultSpecies = new BasicSpecies();
        defaultSpecies.setPopulation(result);
        for (int i = 0; i < PlantUniverse.POPULATION_SIZE; i++) {
            final DoubleArrayGenome genome = randomGenome();
            defaultSpecies.add(genome);
        }
        result.setGenomeFactory(new DoubleArrayGenomeFactory(PlantUniverse.GENOME_SIZE));
        result.getSpecies().add(defaultSpecies);

        return result;
    }
View Full Code Here

Examples of com.heatonresearch.aifh.evolutionary.population.Population

        // Create a random number generator
        GenerateRandom rnd = new MersenneTwisterGenerateRandom();

        // Create a new population.
        Population pop = new BasicPopulation();
        pop.setGenomeFactory(new IntegerArrayGenomeFactory(10));

        // Create a trainer with a very simple score function.  We do not care
        // about the calculation of the score, as they will never be calculated.
        EvolutionaryAlgorithm train = new BasicEA(pop, new ScoreFunction() {
            @Override
            public double calculateScore(MLMethod method) {
                return 0;
            }

            @Override
            public boolean shouldMinimize() {
                return false;
            }
        });

        // Create a splice operator, length = 5.  Use it 1.0 (100%) of the time.
        Splice opp = new Splice(5);
        train.addOperation(1.0, opp);

        // Create two parents, the genes are set to 1,2,3,4,5,7,8,9,10
        // and 10,9,8,7,6,5,4,3,2,1.
        IntegerArrayGenome[] parents = new IntegerArrayGenome[2];
        parents[0] = (IntegerArrayGenome) pop.getGenomeFactory().factor();
        parents[1] = (IntegerArrayGenome) pop.getGenomeFactory().factor();
        for (int i = 1; i <= 10; i++) {
            parents[0].getData()[i - 1] = i;
            parents[1].getData()[i - 1] = 11 - i;
        }
View Full Code Here

Examples of com.heatonresearch.aifh.evolutionary.population.Population

        // Create a random number generator
        GenerateRandom rnd = new MersenneTwisterGenerateRandom();

        // Create a new population.
        Population pop = new BasicPopulation();
        pop.setGenomeFactory(new IntegerArrayGenomeFactory(10));

        // Create a trainer with a very simple score function.  We do not care
        // about the calculation of the score, as they will never be calculated.
        EvolutionaryAlgorithm train = new BasicEA(pop, new ScoreFunction() {
            @Override
            public double calculateScore(MLMethod method) {
                return 0;
            }

            @Override
            public boolean shouldMinimize() {
                return false;
            }
        });

        // Create a splice (no repeat) operator, length = 5.  Use it 1.0 (100%) of the time.
        SpliceNoRepeat opp = new SpliceNoRepeat(5);
        train.addOperation(1.0, opp);

        // Create two parents, the genes are set to 1,2,3,4,5,7,8,9,10
        // and 10,9,8,7,6,5,4,3,2,1.
        IntegerArrayGenome[] parents = new IntegerArrayGenome[2];
        parents[0] = (IntegerArrayGenome) pop.getGenomeFactory().factor();
        parents[1] = (IntegerArrayGenome) pop.getGenomeFactory().factor();
        for (int i = 1; i <= 10; i++) {
            parents[0].getData()[i - 1] = i;
            parents[1].getData()[i - 1] = 11 - i;
        }
View Full Code Here

Examples of com.heatonresearch.aifh.evolutionary.population.Population

*/
public class TournamentCompareExample {
    public static void main(String[] args) {

        // Create a new population.
        Population pop = new BasicPopulation();
        Species species = pop.createSpecies();

        // Create 1000 genomes, assign the score to be the index number.
        for (int i = 0; i < 1000; i++) {
            Genome genome = new IntegerArrayGenome(1);
            genome.setScore(i);
            genome.setAdjustedScore(i);
            pop.getSpecies().get(0).add(genome);
        }

        GenerateRandom rnd = new MersenneTwisterGenerateRandom();

        // Create a trainer with a very simple score function.  We do not care
View Full Code Here

Examples of com.heatonresearch.aifh.evolutionary.population.Population

        // Create a random number generator
        GenerateRandom rnd = new MersenneTwisterGenerateRandom();

        // Create a new population.
        Population pop = new BasicPopulation();
        pop.setGenomeFactory(new IntegerArrayGenomeFactory(5));

        // Create a trainer with a very simple score function.  We do not care
        // about the calculation of the score, as they will never be calculated.
        EvolutionaryAlgorithm train = new BasicEA(pop, new ScoreFunction() {
            @Override
            public double calculateScore(MLMethod method) {
                return 0;
            }

            @Override
            public boolean shouldMinimize() {
                return false;
            }
        });

        // Create a shuffle operator.  Use it 1.0 (100%) of the time.
        MutateShuffle opp = new MutateShuffle();
        train.addOperation(1.0, opp);

        // Create a single parent, the genes are set to 1,2,3,4,5.
        IntegerArrayGenome[] parents = new IntegerArrayGenome[1];
        parents[0] = (IntegerArrayGenome) pop.getGenomeFactory().factor();
        for (int i = 1; i <= 5; i++) {
            parents[0].getData()[i - 1] = i;
        }

        // Create an array to hold the offspring.
View Full Code Here

Examples of ec.Population

    /** A simple breeder that doesn't attempt to do any cross-
        population breeding.  Basically it applies pipelines,
        one per thread, to various subchunks of a new population. */
    public Population breedPopulation(EvolutionState state)
        {
        Population newpop = null;
        if (clonePipelineAndPopulation)
            newpop = (Population) state.population.emptyClone();
        else
            {
            if (backupPopulation == null)
                backupPopulation = (Population) state.population.emptyClone();
            newpop = backupPopulation;
            newpop.clear();
            backupPopulation = state.population;  // swap in
            }
       
        // load elites into top of newpop
        loadElites(state, newpop);
View Full Code Here

Examples of ec.Population

        Obviously, this is an expensive method.  It should only
        be called once typically in a run. */

    public Population initialPopulation(final EvolutionState state, int thread)
        {
        Population p = setupPopulation(state, thread);
        p.populate(state, thread);
        return p;
        }
View Full Code Here

Examples of ec.Population

        }
               
    public Population setupPopulation(final EvolutionState state, int thread)
        {
        Parameter base = new Parameter(P_POP);
        Population p = (Population) state.parameters.getInstanceForParameterEq(base,null,Population.class)// Population.class is fine
        p.setup(state,base);
        return p;
        }
View Full Code Here

Examples of jcgp.backend.population.Population

    resources.setFunctionSet(new SymbolicRegressionFunctions());
  }

  @Before
  public void setUp() throws Exception {
    population = new Population(resources);
  }
View Full Code Here

Examples of jcgp.backend.population.Population

  public void preinitialisedChromosomeTest() {
    // the original chromosome that will be cloned
    Chromosome oc = new Chromosome(resources);

    // initialise a population with a copy of it
    population = new Population(oc, resources);
    // check that the first parent chromosome is identical to, but not the same instance as, the one given
    assertTrue("Incorrect chromosome in population.", population.get(0).compareGenesTo(oc) && population.get(0) != oc);
  }
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.