simple_ga 0.1.1 → 0.2.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/lib/simple_ga/genetic_algorithm.rb +10 -0
- data/lib/simple_ga/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc3011bc562f5b4490d7ce0871474d96e56c3483
|
4
|
+
data.tar.gz: 04cd59e64dee4bc02be52e766215d1b9251e5387
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb77a8312542c68c1d4347a503ea49cd7c1a2125f8602d6b87c7f6a8dfc86d50fb3059cbebea27d0a30de5a6200eaac97b722d98391436b1d049c57126f2d63d
|
7
|
+
data.tar.gz: 732180260c88457c4b84e759d7fa12acdc421e76a4fb7eacc2efbd4baf8fcd087b6c967989cb8a59b70e48355857e556bfae3c7bbb5d3319e56fe65019aa89ce
|
@@ -170,6 +170,16 @@ module SimpleGa
|
|
170
170
|
@data = data
|
171
171
|
end
|
172
172
|
|
173
|
+
def num_of_selected_genes
|
174
|
+
count = 0
|
175
|
+
data.each_with_index do |gene, index|
|
176
|
+
if index % 2 == 0 && gene == 1
|
177
|
+
count += 1
|
178
|
+
end
|
179
|
+
end
|
180
|
+
return count
|
181
|
+
end
|
182
|
+
|
173
183
|
# The fitness method quantifies the optimality of a solution
|
174
184
|
# (that is, a chromosome) in a genetic algorithm so that that particular
|
175
185
|
# chromosome may be ranked against all the other chromosomes.
|
data/lib/simple_ga/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_ga
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johnson Yeap
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|