-
Notifications
You must be signed in to change notification settings - Fork 150
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
Applying different "mutation strategies" to specific chromosomes in Jenetics #900
Comments
The PartialAlterer will do this trick. final Genotype<IntegerGene> genotype = Genotype.of(
IntegerChromosome.of(1, 10, 10), // First chromosome
IntegerChromosome.of(1, 3, 10), // Second chromosome
IntegerChromosome.of(1, 10, 10), // Third chromosome
IntegerChromosome.of(1, 5, 10) // Fourth chromosome
);
final Engine<IntegerGene, Double> engine = Engine
.builder(gt -> gt.gene().doubleValue(), genotype)
.alterers(
PartialAlterer.of(new SwapMutator<IntegerGene, Double>(), 0, 2),
PartialAlterer.of(new GaussianMutator<IntegerGene, Double>(), 1, 3)
)
.build(); Regards, Franz |
Thank you! |
Hello Franz, Thank you for your previous response, it was quite helpful. After diving deeper into the Jenetics documentation, I understand that a Genotype is expected to have chromosomes of the same type. I initially wanted to combine PermutationChromosome and IntegerChromosome within the same Genotype, but it seems that's not feasible. My follow-up question is: Is there a way to use IntegerChromosome to simulate the behaviour of PermutationChromosome? To elaborate, I would like an IntegerChromosome with values ranging from 1 to 10 where the SwapMutator doesn't alter the sequence, thus maintaining a permutation of the original sequence. For example: However, I believe the IntegerChromosome is initialized with random values within the specified range despite setting the allele values manually, which is not the behaviour I expected. With the PermutationChromosome, I wanted to represent the priorities of tasks/jobs, and thus, the repetition of numbers would not yield the desired 'ideal' representation. Is there a way to configure the IntegerChromosome so it behaves like a PermutationChromosome, or is there a workaround using the SwapMutator that could help me achieve this? Thank you for your time and assistance. Best regards, m4r0lt |
I'm currently working with the Jenetics library to implement a genetic algorithm and I've run into a specific need that I'm not sure how to address. I need to apply different mutation strategies to different chromosomes within the same genotype. Specifically, I want to use a Swap Mutator on the first and third chromosomes, and a Gaussian Mutator on the second and fourth chromosomes.
Here's a basic outline of my genotype structure:
Genotype genotype = Genotype.of(
IntegerChromosome.of(1, 10, 10), // First chromosome
IntegerChromosome.of(1, 3, 10), // Second chromosome
IntegerChromosome.of(1, 10, 10), // Third chromosome
IntegerChromosome.of(1, 5, 10) // Fourth chromosome
);
Could anyone share insights on how to implement this or point me towards any resources or examples that might help?
Thank you in advance for your help!
The text was updated successfully, but these errors were encountered: