Genetic Optimizer

Modified on 2016/05/26 20:37 by Eugene — Categorized as: Optimizers

Benefits of Wealth-Lab's Genetic Optimizer


In a nutshell

Simply put, genetic algorithms are about solving an optimization problem by evolving a population of chromosomes of candidate solutions toward better solutions. A "chromosome" represents a combination of Strategy Parameters that defines one of the many possible solutions to the optimization problem that the genetic algorithm is trying to solve.

Genetic optimization rules out the poorly performing parameter combinations and keeps the best, letting them proliferate so that each new generation is based upon a hopefully better genotype.

Is Genetic Algorithm any different from Monte Carlo?

Sure. Although both Genetic optimizer and Monte Carlo work fast and use randomness, unlike Monte Carlo, GA does its search purposefully. Genetic algorithm employs selection and recombination, searching for populations with the best optimization criteria.

How does it work?

After installing extension and restarting Wealth-Lab, Genetic Optimizer appears in your list of installed optimizers, next to "Exhaustive" and "Monte Carlo".


Configuration cheat sheet

Image

1. Specify population and generation count

Population count is the number of chromosomes in each generation. The larger is a population, the better is the diversity (especially in first generations) – ensuring that the algorithm won't hit a local extreme by mischance. Optimization process stops after reaching the number of generations specified as Generation Count.

No formal rule exists for finding the best combination. We recommend starting your optimization using default values for up to 200K runs required. Also, you can use companion Genetic Optimizer Test application to quickly determine optimal population and generation counts. Save the results of an exhaustive optimization of a strategy with similar required runs and perform a genetic search in the Test utility.

2. Choose a fitness function

The metric to optimize is the fitness function – a measure of a chromosome's optimality among the population. To choose one, you can leave the default "Net profit" option or select any performance metric available from Scorecards installed in Wealth-Lab – such as Basic, Extended or Community (if installed). To change a Scorecard, switch to the "Results" tab, select a different Scorecard, click "Begin optimization" and "Cancel optimization", then re-open "Settings".

3. Choose a selection method


4. Configuring reproduction

Crossover and mutation are genetic operators that produce the next generation of chromosomes, increasing the average fitness by breeding and mixing. Among several available crossover methods, WL Crossover 1 and WL Crossover 2 are probably the best choices for solving optimization tasks:


Last but not least, you need to configure mutation: this is what lets GA optimizer to maintain diversity from one generation to the next, i.e., keeps them from becoming too similar to each other, and thus continue evolution. There's one method, Simple Mutation, that randomly mutates a drawn gene according to specified Probability setting.

Note: Wealth-Lab's Genetic Optimizer has elitist selection, pushing the elite – Top 3% chromosomes – to the next generation without breeding and mixing. This also protects from loss of good solutions caused by a mutation rate too high.

Analyzing results

The output of Strategy optimized with GA is available as it happens, in the Chromosomes tab and on the Fitness graph.

First, here's some absolutely necessary geek speak that will help you decipher results coming from the Chromosomes and Fitness. Wealth-Lab's genetic optimizer uses the so called "real-coded" genetic algorithm, where each Strategy optimization parameter becomes a "gene" in "chromosome". Let's take the prepackaged "Channel Breakout VT" strategy for example. It has 2 optimizable parameters: Long Channel (ranging from 35 to 100 with step 5), and Short Channel (ranging from 3 to 33 with step 3).

A chromosome takes the form of a series of numbers. For example, the "chromosome" consisting of the two genes, Long Channel = 100 and Short Channel = 18, would be coded the following way: {13;5}. How does a gene take one value or the other? It's a zero-based enumeration, as the following table illustrates:

Short channel

Gene

3

0

6

1

...

...

18

5

...

...

33

10



When running a genetic optimization, chromosomes that existed before can ensue, in a different or even in the same generation. Hence, the number of Runs Required of a genetic optimization is unknown and can not be precomputed by multiplying Population Count by Generation Count. Genetic optimizer saves processing time by not reprocessing duplicate parameter sets, freeing Wealth-Lab from having to run the Strategy redundantly, so the number of actual runs will be equal to Unique Chromosome count on the Chromosomes tab. You may filter out non-unique chromosomes by checking "Show unique only", as well as sort the table by a column.

Image

The Fitness graph illustrates the progress of a genetic optimization. Each step on the red line means a new generation. The first one is generated randomly, and all the rest, as we already know, are the results of selecting, breeding and mutating of chromosomes.

Image

Note: watching the progress of an optimization in real time can slow it down.

References


Known issues



Powered by ZedGraph