UnconstrainedSelectionProtocol#
- class pybrops.breed.prot.sel.UnconstrainedSelectionProtocol.UnconstrainedSelectionProtocol(**kwargs)[source]#
Bases:
object
Abstract 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:
k
is the number of individuals.
args (tuple) – Additional arguments.
- Returns:
out – An array of objective function values of shape
(o,)
or a scalar.Where:
o
is 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:
j
is the number of selection configurations.k
is the number of individuals.
args (tuple) – Additional arguments.
- Returns:
out – An array of objective function values of shape
(j,o)
or(j,)
.Where:
j
is the number of selection configurations.o
is 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:
frontier
is anumpy.ndarray
of shape(q,v)
containing Pareto frontier points.sel_config
is anumpy.ndarray
of shape(q,k)
containing parent selection decisions for each corresponding point in the Pareto frontier.
Where:
q
is the number of points in the frontier.v
is the number of objectives for the frontier.k
is 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:
pgmat
is a PhasedGenotypeMatrix of parental candidates.sel
is anumpy.ndarray
of indices specifying a cross pattern. Each index corresponds to an individual inpgmat
.ncross
is anumpy.ndarray
specifying the number of crosses to perform per cross pattern.nprogeny
is anumpy.ndarray
specifying the number of progeny to generate per cross.
- Return type:
tuple