n// create a population
npop = new Population();
n// only has 1 sub population
npop.subpop = new Subpopulation[1];
n
n// instantiate your fitness function. It must
n// implement Fitness interface
nfitnessFunction = new MyFitnessFunction();
n
n// create the sub-population with the
subPopulationSize
n// an instance of the individual, and the fitness function
npop.subpop[0] = new Subpopulation(subPopulationSize, new
MyChrom(attributeSize), fitnessFunction);
n
n// Adding operators. Here, it means that CrossOver is
done
n// 0.8 times and mutation is done 0.2 times.
npop.subpop[0].addOperator(new CrossOverOp(), 0.8);
npop.subpop[0].addOperator(new MutationOp(), 0.2);
n
n// Evolve the GA for numGenerations times
npop.evolve(numGenerations);