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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b7db4de54c6784811c6bac3a14c4d3148b24ca1
4
- data.tar.gz: e63666b2ff9f1766afbe733978b0cfed88054d3d
3
+ metadata.gz: fc3011bc562f5b4490d7ce0871474d96e56c3483
4
+ data.tar.gz: 04cd59e64dee4bc02be52e766215d1b9251e5387
5
5
  SHA512:
6
- metadata.gz: 6d715771f639c7c8348a004c1705af58490605be2b7fbbe3ac8f08b6907aa6e86b801414c108cb3243635916add30fd9a98fdba771c200e55a3d6d7e7c86f650
7
- data.tar.gz: fb5c6e32fbf6ce75a43648e04bf866bfedd2982e8b05d101d6aefea7f2670cd7b6216289b9fc19226d7836e4dec7195622ca51d964333a30bdb6d55df9426db0
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.
@@ -1,3 +1,3 @@
1
1
  module SimpleGa
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.1
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-12 00:00:00.000000000 Z
11
+ date: 2015-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler