ant_colony_optimizer 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2c50dc0a687d8571ee8dc1625a4e9b012b2a4de
4
- data.tar.gz: faa09ae4dab05be3948524d2b35ecb1f4cf67079
3
+ metadata.gz: c165cb2a197fa4131103274e2b1c69ce0170ffc5
4
+ data.tar.gz: d56df8db78e16774d99951bc1b19be940c387294
5
5
  SHA512:
6
- metadata.gz: 91d37722dac921ad657cfdf2c4018378b27b7ec1005fe66e53ea47b7fbc6c42b73628241ef480c7380421e8a513142f040344f00bebbde19435ed967fde81eb3
7
- data.tar.gz: d668d3cbe4bd343e85afbf98ee044aed515d807c7c8c462c727ca37e773ce4efdaff5bec14719e86eff023d80fed028d7cba8886c7e68f612678d811cc719b75
6
+ metadata.gz: 22b5ebb269de63516e882b4fe3c8953c76facb97b1465aa17a9cb32ea6deface46fada0783b4ca16feca48d984868af9cd6d9ef7e74150df86ba075ead64aad6
7
+ data.tar.gz: f5f9c2825489a8bde583ea56a6d77c5815c9a38860238511cf2028823894e7f6513d4de67f8aa5d5cf7d6e4fd5bc94a9172d456cddb42633eb7f203c8c62f398
@@ -73,8 +73,13 @@ class AntColonyOptimizer
73
73
  sum += p
74
74
  sum
75
75
  }
76
- probs.map!{|p| p / sum }
77
- idx = probs.index{|p| p > rand }
76
+ if sum == 0.0
77
+ idx = 0
78
+ else
79
+ probs.map!{|p| p / sum }
80
+ idx = probs.index{|p| p > rand }
81
+ raise "idx is nil #{probs.inspect}" if idx.nil?
82
+ end
78
83
  next_i = remain[idx]
79
84
  remain.delete(next_i)
80
85
  visited << next_i
@@ -1,3 +1,3 @@
1
1
  class AntColonyOptimizer
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ant_colony_optimizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - nagachika
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-13 00:00:00.000000000 Z
11
+ date: 2016-10-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ant Colony Optimizer Library
14
14
  email: