Skip to content

EvolutionaryConfigsGenAlg

Samuel Gomes edited this page Jul 15, 2024 · 12 revisions

EvolutionaryConfigsGenAlg

This class is a child of ConfigsGenAlg. It uses the genetic algorithm (GA) implementation present in the DEAP library to optimize the generation of group configurations and preferences. A summarized description of GAs is given in the following website. Using this algorithm instead of the previous ones is that instead of just exploring new solutions, it also exploits the current ones while maintaining scalability.

Note: due to some implementation limitations, some group configuration parameterizations are not supported. The user is advised to test if the needed configuration works and use other approach if the genetic one cannot be applied.

Genetic Structures and Operators

Chromosome Representation

In the context of group organization, a chromosome (or individual) is a group configuration. As such, an individual in our GA implementation is represented using two attributes, the distribution of learners in groups, and a set of InteractionProfiles, one for each group.

For example:

<Individual> ind = [ 
   [
    [1,2,3,4], 
    [5,6,7,8], 
    [9,10,11,12], 
    [13,14,15,16]], 
   [
    <InteractionProfile: {0.86, 0.25}>, 
    <InteractionProfile: {0.12, 0.54}>,
    <InteractionProfile: {0.50, 0.21}>,
    <InteractionProfile: {0.14, 0.97}>
   ]
]

Selection

The currently used selection algorithm is the tools.selBest implemented by DEAP.

Crossover

The crossover operator works on two phases. Firstly, two group configurations are merged in a similar fashion to the method used in the following research paper. Next, the profiles of each group are uniformly crossed over.

Mutation

Similar to the crossover operator, the mutation uses two distinct phases. For the group configuration, the mutation is performed as a crossover with a random configuration, with probability probOfMutationConfig. For the profiles, there is a 50% chance of each dimension decreasing or increasing by a random amount (these changes are currently limited to 0.2). The mutation of each dimension of each profile is computed with probability probOfMutationGIPs.

Fitness Calculation

The fitness is computed resorting to a given QualityEvalAlg.

Constructor and Members

Constructor

EvolutionaryConfigsGenAlg(
        player_model_bridge: PlayerModelBridge,         
        interactions_profile_template: InteractionsProfile,
        quality_eval_alg: QualityEvalAlg,
        min_num_players_per_group: int = 2,
        max_num_players_per_group: int = 5,    
        preferred_num_players_per_group: int = None,   

        initial_population_size: int = 100,         
        num_evolutions_per_iteration: int = 500,
        prob_cross: decimal = 0.7,         
        
        prob_mut: decimal = 0.2,        
        prob_mut_config: decimal = 0.2,         
        prob_mut_profiles: decimal = 0.2,

        num_children_per_iteration: int = 5,
        num_survivors: int = 5,

        cx_op: string {"order", "simple"} = "order",
       
        joint_player_constraints: string = "",
        separated_player_constraints: string = ""): void

Members

Name: expected type Default value Description
__quality_eval_alg: QualityEvalAlg - The algorithm used to evaluate the quality of a group configuration.
__initial_population_size: int 100 The number of individuals to generate before the first genetic iteration.
__num_evolutions_per_iteration: int 500 The number of genetic iterations to perform each time the GA is executed (organize is called).
__prob_cross: decimal 0.7 The probability of selecting the cross operator.
__prob_mut: decimal 0.2 The probability of selecting the mutation operator.
__prob_mut_config: decimal 0.2 The probability of mutating the group configurations within the mutation operator.
__prob_mut_profiles: decimal 0.2 The probability of mutating the group profiles within the mutation operator.
__num_children_per_iteration: int 5 The number of generated offspring between genetic iterations.
__num_survivors: int 5 The number of allowed survivors between genetic iterations.
__cx_op: string {"order", "simple"} "order" Allows to use a simple crossover operator (see below), for debug purposes.
__search_id: string - .
__fitness_func_id: string - .
__individual_id: string - .
__toolbox: - A base.Toolbox instance from DEAP.
__pop: - The population parameter manipulated in a DEAP algorithm.
__hof: - The halloffame parameter manipulated in a DEAP algorithm.
__player_ids: int[] - A list with the player ids allows the algorithm to perceive changes in the selected players.

Functions

__reset(): void

Description

Checks for changes in the selected players and updates the population and current best solutions of the GA. Currently called before group formation in every organize.

__random_individual_generator(playerIds: int[], minNumGroups: int, maxNumGroups: int): <Individual>

Description

Used to generate a random chromosome (group configuration with profiles).

__cx_gimme_order(ind1: <Individual>, ind2: <Individual>): (<Individual>,<Individual>)

Description

Implements the crossover operator (see above).

__cx_gimme_simple(ind1: <Individual>, ind2: <Individual>): (<Individual>,<Individual>)

Description

(legacy) Implements a crossover operator used for debug purposes.

__mut_gimme(individual: <Individual>, pGIPs: decimal, pConfig: decimal): (<Individual>)

Description

Implements the mutation operator.

__calc_fitness_convergence_test(individual: <Individual>): decimal

Description

(legacy) Calculates fitness in a way that makes the GA approximate a given fixed chromosome. This was used for debug purposes.

__calc_fitness(individual: <Individual>): decimal

Description

Obtains an individual's fitness resorting to the QualityEvalAlg passed in the constructor.

__sel_gimme(individuals: <Individual>[], k: int, fit_attr: string = "fitness"): <Individual>[]

Description

Prepares and calls the method selBest from DEAP.

Overrides organize() (see ConfigsGenAlg).

Clone this wiki locally