Open Ririshi opened 1 year ago
I encountered the same issue. I hope this feature can be enabled!
I was using this for my master's thesis but ended up simply not using adaptive mutation instead of enabling parallel processing. I have since finished my thesis and am now busy with work and no longer interested in adding this enhancement. Just want to be clear in my intentions. This library has helped me alot, so I'm sorry that I won't able to contribute to it. I'll leave the issue open so others can make work of it if they are interested in doing so.
Appreciate it @Ririshi! This is now supported so that fitness calculation during adaptive mutation works with parallel processing. This will be available in the next release of the library.
I was checking my CPU usage while running a GA instance with adaptive mutation and noticed it's actually off most of the time. The fitness function I use takes several seconds to compute for every solution, so the lack of parallel processing on this type of mutation really hurts the overall time per generation.
I had a look at the code and expected a simple copy-paste with some minor updates to enable parallel processing in the mutation, but the architecture of the package (i.e.
pygad.GA
is a child class ofpygad.utils.Mutation
) makes it difficult for theMutation
methods to know if parallel processing is enabled without passing additional parameters. What might work is to add an__init__
method toMutation
and calling this method fromGA.__init__
. The parallel processing setup could be moved toMutation
, which is then inherited byGA
. I don't think this is the cleanest solution in terms of OOP best practices, but it would work.I might be able to put some time into creating a PR for this sometime soon.