-
-
Notifications
You must be signed in to change notification settings - Fork 335
Performance
- If you need to run a long term GA, use PerformanceGenerationStrategy.
population.GenerationStrategy = new PerformanceGenerationStrategy();
- If your chromosomes has any external resource, like a bitmap or a file, remember to dispose those resources.
Population class has a property called GenerationStrategy, this property receive an implementation of IGenerationStrategy interface. The generation strategy is responsible for some key points of generation behavior inside a population and can affect the performance.
There two ways to keep track of generation on a population:
- TrackingGenerationStrategy: an IGenerationStrategy's implementation that keeps all generations to further evaluation. This strategy can be slow and can suffer of OutOfMemoryException when you have great population and a long term termination.
- PerformanceGenerationStrategy: an IGenerationStrategy's implementation which takes into account the performance and just keep the last one generations in the population. This strategy is not good for tracking all the generations, but is the best one when you have a very long term termination.
If you need to further evaluation all generations of the GA, use TrackingGenerationStrategy, otherwise use PerformanceGenerationStrategy. By default PerformanceGenerationStrategy will keep only one generation in the Population.Generations list and release all old generation to garbage collector.
If you have a light fitness function, that run very fast, let say about some microseconds or milliseconds, in this case you should use LinearTaskExecutor as the GeneticAlgorithm.TaskExecutor because the cost of start threads using ParallelTaskExecutor will be greater than time to execute fitness evaluate in a linear fashion.
If you have a heavy fitness function that run about seconds or minutes, in those cases you really should use ParallelTaskExecutor.