-
Decide how you would represent the DNA of an individual. For example, for the 0/1 Knapsack Problem where you have
N
items, you would like to have aBoolean
for each of the item, which will mean if you take that item or not. This means your DNA will be an array ofBoolean
s. Let's call this typeGeneType
. -
Decide the domain a gene can take values from. This domain will be used in the population generation step. For the 0/1 Knapsack Problem, the domain will be
Seq(true, false)
. -
Decide the length of an individual's DNA.
-
Write a class that extends
Individual[GeneType]
. For the 0/1 Knapsack Problem,GeneType
will beBoolean
. Let's call this classInd
. -
Implement the
def fitnessFnc: Double
method in your newly created class. -
Instantiate a new instance of
Algorithm[GeneType, Ind]
. You can give it parameters for the population size, the fitness threshold for the algorithm to stop, custom strategies for selection, crossover making or mutating. -
Call the
run
method on the algorithm. You can give it parameters for the maximum number of generations to run or for the fitness threshold. -
Finally, you can look at all the examples provided.
- Write initial version
- Publish to maven
- Do some code cleanup / refactor
- Provide more examples of usage
- Provide more strategies for crossover/selection/mutation
- WRITE TESTS!! :)