run_simulation_cycles
run_simulation_cycles (initial_state:chewc.structs.BreedingState, trait:chewc.structs.Trait, genetic_map:chewc.structs.GeneticMap, heritabilities:jax.Array, n_cycles:int, n_select:int, n_offspring:int, max_crossovers:int)
*Runs the entire multi-cycle simulation using lax.scan for high performance.
Args: initial_state (BreedingState): Starting state of the simulation. trait (Trait): Trait architecture. genetic_map (GeneticMap): Genetic map. heritabilities (jnp.ndarray): Heritability values. n_cycles (int): Number of selection cycles to run. n_select (int): Number of parents to select per cycle. n_offspring (int): Number of offspring to produce per cycle. max_crossovers (int): Maximum crossovers per chromosome.
Returns: final_state (BreedingState): The state after the last cycle. history (jnp.ndarray): Array of shape (n_cycles, 2) containing [mean_tbv, mean_phenotype] for each generation.*
phenotypic_selection_step
phenotypic_selection_step (carry:chewc.structs.BreedingState, _, trait:chewc.structs.Trait, genetic_map:chewc.structs.GeneticMap, heritabilities:jax.Array, n_select:int, n_offspring:int, max_crossovers:int)
*Executes one full cycle of phenotypic selection and breeding.
This function performs the following steps: 1. Phenotyping: Calculates phenotypes and True Breeding Values (TBVs). 2. Selection: Selects top n_select parents based on the first trait (index 0). 3. Mating: Generates a random mating plan. 4. Crossing: Simulates meiosis and crossover to create the next generation. 5. Update: Updates the simulation state (generation, IDs, pedigree).
Args: carry (BreedingState): Current simulation state. _ (Any): Ignored loop iterator from lax.scan. trait (Trait): Trait architecture. genetic_map (GeneticMap): Genetic map for recombination. heritabilities (jnp.ndarray): Heritability values for phenotypes. n_select (int): Number of parents to select. n_offspring (int): Number of offspring to generate. max_crossovers (int): Maximum crossovers per chromosome.
Returns: next_state (BreedingState): The updated simulation state. metrics (jnp.ndarray): Array [mean_tbv, mean_phenotype] for the first trait.*
| Type | Details | |
|---|---|---|
| carry | BreedingState | |
| _ | Placeholder for lax.scan’s iteration number | |
| trait | Trait | |
| genetic_map | GeneticMap | |
| heritabilities | Array | |
| n_select | int | |
| n_offspring | int | |
| max_crossovers | int | |
| Returns | Tuple |