Using Mix to Write Genetic Algorithms
Genetic Algorithms in Elixir — by Sean Moriarity (22 / 101)
👈 Looking Deeper into Genetic Algorithms | TOC | Building a Framework for Genetic Algorithms 👉
Elixir projects are created, built, and tested using Mix. You’ll use Mix for managing dependencies, testing your libraries, and running your genetic algorithms. For now, you’ll create a Mix project that contains a framework for writing genetic algorithms.
Start by opening a terminal and navigating to the genetic directory you created in the previous chapter, like this:
$ cd geneticInside the genetic directory, create a new Mix project using the new command:
$ mix new geneticgenetic is the name of your Mix project. You can choose whatever name you’d like, so long as it’s a valid name for a Mix project.
Navigate to the genetic directory and inspect its contents, like so:
$ cd genetic && ls
lib mix.exs README.md testlib will contain all of the contents of your genetic algorithm framework. It should only contain genetic.ex.
test will contain all of your tests. Don’t worry about the contents of the directory for now.
mix.exs will contain dependencies and other project configurations. The default configuration is sufficient for now.
In addition to the default directories and files, you’ll need a directory named scripts. This directory will contain your solutions to various optimization problems. In a terminal inside of your Mix project, create a new directory, like this:
$ mkdir scripts
With the project set up, it’s time to create your framework.
👈 Looking Deeper into Genetic Algorithms | TOC | Building a Framework for Genetic Algorithms 👉
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.

