PopulationAlleleFrequencyDistanceSubsetSelectionProblem#
- class pybrops.breed.prot.sel.prob.PopulationAlleleFrequencyDistanceSelectionProblem.PopulationAlleleFrequencyDistanceSubsetSelectionProblem(geno, ploidy, mkrwt, tfreq, ndecn, decn_space, decn_space_lower, decn_space_upper, 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, **kwargs)[source]#
Bases:
PopulationAlleleFrequencyDistanceSelectionProblemMixin
,SubsetSelectionProblem
docstring for SubsetMultiObjectiveSelectionProblem.
Constructor for SubsetMultiObjectiveSelectionProblem.
- Parameters:
geno (numpy.ndarray) –
A genotype matrix of shape
(n,p)
representing only biallelic loci. One of the two alleles at a locus is coded using a1
. The other allele is coded as a0
.mat
holds the counts of the allele coded by1
.Where:
n
is the number of individuals.p
is the number of markers.
Example:
# matrix of shape (n = 3, p = 4) geno = numpy.array([[0,2,1,0], [2,2,1,1], [0,1,0,2]])
ploidy (Integral) – Number of phases that the genotype matrix
mat
represents.tfreq (numpy.ndarray) –
A target allele frequency matrix of shape
(p,t)
.Where:
p
is the number of markers.t
is the number of traits.
Example:
tfreq = numpy.array([0.2, 0.6, 0.7, 0.5])
mkrwt (numpy.ndarray) –
A marker weight coefficients matrix of shape
(p,t)
.Where:
p
is the number of markers.t
is the number of traits.
Remarks:
All values in
mkrwt
must be non-negative.
ndecn (Integral) – Number of decision variables.
decn_space (numpy.ndarray, None) – An array of shape
(2,ndecn)
defining the decision space. If None, do not set a decision space.decn_space_lower (numpy.ndarray, Real, None) – An array of shape
(ndecn,)
containing lower limits for decision variables. If a Real is provided, construct an array of shape(ndecn,)
containing the Real. If None, do not set a lower limit for the decision variables.decn_space_upper (numpy.ndarray, Real, None) – An array of shape
(ndecn,)
containing upper limits for decision variables. If a Real is provided, construct an array of shape(ndecn,)
containing the Real. If None, do not set a upper limit for the decision variables.nobj (Integral) – Number of objectives.
obj_wt (numpy.ndarray) – Objective function weights.
obj_trans (Callable, None) – A transformation function transforming a latent space vector to an objective space vector. The transformation function must be of the form:
obj_trans(x: numpy.ndarray, **kwargs) -> numpy.ndarray
If None, use the identity transformation function: copy the latent space vector to the objective space vector.obj_trans_kwargs (dict, None) – Keyword arguments for the latent space to objective space transformation function. If None, an empty dictionary is used.
nineqcv (Integral,) – Number of inequality constraints.
ineqcv_wt (numpy.ndarray,) – Inequality constraint violation weights.
ineqcv_trans (Callable, None) – A transformation function transforming a latent space vector to an inequality constraint violation vector. The transformation function must be of the form:
ineqcv_trans(x: numpy.ndarray, **kwargs) -> numpy.ndarray
If None, use the empty set transformation function: return an empty vector of length zero.ineqcv_trans_kwargs (Optional[dict],) – Keyword arguments for the latent space to inequality constraint violation space transformation function. If None, an empty dictionary is used.
neqcv (Integral) – Number of equality constraints.
eqcv_wt (numpy.ndarray) – Equality constraint violation weights.
eqcv_trans (Callable, None) – A transformation function transforming a latent space vector to an equality constraint violation vector. The transformation function must be of the form:
eqcv_trans(x: numpy.ndarray, **kwargs) -> numpy.ndarray
If None, use the empty set transformation function: return an empty vector of length zero.eqcv_trans_kwargs (dict, None) – Keyword arguments for the latent space to equality constraint violation space transformation function. If None, an empty dictionary is used.
kwargs (dict) – Additional keyword arguments passed to the parent class (SubsetSelectionProblem) constructor.
Methods
bounds
do
Evaluate a candidate solution for the given Problem.
evaluate
from_gmat_gpmod
has_bounds
has_constraints
ideal_point
Multi-objective genomic selection objective function.
nadir_point
name
pareto_front
pareto_set
Attributes
A callback function to be called after every evaluation.
Type of the variable to be evaluated.
Decision space boundaries.
Lower boundary of the decision space.
Upper boundary of the decision space.
Whether the evaluation function should be run elementwise.
A class that creates the function that evaluates a single individual.
A function that runs the function that evaluates a single individual.
Function which transforms outputs from
latentfn
to equality constraint violation values.Keyword arguments for the latent space to equality constraint violation transformation function.
Equality constraint violation function weights.
attributes which are excluded from being serialized.
Genotype matrix of shape (n,p) in {0,1,2} format.
Function which transforms outputs from
latentfn
to inequality constraint violation values.Keyword arguments for the latent space to inequality constraint violation transformation function.
Inequality constraint violation function weights.
Marker weights.
n_constr
n_eq_constr.
Number of inequality constraints.
Number of objectives.
Number of decision variables.
Number of decision variables.
Number of equality constraint violations.
Number of inequality constraint violation functions.
Number of latent variables.
Number of objectives.
Function which transforms outputs from
latentfn
to objective function values.Keyword arguments for the latent space to objective space transformation function.
Objective function weights.
ploidy.
replace_nan_values_by.
Whether the shapes are checked strictly.
Target allele frequency.
Whether the target allele frequency is heterozygous.
Whether the target allele frequency is fixation of a major allele.
Whether the target allele frequency is fixation of a minor allele.
Variables provided in their explicit form.
The variable type.
Lower boundary of the decision space.
Upper boundary of the decision space.
- property callback: Callable | None#
A callback function to be called after every evaluation.
- property data: dict#
Type of the variable to be evaluated.
- property decn_space: ndarray | None#
Decision space boundaries.
- property decn_space_lower: ndarray | None#
Lower boundary of the decision space.
- property decn_space_upper: ndarray | None#
Upper boundary of the decision space.
- property elementwise: bool#
Whether the evaluation function should be run elementwise.
- property elementwise_func: type#
A class that creates the function that evaluates a single individual.
- property elementwise_runner: Callable#
A function that runs the function that evaluates a single individual.
- property eqcv_trans: Callable[[ndarray, ndarray, dict], ndarray]#
Function which transforms outputs from
latentfn
to 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.
- evalfn(x, *args, **kwargs)#
Evaluate a candidate solution for the given Problem.
This calculates three vectors which are to be minimized:
\[\mathbf{v_{obj}} = \mathbf{w_{obj} \odot T_{obj}(L(x))} \ \mathbf{v_{ineqcv}} = \mathbf{w_{ineqcv} \odot T_{ineqcv}(L(x))} \ \mathbf{v_{eqcv}} = \mathbf{w_{eqcv} \odot T_{eqcv}(L(x))}\]- Parameters:
x (numpy.ndarray) – A candidate solution vector of shape
(ndecn,)
.args (tuple) – Additional non-keyword arguments.
kwargs (dict) – Additional keyword arguments.
- Returns:
out – A tuple
(obj, ineqcv, eqcv)
.Where:
obj
is a numpy.ndarray of shape(nobj,)
that containsobjective function evaluations. This is equivalent to \(\mathbf{v_{obj}}\)
ineqcv
is a numpy.ndarray of shape(nineqcv,)
that containsinequality constraint violation values. This is equivalent to \(\mathbf{v_{ineqcv}}\)
eqcv
is a numpy.ndarray of shape(neqcv,)
that containsequality constraint violation values. This is equivalent to \(\mathbf{v_{eqcv}}\)
- Return type:
tuple
- property exclude_from_serialization: Iterable | None#
attributes which are excluded from being serialized.
- property geno: ndarray#
Genotype matrix of shape (n,p) in {0,1,2} format.
- property ineqcv_trans: Callable[[ndarray, ndarray, dict], ndarray]#
Function which transforms outputs from
latentfn
to 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.
- latentfn(x, *args, **kwargs)[source]#
Multi-objective genomic selection objective function.
The goal is to minimize all objectives for this function.
This is a bare bones function. Minimal error checking is done.
Objectives: \(F(\textbf{x})\)
\[F(\textbf{x}) = {[f^{\textup{PAU}}(\textbf{x}), f^{\textup{PAFD}}(\textbf{x})]}'\]Population Allele Frequency Distance (PAFD): \(f^{\textup{PAFD}}(\textbf{x})\)
\[f^{\textup{PAFD}}(\textbf{x}) = \textbf{w} \cdot \left | \textbf{p}_{x} - \textbf{p}_{t} \right |\]Given a genotype matrix
mat
and a selection indices vector \(\textbf{x} =\)sel
, calculate the selection allele frequency \(\textbf{p}_{x}\). From the selection allele frequencies and the target allele frequencies \(\textbf{p}_{t} =\)tfreq
, calculate the absolute value of the difference between the two vectors. Finally, take the dot product between the difference vector and the marker weight vector \(\textbf{w} =\)mkrwt
to calculate \(f^{\textup{PAFD}}(\textbf{x})\) and return the result.- Parameters:
x (numpy.ndarray) – A candidate solution vector of shape
(ndecn,)
.args (tuple) – Additional non-keyword arguments.
kwargs (dict) – Additional keyword arguments.
- Returns:
out – An MOGS matrix of shape
(t,)
.Where:
t
is the number of traits.
- Return type:
numpy.ndarray
- property mkrwt: ndarray#
Marker weights.
- property n_eq_constr: Integral#
n_eq_constr.
- property n_ieq_constr: Integral#
Number of inequality constraints.
- property n_obj: Integral#
Number of objectives.
- property n_var: Integral#
Number of decision variables.
- property ndecn: Integral#
Number of decision variables.
- property neqcv: Integral#
Number of equality constraint violations.
- property nineqcv: Integral#
Number of inequality constraint violation functions.
- property nlatent: Integral#
Number of latent variables.
- property nobj: Integral#
Number of objectives.
- property obj_trans: Callable[[ndarray, ndarray, dict], ndarray]#
Function which transforms outputs from
latentfn
to 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.
- property ploidy: Integral#
ploidy.
- property replace_nan_values_by: Real | None#
replace_nan_values_by.
- property strict: bool#
Whether the shapes are checked strictly.
- property tfreq: ndarray#
Target allele frequency.
- property thet: ndarray#
Whether the target allele frequency is heterozygous.
- property tmajor: ndarray#
Whether the target allele frequency is fixation of a major allele.
- property tminor: ndarray#
Whether the target allele frequency is fixation of a minor allele.
- property vars: Container | None#
Variables provided in their explicit form.
- property vtype: type | None#
The variable type. So far, just used as a type hint.
- property xl: ndarray | None#
Lower boundary of the decision space.
- property xu: ndarray | None#
Upper boundary of the decision space.