The current inject interface interprets, by default, injected solutions "as directions", however, only by shortening the directional vector solution - es.mean when it is exceedingly long. For the injection of a gradient direction, this is somewhat impractical. The correct injection code, to be called before ask or as a callback to fmin2, would be
es.inject(es.mean - self._random_rescaling_factor_to_mahalanobis_size(gradient) * gradient), force=True)
This looks exceedingly obscure and cumbersome. Hence, we should provide
In case of a genotype-phenotype transformation (e.g. with boundary handling and/or fixed variables and/or...), the gradient calculation has to take into account this transformation too, namely es.to_phenotype(es.mean) which is in effect es.gp.pheno(solution, copy=True, into_bounds=es.boundary_handler.repair), because es.mean resides in the genotype space whereas the fitness is computed from the phenotype.
The current
injectinterface interprets, by default, injected solutions "as directions", however, only by shortening the directional vectorsolution - es.meanwhen it is exceedingly long. For the injection of a gradient direction, this is somewhat impractical. The correct injection code, to be called beforeaskor as a callback tofmin2, would beThis looks exceedingly obscure and cumbersome. Hence, we should provide
es.inject_gradient(gradient)es.inject_gradient(gradient, newton=True)In case of a genotype-phenotype transformation (e.g. with boundary handling and/or fixed variables and/or...), the gradient calculation has to take into account this transformation too, namely
es.to_phenotype(es.mean)which is in effectes.gp.pheno(solution, copy=True, into_bounds=es.boundary_handler.repair), becausees.meanresides in the genotype space whereas the fitness is computed from the phenotype.