Evolution
Package related to evolutionary agorithms.
Classes summary
Class for the population of an evolutionary algorithm. |
|
Abstract class for mutation operators. |
|
|
Class for polynomial mutation. |
Abstract class for crossover operators. |
|
|
Class for SBX crossover. |
Class for intermediate crossover (weighted average of decision variables). |
|
|
Class for 2-point crossover. |
Abstract class for selection operators. |
|
Class for Tournament selection. |
|
Class for Tournament_Position selection. |
|
Abstract class for replacement operators. |
|
Class for Elitist replacement. |
|
Class for custom elitist replacement. |
|
Class for the set of reference vectors of RVEA. |
Population
- class Evolution.Population.Population(pb)
Bases:
objectClass for the population of an evolutionary algorithm.
- Parameters:
pb (Problem) – problem
dvec (np.ndarray) – decision vectors of the individuals
obj_vals (np.ndarray) – objective value associated with each individual
fitness_modes (np.ndarray) – evaluation mode associated with each individual: True for real evaluation and False for prediction (surrogate evaluation)
__init__ method’s input
- Parameters:
pb (Problem) – problem
- print_shapes()
Prints the shapes of the arrays dvec, obj_vals and fitness_modes forming the population.
- check_integrity()
Checks arrays’ shapes are consistent.
- Returns:
True for arrays’ consistency and False otherwise
- Return type:
bool
- append(pop)
Appends individuals to the current population.
- Parameters:
pop (Population) – individuals to be appended
- sort()
Sorts the population according to ascending individuals’ objective value (single-objective) or non-dominated and crowded distance sorting (multi-objective).
- split_in_batches(n_batch)
Splits the population in batches.
- Parameters:
n_batch (positive int, not zero) – number of batches
- Returns:
list of batches
- Return type:
list(Population)
- update_best_sim(f_best_profile, f_hypervolume=None)
Updates the best individual (single-objective) or the best non-dominated front (multi-objective) and logs.
For mono-objective: The best evaluated decision vector (minimisation assumed) is saved in Global_Var.dvec_min and its associated objective value is saved in Global_Var.obj_val_min. The best evaluated decision vector is printed to a file along with its associated objective value.
For multi-objective: If the hypervolume has improved, the evaluated decision vectors composing the best non-dominated front are printed to a file along with their respective objective value. The best hyper-volume is always printed to a file.
- Parameters:
f_best_profile (str) – filename for logging
f_hypervolume (str) – filename for logging hypervolume
- save_to_csv_file(f_pop_archive)
Prints the population to a CSV file.
The CSV file is organized as follows: First row: number of decision variables, number of objectives, number of fitness modes Second row: lower bounds of the decision variables Thrid row: upper bounds of the decision variables Remaining rows (one per individual): decision variables, objective values, fitness mode
- Parameters:
f_pop_archive (str) – filename of the CSV file.
- load_from_csv_file(f_pop_archive)
Loads the population from a CSV file.
The CSV file has to be organized as follows: First row: number of decision variables, number of objectives, number of fitness modes Second row: lower bounds of the decision variables Third row: upper bounds of the decision variables Remaining rows (one per individual): decision variables, objective values, fitness mode
- Parameters:
f_pop_archive (str) – filename of the CSV file
- save_sim_archive(f_sim_archive)
Prints the real-evaluated individuals to a CSV file.
The CSV file is organized as follows: One per individual: decision variables, objective values, fitness mode.
- Parameters:
f_sim_archive (str) – filename of the CSV file.
- save_to_pickle_file(f_pop_archive)
Saves the population to a pickle file.
- Parameters:
f_pop_archive (str) – filename of the pickle file
- load_from_pickle_file(f_pop_archive)
Loads a population from a pickle file.
- Parameters:
f_pop_archive (str) – filename of the pickle file
Mutation
Mutation (abstract)
- class Evolution.Mutation.Mutation(prob)
Bases:
ABCAbstract class for mutation operators.
- Parameters:
prob (float in [0,1]) – probability of mutation
Polynomial
- class Evolution.Polynomial.Polynomial(prob, eta)
Bases:
MutationClass for polynomial mutation.
- Parameters:
prob (float in [0,1]) – probability of mutation
eta (positive int, not zero) – distribution index
- perform_mutation(pop)
Mutates the individuals of a population.
- Parameters:
pop (Population) – population to mutate
- Returns:
the mutated population
- Return type:
Crossover
Crossover (abstract)
- class Evolution.Crossover.Crossover(prob)
Bases:
ABCAbstract class for crossover operators.
- Parameters:
prob (float in [0,1]) – probability of crossover
SBX
- class Evolution.SBX.SBX(prob, eta)
Bases:
CrossoverClass for SBX crossover.
- Parameters:
prob (float in [0,1]) – probability of crossover
eta (positive int, not zero) – distribution index
- perform_crossover(pop)
Applies crossover to the individuals of a population.
- Parameters:
pop (Population) – population to mutate
- Returns:
the mutated population
- Return type:
Intermediate
- class Evolution.Intermediate.Intermediate(prob=1.0)
Bases:
CrossoverClass for intermediate crossover (weighted average of decision variables).
- Parameters:
prob (float in [0,1]) – probability of crossover
- perform_crossover(pop)
Applies crossover to the individuals of a population.
- Parameters:
pop (Population) – population to mutate
- Returns:
the crossed population
- Return type:
Two_Points
- class Evolution.Two_Points.Two_Points(prob=1.0)
Bases:
CrossoverClass for 2-point crossover.
- Parameters:
prob (float in [0,1]) – probability of crossover
- perform_crossover(pop)
Applies crossover to the individuals of a population.
- Parameters:
pop (Population) – population of parents
- Returns:
the crossed population
- Return type:
Selection
Selection (abstract)
- class Evolution.Selection.Selection
Bases:
ABCAbstract class for selection operators.
- abstract perform_selection(pop, n_par)
Selects individuals from a population.
- Parameters:
pop (Population) – population to select from
n_par (positive int, not zero) – number of individuals to select
- Returns:
the selected individuals
- Return type:
Tournament
- class Evolution.Tournament.Tournament(size)
Bases:
SelectionClass for Tournament selection.
- Parameters:
size (positive int, not zero) – tournament size
- perform_selection(pop, n_par)
Selects individuals from a population.
- Parameters:
pop (Population) – population to select from
n_par (positive int, not zero) – number of individuals to select
- Returns:
the selected individuals
- Return type:
Tournament_Position
- class Evolution.Tournament_Position.Tournament_Position(size)
Bases:
SelectionClass for Tournament_Position selection.
Candidates are ordered within the population according to their promise (decreasing order).
- Parameters:
size (positive int, not zero) – tournament size
- perform_selection(pop, n_par)
Selects individuals from a population.
- Parameters:
pop (Population) – population to select from
n_par (positive int, not zero) – number of individuals to select
- Returns:
the selected individuals
- Return type:
Replacement
Replacement (abstract)
- class Evolution.Replacement.Replacement
Bases:
ABCAbstract class for replacement operators.
Elitist
- class Evolution.Elitist.Elitist
Bases:
ReplacementClass for Elitist replacement.
Minimization is assumed.
- perform_replacement(pop, children)
Keeps the best individuals of from two populations.
- Parameters:
pop (Population) – first population, will store the best individuals
children (Population) – second population
Custom_Elitism
- class Evolution.Custom_Elitism.Custom_Elitism(ec)
Bases:
ReplacementClass for custom elitist replacement.
- Parameters:
ec (Surrogate) – the criterion defining elitism
- perform_replacement(pop, children)
Keeps the best individuals from two populations.
- Parameters:
pop (Population) – first population, will store the best individuals
children (Population) – second population
Reference Vector Set
- class Evolution.Reference_Vector_Set.Reference_Vector_Set(H, pb)
Bases:
objectClass for the set of reference vectors of RVEA.
- Parameters:
pb (Problem) – problem
rv (np.ndarray) – set of reference vectors
__init__ method’s input
- Parameters:
H (int) – simplex lattice parameter
pb (Problem) – problem
- reference_vector_guided_replacement(pop, search_progress, budget)
Performs replacement based on the set of reference vectors.
- Parameters:
pop (Population) – population to perform replacement on
search_progress (int or float) – current generation index (or elapsed time)
budget (int or float) – number of generations (or time) allocated for the search
- Returns:
the new population
- Return type:
- reference_vector_update(pop)
Updates the set of reference vectors.
- Parameters:
pop (Population) – current population
- Returns:
the updated set of reference vectors
- Return type:
- reference_vector_regeneration(pop)
Regenerates the set of reference vectors (for RVEA*).
- Parameters:
pop (Population) – current population
- save_to_csv_file(f_rv_archive)
Prints the set of reference vectors to a CSV file.
The CSV file is organized as follows: First row: number of reference vectors and number of objectives Remaining rows: the reference vectors
- Parameters:
f_rv_archive (str) – filename of the CSV file.
- plot()
Plot the 3D reference vectors.