RandomInitialiser implements CreationOperation, Stochastic { public Individual createIndividual() { GEGrammar gram = GEGrammar.getGrammar(this.grammar); Phenotype phenotype = new Phenotype(); int[] codons = new int[this.initChromSize]; GEChromosome chrom = new GEChromosome(this.initChromSize, codons); chrom.setMaxChromosomeLength(gram.getMaxChromosomeLengthByDepth()); Genotype genotype = new Genotype(1, chrom); Fitness fitness = new BasicFitness(); GEIndividual individual = new GEIndividual(gram, phenotype, genotype, fitness); return individual; } RandomInitialiser(RandomNumberGenerator rng, GEGrammar g, int initChromSize);  RandomInitialiser(RandomNumberGenerator rng, GEGrammar g, Properties p); void setProperties(Properties p); RandomNumberGenerator getRNG(); void setRNG(RandomNumberGenerator rng); Individual createIndividual(); void doOperation(Individual operand); void doOperation(List<Individual> operands);  }
@Test public void testCreateIndividual() { System.out.println("createIndividual"); Individual result = ri1.createIndividual(); GEGrammar grammar = (GEGrammar) result.getMapper(); System.out.println("the grammar is:" + grammar.getDerivationString()); assertEquals(true, grammar.getDerivationString().equals("geva.Mapper.ContextualDerivationTree")); result = ri2.createIndividual(); grammar = (GEGrammar) result.getMapper(); System.out.println("the grammar is:" + grammar.getDerivationString()); assertEquals(true, grammar.getDerivationString().equals("geva.Mapper.DerivationTree")); }