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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -0
  3. data/CHANGELOG.md +24 -0
  4. data/Gemfile +2 -2
  5. data/Gemfile.lock +44 -25
  6. data/README.md +498 -190
  7. data/README_YARD.md +85 -166
  8. data/bin/console +10 -19
  9. data/docs/Evolvable/ClassMethods.html +1233 -0
  10. data/docs/Evolvable/Community/ClassMethods.html +708 -0
  11. data/docs/Evolvable/Community.html +1342 -0
  12. data/docs/Evolvable/CountGene.html +886 -0
  13. data/docs/Evolvable/EqualizeGoal.html +347 -0
  14. data/docs/Evolvable/Error.html +134 -0
  15. data/docs/Evolvable/Evaluation.html +773 -0
  16. data/docs/Evolvable/Evolution.html +616 -0
  17. data/docs/Evolvable/Gene/ClassMethods.html +413 -0
  18. data/docs/Evolvable/Gene.html +522 -0
  19. data/docs/Evolvable/GeneCluster/ClassMethods.html +431 -0
  20. data/docs/Evolvable/GeneCluster.html +280 -0
  21. data/docs/Evolvable/GeneCombination.html +515 -0
  22. data/docs/Evolvable/GeneSpace.html +619 -0
  23. data/docs/Evolvable/Genome.html +1070 -0
  24. data/docs/Evolvable/Goal.html +500 -0
  25. data/docs/Evolvable/MaximizeGoal.html +348 -0
  26. data/docs/Evolvable/MinimizeGoal.html +348 -0
  27. data/docs/Evolvable/Mutation.html +729 -0
  28. data/docs/Evolvable/PointCrossover.html +444 -0
  29. data/docs/Evolvable/Population.html +2826 -0
  30. data/docs/Evolvable/RigidCountGene.html +501 -0
  31. data/docs/Evolvable/Selection.html +594 -0
  32. data/docs/Evolvable/Serializer.html +293 -0
  33. data/docs/Evolvable/UniformCrossover.html +286 -0
  34. data/docs/Evolvable.html +1619 -0
  35. data/docs/_index.html +341 -0
  36. data/docs/class_list.html +54 -0
  37. data/docs/css/common.css +1 -0
  38. data/docs/css/full_list.css +58 -0
  39. data/docs/css/style.css +503 -0
  40. data/docs/file.README.html +750 -0
  41. data/docs/file_list.html +59 -0
  42. data/docs/frames.html +22 -0
  43. data/docs/index.html +750 -0
  44. data/docs/js/app.js +344 -0
  45. data/docs/js/full_list.js +242 -0
  46. data/docs/js/jquery.js +4 -0
  47. data/docs/method_list.html +1302 -0
  48. data/docs/top-level-namespace.html +110 -0
  49. data/evolvable.gemspec +6 -6
  50. data/examples/ascii_art.rb +5 -9
  51. data/examples/stickman.rb +25 -33
  52. data/{examples/hello_world.rb → exe/hello_evolvable_world} +46 -30
  53. data/lib/evolvable/community.rb +190 -0
  54. data/lib/evolvable/count_gene.rb +65 -0
  55. data/lib/evolvable/equalize_goal.rb +2 -9
  56. data/lib/evolvable/evaluation.rb +113 -14
  57. data/lib/evolvable/evolution.rb +38 -15
  58. data/lib/evolvable/gene.rb +124 -25
  59. data/lib/evolvable/gene_cluster.rb +106 -0
  60. data/lib/evolvable/gene_combination.rb +57 -16
  61. data/lib/evolvable/gene_space.rb +111 -0
  62. data/lib/evolvable/genome.rb +32 -4
  63. data/lib/evolvable/goal.rb +19 -24
  64. data/lib/evolvable/maximize_goal.rb +2 -9
  65. data/lib/evolvable/minimize_goal.rb +3 -9
  66. data/lib/evolvable/mutation.rb +87 -41
  67. data/lib/evolvable/point_crossover.rb +24 -4
  68. data/lib/evolvable/population.rb +258 -84
  69. data/lib/evolvable/rigid_count_gene.rb +36 -0
  70. data/lib/evolvable/selection.rb +68 -14
  71. data/lib/evolvable/serializer.rb +46 -0
  72. data/lib/evolvable/uniform_crossover.rb +30 -6
  73. data/lib/evolvable/version.rb +2 -1
  74. data/lib/evolvable.rb +268 -107
  75. metadata +57 -36
  76. data/examples/images/diagram.png +0 -0
  77. data/exe/hello +0 -16
  78. data/lib/evolvable/error/undefined_method.rb +0 -7
  79. data/lib/evolvable/search_space.rb +0 -181
@@ -0,0 +1,886 @@
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
+ Class: Evolvable::CountGene
8
+
9
+ &mdash; 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::CountGene";
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 (C)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Evolvable.html" title="Evolvable (module)">Evolvable</a></span></span>
41
+ &raquo;
42
+ <span class="title">CountGene</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>Class: Evolvable::CountGene
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">Evolvable::CountGene</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+ <dl>
91
+ <dt>Includes:</dt>
92
+ <dd><span class='object_link'><a href="Gene.html" title="Evolvable::Gene (module)">Gene</a></span></dd>
93
+ </dl>
94
+
95
+
96
+
97
+
98
+
99
+
100
+ <dl>
101
+ <dt>Defined in:</dt>
102
+ <dd>lib/evolvable/count_gene.rb</dd>
103
+ </dl>
104
+
105
+ </div>
106
+
107
+ <h2>Overview</h2><div class="docstring">
108
+ <div class="discussion">
109
+ <p>The CountGene class handles the dynamic count of genes in evolvable instances.
110
+ When a gene is defined with a range for <code>count:</code> (e.g., <code>count: 2..8</code>), a CountGene
111
+ is created to manage this count, allowing the number of genes to change over
112
+ successive generations.</p>
113
+
114
+
115
+ </div>
116
+ </div>
117
+ <div class="tags">
118
+
119
+ <div class="examples">
120
+ <h4 class="tag_title">Examples:</h4>
121
+
122
+
123
+ <h5 class="example_title"><div class='inline'><p>Define a melody with a variable number of notes (4 to 16)</p>
124
+ </div></h5>
125
+
126
+ <pre class="example code"><code><span class='kw'>class</span> <span class='const'>Melody</span>
127
+ <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>
128
+
129
+ <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'>16</span>
130
+
131
+ <span class='comment'># The actual number of notes can change during evolution
132
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_play'>play</span>
133
+ <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Playing melody with </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_notes'>notes</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span><span class='embexpr_end'>}</span><span class='tstring_content'> notes</span><span class='tstring_end'>&quot;</span></span>
134
+ <span class='kw'>end</span>
135
+ <span class='kw'>end</span></code></pre>
136
+
137
+ </div>
138
+
139
+
140
+ </div>
141
+
142
+ <h2>
143
+ Constant Summary
144
+ <small><a href="#" class="constants_summary_toggle">collapse</a></small>
145
+ </h2>
146
+
147
+ <dl class="constants">
148
+
149
+ <dt id="LAMBDAS-constant" class="">LAMBDAS =
150
+ <div class="docstring">
151
+ <div class="discussion">
152
+ <p>Available strategies for combining count genes.
153
+ These lambdas determine how two count genes are merged during evolution.</p>
154
+
155
+ <ol>
156
+ <li>Random selection with slight mutation (-1, 0, or +1)</li>
157
+ <li>Average of the two counts</li>
158
+ </ol>
159
+
160
+
161
+ </div>
162
+ </div>
163
+ <div class="tags">
164
+
165
+
166
+ </div>
167
+ </dt>
168
+ <dd><pre class="code"><span class='lbracket'>[</span><span class='tlambda'>-&gt;</span><span class='lparen'>(</span><span class='id identifier rubyid_a'>a</span><span class='comma'>,</span> <span class='id identifier rubyid_b'>b</span><span class='rparen'>)</span> <span class='tlambeg'>{</span> <span class='lbracket'>[</span><span class='id identifier rubyid_a'>a</span><span class='comma'>,</span> <span class='id identifier rubyid_b'>b</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_sample'>sample</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span> <span class='op'>+</span> <span class='id identifier rubyid_rand'>rand</span><span class='lparen'>(</span><span class='op'>-</span><span class='int'>1</span><span class='op'>..</span><span class='int'>1</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='comma'>,</span>
169
+ <span class='tlambda'>-&gt;</span><span class='lparen'>(</span><span class='id identifier rubyid_a'>a</span><span class='comma'>,</span> <span class='id identifier rubyid_b'>b</span><span class='rparen'>)</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_a'>a</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span> <span class='op'>+</span> <span class='id identifier rubyid_b'>b</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span> <span class='op'>/</span> <span class='int'>2</span> <span class='rbrace'>}</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
170
+
171
+ </dl>
172
+
173
+
174
+
175
+
176
+
177
+ <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
178
+ <ul class="summary">
179
+
180
+ <li class="public ">
181
+ <span class="summary_signature">
182
+
183
+ <a href="#range-instance_method" title="#range (instance method)">#<strong>range</strong> &#x21d2; Range </a>
184
+
185
+
186
+
187
+ </span>
188
+
189
+
190
+
191
+
192
+ <span class="note title readonly">readonly</span>
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+ <span class="summary_desc"><div class='inline'><p>The valid range for the count value.</p>
203
+ </div></span>
204
+
205
+ </li>
206
+
207
+
208
+ </ul>
209
+
210
+
211
+
212
+
213
+
214
+ <h3 class="inherited">Attributes included from <span class='object_link'><a href="Gene.html" title="Evolvable::Gene (module)">Gene</a></span></h3>
215
+ <p class="inherited"><span class='object_link'><a href="Gene.html#evolvable-instance_method" title="Evolvable::Gene#evolvable (method)">#evolvable</a></span></p>
216
+
217
+
218
+
219
+ <h2>
220
+ Class Method Summary
221
+ <small><a href="#" class="summary_toggle">collapse</a></small>
222
+ </h2>
223
+
224
+ <ul class="summary">
225
+
226
+ <li class="public ">
227
+ <span class="summary_signature">
228
+
229
+ <a href="#combination-class_method" title="combination (class method)">.<strong>combination</strong> &#x21d2; Proc </a>
230
+
231
+
232
+
233
+ </span>
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+ <span class="summary_desc"><div class='inline'><p>Selects a random combination strategy from LAMBDAS.</p>
244
+ </div></span>
245
+
246
+ </li>
247
+
248
+
249
+ <li class="public ">
250
+ <span class="summary_signature">
251
+
252
+ <a href="#combine-class_method" title="combine (class method)">.<strong>combine</strong>(gene_a, gene_b) &#x21d2; CountGene </a>
253
+
254
+
255
+
256
+ </span>
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+ <span class="summary_desc"><div class='inline'><p>Combines two count genes to produce a new count gene.</p>
267
+ </div></span>
268
+
269
+ </li>
270
+
271
+
272
+ </ul>
273
+
274
+ <h2>
275
+ Instance Method Summary
276
+ <small><a href="#" class="summary_toggle">collapse</a></small>
277
+ </h2>
278
+
279
+ <ul class="summary">
280
+
281
+ <li class="public ">
282
+ <span class="summary_signature">
283
+
284
+ <a href="#count-instance_method" title="#count (instance method)">#<strong>count</strong> &#x21d2; Integer </a>
285
+
286
+
287
+
288
+ </span>
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+ <span class="summary_desc"><div class='inline'><p>Returns the current count value.</p>
299
+ </div></span>
300
+
301
+ </li>
302
+
303
+
304
+ <li class="public ">
305
+ <span class="summary_signature">
306
+
307
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(range:, count: nil) &#x21d2; CountGene </a>
308
+
309
+
310
+
311
+ </span>
312
+
313
+
314
+ <span class="note title constructor">constructor</span>
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+ <span class="summary_desc"><div class='inline'><p>Initializes a new CountGene instance.</p>
324
+ </div></span>
325
+
326
+ </li>
327
+
328
+
329
+ <li class="public ">
330
+ <span class="summary_signature">
331
+
332
+ <a href="#max_count-instance_method" title="#max_count (instance method)">#<strong>max_count</strong> &#x21d2; Integer </a>
333
+
334
+
335
+
336
+ </span>
337
+
338
+
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+ <span class="summary_desc"><div class='inline'><p>The maximum allowed count value.</p>
347
+ </div></span>
348
+
349
+ </li>
350
+
351
+
352
+ <li class="public ">
353
+ <span class="summary_signature">
354
+
355
+ <a href="#min_count-instance_method" title="#min_count (instance method)">#<strong>min_count</strong> &#x21d2; Integer </a>
356
+
357
+
358
+
359
+ </span>
360
+
361
+
362
+
363
+
364
+
365
+
366
+
367
+
368
+
369
+ <span class="summary_desc"><div class='inline'><p>The minimum allowed count value.</p>
370
+ </div></span>
371
+
372
+ </li>
373
+
374
+
375
+ </ul>
376
+
377
+
378
+
379
+
380
+
381
+
382
+
383
+
384
+
385
+
386
+
387
+ <h3 class="inherited">Methods included from <span class='object_link'><a href="Gene.html" title="Evolvable::Gene (module)">Gene</a></span></h3>
388
+ <p class="inherited"><span class='object_link'><a href="Gene.html#included-class_method" title="Evolvable::Gene.included (method)">included</a></span>, <span class='object_link'><a href="Gene.html#key-instance_method" title="Evolvable::Gene#key (method)">#key</a></span></p>
389
+ <div id="constructor_details" class="method_details_list">
390
+ <h2>Constructor Details</h2>
391
+
392
+ <div class="method_details first">
393
+ <h3 class="signature first" id="initialize-instance_method">
394
+
395
+ #<strong>initialize</strong>(range:, count: nil) &#x21d2; <tt><span class='object_link'><a href="" title="Evolvable::CountGene (class)">CountGene</a></span></tt>
396
+
397
+
398
+
399
+
400
+
401
+ </h3><div class="docstring">
402
+ <div class="discussion">
403
+ <p>Initializes a new CountGene instance.</p>
404
+
405
+
406
+ </div>
407
+ </div>
408
+ <div class="tags">
409
+ <p class="tag_title">Parameters:</p>
410
+ <ul class="param">
411
+
412
+ <li>
413
+
414
+ <span class='name'>range</span>
415
+
416
+
417
+ <span class='type'>(<tt>Range</tt>)</span>
418
+
419
+
420
+
421
+ &mdash;
422
+ <div class='inline'><p>The valid range for the count value</p>
423
+ </div>
424
+
425
+ </li>
426
+
427
+ <li>
428
+
429
+ <span class='name'>count</span>
430
+
431
+
432
+ <span class='type'>(<tt>Integer</tt>, <tt>nil</tt>)</span>
433
+
434
+
435
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
436
+
437
+
438
+ &mdash;
439
+ <div class='inline'><p>Optional initial count value, randomly selected from range if nil</p>
440
+ </div>
441
+
442
+ </li>
443
+
444
+ </ul>
445
+
446
+
447
+ </div><table class="source_code">
448
+ <tr>
449
+ <td>
450
+ <pre class="lines">
451
+
452
+
453
+ 67
454
+ 68
455
+ 69
456
+ 70</pre>
457
+ </td>
458
+ <td>
459
+ <pre class="code"><span class="info file"># File 'lib/evolvable/count_gene.rb', line 67</span>
460
+
461
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='label'>range:</span><span class='comma'>,</span> <span class='label'>count:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
462
+ <span class='ivar'>@range</span> <span class='op'>=</span> <span class='id identifier rubyid_range'>range</span>
463
+ <span class='ivar'>@count</span> <span class='op'>=</span> <span class='id identifier rubyid_count'>count</span>
464
+ <span class='kw'>end</span></pre>
465
+ </td>
466
+ </tr>
467
+ </table>
468
+ </div>
469
+
470
+ </div>
471
+
472
+ <div id="instance_attr_details" class="attr_details">
473
+ <h2>Instance Attribute Details</h2>
474
+
475
+
476
+ <span id=""></span>
477
+ <div class="method_details first">
478
+ <h3 class="signature first" id="range-instance_method">
479
+
480
+ #<strong>range</strong> &#x21d2; <tt>Range</tt> <span class="extras">(readonly)</span>
481
+
482
+
483
+
484
+
485
+
486
+ </h3><div class="docstring">
487
+ <div class="discussion">
488
+ <p>The valid range for the count value.</p>
489
+
490
+
491
+ </div>
492
+ </div>
493
+ <div class="tags">
494
+
495
+ <p class="tag_title">Returns:</p>
496
+ <ul class="return">
497
+
498
+ <li>
499
+
500
+
501
+ <span class='type'>(<tt>Range</tt>)</span>
502
+
503
+
504
+
505
+ &mdash;
506
+ <div class='inline'><p>The range of possible count values</p>
507
+ </div>
508
+
509
+ </li>
510
+
511
+ </ul>
512
+
513
+ </div><table class="source_code">
514
+ <tr>
515
+ <td>
516
+ <pre class="lines">
517
+
518
+
519
+ 77
520
+ 78
521
+ 79</pre>
522
+ </td>
523
+ <td>
524
+ <pre class="code"><span class="info file"># File 'lib/evolvable/count_gene.rb', line 77</span>
525
+
526
+ <span class='kw'>def</span> <span class='id identifier rubyid_range'>range</span>
527
+ <span class='ivar'>@range</span>
528
+ <span class='kw'>end</span></pre>
529
+ </td>
530
+ </tr>
531
+ </table>
532
+ </div>
533
+
534
+ </div>
535
+
536
+
537
+ <div id="class_method_details" class="method_details_list">
538
+ <h2>Class Method Details</h2>
539
+
540
+
541
+ <div class="method_details first">
542
+ <h3 class="signature first" id="combination-class_method">
543
+
544
+ .<strong>combination</strong> &#x21d2; <tt>Proc</tt>
545
+
546
+
547
+
548
+
549
+
550
+ </h3><div class="docstring">
551
+ <div class="discussion">
552
+ <p>Selects a random combination strategy from LAMBDAS.</p>
553
+
554
+
555
+ </div>
556
+ </div>
557
+ <div class="tags">
558
+
559
+ <p class="tag_title">Returns:</p>
560
+ <ul class="return">
561
+
562
+ <li>
563
+
564
+
565
+ <span class='type'>(<tt>Proc</tt>)</span>
566
+
567
+
568
+
569
+ &mdash;
570
+ <div class='inline'><p>A lambda function for combining two count genes</p>
571
+ </div>
572
+
573
+ </li>
574
+
575
+ </ul>
576
+
577
+ </div><table class="source_code">
578
+ <tr>
579
+ <td>
580
+ <pre class="lines">
581
+
582
+
583
+ 56
584
+ 57
585
+ 58</pre>
586
+ </td>
587
+ <td>
588
+ <pre class="code"><span class="info file"># File 'lib/evolvable/count_gene.rb', line 56</span>
589
+
590
+ <span class='kw'>def</span> <span class='id identifier rubyid_combination'>combination</span>
591
+ <span class='const'><span class='object_link'><a href="#LAMBDAS-constant" title="Evolvable::CountGene::LAMBDAS (constant)">LAMBDAS</a></span></span><span class='period'>.</span><span class='id identifier rubyid_sample'>sample</span>
592
+ <span class='kw'>end</span></pre>
593
+ </td>
594
+ </tr>
595
+ </table>
596
+ </div>
597
+
598
+ <div class="method_details ">
599
+ <h3 class="signature " id="combine-class_method">
600
+
601
+ .<strong>combine</strong>(gene_a, gene_b) &#x21d2; <tt><span class='object_link'><a href="" title="Evolvable::CountGene (class)">CountGene</a></span></tt>
602
+
603
+
604
+
605
+
606
+
607
+ </h3><div class="docstring">
608
+ <div class="discussion">
609
+ <p>Combines two count genes to produce a new count gene.
610
+ The combination strategy is randomly selected from LAMBDAS.</p>
611
+
612
+
613
+ </div>
614
+ </div>
615
+ <div class="tags">
616
+ <p class="tag_title">Parameters:</p>
617
+ <ul class="param">
618
+
619
+ <li>
620
+
621
+ <span class='name'>gene_a</span>
622
+
623
+
624
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Evolvable::CountGene (class)">CountGene</a></span></tt>)</span>
625
+
626
+
627
+
628
+ &mdash;
629
+ <div class='inline'><p>The first count gene</p>
630
+ </div>
631
+
632
+ </li>
633
+
634
+ <li>
635
+
636
+ <span class='name'>gene_b</span>
637
+
638
+
639
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Evolvable::CountGene (class)">CountGene</a></span></tt>)</span>
640
+
641
+
642
+
643
+ &mdash;
644
+ <div class='inline'><p>The second count gene</p>
645
+ </div>
646
+
647
+ </li>
648
+
649
+ </ul>
650
+
651
+ <p class="tag_title">Returns:</p>
652
+ <ul class="return">
653
+
654
+ <li>
655
+
656
+
657
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Evolvable::CountGene (class)">CountGene</a></span></tt>)</span>
658
+
659
+
660
+
661
+ &mdash;
662
+ <div class='inline'><p>A new count gene with a combined count value</p>
663
+ </div>
664
+
665
+ </li>
666
+
667
+ </ul>
668
+
669
+ </div><table class="source_code">
670
+ <tr>
671
+ <td>
672
+ <pre class="lines">
673
+
674
+
675
+ 34
676
+ 35
677
+ 36
678
+ 37
679
+ 38
680
+ 39</pre>
681
+ </td>
682
+ <td>
683
+ <pre class="code"><span class="info file"># File 'lib/evolvable/count_gene.rb', line 34</span>
684
+
685
+ <span class='kw'>def</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>
686
+ <span class='id identifier rubyid_min'>min</span> <span class='op'>=</span> <span class='id identifier rubyid_gene_a'>gene_a</span><span class='period'>.</span><span class='id identifier rubyid_min_count'>min_count</span>
687
+ <span class='id identifier rubyid_max'>max</span> <span class='op'>=</span> <span class='id identifier rubyid_gene_a'>gene_a</span><span class='period'>.</span><span class='id identifier rubyid_max_count'>max_count</span>
688
+ <span class='id identifier rubyid_count'>count</span> <span class='op'>=</span> <span class='id identifier rubyid_combination'>combination</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</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><span class='period'>.</span><span class='id identifier rubyid_clamp'>clamp</span><span class='lparen'>(</span><span class='id identifier rubyid_min'>min</span><span class='comma'>,</span> <span class='id identifier rubyid_max'>max</span><span class='rparen'>)</span>
689
+ <span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='label'>range:</span> <span class='id identifier rubyid_gene_a'>gene_a</span><span class='period'>.</span><span class='id identifier rubyid_range'>range</span><span class='comma'>,</span> <span class='label'>count:</span> <span class='id identifier rubyid_count'>count</span><span class='rparen'>)</span>
690
+ <span class='kw'>end</span></pre>
691
+ </td>
692
+ </tr>
693
+ </table>
694
+ </div>
695
+
696
+ </div>
697
+
698
+ <div id="instance_method_details" class="method_details_list">
699
+ <h2>Instance Method Details</h2>
700
+
701
+
702
+ <div class="method_details first">
703
+ <h3 class="signature first" id="count-instance_method">
704
+
705
+ #<strong>count</strong> &#x21d2; <tt>Integer</tt>
706
+
707
+
708
+
709
+
710
+
711
+ </h3><div class="docstring">
712
+ <div class="discussion">
713
+ <p>Returns the current count value.
714
+ If not already set, randomly selects a value from the range.</p>
715
+
716
+
717
+ </div>
718
+ </div>
719
+ <div class="tags">
720
+
721
+ <p class="tag_title">Returns:</p>
722
+ <ul class="return">
723
+
724
+ <li>
725
+
726
+
727
+ <span class='type'>(<tt>Integer</tt>)</span>
728
+
729
+
730
+
731
+ &mdash;
732
+ <div class='inline'><p>The number of genes to create</p>
733
+ </div>
734
+
735
+ </li>
736
+
737
+ </ul>
738
+
739
+ </div><table class="source_code">
740
+ <tr>
741
+ <td>
742
+ <pre class="lines">
743
+
744
+
745
+ 85
746
+ 86
747
+ 87</pre>
748
+ </td>
749
+ <td>
750
+ <pre class="code"><span class="info file"># File 'lib/evolvable/count_gene.rb', line 85</span>
751
+
752
+ <span class='kw'>def</span> <span class='id identifier rubyid_count'>count</span>
753
+ <span class='ivar'>@count</span> <span class='op'>||=</span> <span class='id identifier rubyid_rand'>rand</span><span class='lparen'>(</span><span class='ivar'>@range</span><span class='rparen'>)</span>
754
+ <span class='kw'>end</span></pre>
755
+ </td>
756
+ </tr>
757
+ </table>
758
+ </div>
759
+
760
+ <div class="method_details ">
761
+ <h3 class="signature " id="max_count-instance_method">
762
+
763
+ #<strong>max_count</strong> &#x21d2; <tt>Integer</tt>
764
+
765
+
766
+
767
+
768
+
769
+ </h3><div class="docstring">
770
+ <div class="discussion">
771
+ <p>The maximum allowed count value.</p>
772
+
773
+
774
+ </div>
775
+ </div>
776
+ <div class="tags">
777
+
778
+ <p class="tag_title">Returns:</p>
779
+ <ul class="return">
780
+
781
+ <li>
782
+
783
+
784
+ <span class='type'>(<tt>Integer</tt>)</span>
785
+
786
+
787
+
788
+ &mdash;
789
+ <div class='inline'><p>The maximum value from the range</p>
790
+ </div>
791
+
792
+ </li>
793
+
794
+ </ul>
795
+
796
+ </div><table class="source_code">
797
+ <tr>
798
+ <td>
799
+ <pre class="lines">
800
+
801
+
802
+ 103
803
+ 104
804
+ 105</pre>
805
+ </td>
806
+ <td>
807
+ <pre class="code"><span class="info file"># File 'lib/evolvable/count_gene.rb', line 103</span>
808
+
809
+ <span class='kw'>def</span> <span class='id identifier rubyid_max_count'>max_count</span>
810
+ <span class='ivar'>@range</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span>
811
+ <span class='kw'>end</span></pre>
812
+ </td>
813
+ </tr>
814
+ </table>
815
+ </div>
816
+
817
+ <div class="method_details ">
818
+ <h3 class="signature " id="min_count-instance_method">
819
+
820
+ #<strong>min_count</strong> &#x21d2; <tt>Integer</tt>
821
+
822
+
823
+
824
+
825
+
826
+ </h3><div class="docstring">
827
+ <div class="discussion">
828
+ <p>The minimum allowed count value.</p>
829
+
830
+
831
+ </div>
832
+ </div>
833
+ <div class="tags">
834
+
835
+ <p class="tag_title">Returns:</p>
836
+ <ul class="return">
837
+
838
+ <li>
839
+
840
+
841
+ <span class='type'>(<tt>Integer</tt>)</span>
842
+
843
+
844
+
845
+ &mdash;
846
+ <div class='inline'><p>The minimum value from the range</p>
847
+ </div>
848
+
849
+ </li>
850
+
851
+ </ul>
852
+
853
+ </div><table class="source_code">
854
+ <tr>
855
+ <td>
856
+ <pre class="lines">
857
+
858
+
859
+ 94
860
+ 95
861
+ 96</pre>
862
+ </td>
863
+ <td>
864
+ <pre class="code"><span class="info file"># File 'lib/evolvable/count_gene.rb', line 94</span>
865
+
866
+ <span class='kw'>def</span> <span class='id identifier rubyid_min_count'>min_count</span>
867
+ <span class='ivar'>@range</span><span class='period'>.</span><span class='id identifier rubyid_min'>min</span>
868
+ <span class='kw'>end</span></pre>
869
+ </td>
870
+ </tr>
871
+ </table>
872
+ </div>
873
+
874
+ </div>
875
+
876
+ </div>
877
+
878
+ <div id="footer">
879
+ Generated on Sat May 10 18:39:22 2025 by
880
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
881
+ 0.9.37 (ruby-3.4.2).
882
+ </div>
883
+
884
+ </div>
885
+ </body>
886
+ </html>