pmeth 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pmeth.rb +6 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be93eb83871e0795baa264779bd8ba8eef3708f5
4
- data.tar.gz: 55e2c27e3923bdb6671203c9ea896d965a9b3a25
3
+ metadata.gz: 61a3e9a58c149c0dd393a6b93c459e3c24c6af7a
4
+ data.tar.gz: 72fd294b8447fe4c05803977e8bd2c3589b30d75
5
5
  SHA512:
6
- metadata.gz: 7d2ed29982589d3951b3a643e8f847ae42acf38b7f168bdf74c5dcf950bd63954560daed6d8a52c7b1220e2d7769bd660a59e7ae31f7e144b791c25905992573
7
- data.tar.gz: c881281f8e56adeb2c6c9ffb7786ccea1119a5d24dfb13aa7f7ec594e2fde7c949957249b5a5c5db00b203443188c45d4b7cb503b112d8d1fdc0acc0a5afddf4
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 || coin == 0 # object at index 0 of array can only swap with index 1
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 || coin == 1 # object at index -1 of array can only swap with index -2
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.0
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-27 00:00:00.000000000 Z
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