Using Mix to Write Genetic Algorithms

Genetic Algorithms in Elixir — by Sean Moriarity (22 / 101)

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 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​​ ​​genetic​

Inside the genetic directory, create a new Mix project using the new command:

​ ​$ ​​mix​​ ​​new​​ ​​genetic​

genetic 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 test

lib 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.

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.