gimuby 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 774ea577ca0cd0fe53bc732d56a6e6e560adfc22
4
+ data.tar.gz: 84804ec18561b0fda31713951c3f41e06b7d5733
5
+ SHA512:
6
+ metadata.gz: d01872dc51ad8d00723f0c78a48188181020818a0f9366bb254d88dee504ccb7b78054f62f8e3c69550b6d5df4763c46e251ee1b266045b514749b040f4ad37c
7
+ data.tar.gz: 9ac69252b798eedca91c88d64c7ac6045c7ad17ad288c54fc9f5d19b01e7c5610ef7f1156f92cc195a239c7f5027de55e49c8be10846495934f94a1393880f39
data/Gemfile CHANGED
@@ -1 +1,4 @@
1
- rake
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+ gem 'rake'
data/README.md CHANGED
@@ -0,0 +1,3 @@
1
+ [![Build Status](https://secure.travis-ci.org/frantzmiccoli/Gimuby.png)](http://travis-ci.org/ frantzmiccoli/Gimuby)
2
+
3
+ [Gimuby's presentation page](http://frantzmiccoli.github.io/Gimuby/ "Gimuby").
@@ -133,8 +133,8 @@ class Factory
133
133
  archipelago.connect_strategy = get_random_connect_strategy
134
134
  # between 0.01% and ~35%
135
135
  archipelago.migration_rate = (rand() * 35.0 / 100.0) + 0.0001
136
- archipelago.migration_symmetric = [true, false].choice
137
- archipelago.migration_type = [:random, :synchronized, :fixed_time].choice
136
+ archipelago.migration_symmetric = random_entry(true, false)
137
+ archipelago.migration_type = random_entry(:random, :synchronized, :fixed_time)
138
138
  get_populations_number.times do |_|
139
139
  archipelago.add_population(_get_population(:archipelago, &solution_generator))
140
140
  end
@@ -176,7 +176,7 @@ class Factory
176
176
  solutions_per_population = 0
177
177
  min_solutions_per_population = min_population_size / populations_number
178
178
  begin
179
- picked_solutions_number = solutions_number_range.choice
179
+ picked_solutions_number = random_entry(solutions_number_range)
180
180
  picked_solutions_number /= populations_number
181
181
  picked_solutions_number *= populations_number
182
182
  solutions_per_population = picked_solutions_number / populations_number
@@ -200,7 +200,8 @@ class Factory
200
200
  populations_number_range = *(10..29)
201
201
  end
202
202
 
203
- @_populations_number = populations_number_range.choice
203
+
204
+ @_populations_number = random_entry(populations_number_range)
204
205
  @_populations_number
205
206
  end
206
207
 
@@ -272,4 +273,19 @@ class Factory
272
273
  strategy
273
274
  end
274
275
 
275
- end
276
+ def self.random_entry *args
277
+ array = args.flatten
278
+
279
+ if array.respond_to? :sample
280
+ array.sample
281
+ else
282
+ array.choice
283
+ end
284
+ end
285
+
286
+ private
287
+ def random_entry *args
288
+ self.class.random_entry(*args)
289
+ end
290
+
291
+ end
@@ -48,7 +48,7 @@ class WattsStrogatzConnectStrategy < ConnectStrategy
48
48
  if node1 < node2 # we do not process the other case (undirected model)
49
49
  should_rewire = @rewire_rate < rand()
50
50
  if should_rewire
51
- new_node = nodes.choice while archipelago.has_edge(node1, new_node)
51
+ new_node = Factory.random_entry(nodes) while archipelago.has_edge(node1, new_node)
52
52
  archipelago.remove_edge(node1, node2)
53
53
  archipelago.connect(node1, new_node)
54
54
  end
@@ -60,4 +60,4 @@ class WattsStrogatzConnectStrategy < ConnectStrategy
60
60
  archipelago.get_edges
61
61
  end
62
62
 
63
- end
63
+ end
@@ -7,11 +7,11 @@ class TournamentPickStrategy < PickStrategy
7
7
  number = get_number_to_pick(population)
8
8
  candidates = solutions.clone
9
9
 
10
- while candidates.length > number:
11
- sol1 = candidates.choice()
10
+ while candidates.length > number
11
+ sol1 = Factory.random_entry(candidates)
12
12
  sol2 = sol1
13
- while sol1 == sol2:
14
- sol2 = candidates.choice()
13
+ while sol1 == sol2
14
+ sol2 = Factory.random_entry(candidates)
15
15
  end
16
16
  if population.get_fitness(sol1) < population.get_fitness(sol2)
17
17
  candidates.delete(sol2)
@@ -23,4 +23,4 @@ class TournamentPickStrategy < PickStrategy
23
23
  candidates
24
24
  end
25
25
 
26
- end
26
+ end
@@ -22,6 +22,6 @@ class CombinedNewGenerationStrategy < NewGenerationStrategy
22
22
  protected
23
23
 
24
24
  def get_concrete_strategy
25
- @strategies.choice
25
+ Factory.random_entry(@strategies)
26
26
  end
27
- end
27
+ end
metadata CHANGED
@@ -1,13 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gimuby
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
5
- prerelease:
6
- segments:
7
- - 0
8
- - 7
9
- - 2
10
- version: 0.7.2
4
+ version: 0.7.3
11
5
  platform: ruby
12
6
  authors:
13
7
  - "Fr\xC3\xA4ntz Miccoli"
@@ -15,7 +9,7 @@ autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
11
 
18
- date: 2014-03-30 00:00:00 Z
12
+ date: 2014-04-14 00:00:00 Z
19
13
  dependencies: []
20
14
 
21
15
  description: |-
@@ -93,36 +87,29 @@ files:
93
87
  homepage: https://frantzmiccoli.github.io/Gimuby
94
88
  licenses:
95
89
  - MIT
90
+ metadata: {}
91
+
96
92
  post_install_message:
97
93
  rdoc_options: []
98
94
 
99
95
  require_paths:
100
96
  - lib
101
97
  required_ruby_version: !ruby/object:Gem::Requirement
102
- none: false
103
98
  requirements:
104
- - - ~>
99
+ - - ">="
105
100
  - !ruby/object:Gem::Version
106
- hash: 31
107
- segments:
108
- - 1
109
- - 8
110
101
  version: "1.8"
111
102
  required_rubygems_version: !ruby/object:Gem::Requirement
112
- none: false
113
103
  requirements:
114
104
  - - ">="
115
105
  - !ruby/object:Gem::Version
116
- hash: 3
117
- segments:
118
- - 0
119
106
  version: "0"
120
107
  requirements: []
121
108
 
122
109
  rubyforge_project:
123
- rubygems_version: 1.8.24
110
+ rubygems_version: 2.0.3
124
111
  signing_key:
125
- specification_version: 3
112
+ specification_version: 4
126
113
  summary: "Gimuby: genetic algorithm and island model for Ruby"
127
114
  test_files: []
128
115