# Encoding genetic algorithms

Genetic algorithms are a fascinating technique for solving optimisation problems. If you can create a set of rules that can measure a solution’s performance, you can probably use a GA to help solve the problem. Here are some ways to encode solutions.

If you missed my article on the intuition of genetic algorithms, check this out before continuing: https://rhurbans.com/genetic-algorithms-for-beginners/.

Real-value encoding represents a gene with numeric values, strings, or symbols. The solution is expressed in its natural state. This encoding is used when potential solutions contain continuous values that cannot be encoded easily with binary encoding.

Order encoding, also known as permutation encoding, represents a chromosome as a sequence of elements. Order encoding usually requires all elements to be present in the chromosome. It’s useful for problems where the sequence in the solution is important.

Tree encoding represents a chromosome as a tree of elements. Tree encoding is versatile for representing potential solutions where the hierarchy of elements is important or required. Tree encoding can even represent code functions, which consist of a tree of expressions.

Encoding solutions is the first step in setting up a genetic algorithm for success. It can solve interesting problems on its own or even be used with artificial neural networks, like in this Super Mario example.

If you’re interested in more details about genetic algorithms, see Grokking AI Algorithms with Manning Publications: http://bit.ly/gaia-book, consider following me — @RishalHurbans, or join my mailing list for infrequent knowledge drops: https://rhurbans.com/subscribe.