JSSP.genetic_algorithm.ga module¶
-
class
JSSP.genetic_algorithm.ga.
GASelectionEnum
¶ Bases:
enum.Enum
Enumeration class containing three selection methods for selecting parent solutions for the genetic algorithm.
- Selection Methods:
- GASelectionEnum.TOURNAMENT - Tournament style selection
- GASelectionEnum. FITNESS_PROPORTIONATE - Fitness proportionate selection (also called roulette wheel selection)
- GASelectionEnum.RANDOM - Random selection
-
FITNESS_PROPORTIONATE
()¶ Fitness proportionate selection for the genetic algorithm (also called roulette wheel selection).
This function first normalizes the fitness values (makespan) of the solutions in the population, then randomly removes a solution from the population and returns it.
See https://en.wikipedia.org/wiki/Fitness_proportionate_selection for more info.
Parameters: args – list where args[0] is the population Return type: Solution Returns: a Solution from the population
-
RANDOM
()¶ Random selection for the genetic algorithm.
This function randomly removes a solution from the population and returns it.
Parameters: args – list where args[0] is the population Return type: Solution Returns: a solution from the population
-
TOURNAMENT
()¶ Tournament style selection for the genetic algorithm.
This function selects args[1] (i.e. selection_size) solutions from the population, then removes the best solution out of the selection from the population and returns it.
See https://en.wikipedia.org/wiki/Tournament_selection for more info.
Parameters: args – list where args[0] is the population of solutions and args[1] is the selection size Return type: Solution Returns: a Solution from the population
-
class
JSSP.genetic_algorithm.ga.
GeneticAlgorithmAgent
(stopping_condition, population, time_condition=False, selection_method_enum=<function _tournament_selection>, mutation_probability=0.8, selection_size=2, benchmark=False)¶ Bases:
object
Genetic algorithm optimization agent.
Parameters: - stopping_condition (float) – either the duration to run GA in seconds or the number of generations to iterate though
- population ([Solution]) – list of Solutions to start the GA from, must not be empty
- time_condition (bool) – if true GA is ran for stopping_condition number of seconds else it is ran for stopping_condition generations
- selection_method_enum (GASelectionEnum) – selection method to use for selecting parents from the population. (see GASelectionEnum for selection methods)
- mutation_probability (float) – probability of mutating a child solution (i.e change a random operation’s machine) in range [0, 1]
- selection_size (int) – size of the selection group. (applicable only for tournament style selection)
- benchmark (bool) – if true benchmark data is gathered