pmeth 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pmeth.rb +6 -2
- 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: 61a3e9a58c149c0dd393a6b93c459e3c24c6af7a
|
4
|
+
data.tar.gz: 72fd294b8447fe4c05803977e8bd2c3589b30d75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1169f91434afcc929af67fa8079d7612f5dad0995cba7be7e7e925cefa65aff555669a874ddd9392b76b6a3f6b4374ef68c0798954b6ad1475f5f57104fe4dd1
|
7
|
+
data.tar.gz: 07eeae29ba81c2aa36d18d3f851c784fae99a30e9d7365e8ed76fdcb28aa2b16ad2042a1c24fef1338990dc96621998fe003c0fb9ba7eebca884d6305de0f079
|
data/lib/pmeth.rb
CHANGED
@@ -66,9 +66,13 @@ class PMeth
|
|
66
66
|
def self.adjacent_swap(permutation)
|
67
67
|
x = rand(permutation.length) # randomly choose an index
|
68
68
|
coin = rand(2) # a 50% chance for an object to swap with it's left or right neighbour
|
69
|
-
if x == 0
|
69
|
+
if x == 0 # object at index 0 of array can only swap with index 1
|
70
70
|
y = x + 1
|
71
|
-
elsif x == permutation.length-1
|
71
|
+
elsif x == permutation.length-1 # object at index -1 of array can only swap with index -2
|
72
|
+
y = x - 1
|
73
|
+
elsif coin == 0
|
74
|
+
y = x + 1
|
75
|
+
elsif coin == 1
|
72
76
|
y = x - 1
|
73
77
|
end
|
74
78
|
mutant = permutation.dup
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pmeth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edward Chalstrey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: "Reproduction methods for genetic (and other iterative improvement) algorithms,
|
14
14
|
being used to solve permutation problems, \n where permutations are arrays of unique
|