Genetic Algorithms in Elixir
Solve Problems Using Evolution
by Sean Moriarity
From finance to artificial intelligence, genetic algorithms are a
powerful tool with a wide array of applications. But you don’t need an
exotic new language or framework to get started; you can learn about
genetic algorithms in a language you’re already familiar with. Join us
for an in-depth look at the algorithms, techniques, and methods that go
into writing a genetic algorithm. From introductory problems to
real-world applications, you’ll learn the underlying principles of
problem solving using genetic algorithms.
Evolutionary algorithms are a unique and often overlooked subset of
machine learning and artificial intelligence. Because of this, most of
the available resources are outdated or too academic in nature, and none
of them are made with Elixir programmers in mind.
Start from the ground up with genetic algorithms in a language you are
familiar with. Discover the power of genetic algorithms through simple
solutions to challenging problems. Use Elixir features to write genetic
algorithms that are concise and idiomatic. Learn the complete life cycle
of solving a problem using genetic algorithms. Understand the different
techniques and fine-tuning required to solve a wide array of problems.
Plan, test, analyze, and visualize your genetic algorithms with
real-world applications.
Open your eyes to a unique and powerful field—without having to learn
a new language or framework.
What You Need
You’ll need a macOS, Windows, or Linux distribution with an up-to-date
Elixir installation.
Resources
Releases:
- P1.0 2021/01/20
- B3.0 2020/12/11
- B2.0 2020/11/19
- B1.0 2020/10/19
- Preface
- Who This Book Is For
- What’s in This Book
- How to Use This Book
- How Does Elixir Fit In?
- Writing Your First Genetic Algorithm
excerpt
- Understanding Genetic Algorithms
- Introducing the One-Max Problem
- Initializing the Population
- Understanding the Flow of Genetic Algorithms
- Selecting Parents
- Creating Children
- Running Your Solution
- Adding Mutation
- What You Learned
- Breaking Down Genetic Algorithms
- Reviewing Genetic Algorithms
- Looking Deeper into Genetic Algorithms
- Using Mix to Write Genetic Algorithms
- Building a Framework for Genetic Algorithms
- Understanding Hyperparameters
- Solving the One-Max Problem Again
- What You Learned
- Encoding Problems and Solutions
excerpt
- Using Structs to Represent Chromosomes
- Using Behaviours to Model Problems
- Understanding and Choosing Genotypes
- Solving One-Max for the Last Time
- Spelling Words with Genetic Algorithms
- What You Learned
- Evaluating Solutions and Populations
- Optimizing Cargo Loads
- Introducing Penalty Functions
- Applying a Penalty to the Shipping Problem
- Defining Termination Criteria
- Applying Termination Criteria to Shipping
- Crafting Fitness Functions
- Exploring Different Types of Optimization
- What You Learned
- Selecting the Best
- Exploring Selection
- Customizing Selection in Your Framework
- Implementing Common Selection Strategies
- What You Learned
- Generating New Solutions
- Introducing N-Queens
- Solving N-Queens with Order-One Crossover
- Exploring Crossover
- Implementing Other Common Crossover Strategies
- Crossing Over More Than Two Parents
- Implementing Chromosome Repairment
- What You Learned
- Preventing Premature Convergence
- Breaking Codes with Genetic Algorithms
- Understanding Mutation
- Customizing Mutation in Your Framework
- Implementing Common Mutation Strategies
- Other Methods to Combat Convergence
- What You Learned
- Replacing and Transitioning
- Creating a Class Schedule
- Understanding Reinsertion
- Experimenting with Reinsertion
- Growing and Shrinking Populations
- Local Versus Global Reinsertion
- What You Learned
- Tracking Genetic Algorithms
- Using Genetic Algorithms to Simulate Evolution
- Logging Statistics Using ETS
excerpt
- Tracking Genealogy in a Genealogy Tree
- What You Learned
- Visualizing the Results
- Visualizing the Genealogy of the Tiger Evolution
- Visualizing Basic Statistics
- Playing Tetris with Genetic Algorithms
- Installing and Compiling ALEx
- What You Learned
- Optimizing Your Algorithms
- Benchmarking and Profiling Genetic Algorithms
- Writing Fast Elixir
- Improving Performance with Parallelization
- Improving Performance with NIFs
- What You Learned
- Writing Tests and Code Quality
- Understanding Randomness
- Writing Property Tests with ExUnit
- Cleaning Up Your Framework
- Writing Type Specifications
- What You Learned
- Moving Forward
- Learning with Evolution
- Designing with Evolution
- Trading with Evolution
- Networking with Evolution
- Evolving Neural Networks
- Where to Go Next
Author
Sean Moriarity graduated from the United States Military Academy
with a degree in Computer Science. Sean was first introduced to genetic
algorithms while on a summer internship which inspired him to write
Genex, a library for writing evolutionary algorithms in Elixir. Many
of the problems and solutions you’ll encounter in this book were
inspired from the lessons learned while developing Genex. Sean’s
passions include functional programming, artificial intelligence,
mathematics, and, of course, evolutionary algorithms.