reV.bespoke.gradient_free.GeneticAlgorithm
- class GeneticAlgorithm(bits, bounds, variable_type, objective_function, max_generation=100, population_size=0, crossover_rate=0.1, mutation_rate=0.01, tol=1e-06, convergence_iters=5, max_time=3600, plant_noise=None)[source]
Bases:
objecta simple genetic algorithm used to select bespoke turbine locations
- Parameters:
bits (array of ints) – The number of bits assigned to each of the design variables. The number of discretizations for each design variables will be 2^n where n is the number of bits assigned to that variable.
bounds (array of tuples) – The bounds for each design variable. This parameter looks like: np.array([(lower, upper), (lower, upper)…])
variable_type (array of strings (‘int’ or ‘float’)) – The type of each design variable (int or float).
objective_function (function handle for the objective that is to be) – minimized. Should take a single variable as an input which is a list/array of the design variables.
max_generation (int, optional) – The maximum number of generations that will be run in the genetic algorithm.
population_size (int, optional) – The population size in the genetic algorithm.
crossover_rate (float, optional) – The probability of crossover for a single bit during the crossover phase of the genetic algorithm.
mutation_rate (float, optional) – The probability of a single bit mutating during the mutation phase of the genetic algorithm.
tol (float, optional) – The absolute tolerance to determine convergence.
convergence_iters (int, optional) – The number of generations to determine convergence.
max_time (float) – The maximum time (in seconds) to run the genetic algorithm.
plant_noise (PlantNoise object, optional) – An optional PlantNoise object that can be used to compute the plant-level sound at observer locations. If provided, the genetic algorithm will compute a penalty for any noise violations at the observer locations.
Methods
chromosome_2_variables(chromosome)convert the binary chromosomes to design variable values
perform crossover between individual parents
determine the total number of bits
initialize the design variables from the randomly initialized population
initialize the fitness of member of the parent population
randomly initialize the parent and offspring populations
Make sure no offspring has zero capacity
mutate()randomly mutate bits of each chromosome
run the genetic algorithm
- initialize_design_variables()[source]
initialize the design variables from the randomly initialized population