-
Notifications
You must be signed in to change notification settings - Fork 23
Introduction
Since NSGA-II is more like a set of protocols to follow as an algorithm rather than a concrete implementation of every aspect, this package has been re-written from scratch keeping complete customizability in mind. Apart from the core concepts of the algorithm, everything is considered to be a plugin external to the algorithm that can be implemented by the user and dynamically plugged into the algorithm during runtime as needed. This opens up the possibility of the package to be used simply as a PoC or be converted into something much more complex according to the users needs.
By default, all the customizable aspects of the algorithm is provided with a default implementation. This lets the user to implement only the aspects they would like to change while keeping the others untouched. Visit the documentation to for more in-depth explanation of each plugin.
Before deep-diving into the implementation details, let us first understand how this package works and how it is structured. An Allele
is the atomic element for this implementation. A set of alleles of similar type forms a Chromosome
. In other words, a set of alleles form the genetic code
of a Chromosome
. A set of chromosomes in turn, make a Population
. These are the basics of any Genetic Algorithm and is implemented as the basic data structures of this package.
-
Since an
Allele
can be of various types depending on whether theChromosome
is binary encoded or, say, permutation encoded, this aspect of the algorithm can be changed as required within the package. Every allele must extend theAbstractAllele
class. The implementation details completely depends on the user. By default, aBooleanAllele
is provided which is used for binary encoding. Other types such asIntegerAllele
andValueAllele
have also been implemented. -
The
crossover
operator can be implemented by the user as deemed necessary. The user's implementation must extend theAbstractCrossover
class. By default, an implementation of uniform crossover is provided through theUniformCrossover
class.OrderCrossover
andSimulatedBinaryCrossover
have also been implemented. -
While the crossover operator decides how to perform the crossover on two or more chromosomes once chosen, the package provides even further customizability by allowing to change how the chromosomes to be crossed over are chosen in the first place. This can be done by providing a concrete implementation of the
CrossoverParticipantCreator
interface. By default, two chromosomes are selected at random by performing crowded binary tournament selection over a population. This default implementation is provided inCrossoverParticipantCreatorProvider#selectByBinaryTournamentSelection
method. -
The
mutation
operator can be implemented by the user as deemed necessary. The user's implementation must extend theAbstractMutation
class. By default, an implementation of single point mutation is provided through theSingePointMutation
class.PolynomialMutation
andSwapMutation
have also been implemented. -
The genetic code of each chromosome can be generated in various ways as required by the user. This can be done by providing a concrete implementation of the
GeneticCodeProducer
interface. By default, aGeneticCodeProducer
producing binary encoded alleles ofBooleanAllele
instance is provided byDefaultPluginProvider#defaultGeneticCodeProducer
. -
The implementation details of how the parent population and the child population shall be generated changes from user to user based on their requirements. This is why, these aspects of the package can also be custom implemented by the user as deemed necessary.
- The implementation details of the parent population generation can be provided by implementing the
PopulationProducer
interface. A default implementation of taking the fixed chromosome length (genetic code length) and population size and creating a population using theGeneticCodeProducer
available is provided inDefaultPluginProvider#defaultPopulationProducer
. - The implementation details of the child population generation can be provided by implementing the
ChildPopulationProducer
interface. A default implementation of taking a parent population, child population size, the available crossover operator and the available mutation operator is provided inDefaultPluginProvider#defaultChildPopulationProducer
.
- The implementation details of the parent population generation can be provided by implementing the
-
The objective functions used with this package can be written as required by the user by extending the
AbstractObjectiveFunction
class. Your instance may have as many objective functions as necessary and the algorithm shall scale to it. By default, theSCH_1
andSCH_2
are implemented and provided, but you can use any objective function to your liking. The default objectives are provided through theObjectiveProvider#provideSCHObjectives
method. -
Finally, a
FitnessCalculator
may or may not be implemented which computes some fitness of aChromosome
. NSGA-II does not have any direct fitness calculation and this is not necessary by default. But this can be used either (i) as some extra parameter computation that the user may want to add to the algorithm as required, or (ii) as a parameter to objective functions if they require any extra computational parameter.
Refer to the Documentation for more information or Getting Started section to see the package in action.