propeller/docs/propeller.variation.html
2023-01-24 14:38:24 -05:00

51 lines
24 KiB
HTML

<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>propeller.variation documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Propeller</span> <span class="project-version">0.3.0</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="A_Guide_To_Propeller.html"><div class="inner"><span>A Guide to Propeller</span></div></a></li><li class="depth-1 "><a href="Adding_Genetic_Operators.html"><div class="inner"><span>Adding Genetic Operators</span></div></a></li><li class="depth-1 "><a href="Adding_Problem.html"><div class="inner"><span>Adding a Problem</span></div></a></li><li class="depth-1 "><a href="Adding_Selection_Method.html"><div class="inner"><span>Adding a Selection Method</span></div></a></li><li class="depth-1 "><a href="Additional_Instructions.html"><div class="inner"><span>input_output.cljc</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>propeller</span></div></div></li><li class="depth-2 branch"><a href="propeller.genome.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>genome</span></div></a></li><li class="depth-2 branch"><a href="propeller.gp.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gp</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>problems</span></div></div></li><li class="depth-3"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>PSB2</span></div></div></li><li class="depth-4 branch"><a href="propeller.problems.PSB2.basement.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>basement</span></div></a></li><li class="depth-4 branch"><a href="propeller.problems.PSB2.bouncing-balls.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>bouncing-balls</span></div></a></li><li class="depth-4 branch"><a href="propeller.problems.PSB2.bowling.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>bowling</span></div></a></li><li class="depth-4 branch"><a href="propeller.problems.PSB2.camel-case.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>camel-case</span></div></a></li><li class="depth-4 branch"><a href="propeller.problems.PSB2.dice-game.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>dice-game</span></div></a></li><li class="depth-4 branch"><a href="propeller.problems.PSB2.fizz-buzz.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>fizz-buzz</span></div></a></li><li class="depth-4 branch"><a href="propeller.problems.PSB2.fuel-cost.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>fuel-cost</span></div></a></li><li class="depth-4 branch"><a href="propeller.problems.PSB2.gcd.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gcd</span></div></a></li><li class="depth-4 branch"><a href="propeller.problems.PSB2.luhn.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>luhn</span></div></a></li><li class="depth-4 branch"><a href="propeller.problems.PSB2.middle-character.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>middle-character</span></div></a></li><li class="depth-4 branch"><a href="propeller.problems.PSB2.paired-digits.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>paired-digits</span></div></a></li><li class="depth-4 branch"><a href="propeller.problems.PSB2.shopping-list.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>shopping-list</span></div></a></li><li class="depth-4 branch"><a href="propeller.problems.PSB2.snow-day.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>snow-day</span></div></a></li><li class="depth-4 branch"><a href="propeller.problems.PSB2.solve-boolean.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>solve-boolean</span></div></a></li><li class="depth-4 branch"><a href="propeller.problems.PSB2.spin-words.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>spin-words</span></div></a></li><li class="depth-4 branch"><a href="propeller.problems.PSB2.square-digits.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>square-digits</span></div></a></li><li class="depth-4 branch"><a href="propeller.problems.PSB2.substitution-cipher.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>substitution-cipher</span></div></a></li><li class="depth-4"><a href="propeller.problems.PSB2.twitter.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>twitter</span></div></a></li><li class="depth-3 branch"><a href="propeller.problems.simple-regression.html"><div class="inner"><span class="tree" style="top: -579px;"><span class="top" style="height: 588px;"></span><span class="bottom"></span></span><span>simple-regression</span></div></a></li><li class="depth-3"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>software</span></div></div></li><li class="depth-4 branch"><a href="propeller.problems.software.number-io.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>number-io</span></div></a></li><li class="depth-4"><a href="propeller.problems.software.smallest.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>smallest</span></div></a></li><li class="depth-3 branch"><a href="propeller.problems.string-classification.html"><div class="inner"><span class="tree" style="top: -83px;"><span class="top" style="height: 92px;"></span><span class="bottom"></span></span><span>string-classification</span></div></a></li><li class="depth-3"><a href="propeller.problems.valiant.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>valiant</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree" style="top: -796px;"><span class="top" style="height: 805px;"></span><span class="bottom"></span></span><span>push</span></div></div></li><li class="depth-3"><a href="propeller.push.instructions.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>instructions</span></div></a></li><li class="depth-4 branch"><a href="propeller.push.instructions.bool.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>bool</span></div></a></li><li class="depth-4 branch"><a href="propeller.push.instructions.character.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>character</span></div></a></li><li class="depth-4 branch"><a href="propeller.push.instructions.code.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>code</span></div></a></li><li class="depth-4 branch"><a href="propeller.push.instructions.input-output.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>input-output</span></div></a></li><li class="depth-4 branch"><a href="propeller.push.instructions.numeric.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>numeric</span></div></a></li><li class="depth-4 branch"><a href="propeller.push.instructions.polymorphic.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>polymorphic</span></div></a></li><li class="depth-4 branch"><a href="propeller.push.instructions.string.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>string</span></div></a></li><li class="depth-4"><a href="propeller.push.instructions.vector.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>vector</span></div></a></li><li class="depth-3 branch"><a href="propeller.push.interpreter.html"><div class="inner"><span class="tree" style="top: -269px;"><span class="top" style="height: 278px;"></span><span class="bottom"></span></span><span>interpreter</span></div></a></li><li class="depth-3 branch"><a href="propeller.push.limits.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>limits</span></div></a></li><li class="depth-3"><a href="propeller.push.state.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>state</span></div></a></li><li class="depth-2 branch"><a href="propeller.selection.html"><div class="inner"><span class="tree" style="top: -393px;"><span class="top" style="height: 402px;"></span><span class="bottom"></span></span><span>selection</span></div></a></li><li class="depth-2 branch"><a href="propeller.simplification.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>simplification</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>tools</span></div></div></li><li class="depth-3 branch"><a href="propeller.tools.calculus.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>calculus</span></div></a></li><li class="depth-3 branch"><a href="propeller.tools.character.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>character</span></div></a></li><li class="depth-3 branch"><a href="propeller.tools.distributions.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>distributions</span></div></a></li><li class="depth-3 branch"><a href="propeller.tools.math.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>math</span></div></a></li><li class="depth-3"><a href="propeller.tools.metrics.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>metrics</span></div></a></li><li class="depth-2 branch"><a href="propeller.utils.html"><div class="inner"><span class="tree" style="top: -176px;"><span class="top" style="height: 185px;"></span><span class="bottom"></span></span><span>utils</span></div></a></li><li class="depth-2 current"><a href="propeller.variation.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>variation</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="propeller.variation.html#var-crossover"><div class="inner"><span>crossover</span></div></a></li><li class="depth-1"><a href="propeller.variation.html#var-diploid-crossover"><div class="inner"><span>diploid-crossover</span></div></a></li><li class="depth-1"><a href="propeller.variation.html#var-diploid-flip"><div class="inner"><span>diploid-flip</span></div></a></li><li class="depth-1"><a href="propeller.variation.html#var-diploid-uniform-addition"><div class="inner"><span>diploid-uniform-addition</span></div></a></li><li class="depth-1"><a href="propeller.variation.html#var-diploid-uniform-deletion"><div class="inner"><span>diploid-uniform-deletion</span></div></a></li><li class="depth-1"><a href="propeller.variation.html#var-diploid-uniform-silent-replacement"><div class="inner"><span>diploid-uniform-silent-replacement</span></div></a></li><li class="depth-1"><a href="propeller.variation.html#var-new-individual"><div class="inner"><span>new-individual</span></div></a></li><li class="depth-1"><a href="propeller.variation.html#var-tail-aligned-crossover"><div class="inner"><span>tail-aligned-crossover</span></div></a></li><li class="depth-1"><a href="propeller.variation.html#var-tail-aligned-diploid-crossover"><div class="inner"><span>tail-aligned-diploid-crossover</span></div></a></li><li class="depth-1"><a href="propeller.variation.html#var-uniform-addition"><div class="inner"><span>uniform-addition</span></div></a></li><li class="depth-1"><a href="propeller.variation.html#var-uniform-deletion"><div class="inner"><span>uniform-deletion</span></div></a></li><li class="depth-1"><a href="propeller.variation.html#var-uniform-replacement"><div class="inner"><span>uniform-replacement</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">propeller.variation</h1><div class="doc"><div class="markdown"><p>Propeller includes many kinds of genetic operators to create variation within the population. You can specify the rate of the variation genetic operators with the <code>:variation</code> map.</p>
<h1><a href="#variation" id="variation"></a>Variation</h1>
<p>Propeller includes many kinds of genetic operators to create variation within the population. You can specify the rate of the variation genetic operators with the <code>:variation</code> map.</p>
<h2><a href="#crossover" id="crossover"></a>Crossover</h2>
<p>Crossover genetic operators take two <code>plushy</code> representations of Push programs and exchange genetic material to create a new <code>plushy</code>.</p>
<table>
<thead>
<tr><th> Function </th><th> Parameters </th><th> Description </th></tr>
</thead>
<tbody>
<tr><td> <code>crossover</code> </td><td> <code>plushy-a</code> <code>plushy-b</code> </td><td> Crosses over two individuals using uniform crossover, one Push instruction at a time. Pads shorter one from the end of the list of instructions. </td></tr>
<tr><td> <code>tail-aligned-crossover</code> </td><td> <code>plushy-a</code> <code>plushy-b</code> </td><td> Crosses over two individuals using uniform crossover, one Push instruction at a time. Pads shorter one from the beginning of the list of instructions. </td></tr>
<tr><td> <code>diploid-crossover</code> </td><td> <code>plushy-a</code> <code>plushy-b</code> </td><td> Crosses over two individuals using uniform crossover with pairs of Push instructions. Pads shorter one from the end of the list of instructions. </td></tr>
<tr><td> <code>tail-aligned-diploid-crossover</code> </td><td> <code>plushy-a</code> <code>plushy-b</code> </td><td> Crosses over two individuals using uniform crossover with pairs of Push instructions. Pads shorter one from the beginning of the list of instructions. </td></tr>
</tbody>
</table>
<h2><a href="#addition-deletion-replacement-flip" id="addition-deletion-replacement-flip"></a>Addition, Deletion, Replacement, Flip</h2>
<p>Addition, deletion, replacement, and flip genetic operators take a <code>plushy</code> and a rate of occurrence to create a new <code>plushy</code>.</p>
<table>
<thead>
<tr><th> Function </th><th> Parameters </th><th> Description </th></tr>
</thead>
<tbody>
<tr><td> <code>uniform-addition</code> </td><td> <code>plushy</code> <code>instructions</code> <code>umad-rate</code> </td><td> Returns a plushy with new instructions possibly added before or after each existing instruction. </td></tr>
<tr><td> <code>uniform-replacement</code> </td><td> <code>plushy</code> <code>instructions</code> <code>replacement-rate</code> </td><td> Returns a plushy with new instructions possibly replacing existing instructions. </td></tr>
<tr><td> <code>diploid-uniform-silent-replacement</code> </td><td> <code>plushy</code> <code>instructions</code> <code>replacement-rate</code> </td><td> Returns a plushy with new instructions possibly replacing existing instructions, but only among the silent member of each pair. </td></tr>
<tr><td> <code>diploid-uniform-addition</code> </td><td> <code>plushy</code> <code>instructions</code> <code>umad-rate</code> </td><td> Returns a plushy with new instructions possibly added before or after each existing pair of instructions. </td></tr>
<tr><td> <code>uniform-deletion</code> </td><td> <code>plushy</code> <code>umad-rate</code> </td><td> Randomly deletes instructions from plushy at some rate. </td></tr>
<tr><td> <code>diploid-uniform-deletion</code> </td><td> <code>plushy</code> <code>flip-rate</code> </td><td> Randomly flips pairs in a diploid plushy at some rate. </td></tr>
</tbody>
</table>
<h2><a href="#uniform-mutation-by-addition-and-deletion" id="uniform-mutation-by-addition-and-deletion"></a>Uniform Mutation by Addition and Deletion</h2>
<p>Uniform Mutation by Addition and Deletion (UMAD) is a uniform mutation operator which first adds genes with some probability before or after every existing gene and then deletes random genes from the resulting genome. <a href="http://cs.hamilton.edu/~thelmuth/Pubs/2018-GECCO-UMAD.pdf">It has been found</a> that UMAD, with relatively high rates of addition and deletion, results in significant increases in problem-solving performance on a range of program synthesis benchmark problems. When you run a problem in Propeller, you can specify the <code>umad-rate</code> to determine the frequency of addition and deletion.</p>
<p><code>:umad</code> in the <code>:variation</code> map when running a problem will call <code>uniform-addition</code> and <code>uniform-deletion</code> with the <code>umad-rate</code>. Since <code>uniform-addition</code> and <code>uniform-deletion</code> are somewhat stochastic, you can use <code>:rumad</code> to ensure that the actual rates of addition and deletion are equal when mutating a genome.</p>
<h2><a href="#new-individual" id="new-individual"></a>New Individual</h2>
<p>The function <code>new-individual</code> returns a new individual produced by selection and variation of individuals in the population based on the genetic operators provided in the <code>:variation</code> map.</p>
</div></div><div class="public anchor" id="var-crossover"><h3>crossover</h3><div class="usage"><code>(crossover plushy-a plushy-b)</code></div><div class="doc"><div class="markdown"><p>Crosses over two individuals using uniform crossover, one Push instruction at a time. Pads shorter one from the end of the list of instructions.</p>
</div></div></div><div class="public anchor" id="var-diploid-crossover"><h3>diploid-crossover</h3><div class="usage"><code>(diploid-crossover plushy-a plushy-b)</code></div><div class="doc"><div class="markdown"><p>Crosses over two individuals using uniform crossover with pairs of Push instructions. Pads shorter one from the end of the list of instructions.</p>
</div></div></div><div class="public anchor" id="var-diploid-flip"><h3>diploid-flip</h3><div class="usage"><code>(diploid-flip plushy flip-rate)</code></div><div class="doc"><div class="markdown"><p>Randomly flips pairs in a diploid plushy at some rate.</p>
</div></div></div><div class="public anchor" id="var-diploid-uniform-addition"><h3>diploid-uniform-addition</h3><div class="usage"><code>(diploid-uniform-addition plushy instructions umad-rate)</code></div><div class="doc"><div class="markdown"><p>Returns plushy with new instructions possibly added before or after each existing instruction.</p>
</div></div></div><div class="public anchor" id="var-diploid-uniform-deletion"><h3>diploid-uniform-deletion</h3><div class="usage"><code>(diploid-uniform-deletion plushy umad-rate)</code></div><div class="doc"><div class="markdown"><p>Randomly deletes instructions from plushy at some rate.</p>
</div></div></div><div class="public anchor" id="var-diploid-uniform-silent-replacement"><h3>diploid-uniform-silent-replacement</h3><div class="usage"><code>(diploid-uniform-silent-replacement plushy instructions replacement-rate)</code></div><div class="doc"><div class="markdown"><p>Returns plushy with new instructions possibly replacing existing instructions, but only among the silent member of each pair.</p>
</div></div></div><div class="public anchor" id="var-new-individual"><h3>new-individual</h3><div class="usage"><code>(new-individual pop argmap)</code></div><div class="doc"><div class="markdown"><p>Returns a new individual produced by selection and variation of individuals in the population.</p>
</div></div></div><div class="public anchor" id="var-tail-aligned-crossover"><h3>tail-aligned-crossover</h3><div class="usage"><code>(tail-aligned-crossover plushy-a plushy-b)</code></div><div class="doc"><div class="markdown"><p>Crosses over two individuals using uniform crossover, one Push instruction at a time. Pads shorter one from the beginning of the list of instructions.</p>
</div></div></div><div class="public anchor" id="var-tail-aligned-diploid-crossover"><h3>tail-aligned-diploid-crossover</h3><div class="usage"><code>(tail-aligned-diploid-crossover plushy-a plushy-b)</code></div><div class="doc"><div class="markdown"><p>Crosses over two individuals using uniform crossover with pairs of Push instructions. Pads shorter one from the beginning of the list of instructions.</p>
</div></div></div><div class="public anchor" id="var-uniform-addition"><h3>uniform-addition</h3><div class="usage"><code>(uniform-addition plushy instructions umad-rate)</code></div><div class="doc"><div class="markdown"><p>Returns plushy with new instructions possibly added before or after each existing instruction.</p>
</div></div></div><div class="public anchor" id="var-uniform-deletion"><h3>uniform-deletion</h3><div class="usage"><code>(uniform-deletion plushy umad-rate)</code></div><div class="doc"><div class="markdown"><p>Randomly deletes instructions from plushy at some rate.</p>
</div></div></div><div class="public anchor" id="var-uniform-replacement"><h3>uniform-replacement</h3><div class="usage"><code>(uniform-replacement plushy instructions replacement-rate)</code></div><div class="doc"><div class="markdown"><p>Returns plushy with new instructions possibly replacing existing instructions.</p>
</div></div></div></div></body></html>