Learning with Evolution
Genetic Algorithms in Elixir — by Sean Moriarity (94 / 101)
👈 Chapter 13 Moving Forward | TOC | Designing with Evolution 👉
Artificial intelligence (AI) and machine learning (ML) have dominated the last decade of computing. AI is experiencing its third “boom” with no signs of stopping. It seems that almost everyday there’s a new revolutionary innovation in AI or another startup using AI to improve everyday life. The demand for developers who are familiar with and can solve problems using AI/ML will continue to increase over the next decade.
The latest AI boom is owed mainly to advancements in deep learning. Deep learning is the application of multiple layers of transformations on data to extract features from raw inputs and perform tasks like classification or regression. One area deep learning has found a lot of success is in reinforcement learning.
Reinforcement learning is a subset of machine learning concerned with teaching agents to take optimal actions in an environment. For example, reinforcement learning is often used to implement AI capable of playing arcade games like the Tetris playing agent you implemented in Chapter 10, Visualizing the Results.
Reinforcement learning is all about rewards and punishments. Agents are rewarded for certain actions they take, like completing a line of blocks in Tetris, and punished for others, like losing the game in Tetris. Based on these rewards and their interactions with the environment, agents learn to optimize the decisions under certain conditions.
One area reinforcement learning is applicable is in the optimization of mechanical movement. For example, you can use reinforcement learning to teach a robot how to walk by modeling the movements and angles of a robot’s limbs as a series of actions the robot has to take. Over time, the robot learns to lift its legs at a certain angle and plant them at a certain angle, and so on, until it can efficiently move forward.
So, what does this have to do with genetic algorithms? In some situations, genetic algorithms are a viable alternative to reinforcement learning. One of the drawbacks of reinforcement learning is that it relies on deep learning techniques to train. These techniques can be expensive, difficult to optimize, and ultimately may take a long time to converge on effective solutions. That’s where genetic algorithms come in.
OpenAI proved that in many circumstances evolution strategies[30] were a better alternative to reinforcement learning, as they converged faster and were far less expensive to train. If you recall from previous chapters, evolution strategies are a subset of evolutionary algorithms that very closely resemble genetic algorithms. Evolution is an excellent alternative to reinforcement learning for many of the same tasks because they’re much easier to train and are far less computationally expensive.
👈 Chapter 13 Moving Forward | TOC | Designing with Evolution 👉
Genetic Algorithms in Elixir by Sean Moriarity can be purchased in other book formats directly from the Pragmatic Programmers. If you notice a code error or formatting mistake, please let us know here so that we can fix it.

