intelligence
Version:
Machine learning library written in javascript
1,490 lines (476 loc) • 21.9 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: LinearIndividual</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: LinearIndividual</h1>
<section>
<header>
<h2>
LinearIndividual
</h2>
</header>
<article>
<div class="container-overview">
<dt>
<h4 class="name" id="LinearIndividual"><span class="type-signature"></span>new LinearIndividual<span class="signature">(options)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
<p>Linear genetic programming individual</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"><p>Linear indivdual options</p>
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>numInputs</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>The number of inputs that the individual accepts</p></td>
</tr>
<tr>
<td class="name"><code>numOutputs</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>The number of output the individual should return</p></td>
</tr>
<tr>
<td class="name"><code>functionSet</code></td>
<td class="type">
<span class="param-type">Array.<function()></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>An array of functions that are made available to the individual</p></td>
</tr>
<tr>
<td class="name"><code>removeIntrons</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
true
</td>
<td class="description last"><p>Specify whether introns should be removed before execution</p></td>
</tr>
<tr>
<td class="name"><code>conditionalSet</code></td>
<td class="type">
<span class="param-type">Array.<function()></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
[]
</td>
<td class="description last"><p>An array of functions that can be used to control logic</p></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<h5 class="subsection-title">Properties:</h5>
<dl>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"><p>Linear indivdual options</p></td>
</tr>
</tbody>
</table></dl>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="linearIndividual.js.html">genetic/linear/linearIndividual.js</a>, <a href="linearIndividual.js.html#line20">line 20</a>
</li></ul></dd>
</dl>
</dd>
</div>
<h3 class="subsection-title">Extends</h3>
<ul>
<li><a href="Individual.html">Individual</a></li>
</ul>
<h3 class="subsection-title">Methods</h3>
<dl>
<dt>
<h4 class="name" id="copy"><span class="type-signature"></span>copy<span class="signature">()</span><span class="type-signature"> → {<a href="Individual.html">Individual</a>}</span></h4>
</dt>
<dd>
<div class="description">
<p>Creates a deep copy of the individual</p>
</div>
<dl class="details">
<dt class="inherited-from">Inherited From:</dt>
<dd class="inherited-from"><ul class="dummy"><li>
<a href="Individual.html#copy">Individual#copy</a>
</li></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="individual.js.html">genetic/individual.js</a>, <a href="individual.js.html#line59">line 59</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>A copy of the Individual instance</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Individual.html">Individual</a></span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="createNew"><span class="type-signature"></span>createNew<span class="signature">()</span><span class="type-signature"> → {<a href="Individual.html">Individual</a>}</span></h4>
</dt>
<dd>
<div class="description">
<p>Creates a deep copy of the individual and then re initialises</p>
</div>
<dl class="details">
<dt class="inherited-from">Inherited From:</dt>
<dd class="inherited-from"><ul class="dummy"><li>
<a href="Individual.html#createNew">Individual#createNew</a>
</li></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="individual.js.html">genetic/individual.js</a>, <a href="individual.js.html#line67">line 67</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>A new individual based on the current individual</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Individual.html">Individual</a></span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="execute"><span class="type-signature"></span>execute<span class="signature">(An)</span><span class="type-signature"> → {Array.<object>}</span></h4>
</dt>
<dd>
<div class="description">
<p>Executes the liner code represented by the indivduals body</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>An</code></td>
<td class="type">
<span class="param-type">Array.<object></span>
</td>
<td class="description last"><p>array of inputs</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="linearIndividual.js.html">genetic/linear/linearIndividual.js</a>, <a href="linearIndividual.js.html#line65">line 65</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>An array of outputs</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.<object></span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="initialise"><span class="type-signature"></span>initialise<span class="signature">()</span><span class="type-signature"> → {<a href="Individual.html">Individual</a>}</span></h4>
</dt>
<dd>
<div class="description">
<p>Re creates the individuals body with randomly generated genes</p>
</div>
<dl class="details">
<dt class="inherited-from">Inherited From:</dt>
<dd class="inherited-from"><ul class="dummy"><li>
<a href="Individual.html#initialise">Individual#initialise</a>
</li></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="individual.js.html">genetic/individual.js</a>, <a href="individual.js.html#line46">line 46</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>Reference to current object for chaining</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Individual.html">Individual</a></span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="isFixedLength"><span class="type-signature"></span>isFixedLength<span class="signature">()</span><span class="type-signature"> → {boolean}</span></h4>
</dt>
<dd>
<div class="description">
<p>Determine whether the individual body length can change (i.e. minLength === maxLength)</p>
</div>
<dl class="details">
<dt class="inherited-from">Inherited From:</dt>
<dd class="inherited-from"><ul class="dummy"><li>
<a href="Individual.html#isFixedLength">Individual#isFixedLength</a>
</li></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="individual.js.html">genetic/individual.js</a>, <a href="individual.js.html#line87">line 87</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>A true value if the indiviuals body is of fixed length, otherwise false</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="mutate"><span class="type-signature"></span>mutate<span class="signature">()</span><span class="type-signature"> → {<a href="Individual.html">Individual</a>}</span></h4>
</dt>
<dd>
<div class="description">
<p>Mutates the individual by swapping a single gene with a randomly created gene</p>
</div>
<dl class="details">
<dt class="inherited-from">Inherited From:</dt>
<dd class="inherited-from"><ul class="dummy"><li>
<a href="Individual.html#mutate">Individual#mutate</a>
</li></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="individual.js.html">genetic/individual.js</a>, <a href="individual.js.html#line77">line 77</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>Reference to current object for chaining</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Individual.html">Individual</a></span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="removeIntrons"><span class="type-signature"></span>removeIntrons<span class="signature">()</span><span class="type-signature"> → {<a href="LinearIndividual.html">LinearIndividual</a>}</span></h4>
</dt>
<dd>
<div class="description">
<p>Removes all structurally noneffective code until the body length reaches the minimum allowed length</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="linearIndividual.js.html">genetic/linear/linearIndividual.js</a>, <a href="linearIndividual.js.html#line90">line 90</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>Reference to current object for chaining</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="LinearIndividual.html">LinearIndividual</a></span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="setDefaultOptionsIfNotProvided"><span class="type-signature"></span>setDefaultOptionsIfNotProvided<span class="signature">()</span><span class="type-signature"> → {<a href="LinearIndividual.html">LinearIndividual</a>}</span></h4>
</dt>
<dd>
<div class="description">
<p>Sets default values for options that have not been defined</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="linearIndividual.js.html">genetic/linear/linearIndividual.js</a>, <a href="linearIndividual.js.html#line51">line 51</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>Reference to current object for chaining</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="LinearIndividual.html">LinearIndividual</a></span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="toString"><span class="type-signature"></span>toString<span class="signature">()</span><span class="type-signature"> → {string}</span></h4>
</dt>
<dd>
<div class="description">
<p>Returns a string containing an executable representation of the individual</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="linearIndividual.js.html">genetic/linear/linearIndividual.js</a>, <a href="linearIndividual.js.html#line98">line 98</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>A string containing an executable representation of the individual</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="validateRequiredOptions"><span class="type-signature"></span>validateRequiredOptions<span class="signature">()</span><span class="type-signature"> → {<a href="LinearIndividual.html">LinearIndividual</a>}</span></h4>
</dt>
<dd>
<div class="description">
<p>Validates the linear individuals current options</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="linearIndividual.js.html">genetic/linear/linearIndividual.js</a>, <a href="linearIndividual.js.html#line35">line 35</a>
</li></ul></dd>
</dl>
<h5>Throws:</h5>
<div class="param-desc">
An exception will occur if a required option is missing
</div>
<h5>Returns:</h5>
<div class="param-desc">
<p>Reference to current object for chaining</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="LinearIndividual.html">LinearIndividual</a></span>
</dd>
</dl>
</dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="Individual.html">Individual</a></li><li><a href="LinearConditionalNode.html">LinearConditionalNode</a></li><li><a href="LinearFunctionNode.html">LinearFunctionNode</a></li><li><a href="LinearGPNode.html">LinearGPNode</a></li><li><a href="LinearIndividual.html">LinearIndividual</a></li><li><a href="Population.html">Population</a></li><li><a href="RegisterReference.html">RegisterReference</a></li><li><a href="RegisterSet.html">RegisterSet</a></li></ul><h3>Global</h3><ul><li><a href="global.html#alphabet">alphabet</a></li><li><a href="global.html#arrayEqual">arrayEqual</a></li><li><a href="global.html#binaryNumber">binaryNumber</a></li><li><a href="global.html#binaryString">binaryString</a></li><li><a href="global.html#createCalculation">createCalculation</a></li><li><a href="global.html#createConstant">createConstant</a></li><li><a href="global.html#createInput">createInput</a></li><li><a href="global.html#createOutput">createOutput</a></li><li><a href="global.html#formatString">formatString</a></li><li><a href="global.html#fpEqual">fpEqual</a></li><li><a href="global.html#inherits">inherits</a></li><li><a href="global.html#linearNode">linearNode</a></li><li><a href="global.html#onePointFixed">onePointFixed</a></li><li><a href="global.html#onePointVariable">onePointVariable</a></li><li><a href="global.html#randBetween">randBetween</a></li><li><a href="global.html#random">random</a></li><li><a href="global.html#randomNumber">randomNumber</a></li><li><a href="global.html#rank">rank</a></li><li><a href="global.html#rouletteWheel">rouletteWheel</a></li><li><a href="global.html#selectRandom">selectRandom</a></li><li><a href="global.html#swapGenes">swapGenes</a></li><li><a href="global.html#tournament">tournament</a></li><li><a href="global.html#twoPointFixed">twoPointFixed</a></li><li><a href="global.html#twoPointVariable">twoPointVariable</a></li><li><a href="global.html#uniform">uniform</a></li><li><a href="global.html#validateFixedLength">validateFixedLength</a></li><li><a href="global.html#validateMinimumLength">validateMinimumLength</a></li><li><a href="global.html#validateVariableLength">validateVariableLength</a></li></ul>
</nav>
<br clear="both">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Sat Aug 16 2014 23:33:39 GMT+0100 (GMT Summer Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>