Generalized1NormGenomicSelection#

class pybrops.breed.prot.sel.UnconstrainedGeneralized1NormGenomicSelection.Generalized1NormGenomicSelection(nparent, ncross, nprogeny, weight=<function weight_absolute>, target=<function target_positive>, method='single', objfn_trans=None, objfn_trans_kwargs=None, objfn_wt=-1.0, ndset_trans=None, ndset_trans_kwargs=None, ndset_wt=-1.0, rng=RandomState(MT19937) at 0x7F8D0DF4C840, soalgo=None, moalgo=None, **kwargs)[source]#

Bases: UnconstrainedSelectionProtocol

docstring for Generalized1NormGenomicSelection.

Constructor for Generalized1NormGenomicSelection.

Parameters:

nparent (int) – Number of parents to select.

Methods

objfn

Return an objective function for the provided datasets.

objfn_static

Score a parent selection vector according to its distance from a utopian point.

objfn_vec

Return a vectorized objective function.

objfn_vec_static

Score a parent selection vector according to its distance from a utopian point.

pareto

Calculate a Pareto frontier for objectives.

select

Select parents individuals for breeding.

Attributes

method

Selection method.

moalgo

Multi-objective opimization algorithm.

ncross

Number of crosses per configuration.

ndset_trans

Nondominated set transformation function.

ndset_trans_kwargs

Nondominated set transformation function keyword arguments.

ndset_wt

Nondominated set weights.

nparent

Number of parents to select.

nprogeny

Number of progeny to derive from each cross configuration.

objfn_trans

Objective function transformation function.

objfn_trans_kwargs

Objective function transformation function keyword arguments.

objfn_wt

Objective function weights.

rng

Random number generator source.

soalgo

Single objective optimization algorithm.

target

Allele frequency targets or allele frequency target function.

weight

Marker weights or marker weight function.

property method: str#

Selection method.

property moalgo: UnconstrainedOptimizationAlgorithm#

Multi-objective opimization algorithm.

property ncross: int#

Number of crosses per configuration.

property ndset_trans: Callable | None#

Nondominated set transformation function.

property ndset_trans_kwargs: dict#

Nondominated set transformation function keyword arguments.

property ndset_wt: float | ndarray#

Nondominated set weights.

property nparent: int#

Number of parents to select.

property nprogeny: int#

Number of progeny to derive from each cross configuration.

objfn(pgmat, gmat, ptdf, bvmat, gpmod, t_cur, t_max, **kwargs)[source]#

Return an objective function for the provided datasets.

Parameters:
Returns:

outfn – A selection objective function for the specified problem.

Return type:

function

static objfn_static(sel, V, trans, kwargs)[source]#

Score a parent selection vector according to its distance from a utopian point. The goal is to minimize this function.

Parameters:
  • sel (numpy.ndarray) –

    A selection indices matrix of shape (k,).

    Where:

    • k is the number of individuals to select.

    Each index indicates which individuals to select. Each index in sel represents a single individual’s row.

  • V (numpy.ndarray) –

    A matrix of shape (n,p,t) containing distance values of individuals’ alleles for each trait.

    Where:

    • n is the number of individuals.

    • p is the number of markers.

    • t is the number of traits.

  • trans (function or callable) –

    A transformation operator to alter the output. Function must adhere to the following standard:

    • Must accept a single numpy.ndarray argument.

    • Must return a single object, whether scalar or numpy.ndarray.

  • kwargs (dict) – Dictionary of keyword arguments to pass to trans function.

Returns:

dist – A matrix of shape (t,) if trans is None.

Distances for each target.

Where:

  • t is the number of traits.

Return type:

numpy.ndarray

property objfn_trans: Callable | None#

Objective function transformation function.

property objfn_trans_kwargs: dict#

Objective function transformation function keyword arguments.

objfn_vec(pgmat, gmat, ptdf, bvmat, gpmod, t_cur, t_max, **kwargs)[source]#

Return a vectorized objective function.

static objfn_vec_static(sel, V, trans, kwargs)[source]#

Score a parent selection vector according to its distance from a utopian point. The goal is to minimize this function.

Parameters:
  • sel (numpy.ndarray) –

    A selection indices matrix of shape (j,k).

    Where:

    • j is the number of configurations to score.

    • k is the number of individuals to select.

    Each index indicates which individuals to select. Each index in sel represents a single individual’s row. sel cannot be None.

  • V (numpy.ndarray) –

    A matrix of shape (n,p,t) containing distance values of individuals’ alleles for each trait.

    Where:

    • n is the number of individuals.

    • p is the number of markers.

    • t is the number of traits.

  • trans (function or callable) –

    A transformation operator to alter the output. Function must adhere to the following standard:

    • Must accept a single numpy.ndarray argument.

    • Must return a single object, whether scalar or numpy.ndarray.

  • kwargs (dict) – Dictionary of keyword arguments to pass to trans function.

Returns:

dist – A matrix of shape (j,t) if trans is None.

Distances for each target.

Where:

  • t is the number of traits.

Return type:

numpy.ndarray

property objfn_wt: float | ndarray#

Objective function weights.

pareto(pgmat, gmat, ptdf, bvmat, gpmod, t_cur, t_max, miscout=None, **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.

  • kwargs (dict) – Additional keyword arguments.

Returns:

out – A tuple containing two objects (frontier, sel_config).

Where:

  • frontier is a numpy.ndarray of shape (q,v) containing Pareto frontier points.

  • sel_config is a numpy.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

property rng: Generator | RandomState#

Random number generator source.

select(pgmat, gmat, ptdf, bvmat, gpmod, t_cur, t_max, miscout=None, **kwargs)[source]#

Select parents 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, default = None) – Pointer to a dictionary for miscellaneous user defined output. If dict, write to dict (may overwrite previously defined fields). If None, 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 a numpy.ndarray of indices specifying a cross pattern. Each index corresponds to an individual in pgmat.

  • ncross is a numpy.ndarray specifying the number of crosses to perform per cross pattern.

  • nprogeny is a numpy.ndarray specifying the number of progeny to generate per cross.

Return type:

tuple

property soalgo: UnconstrainedOptimizationAlgorithm#

Single objective optimization algorithm.

property target: ndarray | Callable#

Allele frequency targets or allele frequency target function.

property weight: ndarray | Callable#

Marker weights or marker weight function.