Skip to content

Interface to inject the gradient conveniently #344

@nikohansen

Description

@nikohansen

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

  • the above code as es.inject_gradient(gradient)
  • an option which would transform the gradient to an estimated Newton direction using covariance matrix information, for example like es.inject_gradient(gradient, newton=True)
  • decide whether and how to handle genotype-phenotype transformations. When the gradient is analytically available, like for boundary handling, this would make sense?

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions