answer-factory 0.1.2 → 0.1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/answer-factory.gemspec +15 -8
- data/lib/answer-factory.rb +2 -0
- data/lib/factories/factory.rb +7 -0
- data/lib/factories/workstation.rb +16 -0
- data/lib/machines/evaluate_with_test_cases.rb +140 -0
- data/lib/machines/infrastructure.rb +2 -0
- data/lib/machines/select_by_summed_rank.rb +54 -0
- data/spec/factories/factory_spec.rb +13 -1
- data/spec/factories/workstation_spec.rb +19 -0
- data/spec/fixtures/my_data_source.csv +4 -0
- data/spec/integration_specs/couch_db_integration.rspec +59 -1
- data/spec/machines/evaluate_with_test_cases_spec.rb +296 -0
- data/spec/machines/select_by_summed_rank_spec.rb +134 -0
- data/spec/machines/select_nondominated_spec.rb +8 -0
- data/spec/spec_helper.rb +2 -1
- data/templates/answer_factory_activate_template.erb +44 -56
- metadata +33 -5
data/spec/spec_helper.rb
CHANGED
@@ -14,7 +14,8 @@ include AnswerFactory
|
|
14
14
|
configatron.factory.couchdb.server = 'http://127.0.0.1:5984'
|
15
15
|
|
16
16
|
#### Factory settings:
|
17
|
-
configatron.factory.name = '
|
17
|
+
configatron.factory.name = 'polynomial2'
|
18
|
+
configatron.factory.training_datasource = "http://127.0.0.1:5984/polynomial2_training"
|
18
19
|
|
19
20
|
#### Workstation definitions:
|
20
21
|
configatron.project.workstations.path = '/lib/factory/workstations/*'
|
@@ -27,68 +28,58 @@ configatron.project.nudge.types.path = '/lib/nudge/types/*'
|
|
27
28
|
#### normally these should be in /lib/factory/workstations/**
|
28
29
|
|
29
30
|
class GenerationStation < Workstation
|
30
|
-
|
31
|
-
|
31
|
+
|
32
32
|
def initialize(name, options = {})
|
33
33
|
super
|
34
34
|
@random_program_maker = Machines::BuildRandom.new(
|
35
|
-
how_many:
|
36
|
-
target_size_in_points:
|
37
|
-
reference_names:["x1", "x2"]
|
35
|
+
how_many:50,
|
36
|
+
target_size_in_points:80,
|
37
|
+
reference_names:["x1", "x2", "x3", "x4"],
|
38
|
+
instruction_names:[:int_add, :int_subtract, :int_multiply,
|
39
|
+
:int_divide, :int_modulo, :int_max, :int_min],
|
40
|
+
type_names:[:int])
|
38
41
|
end
|
39
42
|
|
40
43
|
def build!
|
41
44
|
@answers = process_with @random_program_maker
|
42
45
|
@answers.each {|a| a.location = :maker}
|
43
|
-
puts
|
44
|
-
puts "MAKER BUILD: made #{@answers.length}"
|
45
46
|
end
|
46
47
|
|
47
48
|
def ship!
|
48
|
-
ship_to(:
|
49
|
-
puts "MAKER SHIP -> POLISHER"
|
49
|
+
ship_to(:scoring_station) {true}
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
|
54
|
-
class
|
55
|
-
|
56
|
-
|
54
|
+
class ScoringStation < Workstation
|
55
|
+
|
57
56
|
def initialize(name, options = {})
|
58
57
|
super
|
59
|
-
@
|
60
|
-
|
61
|
-
:
|
62
|
-
|
58
|
+
@scorer = Machines::EvaluateWithTestCases.new(
|
59
|
+
:name => :polynomial_fit,
|
60
|
+
training_data_csv: "poly1.csv")
|
61
|
+
|
62
|
+
@scorer.install_training_data_from_csv
|
63
|
+
|
64
|
+
@scorer.build_sensor("y1") {|interpreter| interpreter.peek_value(:int) || 2000000}
|
63
65
|
end
|
64
66
|
|
65
67
|
def receive!
|
66
68
|
gather_mine
|
67
|
-
puts "POLISHER RECEIVE: got #{@answers.length}"
|
68
69
|
end
|
69
70
|
|
70
71
|
def build!
|
71
|
-
@
|
72
|
-
@mutants.each {|a| @answers << a}
|
73
|
-
@answers = process_with @score_1
|
74
|
-
puts "POLISHER BUILD: has #{@answers.length}"
|
72
|
+
@answers = process_with @scorer
|
75
73
|
end
|
76
74
|
|
77
75
|
def ship!
|
78
|
-
ship_to(:picker) {
|
79
|
-
puts "POLISHER SHIP: kept #{@answers.find_all {|a| a.location == :polisher}.length}"
|
80
|
-
end
|
81
|
-
|
82
|
-
def scrap!
|
83
|
-
scrap_if("contains 'oo'") {|a| a.blueprint.include? 'oo'}
|
84
|
-
puts "POLISHER SCRAP: kept #{@answers.find_all {|a| a.location == :polisher}.length}"
|
76
|
+
ship_to(:picker) {true}
|
85
77
|
end
|
86
78
|
end
|
87
79
|
|
88
80
|
|
89
81
|
class ScreeningStation < Workstation
|
90
|
-
|
91
|
-
|
82
|
+
|
92
83
|
def initialize(name, options = {})
|
93
84
|
super
|
94
85
|
@letters = Machines::EvaluateSimpleScore.new(
|
@@ -99,7 +90,6 @@ class ScreeningStation < Workstation
|
|
99
90
|
|
100
91
|
def receive!
|
101
92
|
gather_mine
|
102
|
-
puts "PICKER RECEIVE: got #{@answers.length}"
|
103
93
|
end
|
104
94
|
|
105
95
|
def build!
|
@@ -115,7 +105,6 @@ class ScreeningStation < Workstation
|
|
115
105
|
|
116
106
|
def scrap!
|
117
107
|
scrap_if("dominated") {|a| !@best.include?(a)}
|
118
|
-
puts "PICKER SCRAP: kept #{@answers.find_all {|a| a.location == :picker}.length}"
|
119
108
|
end
|
120
109
|
end
|
121
110
|
|
@@ -123,11 +112,10 @@ end
|
|
123
112
|
##### this will soon be an attribute of the Factory, and saved as persistent config data
|
124
113
|
# but it's the components of your Factory instance, each of which will be sent a #cycle! message,
|
125
114
|
# in this order, by the launch code below
|
126
|
-
workstations =[
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
115
|
+
# workstations =[
|
116
|
+
# GenerationStation.new(:maker),
|
117
|
+
# ScoringStation.new(:scoring_station),
|
118
|
+
# ScreeningStation.new(:picker)]
|
131
119
|
|
132
120
|
####
|
133
121
|
####
|
@@ -156,30 +144,30 @@ db = CouchRest.database!("#{configatron.factory.couchdb.server}/#{configatron.fa
|
|
156
144
|
db.delete!
|
157
145
|
db.create!
|
158
146
|
|
147
|
+
db_train = CouchRest.database!("#{configatron.factory.training_datasource}")
|
148
|
+
db_train.delete!
|
149
|
+
db_train.create!
|
150
|
+
|
159
151
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
emit(doc._id, doc);
|
164
|
-
}
|
165
|
-
}"}}})
|
152
|
+
db_train.save_doc(
|
153
|
+
{'_id' => "_design/polynomial_fit",
|
154
|
+
views: { test_cases: { map:
|
155
|
+
"function(doc) { emit(doc._id, doc); }"}}})
|
166
156
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
}"}}})
|
157
|
+
workstations =[
|
158
|
+
GenerationStation.new(:maker),
|
159
|
+
ScoringStation.new(:scoring_station),
|
160
|
+
ScreeningStation.new(:picker)]
|
172
161
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
}"}}})
|
162
|
+
|
163
|
+
|
164
|
+
# create required view document(s)
|
165
|
+
workstations.each {|ws| ws.couchdb_create_view}
|
178
166
|
|
179
167
|
|
180
168
|
# final workcycle behavior
|
181
|
-
|
169
|
+
1000.times do
|
182
170
|
workstations.each do |ws|
|
183
171
|
ws.cycle
|
184
172
|
end
|
185
|
-
end
|
173
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: answer-factory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 67
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
|
9
|
+
- 3
|
10
|
+
- 4
|
11
|
+
version: 0.1.3.4
|
10
12
|
platform: ruby
|
11
13
|
authors:
|
12
14
|
- Bill Tozier
|
@@ -16,29 +18,34 @@ autorequire:
|
|
16
18
|
bindir: bin
|
17
19
|
cert_chain: []
|
18
20
|
|
19
|
-
date: 2010-05-
|
21
|
+
date: 2010-05-27 00:00:00 -04:00
|
20
22
|
default_executable: answer-factory
|
21
23
|
dependencies:
|
22
24
|
- !ruby/object:Gem::Dependency
|
23
25
|
name: nudge
|
24
26
|
prerelease: false
|
25
27
|
requirement: &id001 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
26
29
|
requirements:
|
27
30
|
- - ">="
|
28
31
|
- !ruby/object:Gem::Version
|
32
|
+
hash: 5
|
29
33
|
segments:
|
30
34
|
- 0
|
31
35
|
- 2
|
32
|
-
|
36
|
+
- 9
|
37
|
+
version: 0.2.9
|
33
38
|
type: :runtime
|
34
39
|
version_requirements: *id001
|
35
40
|
- !ruby/object:Gem::Dependency
|
36
41
|
name: thor
|
37
42
|
prerelease: false
|
38
43
|
requirement: &id002 !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
39
45
|
requirements:
|
40
46
|
- - ">="
|
41
47
|
- !ruby/object:Gem::Version
|
48
|
+
hash: 17
|
42
49
|
segments:
|
43
50
|
- 0
|
44
51
|
- 13
|
@@ -49,9 +56,11 @@ dependencies:
|
|
49
56
|
name: couchrest
|
50
57
|
prerelease: false
|
51
58
|
requirement: &id003 !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
52
60
|
requirements:
|
53
61
|
- - ">="
|
54
62
|
- !ruby/object:Gem::Version
|
63
|
+
hash: 73
|
55
64
|
segments:
|
56
65
|
- 0
|
57
66
|
- 33
|
@@ -62,9 +71,11 @@ dependencies:
|
|
62
71
|
name: configatron
|
63
72
|
prerelease: false
|
64
73
|
requirement: &id004 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
65
75
|
requirements:
|
66
76
|
- - ">="
|
67
77
|
- !ruby/object:Gem::Version
|
78
|
+
hash: 19
|
68
79
|
segments:
|
69
80
|
- 2
|
70
81
|
- 6
|
@@ -76,9 +87,11 @@ dependencies:
|
|
76
87
|
name: fakeweb
|
77
88
|
prerelease: false
|
78
89
|
requirement: &id005 !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
79
91
|
requirements:
|
80
92
|
- - ">="
|
81
93
|
- !ruby/object:Gem::Version
|
94
|
+
hash: 73
|
82
95
|
segments:
|
83
96
|
- 0
|
84
97
|
- 33
|
@@ -89,9 +102,11 @@ dependencies:
|
|
89
102
|
name: sinatra
|
90
103
|
prerelease: false
|
91
104
|
requirement: &id006 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
92
106
|
requirements:
|
93
107
|
- - ">="
|
94
108
|
- !ruby/object:Gem::Version
|
109
|
+
hash: 51
|
95
110
|
segments:
|
96
111
|
- 0
|
97
112
|
- 9
|
@@ -103,9 +118,11 @@ dependencies:
|
|
103
118
|
name: activesupport
|
104
119
|
prerelease: false
|
105
120
|
requirement: &id007 !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
106
122
|
requirements:
|
107
123
|
- - ">="
|
108
124
|
- !ruby/object:Gem::Version
|
125
|
+
hash: 9
|
109
126
|
segments:
|
110
127
|
- 2
|
111
128
|
- 3
|
@@ -138,20 +155,25 @@ files:
|
|
138
155
|
- lib/machines/any_one.rb
|
139
156
|
- lib/machines/build_random.rb
|
140
157
|
- lib/machines/evaluate_simple_score.rb
|
158
|
+
- lib/machines/evaluate_with_test_cases.rb
|
141
159
|
- lib/machines/infrastructure.rb
|
142
160
|
- lib/machines/mutate_footnotes.rb
|
161
|
+
- lib/machines/select_by_summed_rank.rb
|
143
162
|
- lib/machines/select_nondominated.rb
|
144
163
|
- readme.md
|
145
164
|
- spec/answers/answer_spec.rb
|
146
165
|
- spec/answers/batch_spec.rb
|
147
166
|
- spec/factories/factory_spec.rb
|
148
167
|
- spec/factories/workstation_spec.rb
|
168
|
+
- spec/fixtures/my_data_source.csv
|
149
169
|
- spec/integration_specs/couch_db_integration.rspec
|
150
170
|
- spec/machines/any_one_spec.rb
|
151
171
|
- spec/machines/build_random_spec.rb
|
152
172
|
- spec/machines/evaluate_simple_score_spec.rb
|
173
|
+
- spec/machines/evaluate_with_test_cases_spec.rb
|
153
174
|
- spec/machines/infrastructure_spec.rb
|
154
175
|
- spec/machines/mutate_footnotes_spec.rb
|
176
|
+
- spec/machines/select_by_summed_rank_spec.rb
|
155
177
|
- spec/machines/select_nondominated_spec.rb
|
156
178
|
- spec/spec_helper.rb
|
157
179
|
- tasks/setup_factory.thor
|
@@ -167,25 +189,29 @@ rdoc_options:
|
|
167
189
|
require_paths:
|
168
190
|
- lib
|
169
191
|
required_ruby_version: !ruby/object:Gem::Requirement
|
192
|
+
none: false
|
170
193
|
requirements:
|
171
194
|
- - ">="
|
172
195
|
- !ruby/object:Gem::Version
|
196
|
+
hash: 49
|
173
197
|
segments:
|
174
198
|
- 1
|
175
199
|
- 9
|
176
200
|
- 1
|
177
201
|
version: 1.9.1
|
178
202
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
|
+
none: false
|
179
204
|
requirements:
|
180
205
|
- - ">="
|
181
206
|
- !ruby/object:Gem::Version
|
207
|
+
hash: 3
|
182
208
|
segments:
|
183
209
|
- 0
|
184
210
|
version: "0"
|
185
211
|
requirements: []
|
186
212
|
|
187
213
|
rubyforge_project:
|
188
|
-
rubygems_version: 1.3.
|
214
|
+
rubygems_version: 1.3.7
|
189
215
|
signing_key:
|
190
216
|
specification_version: 3
|
191
217
|
summary: Genetic Programming in the Nudge language
|
@@ -197,7 +223,9 @@ test_files:
|
|
197
223
|
- spec/machines/any_one_spec.rb
|
198
224
|
- spec/machines/build_random_spec.rb
|
199
225
|
- spec/machines/evaluate_simple_score_spec.rb
|
226
|
+
- spec/machines/evaluate_with_test_cases_spec.rb
|
200
227
|
- spec/machines/infrastructure_spec.rb
|
201
228
|
- spec/machines/mutate_footnotes_spec.rb
|
229
|
+
- spec/machines/select_by_summed_rank_spec.rb
|
202
230
|
- spec/machines/select_nondominated_spec.rb
|
203
231
|
- spec/spec_helper.rb
|