What you should know about genetic algorithms

In an effort to help you understand why Genetic Algorithms (GAs) act differently than other optimizers to which you may be accustomed, we offer the following facts about our GAs in NeuroShell Trader. Much of this information is applicable to genetic algorithms in our other products too.

GAs emulate the theory of evolution. What they do is much like selective breeding. Multiple pairs of solutions are “mated” during many “generations” to hopefully produce more “fit” offspring.

GAs do not try every combination. Selective breeding causes exploration all around in the search space based on random starting numbers. Algorithms that try every combination are called “exhaustive search” algorithms, and when dealing with parameters that are not integers, exhaustive search optimizers must search in increments.

GAs do not require a search increment. That is because they do not try every combination, so they can deal with real numbers (with decimals) without increments.

GAs dont know when theyre done. Since they dont search in orderly increments, they never know when they have found the optimal solution. They use arbitrary stopping criteria in NeuroShell – they just stop when some number of generations pass with no better solutions being found, or when some amount of time has passed. If they find a better solution, the progress bar in NeuroShell may be set back a bit, because the GA has decided it will be able to successfully search longer. Since when the GA stops is arbitrary, you are allowed to either stop it earlier or tell it to go a long period of time. If you think the result is good enough already, just stop optimizing.

You can never assume you should get the same results with a GA unless you are doing EXACTLY the same thing. Anything different can cause differences because GAs start at random starting points, do not search every combination, and they have arbitrary stopping criteria.

The computation speed of the GA doesn’t depend on the GA or the number of parameters you are optimizing. It depends on how long it takes to backtest the model. Models that have indicators that take a long time to compute are going to take longer, and it has nothing to do with the GA. The computation in the GA is a minor part of the total calculations during optimization. However, when the GA actually ends can depend on the number of parameters, because more parameters may make it more likely that better solutions get found, thus continuing the search. Real parameters as opposed to integers can prolong the searching in the same way.

The GA will only try integers for any parameter that is designated as integer. If the parameter is not integer, the GA will try real numbers (with decimals). All that is decided when the programmer creates the indicator.

GAs are usually much faster than “exhaustive search” algorithms. That is again because they are not trying every combination. They can actually be slower, however, if only a couple of variables are being searched, or the exhaustive search algorithm has been given large increments in which to search.

GAs cannot be guaranteed to always find the optimal solution. That is again because they are not trying every combination. Exhaustive search algorithms ARE guaranteed to find the optimal solution, assuming it is exactly on the search increment of each variable, and assuming you have the time it could take with many variables. Trading usually does not require the optimal solution anyway, because it will most likely over-fit.

GAs do not require a continuous or differentiable search space. “Newtonian” or “hill climbing” type optimizers often do impose such conditions. In fact, exhaustive search algorithms can only work in continuous spaces if they are instructed to search in increments. Continuous and differentiable are mathematical terms you may not understand, but the bottom line is that many optimizers will stop or fail if the search space is not a nice smooth set of curves with no gaps. GAs dont care what the search space looks like mathematically, but see the next item.

GAs can fail if the parameters they are given are too restrictive. Optimization may end early if the genetic algorithm cannot reproduce, i.e. if there is not enough diversity in the optimization parameter search space. This happens when too many parameter combinations yield the same result. It is like “inbreeding” in the selective breeding process. One or more parameter ranges may be too wide or too narrow or otherwise not appropriate for the underlying indicators. You may need to choose parameter ranges that do not result in the same profit result for a majority of the search space.

GAs are less likely to get stuck in local minima or maxima. That is because they are searching many points in the search space simultaneously, and are also not “hill climbing”. High dimensional search spaces frequently contain local maxima and minima that GAs are better suited to overcoming.

Was this article helpful?

Related Articles