avatarThe Pragmatic Programmers

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

1125

Abstract

new command:</p><div id="d805"><pre>​ ​ ​​mix​​ ​​<span class="hljs-keyword">new</span><span class="hljs-type"></span>​​ ​​genetic​</pre></div><p id="d611">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.</p><p id="f81e">Navigate to the genetic directory and inspect its contents, like so:</p><div id="3bf0"><pre>​ ​ ​​<span class="hljs-built_in">cd</span>​​ ​​genetic​​ ​​&&​​ ​​<span class="hljs-built_in">ls</span>​ ​ lib mix.exs README.md <span class="hljs-built_in">test</span></pre></div><p id="80a4">lib will contain all of the contents of your genetic algorithm framework. It should only contain genetic.ex.</p><p id="26b4">test will contain all of your tests. Don’t worry about the contents of the directory for now.</p><p id="0a68">mix.exs will contain dependencies and other project configurations. The default configuration is sufficient for now.</p><p id="0784">In addition to the default directories and files, you’ll need a directory named scripts. This directory will contain your solutions to various optimization pro

Options

blems. In a terminal inside of your Mix project, create a new directory, like this:</p><div id="f976"><pre>​ ​$ ​​mkdir​​ ​​scripts​</pre></div><p id="19a6">With the project set up, it’s time to create your framework.</p><p id="e084"><i>👈 <a href="https://readmedium.com/looking-deeper-into-genetic-algorithms-729de3553406">Looking Deeper into Genetic Algorithms</a> | <a href="https://readmedium.com/table-of-contents-879fc8614df">TOC</a> | <a href="https://readmedium.com/building-a-framework-for-genetic-algorithms-f876cfee3749">Building a Framework for Genetic Algorithms</a> 👉</i></p><p id="4c87"><i>Genetic Algorithms in Elixir by Sean Moriarity can be purchased in other book formats <a href="https://pragprog.com/titles/smgaelixir">directly from the Pragmatic Programmers</a>. If you notice a code error or formatting mistake, please let us know <a href="https://readmedium.com/how-to-report-errata-4e164674347a">here</a> so that we can fix it.</i></p><figure id="b287"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*U2E2a23SuM4520w9CUXSWw.jpeg"><figcaption></figcaption></figure></article></body>

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

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.

Smgaelixir
Recommended from ReadMedium