evolvable 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +2 -0
- data/CHANGELOG.md +24 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +44 -25
- data/README.md +498 -190
- data/README_YARD.md +85 -166
- data/bin/console +10 -19
- data/docs/Evolvable/ClassMethods.html +1233 -0
- data/docs/Evolvable/Community/ClassMethods.html +708 -0
- data/docs/Evolvable/Community.html +1342 -0
- data/docs/Evolvable/CountGene.html +886 -0
- data/docs/Evolvable/EqualizeGoal.html +347 -0
- data/docs/Evolvable/Error.html +134 -0
- data/docs/Evolvable/Evaluation.html +773 -0
- data/docs/Evolvable/Evolution.html +616 -0
- data/docs/Evolvable/Gene/ClassMethods.html +413 -0
- data/docs/Evolvable/Gene.html +522 -0
- data/docs/Evolvable/GeneCluster/ClassMethods.html +431 -0
- data/docs/Evolvable/GeneCluster.html +280 -0
- data/docs/Evolvable/GeneCombination.html +515 -0
- data/docs/Evolvable/GeneSpace.html +619 -0
- data/docs/Evolvable/Genome.html +1070 -0
- data/docs/Evolvable/Goal.html +500 -0
- data/docs/Evolvable/MaximizeGoal.html +348 -0
- data/docs/Evolvable/MinimizeGoal.html +348 -0
- data/docs/Evolvable/Mutation.html +729 -0
- data/docs/Evolvable/PointCrossover.html +444 -0
- data/docs/Evolvable/Population.html +2826 -0
- data/docs/Evolvable/RigidCountGene.html +501 -0
- data/docs/Evolvable/Selection.html +594 -0
- data/docs/Evolvable/Serializer.html +293 -0
- data/docs/Evolvable/UniformCrossover.html +286 -0
- data/docs/Evolvable.html +1619 -0
- data/docs/_index.html +341 -0
- data/docs/class_list.html +54 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +503 -0
- data/docs/file.README.html +750 -0
- data/docs/file_list.html +59 -0
- data/docs/frames.html +22 -0
- data/docs/index.html +750 -0
- data/docs/js/app.js +344 -0
- data/docs/js/full_list.js +242 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +1302 -0
- data/docs/top-level-namespace.html +110 -0
- data/evolvable.gemspec +6 -6
- data/examples/ascii_art.rb +5 -9
- data/examples/stickman.rb +25 -33
- data/{examples/hello_world.rb → exe/hello_evolvable_world} +46 -30
- data/lib/evolvable/community.rb +190 -0
- data/lib/evolvable/count_gene.rb +65 -0
- data/lib/evolvable/equalize_goal.rb +2 -9
- data/lib/evolvable/evaluation.rb +113 -14
- data/lib/evolvable/evolution.rb +38 -15
- data/lib/evolvable/gene.rb +124 -25
- data/lib/evolvable/gene_cluster.rb +106 -0
- data/lib/evolvable/gene_combination.rb +57 -16
- data/lib/evolvable/gene_space.rb +111 -0
- data/lib/evolvable/genome.rb +32 -4
- data/lib/evolvable/goal.rb +19 -24
- data/lib/evolvable/maximize_goal.rb +2 -9
- data/lib/evolvable/minimize_goal.rb +3 -9
- data/lib/evolvable/mutation.rb +87 -41
- data/lib/evolvable/point_crossover.rb +24 -4
- data/lib/evolvable/population.rb +258 -84
- data/lib/evolvable/rigid_count_gene.rb +36 -0
- data/lib/evolvable/selection.rb +68 -14
- data/lib/evolvable/serializer.rb +46 -0
- data/lib/evolvable/uniform_crossover.rb +30 -6
- data/lib/evolvable/version.rb +2 -1
- data/lib/evolvable.rb +268 -107
- metadata +57 -36
- data/examples/images/diagram.png +0 -0
- data/exe/hello +0 -16
- data/lib/evolvable/error/undefined_method.rb +0 -7
- data/lib/evolvable/search_space.rb +0 -181
@@ -0,0 +1,522 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Module: Evolvable::Gene
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.37
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" />
|
16
|
+
|
17
|
+
<script type="text/javascript">
|
18
|
+
pathId = "Evolvable::Gene";
|
19
|
+
relpath = '../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../_index.html">Index (G)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../Evolvable.html" title="Evolvable (module)">Evolvable</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">Gene</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Module: Evolvable::Gene
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
<dl>
|
78
|
+
<dt>Included in:</dt>
|
79
|
+
<dd><span class='object_link'><a href="CountGene.html" title="Evolvable::CountGene (class)">CountGene</a></span>, <span class='object_link'><a href="RigidCountGene.html" title="Evolvable::RigidCountGene (class)">RigidCountGene</a></span></dd>
|
80
|
+
</dl>
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
<dl>
|
85
|
+
<dt>Defined in:</dt>
|
86
|
+
<dd>lib/evolvable/gene.rb</dd>
|
87
|
+
</dl>
|
88
|
+
|
89
|
+
</div>
|
90
|
+
|
91
|
+
<h2>Overview</h2><div class="docstring">
|
92
|
+
<div class="discussion">
|
93
|
+
<p>Genes are the building blocks of evolvable objects, encapsulating individual characteristics
|
94
|
+
that can be combined and mutated during evolution. Each gene represents a trait or behavior
|
95
|
+
that can influence an evolvable's performance.</p>
|
96
|
+
|
97
|
+
<p><strong>To define a gene class:</strong></p>
|
98
|
+
|
99
|
+
<ol>
|
100
|
+
<li>Include the <code>Evolvable::Gene</code> module</li>
|
101
|
+
<li>Define how the gene's value is determined</li>
|
102
|
+
</ol>
|
103
|
+
|
104
|
+
<pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>BehaviorGene</span>
|
105
|
+
<span class='id identifier rubyid_include'>include</span> <span class='const'><span class='object_link'><a href="../Evolvable.html" title="Evolvable (module)">Evolvable</a></span></span><span class='op'>::</span><span class='const'>Gene</span>
|
106
|
+
|
107
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span>
|
108
|
+
<span class='ivar'>@value</span> <span class='op'>||=</span> <span class='qwords_beg'>%w[</span><span class='tstring_content'>explore</span><span class='words_sep'> </span><span class='tstring_content'>gather</span><span class='words_sep'> </span><span class='tstring_content'>attack</span><span class='words_sep'> </span><span class='tstring_content'>defend</span><span class='words_sep'> </span><span class='tstring_content'>build</span><span class='tstring_end'>]</span></span><span class='period'>.</span><span class='id identifier rubyid_sample'>sample</span>
|
109
|
+
<span class='kw'>end</span>
|
110
|
+
<span class='kw'>end</span>
|
111
|
+
</code></pre>
|
112
|
+
|
113
|
+
<p>Then use it in an evolvable class:</p>
|
114
|
+
|
115
|
+
<pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>Robot</span>
|
116
|
+
<span class='id identifier rubyid_include'>include</span> <span class='const'><span class='object_link'><a href="../Evolvable.html" title="Evolvable (module)">Evolvable</a></span></span>
|
117
|
+
|
118
|
+
<span class='id identifier rubyid_gene'>gene</span> <span class='symbol'>:behaviors</span><span class='comma'>,</span> <span class='label'>type:</span> <span class='const'>BehaviorGene</span><span class='comma'>,</span> <span class='label'>count:</span> <span class='int'>3</span><span class='op'>..</span><span class='int'>5</span>
|
119
|
+
<span class='id identifier rubyid_gene'>gene</span> <span class='symbol'>:speed</span><span class='comma'>,</span> <span class='label'>type:</span> <span class='const'>SpeedGene</span><span class='comma'>,</span> <span class='label'>count:</span> <span class='int'>1</span>
|
120
|
+
|
121
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_fitness'>fitness</span>
|
122
|
+
<span class='id identifier rubyid_run_simulation'>run_simulation</span><span class='lparen'>(</span><span class='label'>behaviors:</span> <span class='id identifier rubyid_behaviors'>behaviors</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:value</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='label'>speed:</span> <span class='id identifier rubyid_speed'>speed</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
123
|
+
<span class='kw'>end</span>
|
124
|
+
<span class='kw'>end</span>
|
125
|
+
</code></pre>
|
126
|
+
|
127
|
+
<p><strong>Gene Count</strong></p>
|
128
|
+
|
129
|
+
<p>You can control how many copies of a gene are created using the <code>count:</code> parameter:</p>
|
130
|
+
|
131
|
+
<ul>
|
132
|
+
<li><code>count: 1</code> (default) creates a single instance.</li>
|
133
|
+
<li>A numeric value (e.g. <code>count: 5</code>) creates a fixed number of genes using <code>RigidCountGene</code>.</li>
|
134
|
+
<li>A range (e.g. <code>count: 2..8</code>) creates a variable number of genes using <code>CountGene</code>, allowing the count to evolve over time.</li>
|
135
|
+
</ul>
|
136
|
+
|
137
|
+
<p>Evolves melody length:</p>
|
138
|
+
|
139
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gene'>gene</span> <span class='symbol'>:notes</span><span class='comma'>,</span> <span class='label'>type:</span> <span class='const'>NoteGene</span><span class='comma'>,</span> <span class='label'>count:</span> <span class='int'>4</span><span class='op'>..</span><span class='int'>12</span>
|
140
|
+
</code></pre>
|
141
|
+
|
142
|
+
<p><strong>Custom Combination</strong></p>
|
143
|
+
|
144
|
+
<p>By default, the <code>combine</code> method randomly picks one of the two parent genes.
|
145
|
+
A gene class can implement custom behavior by overriding <code>.combine</code>.</p>
|
146
|
+
|
147
|
+
<pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>SpeedGene</span>
|
148
|
+
<span class='id identifier rubyid_include'>include</span> <span class='const'><span class='object_link'><a href="../Evolvable.html" title="Evolvable (module)">Evolvable</a></span></span><span class='op'>::</span><span class='const'>Gene</span>
|
149
|
+
|
150
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_combine'>combine</span><span class='lparen'>(</span><span class='id identifier rubyid_gene_a'>gene_a</span><span class='comma'>,</span> <span class='id identifier rubyid_gene_b'>gene_b</span><span class='rparen'>)</span>
|
151
|
+
<span class='id identifier rubyid_new_gene'>new_gene</span> <span class='op'>=</span> <span class='id identifier rubyid_new'>new</span>
|
152
|
+
<span class='id identifier rubyid_new_gene'>new_gene</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_gene_a'>gene_a</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span> <span class='op'>+</span> <span class='id identifier rubyid_gene_b'>gene_b</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>/</span> <span class='int'>2</span>
|
153
|
+
<span class='id identifier rubyid_new_gene'>new_gene</span>
|
154
|
+
<span class='kw'>end</span>
|
155
|
+
|
156
|
+
<span class='id identifier rubyid_attr_writer'>attr_writer</span> <span class='symbol'>:value</span>
|
157
|
+
|
158
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span>
|
159
|
+
<span class='ivar'>@value</span> <span class='op'>||=</span> <span class='id identifier rubyid_rand'>rand</span><span class='lparen'>(</span><span class='int'>1</span><span class='op'>..</span><span class='int'>100</span><span class='rparen'>)</span>
|
160
|
+
<span class='kw'>end</span>
|
161
|
+
<span class='kw'>end</span>
|
162
|
+
</code></pre>
|
163
|
+
|
164
|
+
<p><strong>Design Patterns</strong></p>
|
165
|
+
|
166
|
+
<p>Effective gene design typically follows these principles:</p>
|
167
|
+
|
168
|
+
<ul>
|
169
|
+
<li><strong>Immutability</strong>: Cache values after initial sampling (e.g., <code>@value ||= ...</code>)</li>
|
170
|
+
<li><strong>Self-Contained</strong>: Genes should encapsulate their logic and state</li>
|
171
|
+
<li><strong>Composable</strong>: You can build complex structures using multiple genes or clusters</li>
|
172
|
+
<li><strong>Domain-Specific</strong>: Genes should map directly to your problem’s traits or features</li>
|
173
|
+
</ul>
|
174
|
+
|
175
|
+
<p>Genes come in various types, each representing different aspects of a solution.
|
176
|
+
Common examples include numeric genes for quantities, selection genes for choices
|
177
|
+
from sets, boolean genes for binary decisions, structural genes for architecture,
|
178
|
+
and parameter genes for configuration settings.</p>
|
179
|
+
|
180
|
+
|
181
|
+
</div>
|
182
|
+
</div>
|
183
|
+
<div class="tags">
|
184
|
+
|
185
|
+
|
186
|
+
<p class="tag_title">See Also:</p>
|
187
|
+
<ul class="see">
|
188
|
+
|
189
|
+
<li><span class='object_link'><a href="GeneSpace.html" title="Evolvable::GeneSpace (class)">GeneSpace</a></span></li>
|
190
|
+
|
191
|
+
<li><span class='object_link'><a href="GeneCluster.html" title="Evolvable::GeneCluster (module)">GeneCluster</a></span></li>
|
192
|
+
|
193
|
+
<li><span class='object_link'><a href="GeneCombination.html" title="Evolvable::GeneCombination (class)">GeneCombination</a></span></li>
|
194
|
+
|
195
|
+
<li><span class='object_link'><a href="CountGene.html" title="Evolvable::CountGene (class)">CountGene</a></span></li>
|
196
|
+
|
197
|
+
<li><span class='object_link'><a href="RigidCountGene.html" title="Evolvable::RigidCountGene (class)">RigidCountGene</a></span></li>
|
198
|
+
|
199
|
+
</ul>
|
200
|
+
|
201
|
+
</div><h2>Defined Under Namespace</h2>
|
202
|
+
<p class="children">
|
203
|
+
|
204
|
+
|
205
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Gene/ClassMethods.html" title="Evolvable::Gene::ClassMethods (module)">ClassMethods</a></span>
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
</p>
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
|
216
|
+
<ul class="summary">
|
217
|
+
|
218
|
+
<li class="public ">
|
219
|
+
<span class="summary_signature">
|
220
|
+
|
221
|
+
<a href="#evolvable-instance_method" title="#evolvable (instance method)">#<strong>evolvable</strong> ⇒ Evolvable </a>
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
</span>
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
<span class="summary_desc"><div class='inline'><p>The evolvable instance that this gene belongs to.</p>
|
239
|
+
</div></span>
|
240
|
+
|
241
|
+
</li>
|
242
|
+
|
243
|
+
|
244
|
+
</ul>
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
<h2>
|
251
|
+
Class Method Summary
|
252
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
253
|
+
</h2>
|
254
|
+
|
255
|
+
<ul class="summary">
|
256
|
+
|
257
|
+
<li class="public ">
|
258
|
+
<span class="summary_signature">
|
259
|
+
|
260
|
+
<a href="#included-class_method" title="included (class method)">.<strong>included</strong>(base) ⇒ Object </a>
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
</span>
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
<span class="summary_desc"><div class='inline'><p>When included in a class, extends the class with ClassMethods.</p>
|
275
|
+
</div></span>
|
276
|
+
|
277
|
+
</li>
|
278
|
+
|
279
|
+
|
280
|
+
</ul>
|
281
|
+
|
282
|
+
<h2>
|
283
|
+
Instance Method Summary
|
284
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
285
|
+
</h2>
|
286
|
+
|
287
|
+
<ul class="summary">
|
288
|
+
|
289
|
+
<li class="public ">
|
290
|
+
<span class="summary_signature">
|
291
|
+
|
292
|
+
<a href="#key-instance_method" title="#key (instance method)">#<strong>key</strong> ⇒ Symbol </a>
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
</span>
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
<span class="summary_desc"><div class='inline'><p>Returns the unique key for this gene instance.</p>
|
307
|
+
</div></span>
|
308
|
+
|
309
|
+
</li>
|
310
|
+
|
311
|
+
|
312
|
+
</ul>
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
<div id="instance_attr_details" class="attr_details">
|
317
|
+
<h2>Instance Attribute Details</h2>
|
318
|
+
|
319
|
+
|
320
|
+
<span id="evolvable=-instance_method"></span>
|
321
|
+
<div class="method_details first">
|
322
|
+
<h3 class="signature first" id="evolvable-instance_method">
|
323
|
+
|
324
|
+
#<strong>evolvable</strong> ⇒ <tt><span class='object_link'><a href="../Evolvable.html" title="Evolvable (module)">Evolvable</a></span></tt>
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
</h3><div class="docstring">
|
331
|
+
<div class="discussion">
|
332
|
+
<p>The evolvable instance that this gene belongs to.
|
333
|
+
Used for accessing other genes or evolvable properties.</p>
|
334
|
+
|
335
|
+
|
336
|
+
</div>
|
337
|
+
</div>
|
338
|
+
<div class="tags">
|
339
|
+
|
340
|
+
<p class="tag_title">Returns:</p>
|
341
|
+
<ul class="return">
|
342
|
+
|
343
|
+
<li>
|
344
|
+
|
345
|
+
|
346
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Evolvable.html" title="Evolvable (module)">Evolvable</a></span></tt>)</span>
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
—
|
351
|
+
<div class='inline'><p>The evolvable instance this gene is part of</p>
|
352
|
+
</div>
|
353
|
+
|
354
|
+
</li>
|
355
|
+
|
356
|
+
</ul>
|
357
|
+
|
358
|
+
</div><table class="source_code">
|
359
|
+
<tr>
|
360
|
+
<td>
|
361
|
+
<pre class="lines">
|
362
|
+
|
363
|
+
|
364
|
+
152
|
365
|
+
153
|
366
|
+
154</pre>
|
367
|
+
</td>
|
368
|
+
<td>
|
369
|
+
<pre class="code"><span class="info file"># File 'lib/evolvable/gene.rb', line 152</span>
|
370
|
+
|
371
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_evolvable'>evolvable</span>
|
372
|
+
<span class='ivar'>@evolvable</span>
|
373
|
+
<span class='kw'>end</span></pre>
|
374
|
+
</td>
|
375
|
+
</tr>
|
376
|
+
</table>
|
377
|
+
</div>
|
378
|
+
|
379
|
+
</div>
|
380
|
+
|
381
|
+
|
382
|
+
<div id="class_method_details" class="method_details_list">
|
383
|
+
<h2>Class Method Details</h2>
|
384
|
+
|
385
|
+
|
386
|
+
<div class="method_details first">
|
387
|
+
<h3 class="signature first" id="included-class_method">
|
388
|
+
|
389
|
+
.<strong>included</strong>(base) ⇒ <tt>Object</tt>
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
</h3><div class="docstring">
|
396
|
+
<div class="discussion">
|
397
|
+
<p>When included in a class, extends the class with ClassMethods.
|
398
|
+
Gene classes should include this module to participate in the evolutionary process.</p>
|
399
|
+
|
400
|
+
|
401
|
+
</div>
|
402
|
+
</div>
|
403
|
+
<div class="tags">
|
404
|
+
<p class="tag_title">Parameters:</p>
|
405
|
+
<ul class="param">
|
406
|
+
|
407
|
+
<li>
|
408
|
+
|
409
|
+
<span class='name'>base</span>
|
410
|
+
|
411
|
+
|
412
|
+
<span class='type'>(<tt>Class</tt>)</span>
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
—
|
417
|
+
<div class='inline'><p>The class that includes the Gene module</p>
|
418
|
+
</div>
|
419
|
+
|
420
|
+
</li>
|
421
|
+
|
422
|
+
</ul>
|
423
|
+
|
424
|
+
|
425
|
+
</div><table class="source_code">
|
426
|
+
<tr>
|
427
|
+
<td>
|
428
|
+
<pre class="lines">
|
429
|
+
|
430
|
+
|
431
|
+
103
|
432
|
+
104
|
433
|
+
105</pre>
|
434
|
+
</td>
|
435
|
+
<td>
|
436
|
+
<pre class="code"><span class="info file"># File 'lib/evolvable/gene.rb', line 103</span>
|
437
|
+
|
438
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_included'>included</span><span class='lparen'>(</span><span class='id identifier rubyid_base'>base</span><span class='rparen'>)</span>
|
439
|
+
<span class='id identifier rubyid_base'>base</span><span class='period'>.</span><span class='id identifier rubyid_extend'>extend</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="Gene/ClassMethods.html" title="Evolvable::Gene::ClassMethods (module)">ClassMethods</a></span></span><span class='rparen'>)</span>
|
440
|
+
<span class='kw'>end</span></pre>
|
441
|
+
</td>
|
442
|
+
</tr>
|
443
|
+
</table>
|
444
|
+
</div>
|
445
|
+
|
446
|
+
</div>
|
447
|
+
|
448
|
+
<div id="instance_method_details" class="method_details_list">
|
449
|
+
<h2>Instance Method Details</h2>
|
450
|
+
|
451
|
+
|
452
|
+
<div class="method_details first">
|
453
|
+
<h3 class="signature first" id="key-instance_method">
|
454
|
+
|
455
|
+
#<strong>key</strong> ⇒ <tt>Symbol</tt>
|
456
|
+
|
457
|
+
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
</h3><div class="docstring">
|
462
|
+
<div class="discussion">
|
463
|
+
<p>Returns the unique key for this gene instance.
|
464
|
+
Delegates to the class-level key.</p>
|
465
|
+
|
466
|
+
|
467
|
+
</div>
|
468
|
+
</div>
|
469
|
+
<div class="tags">
|
470
|
+
|
471
|
+
<p class="tag_title">Returns:</p>
|
472
|
+
<ul class="return">
|
473
|
+
|
474
|
+
<li>
|
475
|
+
|
476
|
+
|
477
|
+
<span class='type'>(<tt>Symbol</tt>)</span>
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
—
|
482
|
+
<div class='inline'><p>The key that identifies this gene type</p>
|
483
|
+
</div>
|
484
|
+
|
485
|
+
</li>
|
486
|
+
|
487
|
+
</ul>
|
488
|
+
|
489
|
+
</div><table class="source_code">
|
490
|
+
<tr>
|
491
|
+
<td>
|
492
|
+
<pre class="lines">
|
493
|
+
|
494
|
+
|
495
|
+
160
|
496
|
+
161
|
497
|
+
162</pre>
|
498
|
+
</td>
|
499
|
+
<td>
|
500
|
+
<pre class="code"><span class="info file"># File 'lib/evolvable/gene.rb', line 160</span>
|
501
|
+
|
502
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_key'>key</span>
|
503
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span>
|
504
|
+
<span class='kw'>end</span></pre>
|
505
|
+
</td>
|
506
|
+
</tr>
|
507
|
+
</table>
|
508
|
+
</div>
|
509
|
+
|
510
|
+
</div>
|
511
|
+
|
512
|
+
</div>
|
513
|
+
|
514
|
+
<div id="footer">
|
515
|
+
Generated on Sat May 10 18:39:22 2025 by
|
516
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
517
|
+
0.9.37 (ruby-3.4.2).
|
518
|
+
</div>
|
519
|
+
|
520
|
+
</div>
|
521
|
+
</body>
|
522
|
+
</html>
|