ExpectedMaximumBreedingValueBinarySelection#
- class pybrops.breed.prot.sel.ExpectedMaximumBreedingValueSelection.ExpectedMaximumBreedingValueBinarySelection(ntrait, nrep, mateprot, unique_parents, ncross, nparent, nmating, nprogeny, nobj, obj_wt=None, obj_trans=None, obj_trans_kwargs=None, nineqcv=None, ineqcv_wt=None, ineqcv_trans=None, ineqcv_trans_kwargs=None, neqcv=None, eqcv_wt=None, eqcv_trans=None, eqcv_trans_kwargs=None, ndset_wt=None, ndset_trans=None, ndset_trans_kwargs=None, rng=None, soalgo=None, moalgo=None, **kwargs)[source]#
Bases:
ExpectedMaximumBreedingValueSelectionMixin,BinaryMateSelectionProtocolExpected Maximum Breeding Value (EMBV) Selection in a subset search space.
Constructor for the concrete class ExpectedMaximumBreedingValueBinarySelection.
- Parameters:
ntrait (Integral) – Number of traits to expect from genomic model inputs.
nrep (Integral) – Number of replicates performed to estimate expected maximum breeding values.
mateprot (MatingProtocol) – Mating protocol used to calculate expected maximum breeding values.
unique_parents (bool) – Whether parents should be unique.
ncross (Integral) – Number of cross configurations to consider.
nparent (Integral) – Number of parents per cross configuration.
nmating (Integral, numpy.ndarray) –
Number of matings per configuration.
If
nmatingisIntegral, then broadcast to anumpy.ndarrayof shape(ncross,).If
nmatingisnumpy.ndarray, then the array must be of typeIntegraland of shape(ncross,).nprogeny (Integral, numpy.ndarray) –
Number of progeny to derive from each mating event.
If
nprogenyisIntegral, then broadcast to anumpy.ndarrayof shape(ncross,).If
nprogenyisnumpy.ndarray, then the array must be of typeIntegraland of shape(ncross,).nobj (Integral) – Number of optimization objectives when constructing a
SelectionProblem. This is equivalent to the vector length returned by theobj_transfunction. Must beIntegralgreater than 0.obj_wt (numpy.ndarray, Real, None) –
Objective function weights. Weights from this vector are applied to objective function values via the Hadamard product. If values are
1.0or-1.0, this can be used to specify minimizing and maximizing objectives, respectively.If
obj_wtisnumpy.ndarray, then the array must be of shape(nobj,).If
obj_wtisReal, then the value is broadcast to anumpy.ndarrayof shape(nobj,).If
obj_wtisNone, then the value1.0is broadcast to anumpy.ndarrayof shape(nobj,). This assumes that all objectives are to be minimized.obj_trans (Callable, None) –
A function which transforms values from a latent objective space to the objective space. This transformation function must have the following signature:
def obj_trans( decnvec: numpy.ndarray, latentvec: numpy.ndarray, **kwargs: dict ) -> numpy.ndarray: # do stuff return output
Where:
decnvecis anumpy.ndarraycontaining the decision vector.latentvecis anumpy.ndarraycontaining the latent spaceobjective function values which are to be transformed.
kwargsis adictcontaining additional keyword arguments.
If
obj_transisNone, then default to an identity objective transformation function.obj_trans_kwargs (dict) –
Keyword arguments for the latent space to objective space transformation function.
If obj_trans_kwargs` is
None, then default to an empty dictionary.nineqcv (Integral, None) –
Number of inequality constraint violation functions. This is equivalent to the vector length returned by the
ineqcv_transfunction. Must beIntegralgreater than or equal to zero.If
nineqcvisNone, then set to zero.ineqcv_wt (numpy.ndarray, None) –
Inequality constraint violation function weights. Weights from this vector are applied to inequality constraint violation function values via the Hadamard product. If values are
1.0or-1.0, this can be used to specify minimizing and maximizing constraints, respectively.If
ineqcv_wtisnumpy.ndarray, then the array must be of shape(nineqcv,).If
ineqcv_wtisReal, then the value is broadcast to anumpy.ndarrayof shape(nineqcv,).If
ineqcv_wtisNone, then the value1.0is broadcast to anumpy.ndarrayof shape(nineqcv,). This assumes that all constraints are to be minimized.ineqcv_trans (Callable, None) –
A function which transforms values from a latent objective space to the inequality constraint violation space. This transformation function must have the following signature:
def ineqcv_trans( decnvec: numpy.ndarray, latentvec: numpy.ndarray, **kwargs: dict ) -> numpy.ndarray: # do stuff return output
Where:
decnvecis anumpy.ndarraycontaining the decision vector.latentvecis anumpy.ndarraycontaining the latent spaceobjective function values which are to be transformed.
kwargsis adictcontaining additional keyword arguments.
If
ineqcv_transisNone, then default to a transformation function returning an empty vector.ineqcv_trans_kwargs (dict, None) –
Keyword arguments for the latent space to inequality constraint violation transformation function.
If ineqcv_trans_kwargs` is
None, then default to an empty dictionary.neqcv (Integral, None) –
Number of equality constraint violations. This is equivalent to the vector length returned by the
eqcv_transfunction. Must beIntegralgreater than or equal to zero.If
neqcvisNone, then set to zero.eqcv_wt (numpy.ndarray, None) –
Equality constraint violation function weights. Weights from this vector are applied to equality constraint violation function values via the Hadamard product. If values are
1.0or-1.0, this can be used to specify minimizing and maximizing constraints, respectively.If
eqcv_wtisnumpy.ndarray, then the array must be of shape(neqcv,).If
eqcv_wtisReal, then the value is broadcast to anumpy.ndarrayof shape(neqcv,).If
eqcv_wtisNone, then the value1.0is broadcast to anumpy.ndarrayof shape(neqcv,). This assumes that all constraints are to be minimized.eqcv_trans (Callable, None) –
A function which transforms values from a latent objective space to the equality constraint violation space. This transformation function must have the following signature:
def eqcv_trans( decnvec: numpy.ndarray, latentvec: numpy.ndarray, **kwargs: dict ) -> numpy.ndarray: # do stuff return output
Where:
decnvecis anumpy.ndarraycontaining the decision vector.latentvecis anumpy.ndarraycontaining the latent spaceobjective function values which are to be transformed.
kwargsis adictcontaining additional keyword arguments.
If
eqcv_transisNone, then default to a transformation function returning an empty vector.eqcv_trans_kwargs (dict, None) –
Keyword arguments for the latent space to equality constraint violation transformation function.
If eqcv_trans_kwargs` is
None, then default to an empty dictionary.ndset_wt (Real, None) –
Nondominated set weight. The weight from this function is applied to outputs from
ndset_trans. If values are1.0or-1.0, this can be used to specify minimizing and maximizing objectives, respectively.If
ndset_wtisNone, then it is set to the default value of1.0. This assumes that the objective is to be minimized.ndset_trans (Callable, None) –
A function which transforms values from the non-dominated set objective space to the single-objective space. This transformation function must have the following signature:
def ndset_trans( mat: numpy.ndarray, **kwargs: dict ) -> numpy.ndarray: # do stuff return output
Where:
matis anumpy.ndarraycontaining a point coordinate arrayof shape
(npt, nobj)wherenptis the number of points andnobjis the number of objectives (dimensions). This array contains input points for calculating the distance between a point to the vectorvec_wt.
kwargsis adictcontaining additional keyword arguments.
If
ndset_transisNone, then default to a transformation function calculating the distance between a weight vector and provided pointsndset_trans_kwargs (dict, None) –
Nondominated set transformation function keyword arguments.
If
ndset_trans_kwargsisNone, then default to defaults for the defaultndset_transfunction:ndset_trans_kwargs = { "obj_wt": numpy.repeat(1.0, nobj), "vec_wt": numpy.repeat(1.0, nobj) }
rng (numpy.random.Generator, numpy.random.RandomState, None) –
Random number source.
If
rngisNone, default to the global random number generator.soalgo (BinaryOptimizationAlgorithm, None) –
Single-objective optimization algorithm.
If
soalgoisNone, then use a default single-objective optimization algorithm.moalgo (BinaryOptimizationAlgorithm, None) –
Multi-objective opimization algorithm.
If
moalgoisNone, then use a default multi-objective optimization algorithm.kwargs (dict) – Additional keyword arguments.
Methods
Calculate a Pareto frontier for objectives.
Create an optimization problem definition using provided inputs.
Select individuals for breeding.
Solve the selection problem using a single-objective optimization algorithm.
Attributes
Function which transforms outputs from
latentfnto equality constraint violation values.Keyword arguments for the latent space to equality constraint violation transformation function.
Equality constraint violation function weights.
Function which transforms outputs from
latentfnto inequality constraint violation values.Keyword arguments for the latent space to inequality constraint violation transformation function.
Inequality constraint violation function weights.
Mating protocol used to calculate expected maximum breeding values.
Multi-objective opimization algorithm.
Number of cross configurations to consider.
Nondominated set transformation function.
Nondominated set transformation function keyword arguments.
Nondominated set weights.
Number of equality constraint violations.
Number of inequality constraint violation functions.
Number of matings per cross configuration.
Number of optimization objectives.
Number of parents per cross configuration.
Number of progeny to derive from each mating event.
Number of replicates performed to estimate expected maximum breeding values.
Number of selected individuals.
Number of traits to expect from inputs.
Function which transforms outputs from
latentfnto objective function values.Keyword arguments for the latent space to objective space transformation function.
Objective function weights.
rng.
Single-objective optimization algorithm.
Whether parents should be unique.
- property eqcv_trans: Callable[[ndarray, ndarray, dict], ndarray]#
Function which transforms outputs from
latentfnto equality constraint violation values.
- property eqcv_trans_kwargs: dict#
Keyword arguments for the latent space to equality constraint violation transformation function.
- property eqcv_wt: ndarray#
Equality constraint violation function weights.
- property ineqcv_trans: Callable[[ndarray, ndarray, dict], ndarray]#
Function which transforms outputs from
latentfnto inequality constraint violation values.
- property ineqcv_trans_kwargs: dict#
Keyword arguments for the latent space to inequality constraint violation transformation function.
- property ineqcv_wt: ndarray#
Inequality constraint violation function weights.
- property mateprot: MatingProtocol#
Mating protocol used to calculate expected maximum breeding values.
- property moalgo: BinaryOptimizationAlgorithm#
Multi-objective opimization algorithm.
- mosolve(pgmat, gmat, ptdf, bvmat, gpmod, t_cur, t_max, miscout=None, **kwargs)#
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
- property ncross: Integral#
Number of cross configurations to consider.
- property ndset_trans: Callable[[ndarray, dict], ndarray]#
Nondominated set transformation function.
- property ndset_trans_kwargs: dict#
Nondominated set transformation function keyword arguments.
- property ndset_wt: Real#
Nondominated set weights.
- property neqcv: Integral#
Number of equality constraint violations.
- property nineqcv: Integral#
Number of inequality constraint violation functions.
- property nmating: ndarray#
Number of matings per cross configuration.
- property nobj: Integral#
Number of optimization objectives.
- property nparent: Integral#
Number of parents per cross configuration.
- property nprogeny: ndarray#
Number of progeny to derive from each mating event.
- property nrep: Integral#
Number of replicates performed to estimate expected maximum breeding values.
- property nselindiv: Integral#
Number of selected individuals.
- property ntrait: Integral#
Number of traits to expect from inputs.
- property obj_trans: Callable[[ndarray, ndarray, dict], ndarray]#
Function which transforms outputs from
latentfnto objective function values.
- property obj_trans_kwargs: dict#
Keyword arguments for the latent space to objective space transformation function.
- property obj_wt: ndarray#
Objective function weights.
- problem(pgmat, gmat, ptdf, bvmat, gpmod, t_cur, t_max, **kwargs)[source]#
Create an optimization problem definition using provided inputs.
- 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 – An optimization problem definition.
- Return type:
- property rng: Generator | RandomState#
rng.
- select(pgmat, gmat, ptdf, bvmat, gpmod, t_cur, t_max, miscout=None, **kwargs)#
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 selection configuration object, requiring all necessary information to mate individuals.
- Return type:
- property soalgo: BinaryOptimizationAlgorithm#
Single-objective optimization algorithm.
- sosolve(pgmat, gmat, ptdf, bvmat, gpmod, t_cur, t_max, miscout=None, **kwargs)#
Solve the selection problem using a single-objective optimization algorithm.
- 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 single-objective solution to the posed selection problem.
- Return type:
- property unique_parents: bool#
Whether parents should be unique.