Genetic algorithms optimiser¶
-
GA_Analysis.
GA_iterate
(iterations=5, population_size=30, constraint=False, constraint_levers=[], constraint_values=[], output_constraint=False, output_constraint_names=[], output_constraints=[], threshold=False, threshold_names=[], thresholds=[], std_devs=3)¶ Given a set of constraints performs GA iteration(s) on the Global Calculator.
Args:
iterations (int): Number of GA iterations.
population_size (int): Number of chromosomes per iteration.
constraint (boolean): Flag to decide whether to fix input levers or not.
constraint_levers (list): Contains the names of the levers to be fixed.
constraint_Values (list): Contains the values of the levers to be fixed.
output_constraint (boolean): Flag to decide whether to fix outputs or not.
output_constraint_names (list): Contains the names of the output to be fixed.
output_constraints (list): Contains the values of the output to be fixed.
threshold (boolean): Flag to decide whether to bound levers within a range or not.
threshold_names (list): Contains the names of the levers to be bounded within a range.
thresholds (list): Contains the upper and lower threshold to bound the specified levers.
Returns:
Total fitness value of each generation and lever values of all the chromosomes from the last generation.
-
GA_Analysis.
fitness
(chromosome, target_temperature=3000, target_cost=0, output_constraint=False, current_output_values=[], output_constraint_names=[], output_constraints=[], std_devs=[])¶ Need to apply some sort of normalisation. Divide by standard deviation
-
GA_Analysis.
generate_chromosome
(constraint=False, constraint_levers=[], constraint_values=[], threshold=False, threshold_names=[], thresholds=[])¶ Initialises a chromosome and returns its corresponding lever values, and temperature and cost.
Args:
constraint (boolean): Flag to select whether any inputs have been fixed.
constraint_levers (list): Contains the name of levers to be fixed.
constraint_values (list): Contains the values to fix the selected levers to.
threshold (boolean): Flag to select whether any inputs have to be bounded within a range.
threshold_names (list): Contains the name of the levers to be bounded within a range.
thresholds (list): Contains the upper and lower bound for each specified lever.
Returns:
Lever values corresponding to generated chromosome and temperature-cost values corresponding to the current chromosome.
-
GA_Analysis.
mate
(parent_1, parent_2, threshold=False, threshold_name='', threshold_value='')¶ Takes a couple of parents, performs crossover, and returns resulting child.
-
GA_Analysis.
move_lever
(lever, value, costs=False, address='', constraint=False, constraint_levers=[], constraint_values=[])¶ Sets a lever to a given value. Reads corresponding temperature and, if selected, cost values.
Args:
lever (list): Contains the names of the levers to be moved.
value (list): Contains the value of the levers to be moved - Automatically matched to lever names.
costs (boolean): Flag to decide whether to read cost values or not.
address (string): URL address corresponding to given lever combination.
constraint (boolean): Flag to decide whether to set exact input constraints or not.
constraint_levers (list): Contains the names of the levers to be fixed.
constraint_values (*list): Contains the values to fix the specified levers.
Returns:
List of temperature and cost values for the new lever position
-
GA_Analysis.
moving_average
(a, n=3)¶ Simple moving average filter
-
GA_Analysis.
mutated_genes
(lever_value, thresholds=[1, 3.9], threshold=False, threshold_name='', threshold_value='')¶ Mutate gene by randomly moving a lever up or down by 0.1. Returns the mutated gene (the new lever value)
-
GA_Analysis.
overwrite
(levers, values, address='')¶ Given a set of lever names and corresponding values, overwrite specified lever combination
-
GA_Analysis.
overwrite_lever_values
(levers, values, constraint_levers, constraint_values)¶ Given a set of lever names and corresponding values, and a set of constrained lever names and their values, return the corresponding lever combination and its values.
-
GA_Analysis.
read_outputs
()¶ Reads all outputs and returns them as a list (empirical scraping)
-
GA_Analysis.
selection
(fitness_values)¶ Given an array of fitness values, find the indeces and the values of the 2 fittest candidates -> Parents