<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns=“www.w3.org/1999/xhtml” xml:lang=“en” lang=“en”>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>

Class: NEAT::Evolver

  &mdash; Documentation by YARD 0.8.7.3

</title>

<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />

<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />

<script type=“text/javascript” charset=“utf-8”>

hasFrames = window.top.frames.main ? true : false;
relpath = '../';
framesUrl = "../frames.html#!" + escape(window.location.href);

</script>

<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>

<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>

</head>
<body>
  <div id="header">
    <div id="menu">

  <a href="../_index.html">Index (E)</a> &raquo;
  <span class='title'><span class='object_link'><a href="../NEAT.html" title="NEAT (module)">NEAT</a></span></span>
   &raquo; 
  <span class="title">Evolver</span>

<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>

</div>

  <div id="search">

<a class="full_list_link" id="class_list_link"
    href="../class_list.html">
  Class List
</a>

<a class="full_list_link" id="method_list_link"
    href="../method_list.html">
  Method List
</a>

<a class="full_list_link" id="file_list_link"
    href="../file_list.html">
  File List
</a>

</div>

  <div class="clear"></div>
</div>

<iframe id="search_frame"></iframe>

<div id="content"><h1>Class: NEAT::Evolver

</h1>

<dl class=“box”>

<dt class="r1">Inherits:</dt>
<dd class="r1">
  <span class="inheritName"><span class='object_link'><a href="Operator.html" title="NEAT::Operator (class)">Operator</a></span></span>

    <ul class="fullTree">
      <li>Object</li>

        <li class="next"><span class='object_link'><a href="NeatOb.html" title="NEAT::NeatOb (class)">NeatOb</a></span></li>

        <li class="next"><span class='object_link'><a href="Operator.html" title="NEAT::Operator (class)">Operator</a></span></li>

        <li class="next">NEAT::Evolver</li>

    </ul>
    <a href="#" class="inheritanceTree">show all</a>

  </dd>

<dt class="r2 last">Defined in:</dt>
<dd class="r2 last">lib/rubyneat/evolver.rb</dd>

</dl> <div class=“clear”></div>

<h2>Overview</h2><div class=“docstring”>

<div class="discussion">

<h1 id=“label-Evolver+–+Basis+of+all+evolvers.”>Evolver – Basis of all evolvers.</h1>

<p>All evolvers shall derive from this basic evolver (or this one can be used as is). Here, we&#39;ll have many different evolutionary operators that will perform operations on the various critters in the population.</p>

</div>

</div> <div class=“tags”>

</div><h2>Defined Under Namespace</h2> <p class=“children”>

<strong class="classes">Classes:</strong> <span class='object_link'><a href="Evolver/CritterOp.html" title="NEAT::Evolver::CritterOp (class)">CritterOp</a></span>

</p>

<h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
<ul class="summary">

    <li class="public ">
<span class="summary_signature">

    <a href="#npop-instance_method" title="#npop (instance method)">- (Object) <strong>npop</strong> </a>

</span>

    <span class="note title readonly">readonly</span>

  <span class="summary_desc"><div class='inline'>

<p>Returns the value of attribute npop.</p> </div></span>

</li>

</ul>

<h3 class="inherited">Attributes inherited from <span class='object_link'><a href="NeatOb.html" title="NEAT::NeatOb (class)">NeatOb</a></span></h3>
<p class="inherited"><span class='object_link'><a href="NeatOb.html#controller-instance_method" title="NEAT::NeatOb#controller (method)">#controller</a></span>, <span class='object_link'><a href="NeatOb.html#name-instance_method" title="NEAT::NeatOb#name (method)">#name</a></span></p>

  <h2>
    Instance Method Summary
    <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
  </h2>

  <ul class="summary">

      <li class="public ">
<span class="summary_signature">

    <a href="#evolve-instance_method" title="#evolve (instance method)">- (Object) <strong>evolve</strong>(population) </a>

</span>

  <span class="summary_desc"><div class='inline'>

<p>Here we clone the population and then evolve it on the basis of fitness and novelty, etc.</p> </div></span>

</li>

      <li class="public ">
<span class="summary_signature">

    <a href="#gen_initial_genes%21-instance_method" title="#gen_initial_genes! (instance method)">- (Object) <strong>gen_initial_genes!</strong>(genotype) </a>

</span>

  <span class="summary_desc"><div class='inline'>

<p>Generate the initial genes for a given genotype.</p> </div></span>

</li>

      <li class="public ">
<span class="summary_signature">

    <a href="#initialize-instance_method" title="#initialize (instance method)">- (Evolver) <strong>initialize</strong>(c) </a>

</span>

  <span class="note title constructor">constructor</span>

  <span class="summary_desc"><div class='inline'>

<p>A new instance of Evolver.</p> </div></span>

</li>

      <li class="public ">
<span class="summary_signature">

    <a href="#mutate%21-instance_method" title="#mutate! (instance method)">- (Object) <strong>mutate!</strong>(population) </a>

</span>

  <span class="summary_desc"><div class='inline'>

<p>Here we mutate the population.</p> </div></span>

</li>

  </ul>

<h3 class="inherited">Methods inherited from <span class='object_link'><a href="NeatOb.html" title="NEAT::NeatOb (class)">NeatOb</a></span></h3>
<p class="inherited"><span class='object_link'><a href="NeatOb.html#log-instance_method" title="NEAT::NeatOb#log (method)">#log</a></span>, <span class='object_link'><a href="NeatOb.html#log-class_method" title="NEAT::NeatOb.log (method)">log</a></span>, <span class='object_link'><a href="NeatOb.html#to_s-instance_method" title="NEAT::NeatOb#to_s (method)">#to_s</a></span></p>

<div id="constructor_details" class="method_details_list">
<h2>Constructor Details</h2>

  <div class="method_details first">
<h3 class="signature first" id="initialize-instance_method">

  - (<tt><span class='object_link'><a href="" title="NEAT::Evolver (class)">Evolver</a></span></tt>) <strong>initialize</strong>(c)

</h3><div class=“docstring”>

<div class="discussion">

<p>Returns a new instance of Evolver</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

13 14 15 16</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/evolver.rb', line 13</span>

<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_c'>c</span><span class='rparen'>)</span>

<span class='kw'>super</span>
<span class='ivar'>@critter_op</span> <span class='op'>=</span> <span class='const'>CritterOp</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>self</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

</div>

<div id="instance_attr_details" class="attr_details">
  <h2>Instance Attribute Details</h2>

    <span id=""></span>
    <div class="method_details first">
<h3 class="signature first" id="npop-instance_method">

  - (<tt>Object</tt>) <strong>npop</strong>  <span class="extras">(readonly)</span>

</h3><div class=“docstring”>

<div class="discussion">

<p>Returns the value of attribute npop</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

11 12 13</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/evolver.rb', line 11</span>

<span class='kw'>def</span> <span class='id identifier rubyid_npop'>npop</span>

<span class='ivar'>@npop</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

</div>

<div id="instance_method_details" class="method_details_list">
  <h2>Instance Method Details</h2>

    <div class="method_details first">
<h3 class="signature first" id="evolve-instance_method">

  - (<tt>Object</tt>) <strong>evolve</strong>(population)

</h3><div class=“docstring”>

<div class="discussion">

<p>Here we clone the population and then evolve it on the basis of fitness and novelty, etc.</p>

<p>Returns the newly-evolved population.</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

53 54 55 56 57 58 59 60 61 62 63 64</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/evolver.rb', line 53</span>

<span class='kw'>def</span> <span class='id identifier rubyid_evolve'>evolve</span><span class='lparen'>(</span><span class='id identifier rubyid_population'>population</span><span class='rparen'>)</span>

<span class='ivar'>@npop</span> <span class='op'>=</span> <span class='id identifier rubyid_population'>population</span><span class='period'>.</span><span class='id identifier rubyid_dclone'>dclone</span>

<span class='comment'># Population sorting and evaluation for breeding, mutations, etc.

</span> <span class='id identifier rubyid_prepare_speciation!'>prepare_speciation!</span>

<span class='id identifier rubyid_prepare_fitness!'>prepare_fitness!</span>
<span class='id identifier rubyid_prepare_novelty!'>prepare_novelty!</span>

<span class='id identifier rubyid_mate!'>mate!</span>

<span class='kw'>return</span> <span class='ivar'>@npop</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

    <div class="method_details ">
<h3 class="signature " id="gen_initial_genes!-instance_method">

  - (<tt>Object</tt>) <strong>gen_initial_genes!</strong>(genotype)

</h3><div class=“docstring”>

<div class="discussion">

<p>Generate the initial genes for a given genotype. We key genes off their innovation numbers.</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

20 21 22 23 24 25 26 27 28</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/evolver.rb', line 20</span>

<span class='kw'>def</span> <span class='id identifier rubyid_gen_initial_genes!'>gen_initial_genes!</span><span class='lparen'>(</span><span class='id identifier rubyid_genotype'>genotype</span><span class='rparen'>)</span>

<span class='id identifier rubyid_genotype'>genotype</span><span class='period'>.</span><span class='id identifier rubyid_genes'>genes</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
<span class='id identifier rubyid_genotype'>genotype</span><span class='period'>.</span><span class='id identifier rubyid_neural_inputs'>neural_inputs</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_s1'>s1</span><span class='comma'>,</span> <span class='id identifier rubyid_input'>input</span><span class='op'>|</span>
  <span class='id identifier rubyid_genotype'>genotype</span><span class='period'>.</span><span class='id identifier rubyid_neural_outputs'>neural_outputs</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_s2'>s2</span><span class='comma'>,</span> <span class='id identifier rubyid_output'>output</span><span class='op'>|</span>
    <span class='id identifier rubyid_g'>g</span> <span class='op'>=</span> <span class='const'>Critter</span><span class='op'>::</span><span class='const'>Genotype</span><span class='op'>::</span><span class='const'>Gene</span><span class='lbracket'>[</span><span class='id identifier rubyid_genotype'>genotype</span><span class='comma'>,</span> <span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='id identifier rubyid_output'>output</span><span class='comma'>,</span> <span class='const'>NEAT</span><span class='op'>::</span><span class='id identifier rubyid_controller'>controller</span><span class='period'>.</span><span class='id identifier rubyid_gaussian'>gaussian</span><span class='rbracket'>]</span>
    <span class='id identifier rubyid_genotype'>genotype</span><span class='period'>.</span><span class='id identifier rubyid_genes'>genes</span><span class='lbracket'>[</span><span class='id identifier rubyid_g'>g</span><span class='period'>.</span><span class='id identifier rubyid_innovation'>innovation</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_g'>g</span>
  <span class='kw'>end</span>
<span class='kw'>end</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

    <div class="method_details ">
<h3 class="signature " id="mutate!-instance_method">

  - (<tt>Object</tt>) <strong>mutate!</strong>(population)

</h3><div class=“docstring”>

<div class="discussion">

<p>Here we mutate the population.</p>

</div>

</div> <div class=“tags”>

</div><table class=“source_code”>

<tr>
  <td>
    <pre class="lines">

31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47</pre>

</td>
<td>
  <pre class="code"><span class="info file"># File 'lib/rubyneat/evolver.rb', line 31</span>

<span class='kw'>def</span> <span class='id identifier rubyid_mutate!'>mutate!</span><span class='lparen'>(</span><span class='id identifier rubyid_population'>population</span><span class='rparen'>)</span>

<span class='ivar'>@npop</span> <span class='op'>=</span> <span class='id identifier rubyid_population'>population</span>

<span class='kw'>if</span> <span class='ivar'>@controller</span><span class='period'>.</span><span class='id identifier rubyid_parms'>parms</span><span class='period'>.</span><span class='id identifier rubyid_mate_only_prob'>mate_only_prob</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='kw'>or</span> <span class='id identifier rubyid_rand'>rand</span> <span class='op'>&gt;</span> <span class='ivar'>@controller</span><span class='period'>.</span><span class='id identifier rubyid_parms'>parms</span><span class='period'>.</span><span class='id identifier rubyid_mate_only_prob'>mate_only_prob</span>
  <span class='id identifier rubyid_log'>log</span><span class='period'>.</span><span class='id identifier rubyid_debug'>debug</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>[[[ Neuron and Gene Giggling!</span><span class='tstring_end'>&quot;</span></span>
  <span class='id identifier rubyid_mutate_perturb_gene_weights!'>mutate_perturb_gene_weights!</span>
  <span class='id identifier rubyid_mutate_change_gene_weights!'>mutate_change_gene_weights!</span>
  <span class='id identifier rubyid_mutate_add_neurons!'>mutate_add_neurons!</span>
  <span class='id identifier rubyid_mutate_change_neurons!'>mutate_change_neurons!</span>
  <span class='id identifier rubyid_mutate_add_genes!'>mutate_add_genes!</span>
  <span class='id identifier rubyid_mutate_disable_genes!'>mutate_disable_genes!</span>
  <span class='id identifier rubyid_mutate_reenable_genes!'>mutate_reenable_genes!</span>
  <span class='id identifier rubyid_log'>log</span><span class='period'>.</span><span class='id identifier rubyid_debug'>debug</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>]]] End Neuron and Gene Giggling!\n</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>else</span>
  <span class='id identifier rubyid_log'>log</span><span class='period'>.</span><span class='id identifier rubyid_debug'>debug</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>*** Mating only!</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>end</span>

<span class='kw'>end</span></pre>

  </td>
</tr>

</table> </div>

</div>

</div>

  <div id="footer">
Generated on Sun Mar 16 16:36:51 2014 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.8.7.3 (ruby-2.1.1).

</div>

</body>

</html>