Closed debashis66 closed 3 years ago
Yes, you will need to write your own implementation.
Thank you. Can you point me to an example I can use for custom operators and how we can pick up specific genes/ variables for mutation.
On Wed, Jun 3, 2020 at 4:31 PM Diego Giacomelli notifications@github.com wrote:
Yes, you will need to write your own implementation.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/giacomelli/GeneticSharp/issues/74#issuecomment-638122213, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANASQI2UC3P3STKRZSNBFY3RUYUPPANCNFSM4NROFCTA .
You can take a look at mutation operators developed on GeneticSharp itself.
ReverseSequenceMutation it's a really basic sample and TworsMutation is a good sample of how you can get specific genes.
Is there a better way to mutate only the genes for 1 parameter ?
protected override void PerformMutate(IChromosome chromosome, float probability)
{
var fc = chromosome as FloatingPointChromosome;
var values = fc.ToFloatingPoints();
int index = RandomizationProvider.Current.GetInt(0, values .Length);
if (RandomizationProvider.Current.GetDouble() <= probability)
{
var newValue = RandomizationProvider.Current.GetInt(minValue, maxValue);
values[index] = (double)newValue;
var newFc = new FloatingPointChromosome(minPositions, maxPositions, bits, decimals, values);
for (int i = 0; i < chromosome.Length; i++)
chromosome.ReplaceGene(i, newFc.GetGene(i));
}
}
Do you want to mutate a specific gene or only a random one?
Closing due to inactivity. Feel free to reopen in case you still need help.
I am trying to mimic large jumps (within the search space) and small jumps in the neighborhood changing only one parameter at a time (instead of allowing all variables to change at once). Is it possible to do this in GA using the available( mutation) operators where I can define different probability for the small and large changes or do I need to write my own implementation to achieve this ?