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 +4 -4
- data/lib/ant_colony_optimizer.rb +7 -2
- data/lib/ant_colony_optimizer/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: c165cb2a197fa4131103274e2b1c69ce0170ffc5
|
4
|
+
data.tar.gz: d56df8db78e16774d99951bc1b19be940c387294
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22b5ebb269de63516e882b4fe3c8953c76facb97b1465aa17a9cb32ea6deface46fada0783b4ca16feca48d984868af9cd6d9ef7e74150df86ba075ead64aad6
|
7
|
+
data.tar.gz: f5f9c2825489a8bde583ea56a6d77c5815c9a38860238511cf2028823894e7f6513d4de67f8aa5d5cf7d6e4fd5bc94a9172d456cddb42633eb7f203c8c62f398
|
data/lib/ant_colony_optimizer.rb
CHANGED
@@ -73,8 +73,13 @@ class AntColonyOptimizer
|
|
73
73
|
sum += p
|
74
74
|
sum
|
75
75
|
}
|
76
|
-
|
77
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2016-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ant Colony Optimizer Library
|
14
14
|
email:
|