<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="283046" data-post-id="283046">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="fceruti" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fceruti/120/28850_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  fceruti
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I was getting cozy in my chair,  still blowing my hot tea, when I found this bug in page 1:</p>
<p></p><div class="lightbox-wrapper"><a class="lightbox" href="https://forum.elixirforum.com/uploads/default/original/3X/9/e/9ee4e0e35b44ffc84d80c7d6a30199bbd5966726.jpeg" data-download-href="https://forum.elixirforum.com/uploads/default/9ee4e0e35b44ffc84d80c7d6a30199bbd5966726" title="Screenshot 2023-03-26 at 15.22.23" rel="nofollow"><img src="https://forum.elixirforum.com/uploads/default/original/3X/9/e/9ee4e0e35b44ffc84d80c7d6a30199bbd5966726.jpeg" alt="Screenshot 2023-03-26 at 15.22.23" data-base62-sha1="mFDOemS1jPE6osNDb8iaokjNmUm" width="690" height="357" data-dominant-color="A19D9E"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screenshot 2023-03-26 at 15.22.23</span><span class="informations">1200×622 71.5 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><p></p>
<p>130 trillion paths → 1.3 trillion paths.</p>
<p>Quite a lot paths as well, but still, it’s a two-order magnitude error.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="283046" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/genetic-algorithms-in-elixir-book-club/54827/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-283046" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="283046"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="283048" data-post-id="283048">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="code-shoily" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/code-shoily/120/8052_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  code-shoily
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Good catch. Post an erratum maybe?</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://devtalk.com/books/genetic-algorithms-in-elixir/errata">
  <header class="source">
      <img src="https://devtalk.com/favicon-32x32.png" class="site-icon" alt="" width="32" height="32">

      <a href="https://devtalk.com/books/genetic-algorithms-in-elixir/errata" target="_blank" rel="noopener nofollow">devtalk.com</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/827;"><img src="https://forum.devtalk.com/uploads/default/original/2X/2/218376e0511bde49da1841cdb106e6c94c710ffa.jpeg" class="thumbnail" alt="" width="690" height="827"></div>

<h3><a href="https://devtalk.com/books/genetic-algorithms-in-elixir/errata" target="_blank" rel="noopener nofollow">Genetic Algorithms in Elixir Book Portal | Devtalk</a></h3>

  <p>Genetic Algorithms in Elixir book published by PragProg</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<p>Update: Added the link here for future reference. Also, clicking erratum on my pdf sent me to the book link and then I had to click again to get to the DevTalk link.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="283048" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/genetic-algorithms-in-elixir-book-club/54827/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-283048" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="283048"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="283050" data-post-id="283050">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="code-shoily" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/code-shoily/120/8052_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  code-shoily
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I wanted to try out some VegaLite on this and these are what I got:</p>
<p>Without Mutation:<br>
</p><div class="lightbox-wrapper"><a class="lightbox" href="https://forum.elixirforum.com/uploads/default/original/3X/b/6/b6957dfc9b3f3864f1a0210a191695c0a254b57b.png" data-download-href="https://forum.elixirforum.com/uploads/default/b6957dfc9b3f3864f1a0210a191695c0a254b57b" title="visualization" rel="nofollow"><img src="https://forum.elixirforum.com/uploads/default/original/3X/b/6/b6957dfc9b3f3864f1a0210a191695c0a254b57b.png" alt="visualization" data-base62-sha1="q3dbtjusVIPamstZ2V90VrumnJF" width="478" height="454"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">visualization</span><span class="informations">478×454 13.1 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><p></p>
<p>With Mutation:<br>
</p><div class="lightbox-wrapper"><a class="lightbox" href="https://forum.elixirforum.com/uploads/default/original/3X/1/b/1ba492facccf656c856850495a350a90b03592ad.png" data-download-href="https://forum.elixirforum.com/uploads/default/1ba492facccf656c856850495a350a90b03592ad" title="visualization-2" rel="nofollow"><img src="https://forum.elixirforum.com/uploads/default/original/3X/1/b/1ba492facccf656c856850495a350a90b03592ad.png" alt="visualization-2" data-base62-sha1="3Wxuod9bOcuj19O6Uslb3gN4TM1" width="478" height="454"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">visualization-2</span><span class="informations">478×454 20.4 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><p></p>
<p>I did not configure the chart for look pretty though, just added:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">chart =
  Vl.new(width: 400, height: 400)
  |&gt; Vl.mark(:line)
  |&gt; Vl.encode_field(:x, "x", type: :quantitative)
  |&gt; Vl.encode_field(:y, "y", type: :quantitative)
  |&gt; Kino.VegaLite.new()
  |&gt; Kino.render()
</code></pre>
<p>and tweaked the <code>algorithm</code> to look like:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">algorithm = fn population, iter, algorithm -&gt;
  best = Enum.max_by(population, &amp;Enum.sum/1)
  IO.write("\rCurrent Best (# #{iter}): " &lt;&gt; Integer.to_string(Enum.sum(best)))
  Kino.VegaLite.push(chart, %{x: iter, y: Integer.to_string(Enum.sum(best))})

  if Enum.sum(best) == 1000 do
    best
  else
    population
    |&gt; evaluate.()
    |&gt; selection.()
    |&gt; crossover.()
    |&gt; mutation.()
    |&gt; algorithm.(iter + 1, algorithm)
  end
end
</code></pre>
<p>The one without mutation nearly broke my LiveBook though</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="283050" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/genetic-algorithms-in-elixir-book-club/54827/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-283050" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="283050"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="283057" data-post-id="283057">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="stevensonmt" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/stevensonmt/120/20503_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  stevensonmt
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I think the algorithm will always run until it reaches the terminating condition, right? The only terminating condition was for <code>Enum.sum(best) == 1000</code> so it should run until it hits that or maybe hits some sort of timeout. On my machine it definitely slowed down in progress around 950 but eventually reached 1000.</p>
<p>My notes as I was going through chapter 1:</p>
<h2><a name="p-283057-basic-conceptflow-of-genetic-algorithm-1" class="anchor" href="#p-283057-basic-conceptflow-of-genetic-algorithm-1" aria-label="Heading link" rel="nofollow"></a>Basic concept/flow of genetic algorithm:</h2>
<ul>
<li>Initialize population</li>
<li>Evaluate population (apply fitness function)</li>
<li>Select parents</li>
<li>Create children (crossover)</li>
<li>Mutate children (introduce randomness)</li>
<li>Loop back to evaluate</li>
</ul>
<h3><a name="p-283057-population-size-ie-number-of-chormosomes-2" class="anchor" href="#p-283057-population-size-ie-number-of-chormosomes-2" aria-label="Heading link" rel="nofollow"></a>Population size (i.e., number of chormosomes)</h3>
<ul>
<li>larger population → longer transformation step</li>
<li>smaller population → more generations needed to produce soln and more<br>
likely to have premature convergence</li>
</ul>
<h3><a name="p-283057-premature-convergence-3" class="anchor" href="#p-283057-premature-convergence-3" aria-label="Heading link" rel="nofollow"></a>Premature convergence</h3>
<ul>
<li>focusing on solution that appears “good enough” when more optimal solutions exist</li>
<li>Mutation helps fight premature convergence</li>
</ul>
<blockquote>
<p>Initial example shows how to get to a solution when you know what the answer is, but how<br>
will genetic algorithms work when you don’t know the solution ahead of time? ??</p>
</blockquote>
<ul>
<li>Fitness functions should be sorting/ordering (?)</li>
</ul>
<blockquote>
<p>Single point crossover I assume is faster per generation but may lead to more generations needed if initial population is small.</p>
</blockquote>
<h3><a name="p-283057-mutation-4" class="anchor" href="#p-283057-mutation-4" aria-label="Heading link" rel="nofollow"></a>Mutation</h3>
<p>Mutation probability in example is 5%.</p>
<ul>
<li>Impact of higher/lower probability of mutation?
<ul>
<li>I assume higher probability leads to slower optimization as higher chance of undoing<br>
progress, however it might serve to counterbalance low initial population size/diversity</li>
</ul>
</li>
<li>The example mutation shuffles entire chromosome. How does single gene mutation or transposition mutation impact performance?
<ul>
<li>Again, I assume that broader mutations lead to more diversity and can offset small initial<br>
population size at expense of potentially requiring more generations to acheive optimal solution</li>
</ul>
</li>
</ul> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="283057" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/genetic-algorithms-in-elixir-book-club/54827/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-283057" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="283057"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="283058" data-post-id="283058">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="code-shoily" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/code-shoily/120/8052_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  code-shoily
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><strong>Chapter 1 is read!</strong></p>
<p>This was a great read. I don’t have any prior exposure to genetic algorithm, other than my university AI course that happened 20 years ago. So, this was quite a fun experience for me.</p>
<p>My initial reaction was to read the prose first and take a stab at the code later, but the way the example was arranged, I felt it would be more convenient if I experiment with each function and their result on a shell, and what better shell than LiveBook?</p>
<p>I experimented with each artifacts (i.e. <code>population</code>, <code>evaluate</code>, <code>selection</code>, <code>crossover</code>, <code>mutation</code> (when it appeared after the interval), <code>algorithm</code>). I even came up with an acronym (P.E.S.C.A), until <code>M</code> for mutation came along and mutated my acronym into an unpronounceable one. I keep thinking <code>evaluate</code> could <code>evaluation</code> to belong to same parts of speech class as all other functions (or selection → select, mutation → mutate etc). Or maybe that’s just me.</p>
<p>I really liked how, for the first time in my life, I understood what an AI book is trying to tell me in one run. The writing style is enjoyable and the introductory elements fit right in. The presentation, both in terms of english and code, are very easy to visualize. I have not seen any genetic algorithm code in other languages but I felt like both the recursion and piped workflow is perfect representation. I eagerly await reading next chapters to see if this can turn into a generic pattern for larger set of problems.</p>
<p>I have discussed the code running completely without <code>mutate</code> (or is it <code>mutation</code>?) at all attempts I made (contrary to what the book said), but one update is that, when I tried the same on <code>10</code>, <code>100</code> on REPLIT (1 CPU, OTP 24 etc), then it kept dancing around <code>82</code>, <code>87</code> for 200k iterations <img src="https://forum.elixirforum.com/images/emoji/apple/person_shrugging.png?v=15" title=":person_shrugging:" class="emoji" alt=":person_shrugging:" loading="lazy" width="20" height="20"> … but that aside, running all the code is strongly recommended if you ask me, even better with LiveBook. It gives a “feel” for what the author is trying to explain.</p>
<p>That’s my brief summary of my experience with chapter 1. A bunch of things I would like to do (Please folks, tell me if this would be futile):</p>
<ul>
<li>Create a repository of livemds for the code</li>
<li>Try using the <code>Nx</code> data structures and functions to solve the same problems, who knows, if chapter permits, <code>Explore</code>?</li>
<li>Produce <code>VegaLite</code> charts.</li>
<li>Benchmark things on different backends (I will admit, I don’t even know what backends will do for these problems)</li>
</ul>
<p>Anyways, I will try to pick one or more of those and share it with y’all. That’ll be all for my chapter 1. I briefly read chapter 2 and already like the way it built upon Chapter 1. Thank you <a class="mention" href="/u/astonj" rel="nofollow">@AstonJ</a> and <a class="mention" href="/u/stevensonmt" rel="nofollow">@stevensonmt</a> for doing this.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="283058" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/genetic-algorithms-in-elixir-book-club/54827/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-283058" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="283058"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #15"></div>
  </section>
</div>
    <div class="postbit" id="283108" data-post-id="283108">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="stevensonmt" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/stevensonmt/120/20503_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  stevensonmt
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="bdarla" data-post="8" data-topic="54827">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/bdarla/48/19471_2.png" class="avatar"> bdarla:</div>
<blockquote>
<p>An interesting question for me is whether genetic algorithms are suitable for matching two pieces of text, for example, in order to assess whether a patent claim extends beyond the original patent description.</p>
</blockquote>
</aside>
<p>Maybe not that complex, but chapter 3 has an example of text matching.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="283108" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/genetic-algorithms-in-elixir-book-club/54827/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-283108" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="283108"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #16"></div>
  </section>
</div>
    <div class="postbit" id="283109" data-post-id="283109">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="stevensonmt" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/stevensonmt/120/20503_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  stevensonmt
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group quote-modified" data-username="code-shoily" data-post="9" data-topic="54827">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/code-shoily/48/8052_2.png" class="avatar"> code-shoily:</div>
<blockquote>
<p>I added an iterator and seems like (again based on the few tries I did), WITH MUTATION reaches the best result in ~50% less iteration count.</p>
</blockquote>
</aside>
<p>What do you mean by <code>iterator</code> here? I’m mostly familiar with that in the context of Rust and think of anything that’s Enumerable in Elixir as being roughly analogous to Rust iterators via the Enum module.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="283109" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/genetic-algorithms-in-elixir-book-club/54827/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-283109" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="283109"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #17"></div>
  </section>
</div>
    <div class="postbit" id="283113" data-post-id="283113">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="code-shoily" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/code-shoily/120/8052_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  code-shoily
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>My bad with quick typing on the phone. I mean ‘iteration-counter’ - something that keeps track of each iteration (I mean, every time algorithm is called). Thank you for catching this.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="283113" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/genetic-algorithms-in-elixir-book-club/54827/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-283113" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="283113"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #18"></div>
  </section>
</div>
    <div class="postbit" id="283115" data-post-id="283115">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="fceruti" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fceruti/120/28850_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  fceruti
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks, I just left an errata there, I was unaware that medium existed.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="283115" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/genetic-algorithms-in-elixir-book-club/54827/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-283115" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="283115"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #19"></div>
  </section>
</div>
    <div class="postbit" id="283126" data-post-id="283126">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="code-shoily" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/code-shoily/120/8052_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  code-shoily
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<h1><a name="p-283126-chapter-2-1" class="anchor" href="#p-283126-chapter-2-1" aria-label="Heading link" rel="nofollow"></a>Chapter 2</h1>
<p>Okay, so chapter 1 mostly introduced genetic algorithms and this  <code>population &gt; evaluate &gt; selection &gt; crossover &gt; mutation</code> workflow, but had a lot of the parameters hard-coded, and it was presented as a stand-alone <code>exs</code> script. By the time I finished it, I knew what was coming in chapter 2.</p>
<p>So, we took everything learnt in chapter 1, and modularized it in chapter 2. Lift the hard-coded values and turn them into (hyper)parameters, inject the genotype and fitness function, and have the solution run while punching everything in.</p>
<p>All in all, a nice supplement to chapter 1, quite a few new concepts to learn (Hyper-parameters!). And learned a new word: Genotype.</p>
<p>No, I looked up genotype and saw the definition read as:</p>
<blockquote>
<p>In a broad sense, the term “genotype” refers to <strong>the genetic makeup of an organism</strong> ; in other words, it describes an organism’s complete set of genes. In a more narrow sense, the term can be used to refer to the alleles, or variant forms of a gene, that are carried by an organism.</p>
</blockquote>
<p>I was wondering why the function name wasn’t something like <code>make_chromosome</code> or something like that, but this term seemed to be a good fit for the purpose!</p>
<h3><a name="p-283126-error-2" class="anchor" href="#p-283126-error-2" aria-label="Heading link" rel="nofollow"></a>Error?</h3>
<p>On page 27, when <code>run</code> was defined, we see <code>fitness_function</code> as the first argument. However, on page 28 when it introduces the <code>opt</code> parameter, it has <code>genotype</code> as the first argument (We see the same thing at the bottom of that page too as <code>run</code> receives code). However, on page 30, when <code>run</code> is called to form solution, we see <code>soln = Genetic.run(fitness_function, genotype, max_fitness)</code>, <code>fitness_function</code> is back at number 1 position. <em>Update: Looks like someone already <a href="https://forum.devtalk.com/t/genetic-algorithms-in-elixir-genetic-run-argument-order-page-30/7818" rel="nofollow">reported this one here</a>!</em></p>
<p>Looking at how <code>population</code> gets the first spot for other functions and <code>fitness_function</code> being second, I feel it should also be the case for <code>run</code>. But even if not, the function got different signatures here.</p>
<p>Looking forward to starting next weekend, I’ll get back with update once done with that.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="283126" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/genetic-algorithms-in-elixir-book-club/54827/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-283126" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="283126"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #20"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/54827/load_more?page=3">Load more posts (48 remaining)</a>
</div></template></turbo-stream>