propeller/docs/propeller.variation.html
2024-01-07 12:53:34 -05:00

46 lines
25 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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.2</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>Additional Instructions</span></div></a></li><li class="depth-1 "><a href="Downsampling_training_data.html"><div class="inner"><span># Downsample Functions</span></div></a></li><li class="depth-1 "><a href="Generating_Documentation.html"><div class="inner"><span>Generating Documentation for Propeller</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.downsample.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>downsample</span></div></a></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>PSB1</span></div></div></li><li class="depth-4 branch"><a href="propeller.problems.PSB1.count-odds.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>count-odds</span></div></a></li><li class="depth-4 branch"><a href="propeller.problems.PSB1.grade.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>grade</span></div></a></li><li class="depth-4 branch"><a href="propeller.problems.PSB1.scrabble-score.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>scrabble-score</span></div></a></li><li class="depth-4"><a href="propeller.problems.PSB1.small-or-large.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>small-or-large</span></div></a></li><li class="depth-3"><div class="no-link"><div class="inner"><span class="tree" style="top: -145px;"><span class="top" style="height: 154px;"></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.find-pair.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>find-pair</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.UBall5D.html"><div class="inner"><span class="tree" style="top: -610px;"><span class="top" style="height: 619px;"></span><span class="bottom"></span></span><span>UBall5D</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>boolean</span></div></div></li><li class="depth-4 branch"><a href="propeller.problems.boolean.mul3.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>mul3</span></div></a></li><li class="depth-4"><a href="propeller.problems.boolean.mul4.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>mul4</span></div></a></li><li class="depth-3 branch"><a href="propeller.problems.complex-regression.html"><div class="inner"><span class="tree" style="top: -83px;"><span class="top" style="height: 92px;"></span><span class="bottom"></span></span><span>complex-regression</span></div></a></li><li class="depth-3 branch"><a href="propeller.problems.data-creation.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>data-creation</span></div></a></li><li class="depth-3 branch"><a href="propeller.problems.float-regression.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>float-regression</span></div></a></li><li class="depth-3 branch"><a href="propeller.problems.integer-regression.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>integer-regression</span></div></a></li><li class="depth-3 branch"><a href="propeller.problems.simple-classification.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>simple-classification</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: -1230px;"><span class="top" style="height: 1239px;"></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.parentheses.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>parentheses</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: -300px;"><span class="top" style="height: 309px;"></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: -424px;"><span class="top" style="height: 433px;"></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-alternation"><div class="inner"><span>alternation</span></div></a></li><li class="depth-1"><a href="propeller.variation.html#var-bmx"><div class="inner"><span>bmx</span></div></a></li><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-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-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-gap-addition"><div class="inner"><span>uniform-gap-addition</span></div></a></li><li class="depth-1"><a href="propeller.variation.html#var-uniform-gap-deletion"><div class="inner"><span>uniform-gap-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>
<p><strong><em>Some</em></strong> of the available genetic operators are described in this documentation. See the code for others and for details.</p>
<p>To add a new genetic operator you must add a case for the operators keyword in new-individual, calling existing or new utility functions that should be included earlier in this file.</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>
</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>uniform-deletion</code> </td><td> <code>plushy</code> <code>umad-rate</code> </td><td> Randomly deletes instructions from 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-alternation"><h3>alternation</h3><div class="usage"><code>(alternation genome1 genome2 alternation-rate alignment-deviation)</code></div><div class="doc"><div class="markdown"><p>Alternates between the two parent genomes.</p>
</div></div></div><div class="public anchor" id="var-bmx"><h3>bmx</h3><div class="usage"><code>(bmx plushy-a plushy-b rate max-distance argmap)</code></div><div class="doc"><div class="markdown"><p>Crosses over two plushies using best match crossover (bmx).</p>
</div></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-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-uniform-addition"><h3>uniform-addition</h3><div class="usage"><code>(uniform-addition plushy instructions umad-rate argmap)</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 a rate that is adjusted relative to the rate used for addition.</p>
</div></div></div><div class="public anchor" id="var-uniform-gap-addition"><h3>uniform-gap-addition</h3><div class="usage"><code>(uniform-gap-addition plushy gap-change-prob)</code></div><div class="doc"><div class="markdown"><p>Returns plushy with new instances of :gap possibly added within each gene, each of which is a subsequence of the plushy.</p>
</div></div></div><div class="public anchor" id="var-uniform-gap-deletion"><h3>uniform-gap-deletion</h3><div class="usage"><code>(uniform-gap-deletion plushy gap-change-prob)</code></div><div class="doc"><div class="markdown"><p>Randomly deletes instances of :gap from plushy at a rate that is adjusted relative to the rate used for gap addition.</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 argmap)</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>