class GenoPheno(object):
Constructor: GenoPheno(dim, scaling, typical_x, fixed_values, tf)
Genotype-phenotype transformation.
Method pheno
provides the transformation from geno- to phenotype,
that is from the internal representation to the representation used
in the objective function. Method geno
provides the "inverse" pheno-
to genotype transformation. The geno-phenotype transformation comprises,
in this order:
- insert fixed variables (with the phenotypic values)
- affine linear transformation (first scaling then shift)
- user-defined transformation
- repair (e.g. into feasible domain due to boundaries)
- re-assign fixed variables their original phenotypic value
By default all transformations are the identity. The repair is only
applied, if the transformation is given as argument to the method
pheno
.
geno
is only necessary, if solutions have been injected.
Method | __init__ |
return GenoPheno instance with phenotypic dimension dim . |
Method | geno |
maps the phenotypic input argument into the genotypic space, that is, computes essentially the inverse of pheno. |
Method | pheno |
maps the genotypic input argument into the phenotypic space, see help for class GenoPheno |
Instance Variable | fixed |
Undocumented |
Instance Variable | isidentity |
Undocumented |
Instance Variable | islinear |
Undocumented |
Instance Variable | N |
Undocumented |
Instance Variable | repaired |
Undocumented |
Instance Variable | scales |
Undocumented |
Instance Variable | tf |
Undocumented |
Instance Variable | tf |
Undocumented |
Instance Variable | typical |
Undocumented |
return GenoPheno
instance with phenotypic dimension dim
.
Keyword Arguments
scaling
- the diagonal of a scaling transformation matrix, multipliers in the genotyp-phenotyp transformation, see
typical_x
typical_x
- pheno = scaling*geno + typical_x
fixed_values
- a dictionary of variable indices and values, like {0:2.0, 2:1.1}, that are not subject to change, negative indices are ignored (they act like incommenting the index), values are phenotypic values.
tf
list of two user-defined transformation functions, or
None
.tf[0] is a function that transforms the internal representation as used by the optimizer into a solution as used by the objective function. tf[1] does the back-transformation. For example:
tf_0 = lambda x: [xi**2 for xi in x] tf_1 = lambda x: [abs(xi)**0.5 fox xi in x]or "equivalently" without the
lambda
construct:def tf_0(x): return [xi**2 for xi in x] def tf_1(x): return [abs(xi)**0.5 fox xi in x]tf=[tf_0, tf_1] is a reasonable way to guaranty that only positive values are used in the objective function.
Details
If tf_0 is not the identity and tf_1 is ommitted, the genotype of x0 cannot be computed consistently and "injection" of phenotypic solutions is likely to lead to unexpected results.
maps the phenotypic input argument into the genotypic space, that is, computes essentially the inverse of pheno.
By default a copy is made only to prevent to modify y.
The inverse of the user-defined transformation (if any) is only needed if external solutions are injected, it is not applied to the initial solution x0.
Details
geno searches first in archive for the genotype of y and returns the found value, typically unrepaired. Otherwise, first from_bounds is applied, to revert a projection into the bound domain (if necessary) and pheno is reverted. repair is applied last, and is usually the method CMAEvolutionStrategy.repair_genotype that limits the Mahalanobis norm of geno(y) - mean.
maps the genotypic input argument into the phenotypic space,
see help for class GenoPheno
Details
If copy, values from x are copied if changed under the transformation.