Skip to content
Diego Giacomelli edited this page Jan 15, 2016 · 16 revisions

#Performance tips

  • 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.

#Generation strategy 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.

#LinearTaskExecutor vs SmartThreadPoolTaskExecutor

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, because the cost of start threads using SmartThreadPoolTaskExecutor 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 SmartThreadPoolTaskExecutor.

Clone this wiki locally