This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<repository> | |
<id>jmona.repo</id> | |
<name>jmona repository</name> | |
<url>http://www.eecs.tufts.edu/~jfinke02/repo</url> | |
</repository> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Factory<Byte> bitFactory = new BitFactory(); | |
int length = 20; | |
PartialDeepCopyableListFactory<Byte> individualFactory = new PartialDeepCopyableListFactory<Byte>(); | |
individualFactory.setElementFactory(bitFactory); | |
individualFactory.setSize(length); | |
int numberOfIndividuals = 100; | |
DefaultListFactory<DeepCopyableList<Byte>> populationFactory = new DefaultListFactory<DeepCopyableList<Byte>>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<MyIndividual> population = new Vector<MyIndividual>(); | |
// initialize the population with random individuals | |
// | |
// ... | |
// | |
GeneticEvolutionContext<MyIndividual> context = new GAEvolutionContext<MyIndividual>(population); | |
context.setCrossoverFunction(new MyCrossoverFunction()); | |
context.setFitnessFunction(new MyFitnessFunction()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<MyIndividual> initialPopulation = new Vector<MyIndividual>(); | |
// add the initial individuals to the population | |
// | |
// ... | |
// | |
EvolutionContext<MyIndividual> context = new GAEvolutionContext<MyIndividual>(initialPopulation); | |
// set the necessary properties on the EvolutionContext |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OnesMutationFunction extends ImmutableElementsListMutationFunction<Byte> { | |
@Override | |
protected Byte mutated(final Byte bit) { | |
return (byte) (1 - bit); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OnesFitnessFunction extends MaximizingFitnessFunction<List<Byte>> { | |
public OnesFitnessFunction(int length) { | |
super(length); | |
} | |
@Override | |
public double rawFitness(final List<Byte> individual) { | |
int fitness = 0; | |
for (Byte bit : individual) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int numberOfIndividuals = 100; | |
Factory<MyIndividual> individualFactory = new MyIndividualFactory(); | |
DefaultListFactory<MyIndividual> populationFactory = new DefaultListFactory<MyIndividual>(); | |
populationFactory.setSize(numberOfIndividuals); | |
populationFactory.setElementFactory(individualFactory); | |
List<MyIndividual> population = populationFactory.createObject(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Factory<Byte> bitFactory = new BitFactory(); | |
int length = 20; | |
Factory<DeepCopyableList<Byte>> individualFactory = new PartialDeepCopyableListFactory<Byte>(); | |
individualFactory.setElementFactory(bitFactory); | |
individualFactory.setSize(length); | |
try { | |
DeepCopyableList<Byte> individual = individualFactory.createObject(); | |
} catch (InitializationException exception) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<MyIndividual> initialPopulation = new Vector<MyIndividual>(); | |
// add initial random individuals to the initial population | |
// | |
// ... | |
// | |
EvolutionContext<MyIndividual> context = new GAEvolutionContext<MyIndividual>(initialPopulation); | |
context.setSelectionFunction(new FitnessProportionateSelection<MyIndividual>()); |
NewerOlder