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:
  1. Selection (both single- and multi-objective) of genotypes.

  2. Construction of fast objective functions.

  3. Mapping of the Pareto frontier for the selection protocol.

  4. Access to static objective functions for the selection protocol.

Constructor for the abstract class SelectionProtocol.

Parameters:

kwargs (dict) – Additional keyword arguments.

Methods

objfn

Return an objective function constructed from inputs for fast calling.

objfn_static

Objective function for the selection protocol.

objfn_vec

Return a vectorized objective function constructed from inputs for fast calling.

objfn_vec_static

Vectorized objective function for the selection protocol.

pareto

Calculate a Pareto frontier for objectives.

select

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). If None, 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 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

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). 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