Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make 'Mutator' class easier to extend #121

Closed
jenetics opened this issue Aug 5, 2016 · 2 comments
Closed

Make 'Mutator' class easier to extend #121

jenetics opened this issue Aug 5, 2016 · 2 comments
Assignees
Milestone

Comments

@jenetics
Copy link
Owner

jenetics commented Aug 5, 2016

Currently, the Mutator class allows you to override on protected method for implementing own mutators:

protected int mutate(final MSeq<G> genes, final double p);

This method allows to change the genes of one chromosome, where the chromosome can't be chosen by the implementor. The second drawback is, that it is not possible to change the length of the Chromosome and Genotype.

To reach the desired flexibility, the signature of the existing method is changed and an additional is added:

// Using a 'List' instead of a 'MSeq' also allows to chromosome length.
protected int mutateChromosome(final List<G> chromosome, final double p);

// The additional method allows to change the genotype, including it's length.
protected int mutateGenotype(final List<Chromosome<G>> genotype, final double p);

This is an incompatible change.

@jenetics jenetics added this to the v4.0.0 milestone Aug 5, 2016
@jenetics jenetics self-assigned this Aug 5, 2016
jenetics added a commit that referenced this issue Oct 16, 2017
jenetics added a commit that referenced this issue Oct 16, 2017
jenetics added a commit that referenced this issue Oct 16, 2017
jenetics added a commit that referenced this issue Oct 16, 2017
jenetics added a commit that referenced this issue Oct 16, 2017
jenetics added a commit that referenced this issue Oct 16, 2017
@jenetics
Copy link
Owner Author

The Mutator class can now be extended through four methods:

protected MutatorResult<Phenotype<G, C>> mutate(
	final Phenotype<G, C> phenotype,
	final long generation,
	final double p,
	final Random random
)
protected MutatorResult<Genotype<G>> mutate(
	final Genotype<G> genotype,
	final double p,
	final Random random
)
protected MutatorResult<Chromosome<G>> mutate(
	final Chromosome<G> chromosome,
	final double p,
	final Random random
)
protected G mutate(final G gene, final Random random)

jenetics added a commit that referenced this issue Oct 16, 2017
jenetics added a commit that referenced this issue Oct 16, 2017
@jenetics
Copy link
Owner Author

Merged into r4.0.0 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant