-
Notifications
You must be signed in to change notification settings - Fork 22
Documentation
An instance of this class is used to run the NSGA-II algorithm. This class defines the core algorithm of NSGA-II. Calling the
run()method on an instance ofNSGA2gets the algorithm running. It requires an instance ofConfigurationclass to run, which describes all the configuration required for that run. TheConfigurationclass is described later in the documentation.
NSGA2 has two constructors:
-
NSGA2(): creates an instance ofNSGA2with a default configuration object that provides a default implementation of every plugin needed by the algorithm to run. While this constructor is not of much use to the user, but this helps run a proof-of-concept for the algorithm itself with all the default plugins filled in. To run the PoC, the user can simply run
(new NSGA2()).run();-
NSGA2(Configuration): creates an instance ofNSGA2by taking a configuration object as parameter. This will be usually the most useful constructor forNSGA2for the user. The user can configure his / her plugins to the liking and then pass it to theNSGA2constructor for the algorithm to be setup according to the users needs.
-
run(): Runs the actual NSGA-II core algorithm. It returns the Pareto Front or the last child as aPopulationobject. This needs to be called on an instance ofNSGA2to run the actual algorithm. -
preparePopulation(Population): This method takes aPopulationobject and basically performs all the operations needed to be performed on the parent population in each generation. It executes the following operations on the population instance in order.- It calculates the objective values of all the chromosomes in the population based on the objective functions set in the
Configurationinstance. - It then runs fast non-dominated sort on the population as defined in
NSGA-II paper [DOI: 10.1109/4235.996017] Section III Part A. - It then assigns crowding distance to each chromosome.
- Finally, it sorts the chromosomes in the population based on its assigned rank.
- It calculates the objective values of all the chromosomes in the population based on the objective functions set in the
-
getChildFromCombinedPopulation(Population): This method takes aPopulationof size2N(a combination of parent and child, both of sizeN, according to the originally proposed algorithm) and returns a newPopulationinstance of sizeNby selecting the firstNchromosomes from the combined population, based on their rank. If it has to chooseMchromosomes of rankNsuch thatM > N, it then sorts theMchromosomes based on their crowding distance. -
fastNonDominatedSort(Population): This is an implementation of the fast non-dominated sorting algorithm as defined in the NSGA-II paper [DOI: 10.1109/4235.996017] Section III Part A. It takes as a parameter, the population object that needs to undergo fast non-dominated sorting algorithm. -
crowdingDistanceAssignment(Population): This is the implementation of the crowding distance assignment algorithm as defined in the NSGA-II paper [DOI: 10.1109/4235.996017] Section III Part B. this ensures diversity preservation. It returns the the population whose crowding distances are tor be calculated. -
dominates(Chromosome, Chromosome): This method checks whether one chromosome dominates the other chromosome or not. While the actual domination logic has been described in theisDominant(Chromosome, Chromosome)method, thedominates(Chromosome, Chromosome)method returns one among the three values based on whether chromosome1 is dominant over chromosome2, or is inferior to chromosome2 or whether both of them are non-dominating, by returningcom.debacharya.nsgaii.NSGA2.DOMINANT,com.debacharya.nsgaii.NSGA2.INFERIORorcom.debacharya.nsgaii.NSGA2.NON_DOMINATEDrespectively. -
isDominant(Chromosome, Chromosome): This method checks whether chromosome1 dominates chromosome2. Requires that none of the values of the objective function values of chromosome1 is smaller than the values of the objective function values of chromosome2 and at least one of the values of the objective function of chromosome1 is greater than the corresponding value of the objective function of chromosome2. Returns boolean logic whether chromosome1 dominates chromosome2.
com.debacharya.nsgaii.Configuration
The Configuration class is used to setup the runtime settings of the NSGA-II algorithm. Since a lot of the settings within the algorithm can be changed, this class manages them all. An instance of this class is needed to be setup before creating an instance of
NSGA2class or running the algorithm. Changing settings of an instance of a Configuration class between runs will also reflect immediately on the result. This means that, if required (but almost rarely), the configuration of the algorithm within the same run can be changed dynamically.
in progress
com.debacharya.nsgaii.datastructure.AbstractAllelecom.debacharya.nsgaii.datastructure.BooleanAllelecom.debacharya.nsgaii.datastructure.IntegerAllelecom.debacharya.nsgaii.datastructure.ValueAllele
in progress
com.debacharya.nsgaii.crossover.AbstractCrossovercom.debacharya.nsgaii.crossover.UniformCrossovercom.debacharya.nsgaii.crossover.OrderCrossovercom.debacharya.nsgaii.crossover.SimulatedBinaryCrossover
in progress
com.debacharya.nsgaii.mutation.AbstractMutationcom.debacharya.nsgaii.mutation.PolynomialMutationcom.debacharya.nsgaii.mutation.SinglePointMutationcom.debacharya.nsgaii.mutation.SwapMutation
com.debacharya.nsgaii.plugin.GeneticCodeProducer
The GeneticCodeProducer interface is used to create a genetic code, which in turn is used to encode a Chromosome for the algorithm to use. It has only one method,
produce, which takes as its argument, the length of the genetic code to be produced.
com.debacharya.nsgaii.plugin.PopulationProducer
-
produce(int): This method is used to create a list ofAbstractAlleles which represents the genetic code of aChromosomeand has a size equal to thelengthargument passed as parameter. It takes, as a parameter, thelengthargument, which is of typeint, which represents the length of the list ofAbstractAlleles to be created. This should be the length of the genetic code. It returns a list ofAbstractAlleleswhose size should be equal to the length argument.
The PopulationProducer interface is used to produce a population of chromosomes for the algorithm to use. It has only one method,
produce()that produces a fixed amount of chromosomes using theGeneticCodeProvider, each having a fixed chromosome length. It also integrates aFitnessCalculatorwhich can be used to provide any extra computation required to perform during the creation of the population. Note that any concrete implementation of this interface is used to only to generate the initial parent population at the very beginning of the algorithm. For all consecutive population production at later generations, theChildPopulationProducerinterface is used.
-
produce(int, int, GeneticCodeProducer, FitnessCalculator): This method is used to create a list ofAbstractAlleles which represents the genetic code of aChromosomeand has a size equal to thelengthargument passed as parameter. It takes, as a parameter, thelengthargument, which is of typeint, which represents the length of the list ofAbstractAlleles to be created. This should be the length of the genetic code. It returns a list ofAbstractAlleleswhose size should be equal to the length argument. It takes as arguments,populationSize, which is the size of the population, i.e., the number of chromosomes to be created,chromosomeLength, which is the length of each chromosome to be created, i.e., the length of the genetic code,geneticCodeProducerwhich is theGeneticCodeProducerobject used to generate the genetic code of each chromosome andfitnessCalculatorwhich is theFitnessCalculatorobject to carry out any additional computation on the chromosome. It returns aPopulationwithpopulationSizenumber of chromosomes.
The ChildPopulationProducer interface is used to produce a population of chromosomes for the algorithm to use. It has only one method,
produce()that produces a child population from a provided parent population. For every child population, a fixed amount of chromosomes is created by executing the providedcrossoverandmutationoperators on the parent population. This interface is used to generate every child population at each generation. Note that the initial parent population is generated using thePopulationProducerinterface.
-
produce(Population, AbstractCrossover, AbstractMutation, int): This method generates a childPopulation, which is a collection ofChromosomesequal to providedpopulationSize, from the givenparentPopulation. The child chromosomes are created by executing the providedcrossoverandmutationoperators on theparentPopulation. A newPopulationis hence created. It takes as arguments,parentPopulation, which is the population from which the child population is to be generated,crossover, which is the crossover operator which is a concrete implementation ofAbstractCrossover,mutation, which is the mutation operator which is a concrete implementation ofAbstractMutationandpopulationSize, which is the size of the population, i.e., the number of child chromosomes to be created. It returns a new childPopulation, withpopulationSizenumber of chromosomes.
in progress