Betty 1.1
|
Public Member Functions | |
EvolutionaryFMGenerator (float crossoverProb, float mutationProb, int populationSize, int extraChromosomes, int maxIterations, int maxGenerations, double fitnessToBeat, int improvementFactor, AbstractFMGenerator generator, boolean isRolueteSelection, int opponentsPerTournament) throws BettyException | |
EvolutionaryFMGenerator () throws BettyException | |
VariabilityModel | generateFM (Characteristics ch) throws BettyException |
void | mutation (Chromosome c, GeneratorCharacteristics chars) |
void | mutantOperator1 (List< String[]> tree, int position) |
void | mutantOperator2 (List< String[]> tree, int position, int maxChildren) |
void | mutantOperator3 (List< String[]> ctc, int position) |
void | mutantOperator4 (List< String[]> ctc, int position, int numberOfFeatures) |
String | printPopulation () |
Chromosome | tournamentSelection (int numberOfOpponents) |
void | crossover1P (Chromosome mum, Chromosome dad, List< Chromosome > population) |
double | evaluate (Chromosome chromosome) |
void | setGenerator (AbstractFMGenerator generator) throws BettyException |
void | setFitnessFunction (FitnessFunction ff) throws BettyException |
void | setCrossoverProb (float crossoverProb) throws BettyException |
void | setMutationProb (float mutationProb) throws BettyException |
void | setPopulationSize (int populationSize) throws BettyException |
void | setExtraChromosomes (int extraChromosomes) throws BettyException |
void | setMaxIterations (int maxIterations) throws BettyException |
void | setMaxGenerations (int maxGenerations) throws BettyException |
void | setfitnessToBeat (double fitnessToBeat) |
void | setImprovementFactor (int improvementFactor) |
void | setRolueteSelection (boolean isRolueteSelection) |
void | setOpponentsPerTournament (int opponentsPerTournament) throws BettyException |
void | setMaximize (boolean max) |
int | getBestFitnessGeneration () |
void | setBestFitnessGeneration (int bestFitnessGeneration) |
double | getBestFitness () |
void | setBestFitness (double bestFitness) |
List< Double > | getAvFitnesses () |
void | setAvFitnesses (List< Double > avFitnesses) |
Chromosome | getChr () |
void | setChr (Chromosome chr) |
Public Attributes | |
SortedMap< Double, List < Chromosome > > | population |
Package Attributes | |
double | fitnesses |
int | individuals |
List< Double > | AvFitnesses |
FitnessFunction | ff |
Chromosome | chr |
A novel evolutionary algorithm for solving optimization problems on feature models. The algorithm takes several size parameters and an objective function as input and returns a feature model of the given size maximizing or minimizing the optimization criteria defined by the function.
es.us.isa.generator.FM.Evolutionay.EvolutionaryFMGenerator.EvolutionaryFMGenerator | ( | ) | throws BettyException |
Constructor using defaults parameters
BettyException |
void es.us.isa.generator.FM.Evolutionay.EvolutionaryFMGenerator.crossover1P | ( | Chromosome | mum, |
Chromosome | dad, | ||
List< Chromosome > | population | ||
) |
These are the techniques used to combine chromosomes in some way and produce new individuals in an analogous way to biological reproduction. Single point crossover
TREE CROSSOVER
VariabilityModel es.us.isa.generator.FM.Evolutionay.EvolutionaryFMGenerator.generateFM | ( | Characteristics | ch | ) | throws BettyException |
Generate a variability model with the characteristic specified as input.
ch | The preferences of the user for the generation. |
BettyException |
Number of iterations without improvement
Variable to sum the fitnesses and then save the average on each generation
Reset statistics
Implements es.us.isa.generator.IGenerator.
void es.us.isa.generator.FM.Evolutionay.EvolutionaryFMGenerator.mutantOperator1 | ( | List< String[]> | tree, |
int | position | ||
) |
Operator 1. It changes randomly the type of a relationship in the tree array, e.g. from mandatory, [M, 3] , to optional,[ O, 3 ].
tree | The tree containing the relationship |
position | The position to do the change |
void es.us.isa.generator.FM.Evolutionay.EvolutionaryFMGenerator.mutantOperator2 | ( | List< String[]> | tree, |
int | position, | ||
int | maxChildren | ||
) |
It changes randomly the number of children of a feature in the tree, e.g. from [ M, 3 ] to [ M, 5 ]. The new number of children is the range [0, BF ] where BF is the maximum branching factor indicated as input.
The tree containing the children The position to do the change
maxChildren | The new max number of Children |
void es.us.isa.generator.FM.Evolutionay.EvolutionaryFMGenerator.mutantOperator3 | ( | List< String[]> | ctc, |
int | position | ||
) |
Operator 3. It changes the type of a cross-tree constraint in the CTC array, e.g. from excludes [ E, 3, 6 ] to requires [ R, 3, 6 ].
ctc | The ctc to be changed |
position | The position where it is |
void es.us.isa.generator.FM.Evolutionay.EvolutionaryFMGenerator.mutantOperator4 | ( | List< String[]> | ctc, |
int | position, | ||
int | numberOfFeatures | ||
) |
Operator 4. It changes randomly (with equal probability) the origin or destination feature of a constraint in the CTC array, e.g. from [ E, 3, 6 ] to requires [ E, 1, 6 ]. Origin and destination features are ensured to be different.
ctc | The ctc to be changed |
position | The position to do the change |
numberOfFeatures | the number of features of the model |
void es.us.isa.generator.FM.Evolutionay.EvolutionaryFMGenerator.mutation | ( | Chromosome | c, |
GeneratorCharacteristics | chars | ||
) |
In this methods, random changes are applied to the chromosomes to prevent the algorithm from getting stuck prematurely at a locally optimal solution. Mutation operators must be specifically designed for the type of encoding used.
c | The chromosome |
chars | The characteristics of the generator |
String es.us.isa.generator.FM.Evolutionay.EvolutionaryFMGenerator.printPopulation | ( | ) |
Print population in a readable format
Chromosome es.us.isa.generator.FM.Evolutionay.EvolutionaryFMGenerator.tournamentSelection | ( | int | numberOfOpponents | ) |
Determines how the individuals of one generation are selected to be combined and produce new offspring. Tournament Selection
numberOfOpponents | The number of opponents used in the tournament |
Select the index of the chosen chromosme: As we use a sorted Map an it is a maximization problem we chose the solution with a smaller index.
Get the chosen chromosme from population map:
If the chosen chromosome is not in this list we go to to next list.
The chosen chormosome is in this list, so we get it:
List<Double> es.us.isa.generator.FM.Evolutionay.EvolutionaryFMGenerator.AvFitnesses [package] |
Save the average fitness of each generation
double es.us.isa.generator.FM.Evolutionay.EvolutionaryFMGenerator.fitnesses [package] |
Variable to sum the fitnesses and then save the average on each generation