UnconstrainedSelectionProtocol#
- class pybrops.breed.prot.sel.UnconstrainedSelectionProtocol.UnconstrainedSelectionProtocol(**kwargs)[source]#
Bases:
objectAbstract class defining interfaces for selection protocols.
- The purpose of this abstract class is to define functionality for:
Selection (both single- and multi-objective) of genotypes.
Construction of fast objective functions.
Mapping of the Pareto frontier for the selection protocol.
Access to static objective functions for the selection protocol.
Constructor for the abstract class SelectionProtocol.
- Parameters:
kwargs (dict) – Additional keyword arguments.
Methods
Return an objective function constructed from inputs for fast calling.
Objective function for the selection protocol.
Return a vectorized objective function constructed from inputs for fast calling.
Vectorized objective function for the selection protocol.
Calculate a Pareto frontier for objectives.
Select individuals for breeding.
- objfn(pgmat, gmat, ptdf, bvmat, gpmod, t_cur, t_max, **kwargs)[source]#
Return an objective function constructed from inputs for fast calling.
- Parameters:
pgmat (PhasedGenotypeMatrix) – Genomes
gmat (GenotypeMatrix) – Genotypes
ptdf (pandas.DataFrame) – Phenotype dataframe
bvmat (BreedingValueMatrix) – Breeding value matrix
gpmod (GenomicModel) – Genomic prediction model
t_cur (int) – Current generation number.
t_max (int) – Maximum (deadline) generation number.
kwargs (dict) – Additional keyword arguments.
- Returns:
out – A selection objective function for the specified problem.
- Return type:
function
- static objfn_static(sel, *args)[source]#
Objective function for the selection protocol.
- Parameters:
sel (numpy.ndarray, None) –
A selection vector of shape
(k,).Where:
kis the number of individuals.
args (tuple) – Additional arguments.
- Returns:
out – An array of objective function values of shape
(o,)or a scalar.Where:
ois the number of objectives.
- Return type:
numpy.ndarray, scalar
- objfn_vec(pgmat, gmat, ptdf, bvmat, gpmod, t_cur, t_max, **kwargs)[source]#
Return a vectorized objective function constructed from inputs for fast calling.
- Parameters:
pgmat (PhasedGenotypeMatrix) – Genomes
gmat (GenotypeMatrix) – Genotypes
ptdf (pandas.DataFrame) – Phenotype dataframe
bvmat (BreedingValueMatrix) – Breeding value matrix
gpmod (GenomicModel) – Genomic prediction model
t_cur (int) – Current generation number.
t_max (int) – Maximum (deadline) generation number.
kwargs (dict) – Additional keyword arguments.
- Returns:
out – A vectorized selection objective function for the specified problem.
- Return type:
function
- static objfn_vec_static(sel, *args)[source]#
Vectorized objective function for the selection protocol.
- Parameters:
sel (numpy.ndarray, None) –
A selection vector of shape
(j,k).Where:
jis the number of selection configurations.kis the number of individuals.
args (tuple) – Additional arguments.
- Returns:
out – An array of objective function values of shape
(j,o)or(j,).Where:
jis the number of selection configurations.ois the number of objectives.
- Return type:
numpy.ndarray
- pareto(pgmat, gmat, ptdf, bvmat, gpmod, t_cur, t_max, miscout, **kwargs)[source]#
Calculate a Pareto frontier for objectives.
- Parameters:
pgmat (PhasedGenotypeMatrix) – Genomes
gmat (GenotypeMatrix) – Genotypes
ptdf (pandas.DataFrame) – Phenotype dataframe
bvmat (BreedingValueMatrix) – Breeding value matrix
gpmod (GenomicModel) – Genomic prediction model
t_cur (int) – Current generation number.
t_max (int) – Maximum (deadline) generation number.
miscout (dict, None) – Pointer to a dictionary for miscellaneous user defined output. If
dict, write to dict (may overwrite previously defined fields). IfNone, user defined output is not calculated or stored.kwargs (dict) – Additional keyword arguments.
- Returns:
out – A tuple containing two objects
(frontier, sel_config).Where:
frontieris anumpy.ndarrayof shape(q,v)containing Pareto frontier points.sel_configis anumpy.ndarrayof shape(q,k)containing parent selection decisions for each corresponding point in the Pareto frontier.
Where:
qis the number of points in the frontier.vis the number of objectives for the frontier.kis the number of search space decision variables.
- Return type:
tuple
- select(pgmat, gmat, ptdf, bvmat, gpmod, t_cur, t_max, miscout, **kwargs)[source]#
Select individuals for breeding.
- Parameters:
pgmat (PhasedGenotypeMatrix) – Genomes
gmat (GenotypeMatrix) – Genotypes
ptdf (pandas.DataFrame) – Phenotype dataframe
bvmat (BreedingValueMatrix) – Breeding value matrix
gpmod (GenomicModel) – Genomic prediction model
t_cur (int) – Current generation number.
t_max (int) – Maximum (deadline) generation number.
miscout (dict, None) – Pointer to a dictionary for miscellaneous user defined output. If
dict, write to dict (may overwrite previously defined fields). IfNone, user defined output is not calculated or stored.kwargs (dict) – Additional keyword arguments.
- Returns:
out – A tuple containing four objects:
(pgmat, sel, ncross, nprogeny).Where:
pgmatis a PhasedGenotypeMatrix of parental candidates.selis anumpy.ndarrayof indices specifying a cross pattern. Each index corresponds to an individual inpgmat.ncrossis anumpy.ndarrayspecifying the number of crosses to perform per cross pattern.nprogenyis anumpy.ndarrayspecifying the number of progeny to generate per cross.
- Return type:
tuple