What’s in This Book
Genetic Algorithms in Elixir — by Sean Moriarity (6 / 101)
👈 Who This Book Is For | TOC | How to Use This Book 👉
In Chapter 1, Writing Your First Genetic Algorithm, you’ll learn the basics of the genetic algorithm by solving an introductory optimization problem. You’ll learn about the core concepts of a genetic algorithm by writing an Elixir script. By the end of the chapter, you’ll get to see a genetic algorithm in action, and you’ll begin to understand the kinds of problems best suited for using genetic algorithms.
In Chapter 2, Breaking Down Genetic Algorithms, you’ll dive deeper into the core concepts you learned about in the first chapter and you’ll use some of Elixir’s code constructs to turn the script you wrote in Chapter 1, Writing Your First Genetic Algorithm, into a reusable framework for solving optimization problems. You’ll learn more about each step in the evolutionary process of a genetic algorithm and, by the end of the chapter, have a barebones framework for using genetic algorithms.
In Chapter 3, Encoding Problems and Solutions, you’ll learn about how to use Elixir to represent optimization problems and solutions to optimization problems. You’ll learn about how genetic algorithms represent solutions and how you can use a variety of strategies to represent real-world solutions using code. Finally, you’ll create a program that learns how to spell in order to see how you can use Elixir behaviours to represent any optimization problem imaginable.
In Chapter 4, Evaluating Solutions and Populations, you’ll explore how genetic algorithms learn to find better and better solutions by evaluating a set of solutions. You’ll learn more about the concept of fitness. You’ll also learn about how to write different fitness functions and termination criteria for different types of problems, including shipping optimization, portfolio optimization, and website optimization.
In Chapter 5, Selecting the Best, you’ll learn about the first operator in a genetic algorithm — selection. You’ll learn about why selection is important, how selection rate affects your algorithms, and how to write different types of selection strategies. You’ll learn about how different selection strategies apply best to different types of problems, and you’ll learn how to customize them within your genetic algorithms.
In Chapter 6, Generating New Solutions, you’ll learn about how genetic algorithms create new solutions from existing ones using crossover. You will learn about different types of crossover strategies and how to implement them in Elixir. You’ll learn how to solve the N-queens problem to see how crossover strategies can affect the solutions produced by your genetic algorithm.
In Chapter 7, Preventing Premature Convergence, you’ll learn about a common problem in genetic algorithms — premature convergence — and how to solve it using mutation. You’ll create a basic password cracker to demonstrate premature convergence. You’ll learn how to implement several different types of mutation strategies, and you’ll learn which ones apply best to different problems.
In Chapter 9, Tracking Genetic Algorithms, you’ll learn about the different metrics and statistics you can track while running your genetic algorithms. You’ll learn how to implement an evolutionary simulation using genetic algorithms, and you’ll build statistics and genealogy tracking mechanisms around that problem.
In Chapter 10, Visualizing the Results, you’ll use the statistics collected in Chapter 9, Tracking Genetic Algorithms, to create visualizations using different plotting tools. Next, you’ll create a genetic algorithm that learns how to play Tetris, and you’ll learn how to use different tools to watch your algorithm in action.
In Chapter 11, Optimizing Your Algorithms, you’ll work through a general optimization process to learn how to get the most performance out of your code. You’ll learn how to use Elixir tools to benchmark and profile your algorithms. You’ll learn how to write faster Elixir and faster algorithms. You’ll learn how to parallelize your algorithms and how to implement NIFs that run faster than pure Elixir code.
In Chapter 12, Writing Tests and Code Quality, you’ll learn how to use Elixir features and packages to test and type check your code. You’ll learn a bit about writing tests that work well with randomness. You’ll then learn how to write typespecs and how to verify your typespecs are correct.
In Chapter 13, Moving Forward, you’ll be introduced to a variety of practical applications of genetic algorithms. From artificial intelligence to finance to advertising, you’ll learn how genetic algorithms are applied in practice, and you’ll learn about how you can use them in almost any field.
👈 Who This Book Is For | TOC | How to Use This Book 👉
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.

