Genetic Algorithms in Elixir (PragProg)

Sean Moriarity @seanmor5

edited by Tammy Coron @Paradox927

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.

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.

Don’t forget you can get 35% off with your Devtalk discount! Just use the coupon code “" at checkout :+1:

Posted via Devtalk.

A new Elixir resource is available


@kokolegorille Author here. Thanks for sharing! If anybody has any questions or comments about the book, feel free to PM me!


Oh hey, that looks really cool! I wasn’t aware that Elixir was a suitable language for machine learning. Though I suppose that if you think about it, about any language would be able to do it.


Thanks for writing this book, Sean! I am really curious about it!

1 Like

I could not find information on the website, but will a paper version be available. I’m one of those that don’t do well with ebook formats and prefer holding a physical book.

Yes there will, but don’t expect the book release before version 1.0 :slight_smile:

I bought a copy recently, looking forward to learn a great deal from this book. Thank you.

@seanmor5 Hi, the book is pretty informative so far, but there are some code inconsistencies, which is understandable given the book is still in beta; Still a great resource!

I do have something I can’t seem to figure out, though, which is the representation of the N-Queens problem. Given the configuration [0, 2, 1, 3, 6, 4, 7, 5], it’s being represented as such in the book:


  1. I can’t seem to figure out the relationship between the configuration, and the illustration. I don’t understand how a 2D board can be represented with only a 1D list, if each element in the list were to be a queen’s location.
  2. It isn’t a valid solution because of the 2 queens in the last column. Or maybe this is just to serve as an example, and not as a solution?

Edit: I found a resource that expounds further on this, and confirmed my guess. The index of an element represents the column number, and the element value represents the row value. But regardless, the image doesn’t really line up with the configuration.

Columns from left to right are the index of each value from the list, and the value is the row from top to bottom (both starting from zero). So it is the index that is making up for that X coordinate you are looking for, the Y coordinates are each value on the list, assuming the origin of this plane on the top left corner.

I am extremely excited about this announcement! I’ve been fascinated by genetic algorithms for a long time, but I’ve had to portion out my time to learning one thing or another. Since my learning time is mostly spent in Elixir, this can kill two birds with one stone!

Yeah, the image is wrong. I need to adjust. Sorry about that