Entry Point

UTCGP.mage_crossoverFunction
mage_crossover(inds::Population, run_config::AbstractRunConf, model_architecture::modelArchitecture,
               meta_library::MetaLibrary, shared_inputs::SharedInput, fitness::Vector{Float64}; extras::Dict=Dict()) -> Population

Entry Point for using the standard mage_crossover.

Creates a new population by performing truncation selection and generating new individuals via crossover (with subsequent mutation). The provided run_config is converted via the trait APIs to extract crossover/mutation and ES parameters.

Lower fitness is considered better.

Arguments

  • inds: Current population (vector of UTGenome).
  • run_config: Run configuration that supports the crossover trait and mutation trait.
  • model_architecture: Genome architecture information.
  • meta_library: Library of functions used during mutation.
  • shared_inputs: Shared inputs required during mutation.
  • fitness: Vector of fitness values.
  • extras: Optional extra parameters.

Returns

  • A new population (Vector{UTGenome}).
source
mage_crossover(inds::Population, crossover_args::CrossOverArgs, evolutionary_strategy_args::GAWithTournamentArgs,
               model_architecture::modelArchitecture, meta_library::MetaLibrary,
               shared_inputs::SharedInput, fitness::Vector{Float64}; extras::Dict=Dict()) -> Population

Creates a new population using truncation selection and generating new individuals through crossover (and mutation) using the GA with tournament selection strategy.

Arguments

  • inds: Current population.
  • crossover_args: Minimal crossover arguments.
  • evolutionary_strategy_args: GA-specific strategy arguments
  • model_architecture: Genome architecture information.
  • meta_library: Library used during mutation.
  • shared_inputs: Shared inputs for mutation.
  • fitness: Vector of fitness values.
  • extras: Optional extra parameters.

Returns

  • A new population (Vector{UTGenome}).
source
mage_crossover(inds::Population, crossover_args::CrossOverMutRateArgs, evolutionary_strategy_args::OnePlusLambda,
               model_architecture::modelArchitecture, meta_library::MetaLibrary,
               shared_inputs::SharedInput, fitness::Vector{Float64}; extras::Dict=Dict()) -> Population

Placeholder for a crossover method using a mutation rate strategy and OnePlus Lambda

source

High Level

Crossover Operator

UTCGP.mage_crossover_with_numbered_mutationFunction
mage_crossover_with_numbered_mutation(p1::UTGenome, p2::UTGenome, crossover_args::CrossOverArgs,
                                      model_architecture::modelArchitecture, meta_library::MetaLibrary,
                                      shared_inputs::SharedInput; p1_fitness, p2_fitness) -> UTGenome

Performs individual-level crossover between two parent genomes, with a numbered mutation applied if triggered. Uses a binary mask to swap whole chromosomes.

Behavior

  • If the drawn random number for crossover is below crossover_args.crossover_prob, a crossover is performed.
  • Otherwise, the fitter parent (or a random parent) is chosen.
  • Mutation is applied if the random draw is within crossover_args.mutation_prob.

Caveats

  • Ensures that at least one genetic operator (crossover and/or mutation) is applied.
  • Prevents a complete swap of all chromosomes to avoid simply exchanging individuals.

Arguments

  • p1: First parent genome.
  • p2: Second parent genome.
  • crossover_args: Minimal crossover configuration.
  • model_architecture: Genome architecture information.
  • meta_library: Library for mutation operations.
  • shared_inputs: Shared inputs for mutation.
  • p1_fitness: Fitness of parent1 (optional).
  • p2_fitness: Fitness of parent2 (optional).

Returns

  • A new UTGenome produced by crossover and mutation.
source

Traits

UTCGP.CrossOverArgsType
CrossOverArgs

Basic crossover configuration parameters.

Fields

  • mutation_prob::Float64: Probability of applying mutation.
  • mutation_n_active_nodes::Int64: Number of active nodes used in mutation.
  • crossover_prob::Float64: Probability of performing crossover.
source
UTCGP.CrossOverMutRateArgsType
CrossOverMutRateArgs

Crossover configuration parameters using an explicit mutation rate.

Fields

  • mutation_prob::Float64: Probability of applying mutation.
  • mutation_rate::Int64: The Probability for mutation rate (normally on each node).
  • crossover_prob::Float64: Probability of performing crossover.
source
UTCGP.runconf_trait_crossoverFunction

If there is no method specialized

source
runconf_trait_crossover(conf::UTCGP.RunConfCrossOverGA) -> CrossOverArgs

Extracts the minimal crossover arguments from a run configuration.

source
UTCGP.numbered_mutation_traitFunction
numbered_mutation_trait(conf::CrossOverArgs) -> NumberedMutationArgs

Extracts the arguments for numbered mutation from the provided crossover configuration.

source

Helper

UTCGP._initialize_populationFunction
_initialize_population(inds::Population, evo_args::GAWithTournamentArgs, fitness::Vector{Float64}) -> (Vector{UTGenome}, Int)

Initializes a new population vector based on the evolutionary strategy arguments.

Arguments

  • inds: The current population (after selection).
  • evo_args: Evolutionary strategy arguments.

Returns

  • A tuple (new_pop, n_elite) where new_pop is an uninitialized vector of UTGenome with size equal to n_new + n_elite, and n_elite is the number of elite individuals to preserve.

Errors

  • Throws an error if the expected population size (n_elite) does not match the length of inds.
source
UTCGP._apply_truncation_selection!Function
_apply_truncation_selection!(new_pop::Vector{UTGenome}, inds::Population, fitness::Vector{Float64}, n_elite::Int)

Performs truncation selection by copying the best n_elite individuals (with the lowest fitness values) from the current population inds into the beginning of the new population vector new_pop.

Arguments

  • new_pop: The new population vector to be filled (modified in-place).
  • inds: The current population (vector of UTGenome).
  • fitness: Vector of fitness values (lower is better).
  • n_elite: Number of elite individuals to preserve.

Returns

  • The sorted indices of the whole population.

Side Effects

  • Modifies new_pop in-place by copying the elite individuals.
source
UTCGP._apply_crossover_and_mutation!Function
_apply_crossover_and_mutation!(new_pop::Vector{UTGenome},
                                 inds::Population,
                                 offset::Int64,
                                 tournament_size::Int64,
                                 n_new::Int64,
                                 crossover_args::CrossOverArgs,
                                 model_architecture::modelArchitecture,
                                 meta_library::MetaLibrary,
                                 shared_inputs::SharedInput,
                                 fitness::Vector{Float64};
                                 crossover_operator::Function = mage_crossover_with_numbered_mutation)

Generates new individuals by applying crossover (and mutation) to selected parent pairs and inserts them into the new population vector new_pop, starting at the given offset.

This function performs the following steps:

  1. For each new individual to be created (total n_new):
    • Selects two parents from the current population inds using tournament selection with the specified tournament_size and based on the provided fitness (lower fitness is better). Not possible to select the same ind twice.
    • Applies the given crossover_operator (default is mage_crossover_with_numbered_mutation) to the selected parents to produce a new individual.
    • Inserts the new individual into new_pop at the corresponding position (starting at offset+1).
  2. Debug messages are logged at key steps to trace the selection and generation process.

Arguments

  • new_pop::Vector{UTGenome}: The preallocated population vector where new individuals will be stored.
  • inds::Population: The current population from which parents are selected.
  • offset::Int64: The starting index in new_pop where new individuals should be placed (typically equal to the number of elite individuals preserved).
  • tournament_size::Int64: The size of the tournament used for parent selection.
  • n_new::Int64: The number of new individuals to generate via crossover.
  • crossover_args::CrossOverArgs: Crossover configuration parameters.
  • model_architecture::modelArchitecture: Information about the genome architecture.
  • meta_library::MetaLibrary: Library of functions used during mutation.
  • shared_inputs::SharedInput: Shared inputs required for mutation operations.
  • fitness::Vector{Float64}: A vector of fitness values for the current population (lower is better).
  • crossover_operator::Function (keyword): The function used to perform crossover and mutation on two parents. Defaults to mage_crossover_with_numbered_mutation.

Side Effects

  • Modifies new_pop in-place by inserting new individuals at indices offset+1 to offset+n_new.
source
_apply_crossover_and_mutation!(new_pop::Vector{UTGenome},
                                 inds::Population,
                                 ga_strategy::GAWithTournamentArgs,
                                 crossover_args::CrossOverArgs,
                                 model_architecture::modelArchitecture,
                                 meta_library::MetaLibrary,
                                 shared_inputs::SharedInput,
                                 fitness::Vector{Float64};
                                 crossover_operator::Function = mage_crossover_with_numbered_mutation)

Convenience wrapper that extracts parameters from a GA strategy configuration and calls the more general _apply_crossover_and_mutation! function.

This function uses the fields from ga_strategy as follows:

  • ga_strategy.n_elite is used as the offset in new_pop.
  • ga_strategy.tournament_size is used for tournament selection.
  • ga_strategy.n_new is the number of new individuals to generate.

Side Effects

  • Calls the general _apply_crossover_and_mutation! function with parameters extracted from ga_strategy.
source

For Crossover :

UTCGP._check_genome_compatibilityFunction
_check_genome_compatibility(p1::UTGenome, p2::UTGenome) -> Int

Ensures that both parent genomes have the same number of chromosomes and that the genome is not a single-chromosome (CGP) genome. Returns the number of chromosomes.

Errors

  • Throws an error if genomes have different lengths or if there is only one chromosome.
source
UTCGP._draw_until_one_operatorFunction
_draw_until_one_operator(crossover_prob::Float64, mutation_prob::Float64) -> (Float64, Float64)

Draws random numbers repeatedly until either the crossover or mutation condition is met. Returns a tuple (r_c, r_m) representing the drawn random values.

Side Effects

  • Logs the drawn random values.
source