feldtruby 0.4.11 → 0.4.12

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: 80276e85ca35677642bd949c9c7c55d5647f040d
4
+ data.tar.gz: f15ba5e0a5b4d6ff60e2c974a5c6560723a318ab
5
+ SHA512:
6
+ metadata.gz: 05e6499886ac5c29c2de3848ef24387c138ed14fb4f1a05af9a7a4dfd9e763203b9dc34d8e2705cab6e841bd5501bc2f7eadbc553de932dc8d38c2826938df61
7
+ data.tar.gz: fff4b90d0b79589ad20839b71692e0c265296989a642d089d4cfa156e4db5f167f4c5b7afb64a39b9da112c00da31fffa341d7e95145c7a0e05e904367e2115d
data/archive.json ADDED
@@ -0,0 +1,124 @@
1
+ {
2
+ "json_class": "FeldtRuby::Optimize::Archive",
3
+ "data": {
4
+ "generalists": {
5
+ "json_class": "FeldtRuby::Optimize::Archive::GlobalTopList",
6
+ "data": {
7
+ "max_size": 20,
8
+ "top_list": [
9
+ "Vector[495.6220472008826, 426.35485642424766]",
10
+ "Vector[495.62205148094733, 426.354855256089]",
11
+ "Vector[495.62206987534034, 426.35501558097434]",
12
+ "Vector[495.62206987534034, 426.35501558097434]",
13
+ "Vector[495.6222720656514, 426.3550214881676]",
14
+ "Vector[495.62243252506755, 426.3551965381708]",
15
+ "Vector[495.6225366749033, 426.35541061734784]",
16
+ "Vector[495.62212266198037, 426.35508493132687]",
17
+ "Vector[495.6221285692303, 426.35482208453755]",
18
+ "Vector[495.62193937576654, 426.3546416267843]",
19
+ "Vector[495.6217543885617, 426.3547529062279]",
20
+ "Vector[495.6218500005808, 426.3545574537555]",
21
+ "Vector[495.62205148094733, 426.35473354022747]",
22
+ "Vector[495.6224622727039, 426.35513589259864]",
23
+ "Vector[495.6219540985794, 426.3549875733886]",
24
+ "Vector[495.6213699750297, 426.3542789980689]",
25
+ "Vector[495.6216018228837, 426.3546210939662]",
26
+ "Vector[495.6213463241329, 426.3542924512532]",
27
+ "Vector[495.6226218518193, 426.3556277556064]",
28
+ "Vector[495.6229365324784, 426.3556566577018]"
29
+ ],
30
+ "quality_values": [
31
+ "100.0% (SubQs = [6.14e-09], ver. 43)",
32
+ "100.0% (SubQs = [7.38e-09], ver. 43)",
33
+ "100.0% (SubQs = [2.65e-08], ver. 43)",
34
+ "100.0% (SubQs = [2.65e-08], ver. 43)",
35
+ "100.0% (SubQs = [2.84e-08], ver. 43)",
36
+ "100.0% (SubQs = [3.16e-08], ver. 43)",
37
+ "100.0% (SubQs = [3.63e-08], ver. 43)",
38
+ "100.0% (SubQs = [3.72e-08], ver. 43)",
39
+ "100.0% (SubQs = [6.82e-08], ver. 43)",
40
+ "100.0% (SubQs = [7.38e-08], ver. 43)",
41
+ "100.0% (SubQs = [7.61e-08], ver. 43)",
42
+ "100.0% (SubQs = [8.0e-08], ver. 43)",
43
+ "100.0% (SubQs = [8.29e-08], ver. 43)",
44
+ "100.0% (SubQs = [9.39e-08], ver. 43)",
45
+ "100.0% (SubQs = [9.58e-08], ver. 43)",
46
+ "100.0% (SubQs = [1.04e-07], ver. 43)",
47
+ "100.0% (SubQs = [1.12e-07], ver. 43)",
48
+ "100.0% (SubQs = [1.21e-07], ver. 43)",
49
+ "100.0% (SubQs = [1.37e-07], ver. 43)",
50
+ "100.0% (SubQs = [1.44e-07], ver. 43)"
51
+ ],
52
+ "objective": "#<MinEggHolder:0x007fe62a945878>"
53
+ }
54
+ },
55
+ "specialists": [
56
+ {
57
+ "json_class": "FeldtRuby::Optimize::Archive::GoalTopList",
58
+ "data": {
59
+ "max_size": 5,
60
+ "top_list": [
61
+ "Vector[495.6220472008826, 426.35485642424766]",
62
+ "Vector[495.62205148094733, 426.354855256089]",
63
+ "Vector[495.62206987534034, 426.35501558097434]",
64
+ "Vector[495.62206987534034, 426.35501558097434]",
65
+ "Vector[495.6222720656514, 426.3550214881676]"
66
+ ],
67
+ "quality_values": [
68
+ "100.0% (SubQs = [6.14e-09], ver. 43)",
69
+ "100.0% (SubQs = [7.38e-09], ver. 43)",
70
+ "100.0% (SubQs = [2.65e-08], ver. 43)",
71
+ "100.0% (SubQs = [2.65e-08], ver. 43)",
72
+ "100.0% (SubQs = [2.84e-08], ver. 43)"
73
+ ],
74
+ "objective": "#<MinEggHolder:0x007fe62a945878>",
75
+ "objective_index": 0,
76
+ "objective_name": "objective_min_func"
77
+ }
78
+ }
79
+ ],
80
+ "weirdos": {
81
+ "json_class": "FeldtRuby::Optimize::Archive::WeirdoTopList",
82
+ "data": {
83
+ "max_size": 10,
84
+ "top_list": [
85
+ "Vector[507.3847536905826, -428.24322756547286]",
86
+ "Vector[508.6757864296741, -425.8072060429839]",
87
+ "Vector[511.8607587787378, -424.7094976121834]",
88
+ "Vector[500.3795974754322, -424.47828024297644]",
89
+ "Vector[511.7927496243458, -423.6663163699823]",
90
+ "Vector[505.7249524392083, -421.85963040462264]",
91
+ "Vector[509.5386880993205, -421.0315337832495]",
92
+ "Vector[507.3309830642148, -418.7568618991539]",
93
+ "Vector[507.72601159816423, -417.65978621902434]",
94
+ "Vector[505.48809715871784, -417.65978621902434]"
95
+ ],
96
+ "quality_values": [
97
+ "95.1569% (SubQs = [92.1], ver. 43)",
98
+ "95.7011% (SubQs = [81.8], ver. 43)",
99
+ "96.0874% (SubQs = [74.4], ver. 43)",
100
+ "94.0684% (SubQs = [113.0], ver. 43)",
101
+ "96.0299% (SubQs = [75.5], ver. 43)",
102
+ "95.2259% (SubQs = [90.8], ver. 43)",
103
+ "95.5442% (SubQs = [84.7], ver. 43)",
104
+ "94.8863% (SubQs = [97.2], ver. 43)",
105
+ "94.6025% (SubQs = [103.0], ver. 43)",
106
+ "94.4247% (SubQs = [106.0], ver. 43)"
107
+ ],
108
+ "objective": "#<FeldtRuby::Optimize::EuclideanDistanceToBest:0x007fe62b86c900>",
109
+ "diversity_quality_values": [
110
+ "95.4506% (SubQs = [855.0], ver. 26)",
111
+ "95.1807% (SubQs = [852.0], ver. 26)",
112
+ "95.0642% (SubQs = [851.0], ver. 26)",
113
+ "95.0226% (SubQs = [851.0], ver. 26)",
114
+ "94.9476% (SubQs = [850.0], ver. 26)",
115
+ "94.7354% (SubQs = [848.0], ver. 26)",
116
+ "94.6489% (SubQs = [848.0], ver. 26)",
117
+ "94.3912% (SubQs = [845.0], ver. 26)",
118
+ "94.2693% (SubQs = [844.0], ver. 26)",
119
+ "94.2661% (SubQs = [844.0], ver. 26)"
120
+ ]
121
+ }
122
+ }
123
+ }
124
+ }
@@ -1,5 +1,6 @@
1
1
  require 'feldtruby/optimize'
2
2
  require 'feldtruby/logger'
3
+ require 'json'
3
4
 
4
5
  module FeldtRuby::Optimize
5
6
 
@@ -90,7 +91,7 @@ class Archive
90
91
 
91
92
  @generalists = GlobalTopList.new(@params[:NumTopAggregate], @objective)
92
93
 
93
- @weirdos = GlobalTopList.new(@params[:NumTopDiversityAggregate], @diversity_objective)
94
+ @weirdos = WeirdoTopList.new(@params[:NumTopDiversityAggregate], @diversity_objective, @objective)
94
95
  end
95
96
 
96
97
  # Add a candidate to the top lists if it is good enough to be there. Throws
@@ -113,7 +114,19 @@ class Archive
113
114
  "Old best" => prev_best,
114
115
  "Old quality" => prev_qv}, "Archive: New best solution found", true
115
116
 
116
- @weirdos.each {|w| @diversity_objective.invalidate_quality_of(w)}
117
+ # We must delete weirdos that are no longer good enough to be on the
118
+ # weirdos list.
119
+ to_delete = []
120
+ @weirdos.each {|w|
121
+ # Invalidate quality since it must now be re-calculated (since it will
122
+ # typically depend on the best and we have a new best...)
123
+ @diversity_objective.invalidate_quality_of(w)
124
+
125
+ to_delete << w unless good_enough_quality_to_be_interesting?(w)
126
+ }
127
+ #puts "Deleting #{to_delete.length} out of #{@weirdos.length} weirdos"
128
+ #@weirdos.delete_candidates(to_delete)
129
+
117
130
  elsif good_enough_quality_to_be_interesting?(candidate)
118
131
  # When we add a new one this will lead to re-calc of the diversity quality
119
132
  # of the previous ones if there has been a new best since last time.
@@ -124,13 +137,16 @@ class Archive
124
137
  # Is quality of candidate good enough (within MaxPercentDistanceToBestForDiversity
125
138
  # from quality of best candidate)
126
139
  def good_enough_quality_to_be_interesting?(candidate)
127
- qv_best = @objective.quality_of(best).value
128
- ((qv_best - @objective.quality_of(candidate).value).abs / qv_best) <= @params[:MaxPercentDistanceToBestForDiversity]
140
+ qv_best = @objective.quality_of(best).display_value
141
+ qv = @objective.quality_of(candidate).display_value
142
+ res = ((qv_best - qv).abs / qv_best) <= @params[:MaxPercentDistanceToBestForDiversity]
143
+ #puts "qvbest = #{qv_best}, qv = #{qv}, res = #{res}"
144
+ res
129
145
  end
130
146
 
131
147
  # A top list is an array of a fixed size that saves the top candidates
132
148
  # based on their (aggregate) quality values.
133
- class GlobalTopList
149
+ class GlobalTopList
134
150
  def initialize(maxSize, objective)
135
151
  @max_size =maxSize
136
152
  @top_list = Array.new
@@ -159,6 +175,10 @@ class Archive
159
175
  @objective.is_better_than?(candidate1, candidate2)
160
176
  end
161
177
 
178
+ def delete_candidates(candidates)
179
+ @top_list = @top_list - candidates
180
+ end
181
+
162
182
  def sort_top_list
163
183
  @top_list.sort_by {|c| @objective.quality_of(c).value}
164
184
  end
@@ -166,6 +186,38 @@ class Archive
166
186
  def inspect
167
187
  self.class.inspect + @top_list.inspect
168
188
  end
189
+
190
+ def to_json(*a)
191
+ {
192
+ 'json_class' => self.class.name,
193
+ 'data' => data_to_json_hash,
194
+ }.to_json(*a)
195
+ end
196
+
197
+ def data_to_json_hash
198
+ {
199
+ 'max_size' => @max_size,
200
+ 'top_list' => @top_list,
201
+ 'quality_values' => @top_list.map {|c| @objective.quality_of(c)},
202
+ 'objective' => @objective
203
+ }
204
+ end
205
+ end
206
+
207
+ class WeirdoTopList < GlobalTopList
208
+ def initialize(maxSize, diversityObjective, qualityObjective)
209
+ super(maxSize, diversityObjective)
210
+ @quality_objective = qualityObjective
211
+ end
212
+
213
+ def data_to_json_hash
214
+ h = super()
215
+ # Since the diversity objective is used to sort the weirdos their
216
+ # 'quality_values' are actually the diversity quality values.
217
+ h['diversity_quality_values'] = h['quality_values']
218
+ h['quality_values'] = @top_list.map {|c| @quality_objective.quality_of(c)}
219
+ h
220
+ end
169
221
  end
170
222
 
171
223
  class GoalTopList < GlobalTopList
@@ -182,6 +234,24 @@ class Archive
182
234
  qv.sub_quality(@index, true) # We want the sub quality value posed as a minimization goal regardless of whether it is a min or max goal
183
235
  }
184
236
  end
237
+
238
+ # We add additional data about which goal/objective we are a top list for.
239
+ def data_to_json_hash
240
+ h = super()
241
+ h['objective_index'] = @index
242
+ h['objective_name'] = @objective.goal_methods[@index]
243
+ h
244
+ end
245
+ end
246
+
247
+ def to_json(*a)
248
+ {
249
+ 'json_class' => self.class.name,
250
+ 'data' => {
251
+ 'generalists' => @generalists,
252
+ 'specialists' => @specialists,
253
+ 'weirdos' => @weirdos},
254
+ }.to_json(*a)
185
255
  end
186
256
  end
187
257
 
@@ -473,8 +473,13 @@ class QualityValue
473
473
  -(@sub_qualities[index])
474
474
  end
475
475
 
476
+ # The value to display. For this default class we just use the quality value.
477
+ def display_value
478
+ value
479
+ end
480
+
476
481
  def value_to_s
477
- "#{value.to_significant_digits(4)}"
482
+ "#{display_value.to_significant_digits(4)}"
478
483
  end
479
484
 
480
485
  def to_s
@@ -486,9 +491,12 @@ class QualityValue
486
491
  end
487
492
 
488
493
  class PercentageQualityValue < QualityValue
494
+ def display_value
495
+ (1.0 - value) * 100.0
496
+ end
489
497
  def value_to_s
490
498
  return "N/A" if @sub_qualities.any? {|sq| sq.nil?}
491
- "%s%%" % ((1.0 - value) * 100.0).to_significant_digits(6).to_s
499
+ "%s%%" % display_value.to_significant_digits(6).to_s
492
500
  end
493
501
  end
494
502
 
@@ -110,6 +110,23 @@ class RCommunicator
110
110
  end
111
111
  end
112
112
 
113
+ # Pull a matrix variable into a hash and name the columns according to
114
+ # values in columnNames.
115
+ def pull_matrix_variable_to_hash_with_column_names(variableName, columnNames)
116
+ var = arg_name(rand(1e5), variableName)
117
+ RC.eval "#{var} <- toJSON(data.frame(#{variableName}));"
118
+ hash = pull_json_variable(var).to_h
119
+
120
+ # Now convert back to the proper parameter names and delete the ones generated by lhs.
121
+ index = 0
122
+ columnNames.each do |p|
123
+ name_of_column = "X#{index += 1}"
124
+ hash[p] = hash[name_of_column]
125
+ hash.delete(name_of_column)
126
+ end
127
+ hash
128
+ end
129
+
113
130
  # Convert a Ruby object of one of the types String, Symbol, Array, Integer
114
131
  # or Float to a String that can be used in R code/scripts to
115
132
  # represent the object.
@@ -0,0 +1,48 @@
1
+ module FeldtRuby::Statistics
2
+
3
+ # Functions for designing parameter exploration experiments using Bayesian
4
+ # Treed Gaussian Process models.
5
+ #
6
+ # Parameters are assumed to be given in a hash, mapping a parameter name to its
7
+ # range of allowed values, like:
8
+ #
9
+ # IndependenVars = {
10
+ # :PopulationSize => [5, 500],
11
+ # :PopulationSamplerRadius => [4, 500], # must actually be smaller than the population size or it makes no difference, how to spec such constraints?
12
+ # :F => [0.0, 1.0],
13
+ # :CR => [0.0, 1.0],
14
+ # :numEvals => [1e3, 1e5] # Or should we vary this for each setting of the others and just measure the outputs at several points of numEvals?
15
+ # }
16
+ #
17
+ # DependentVars = {
18
+ # Y1 = # execution_time for running the algorithm
19
+ # Y2 = # best model RMS error
20
+ # }
21
+ module DesignOfExperiments
22
+ # Do a latin hypercube sampling of the parameter space with bouding box per
23
+ # parameter specified in _parameters_.
24
+ def latin_hypercube_sample_of_parameters(parameters, numSamples)
25
+ include_library("tgp")
26
+ param_order = parameters.keys.sort
27
+ script = <<-EOS
28
+ params <- #{parameters_to_R_data_frame(parameters, param_order)};
29
+ x_candidates <- lhs(#{numSamples}, params);
30
+ EOS
31
+ subst_eval script, {}
32
+ pull_matrix_variable_to_hash_with_column_names "x_candidates", param_order
33
+ end
34
+
35
+ def parameters_to_R_data_frame(parameters, param_order = parameter.keys)
36
+ s = param_order.map do |p|
37
+ lim = parameters[p]
38
+ "c(#{lim[0]}, #{lim[1]})"
39
+ end.join(", ")
40
+ "rbind(#{s})"
41
+ end
42
+ end
43
+
44
+ end
45
+
46
+ class FeldtRuby::RCommunicator
47
+ include FeldtRuby::Statistics::DesignOfExperiments
48
+ end
@@ -1,3 +1,3 @@
1
1
  module FeldtRuby
2
- VERSION = "0.4.11"
2
+ VERSION = "0.4.12"
3
3
  end
@@ -0,0 +1,147 @@
1
+ {
2
+ "json_class": "FeldtRuby::Optimize::Archive",
3
+ "data": {
4
+ "generalists": {
5
+ "json_class": "FeldtRuby::Optimize::Archive::GlobalTopList",
6
+ "data": {
7
+ "max_size": 20,
8
+ "top_list": [
9
+ "Vector[3.92978592984352e-34, 3.177186083763661e-35, -6.705768207338718e-34, -1.6854383035496224e-34]",
10
+ "Vector[1.5144596966432141e-34, 3.2854085523776127e-34, -4.919007599874781e-34, -5.254279363766363e-34]",
11
+ "Vector[5.690616393750528e-34, -2.3355528642494594e-34, 4.643573191513474e-34, -1.917310422255142e-34]",
12
+ "Vector[5.841696796512456e-34, 5.961044199327782e-34, 1.493847002166183e-35, -1.0898686439738699e-33]",
13
+ "Vector[-1.430133126940755e-34, -9.3610480250286e-34, 2.1346746119941773e-34, -1.5536563098293578e-34]",
14
+ "Vector[-7.985448841993761e-34, -4.650702542519649e-34, 1.0333041708593775e-34, -1.715732599374026e-34]",
15
+ "Vector[-3.2974922751978836e-34, -1.1378942343472195e-33, 1.2433783562274253e-34, 1.2911154676479549e-33]",
16
+ "Vector[-4.316734242818529e-34, -1.1378942343472195e-33, 1.2433783562274253e-34, 1.2911154676479549e-33]",
17
+ "Vector[7.714498498702072e-34, 1.4732439530231907e-34, 4.776830230246573e-34, 1.319508569506661e-34]",
18
+ "Vector[6.123633511609725e-34, -2.62755936793382e-34, -1.3377160149401275e-33, 3.895644744559003e-34]",
19
+ "Vector[-4.176201753482501e-34, 7.954221933754592e-34, -1.5160566450653443e-33, 3.7883757691656654e-34]",
20
+ "Vector[-7.723590455216934e-34, -2.3355528642494594e-34, 4.643573191513474e-34, 1.4410131568651712e-33]",
21
+ "Vector[1.436165919956631e-33, 2.9867170288833136e-34, -1.5906202273547187e-33, -3.6632624990326594e-34]",
22
+ "Vector[1.5144596966432141e-34, 1.626004974771429e-33, -4.919007599874781e-34, -3.23180762074661e-34]",
23
+ "Vector[-1.430133126940755e-34, -9.3610480250286e-34, 2.1346746119941773e-34, -9.510504303572618e-34]",
24
+ "Vector[-1.5350491811590863e-33, -5.341963141796802e-34, 1.5575490243063648e-33, -1.1393839558555175e-35]",
25
+ "Vector[-1.5350491811590863e-33, -5.341963141796802e-34, 8.732015868384436e-34, -1.1393839558555175e-35]",
26
+ "Vector[2.1481152051158145e-34, -1.1561136621745396e-33, 1.1802401093042232e-33, -1.1926088222499382e-33]",
27
+ "Vector[5.4468703973847035e-34, 1.3947548738235502e-33, 4.244444951915549e-34, -1.5154918934744699e-33]",
28
+ "Vector[4.407040152206215e-34, -2.6755349121192108e-34, -7.009651291770463e-34, -1.374288578447605e-33]"
29
+ ],
30
+ "quality_values": [
31
+ "100.0% (SubQs = [4.14e-34, 3.98e-34], ver. 420)",
32
+ "100.0% (SubQs = [5.37e-34, 4.03e-34], ver. 420)",
33
+ "100.0% (SubQs = [6.08e-34, 3.97e-34], ver. 420)",
34
+ "100.0% (SubQs = [1.05e-34, 6.86e-34], ver. 420)",
35
+ "100.0% (SubQs = [1.02e-33, 4.92e-34], ver. 420)",
36
+ "100.0% (SubQs = [1.33e-33, 4.73e-34], ver. 420)",
37
+ "100.0% (SubQs = [5.22e-35, 8.78e-34], ver. 420)",
38
+ "100.0% (SubQs = [1.54e-34, 8.89e-34], ver. 420)",
39
+ "100.0% (SubQs = [1.53e-33, 4.64e-34], ver. 420)",
40
+ "100.0% (SubQs = [5.99e-34, 7.72e-34], ver. 420)",
41
+ "100.0% (SubQs = [7.59e-34, 9.01e-34], ver. 420)",
42
+ "100.0% (SubQs = [8.99e-34, 8.58e-34], ver. 420)",
43
+ "100.0% (SubQs = [2.22e-34, 1.1e-33], ver. 420)",
44
+ "100.0% (SubQs = [9.62e-34, 8.68e-34], ver. 420)",
45
+ "100.0% (SubQs = [1.82e-33, 6.79e-34], ver. 420)",
46
+ "100.0% (SubQs = [5.23e-34, 1.13e-33], ver. 420)",
47
+ "100.0% (SubQs = [1.21e-33, 9.23e-34], ver. 420)",
48
+ "100.0% (SubQs = [9.54e-34, 1.02e-33], ver. 420)",
49
+ "100.0% (SubQs = [8.48e-34, 1.09e-33], ver. 420)",
50
+ "100.0% (SubQs = [1.9e-33, 8.13e-34], ver. 420)"
51
+ ],
52
+ "objective": "#<MinimizeRMSAndSum:0x007fe9a184be70>"
53
+ }
54
+ },
55
+ "specialists": [
56
+ {
57
+ "json_class": "FeldtRuby::Optimize::Archive::GoalTopList",
58
+ "data": {
59
+ "max_size": 5,
60
+ "top_list": [
61
+ "Vector[-9.615930905072786e-33, 4.59127418428953e-33, 1.5234591770668713e-32, -1.0213910705788213e-32]",
62
+ "Vector[2.9703517549037285e-33, -1.248167005887202e-32, 1.1288694472406572e-32, -1.7718788688711247e-33]",
63
+ "Vector[1.1474528493196208e-32, -2.7528425396866883e-33, 2.6715836582877643e-33, -1.1400340625482263e-32]",
64
+ "Vector[4.449719771038471e-33, 1.850578404606684e-32, -1.372599097841034e-32, -9.215288004790806e-33]",
65
+ "Vector[-3.571926477368521e-32, 3.244495926808932e-32, -5.418334544872519e-33, 8.713179387296223e-33]"
66
+ ],
67
+ "quality_values": [
68
+ "100.0% (SubQs = [3.98e-36, 1.06e-32], ver. 420)",
69
+ "100.0% (SubQs = [5.5e-36, 8.59e-33], ver. 420)",
70
+ "100.0% (SubQs = [7.07e-36, 8.31e-33], ver. 420)",
71
+ "100.0% (SubQs = [1.42e-35, 1.26e-32], ver. 420)",
72
+ "100.0% (SubQs = [2.05e-35, 2.47e-32], ver. 420)"
73
+ ],
74
+ "objective": "#<MinimizeRMSAndSum:0x007fe9a184be70>",
75
+ "objective_index": 0,
76
+ "objective_name": "objective_min_sum"
77
+ }
78
+ },
79
+ {
80
+ "json_class": "FeldtRuby::Optimize::Archive::GoalTopList",
81
+ "data": {
82
+ "max_size": 5,
83
+ "top_list": [
84
+ "Vector[5.690616393750528e-34, -2.3355528642494594e-34, 4.643573191513474e-34, -1.917310422255142e-34]",
85
+ "Vector[3.92978592984352e-34, 3.177186083763661e-35, -6.705768207338718e-34, -1.6854383035496224e-34]",
86
+ "Vector[1.5144596966432141e-34, 3.2854085523776127e-34, -4.919007599874781e-34, -5.254279363766363e-34]",
87
+ "Vector[7.714498498702072e-34, 1.4732439530231907e-34, 4.776830230246573e-34, 1.319508569506661e-34]",
88
+ "Vector[-7.985448841993761e-34, -4.650702542519649e-34, 1.0333041708593775e-34, -1.715732599374026e-34]"
89
+ ],
90
+ "quality_values": [
91
+ "100.0% (SubQs = [6.08e-34, 3.97e-34], ver. 420)",
92
+ "100.0% (SubQs = [4.14e-34, 3.98e-34], ver. 420)",
93
+ "100.0% (SubQs = [5.37e-34, 4.03e-34], ver. 420)",
94
+ "100.0% (SubQs = [1.53e-33, 4.64e-34], ver. 420)",
95
+ "100.0% (SubQs = [1.33e-33, 4.73e-34], ver. 420)"
96
+ ],
97
+ "objective": "#<MinimizeRMSAndSum:0x007fe9a184be70>",
98
+ "objective_index": 1,
99
+ "objective_name": "objective_min_rms"
100
+ }
101
+ }
102
+ ],
103
+ "weirdos": {
104
+ "json_class": "FeldtRuby::Optimize::Archive::WeirdoTopList",
105
+ "data": {
106
+ "max_size": 10,
107
+ "top_list": [
108
+ "Vector[-0.0019044882512560613, 0.009481335601935582, -0.024299149058169944, 0.01644621882943969]",
109
+ "Vector[-0.002336002098539184, -0.0011328152153534908, -0.002919457015502706, 0.005384406255801217]",
110
+ "Vector[-0.000212713252898527, -0.00026116276684590893, -0.00015700863312597923, 0.0006925169327167096]",
111
+ "Vector[-0.0006292872425139322, 0.00028433348523478833, -3.296307630564648e-05, 0.00025614364670802737]",
112
+ "Vector[-0.00044589271102821995, 0.0001507180794986237, 0.0005375696283590799, -0.00012391959968973396]",
113
+ "Vector[0.0002685510741798464, -0.00018255262169129994, 0.00011099055409430846, 0.00033646021393768475]",
114
+ "Vector[-2.9171529527878796e-05, -6.5003814421593835e-06, -8.256851193381469e-06, 5.0270287068797815e-05]",
115
+ "Vector[1.1999984048880376e-05, -3.223391818033675e-05, 1.1715098248587656e-05, -1.80284782645308e-06]",
116
+ "Vector[1.285250921671595e-07, -7.961342736434783e-08, -5.3641724601111016e-08, -1.4897905737316017e-07]",
117
+ "Vector[3.857240621811628e-08, 9.77694067874942e-08, -1.2780417924260806e-07, 3.661084070782956e-07]"
118
+ ],
119
+ "quality_values": [
120
+ "99.1567% (SubQs = [0.000276, 0.0154], ver. 420)",
121
+ "99.8024% (SubQs = [0.001, 0.00333], ver. 420)",
122
+ "99.9776% (SubQs = [6.16e-05, 0.000393], ver. 420)",
123
+ "99.9779% (SubQs = [0.000122, 0.000369], ver. 420)",
124
+ "99.9783% (SubQs = [0.000118, 0.000363], ver. 420)",
125
+ "99.9779% (SubQs = [0.000533, 0.00024], ver. 420)",
126
+ "99.9983% (SubQs = [6.34e-06, 2.95e-05], ver. 420)",
127
+ "99.9988% (SubQs = [1.03e-05, 1.82e-05], ver. 420)",
128
+ "100.0% (SubQs = [1.54e-07, 1.09e-07], ver. 420)",
129
+ "100.0% (SubQs = [3.75e-07, 2.01e-07], ver. 420)"
130
+ ],
131
+ "objective": "#<FeldtRuby::Optimize::EuclideanDistanceToBest:0x007fe9a1853ff8>",
132
+ "diversity_quality_values": [
133
+ "90.3578% (SubQs = [0.0309], ver. 39)",
134
+ "19.4568% (SubQs = [0.00665], ver. 39)",
135
+ "2.29865% (SubQs = [0.000786], ver. 39)",
136
+ "2.15629% (SubQs = [0.000737], ver. 39)",
137
+ "2.12095% (SubQs = [0.000725], ver. 39)",
138
+ "1.40562% (SubQs = [0.000481], ver. 39)",
139
+ "0.172746% (SubQs = [5.91e-05], ver. 39)",
140
+ "0.106403% (SubQs = [3.64e-05], ver. 39)",
141
+ "0.000640308% (SubQs = [2.19e-07], ver. 39)",
142
+ "0.00117507% (SubQs = [4.02e-07], ver. 39)"
143
+ ]
144
+ }
145
+ }
146
+ }
147
+ }
@@ -15,7 +15,9 @@ def best_from_de_on_objective(objective, dimensions, numSteps = 25_000,
15
15
  best = de.optimize().to_a
16
16
  elapsed = Time.now - start_time
17
17
 
18
- return best, objective, elapsed
18
+ return best, objective, elapsed, de
19
19
  end
20
20
 
21
- best, obj, time = best_from_de_on_objective MinSphere.new, 30, 220_000
21
+ #best, obj, time, de = best_from_de_on_objective MinSphere.new, 30, 220_000
22
+ best, obj, time, de = best_from_de_on_objective MinEggHolder.new, nil, 15_000
23
+ File.open("archive.json", "w") {|fh| fh.puts(JSON.pretty_generate(de.archive))}
@@ -24,4 +24,6 @@ o2 = MinimizeRMSAndSum.new
24
24
 
25
25
  de = DEOptimizer.new(o2, s4, {:verbose => true, :maxNumSteps => $NumSteps})
26
26
 
27
- de.optimize()
27
+ best = de.optimize()
28
+
29
+ File.open("archive.json", "w") {|fh| fh.puts(JSON.pretty_generate(de.archive))}
@@ -1,5 +1,5 @@
1
- require File.join(FeldtRubyLongTestDir, "single_objective_problems")
2
1
  require 'feldtruby/optimize/differential_evolution'
2
+ require 'feldtruby/optimize/problems/single_objective_problems'
3
3
  include FeldtRuby::Optimize
4
4
 
5
5
  module MiniTest::Assertions
@@ -79,7 +79,7 @@ end
79
79
 
80
80
  describe "Easom function" do
81
81
  it 'can optimize the Easom function' do
82
- best, obj, time = best_from_de_on_objective MinEasom.new, nil, 10_000, false, FeldtRuby::Optimize::DEOptimizer_Best_1_Bin
82
+ best, obj, time = best_from_de_on_objective MinEasom.new, nil, 15_000, false, FeldtRuby::Optimize::DEOptimizer_Best_1_Bin
83
83
  best.must_be_close_to_one_solution_of obj
84
84
  time.must_be :<, 1.5
85
85
  end
@@ -0,0 +1,35 @@
1
+ require 'feldtruby/statistics/design_of_experiments'
2
+
3
+ describe 'Latin Hypercube Sampling' do
4
+ it "can sample in a rectangular multi-dim bounding box" do
5
+ params = {
6
+ :a => [0,100],
7
+ :b => [0,50],
8
+ :c => [0.0, 1.0]
9
+ }
10
+ candidates = RC.latin_hypercube_sample_of_parameters(params, 100)
11
+ candidates.must_be_instance_of Hash
12
+ candidates.keys.sort.must_equal params.keys.sort
13
+
14
+ candidates[:a].must_be_instance_of Array
15
+ candidates[:a].length.must_equal 100
16
+ candidates[:a].each do |a|
17
+ a.must_be :>=, 0
18
+ a.must_be :<=, 100
19
+ end
20
+
21
+ candidates[:b].must_be_instance_of Array
22
+ candidates[:b].length.must_equal 100
23
+ candidates[:b].each do |b|
24
+ b.must_be :>=, 0
25
+ b.must_be :<=, 50
26
+ end
27
+
28
+ candidates[:c].must_be_instance_of Array
29
+ candidates[:c].length.must_equal 100
30
+ candidates[:c].each do |b|
31
+ b.must_be :>=, 0.0
32
+ b.must_be :<=, 1.0
33
+ end
34
+ end
35
+ end
metadata CHANGED
@@ -1,94 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feldtruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.11
5
- prerelease:
4
+ version: 0.4.12
6
5
  platform: ruby
7
6
  authors:
8
7
  - Robert Feldt
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-18 00:00:00.000000000 Z
11
+ date: 2013-04-21 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rinruby
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: json
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: nokogiri
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: mongo
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: bson_ext
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  description: Robert Feldt's Common Ruby Code lib
@@ -106,6 +95,7 @@ files:
106
95
  - README.md
107
96
  - Rakefile
108
97
  - TODO
98
+ - archive.json
109
99
  - feldtruby.gemspec
110
100
  - lib/feldtruby.rb
111
101
  - lib/feldtruby/annotations.rb
@@ -128,6 +118,8 @@ files:
128
118
  - lib/feldtruby/optimize/max_steps_termination_criterion.rb
129
119
  - lib/feldtruby/optimize/objective.rb
130
120
  - lib/feldtruby/optimize/optimizer.rb
121
+ - lib/feldtruby/optimize/problems/multi_objective_problems.rb
122
+ - lib/feldtruby/optimize/problems/single_objective_problems.rb
131
123
  - lib/feldtruby/optimize/random_search.rb
132
124
  - lib/feldtruby/optimize/search_space.rb
133
125
  - lib/feldtruby/optimize/stdout_logger.rb
@@ -136,6 +128,7 @@ files:
136
128
  - lib/feldtruby/statistics.rb
137
129
  - lib/feldtruby/statistics/array_archive.rb
138
130
  - lib/feldtruby/statistics/clustering.rb
131
+ - lib/feldtruby/statistics/design_of_experiments.rb
139
132
  - lib/feldtruby/statistics/distance.rb
140
133
  - lib/feldtruby/statistics/distance/string_distance.rb
141
134
  - lib/feldtruby/statistics/euclidean_distance.rb
@@ -149,6 +142,7 @@ files:
149
142
  - lib/feldtruby/visualization/circos.rb
150
143
  - lib/feldtruby/word_counter.rb
151
144
  - old/event_logger.rb
145
+ - spikes/archive.json
152
146
  - spikes/comparing_samplers_on_classic_optimization_functions/analyze_sampler_comparison_results.R
153
147
  - spikes/comparing_samplers_on_classic_optimization_functions/compare_samplers.rb
154
148
  - spikes/comparing_samplers_on_classic_optimization_functions/results_comparing_samplers_130405_175934.csv
@@ -160,8 +154,6 @@ files:
160
154
  - spikes/simple_de_run.rb
161
155
  - spikes/zlib_for_short_strings.rb
162
156
  - test/helper.rb
163
- - test/long_running/multi_objective_problems.rb
164
- - test/long_running/single_objective_problems.rb
165
157
  - test/long_running/test_single_objective_optimization.rb
166
158
  - test/skip_test_array_archive.rb
167
159
  - test/test_array.rb
@@ -187,6 +179,7 @@ files:
187
179
  - test/test_optimize_stochastic_hill_climber.rb
188
180
  - test/test_sax.rb
189
181
  - test/test_statistics.rb
182
+ - test/test_statistics_design_of_experiments.rb
190
183
  - test/test_string_distance.rb
191
184
  - test/test_sub_qualitites_comparator.rb
192
185
  - test/test_time.rb
@@ -196,32 +189,29 @@ files:
196
189
  - test/tmp_shorter.csv
197
190
  homepage: https://github.com/robertfeldt/feldtruby
198
191
  licenses: []
192
+ metadata: {}
199
193
  post_install_message:
200
194
  rdoc_options: []
201
195
  require_paths:
202
196
  - lib
203
197
  required_ruby_version: !ruby/object:Gem::Requirement
204
- none: false
205
198
  requirements:
206
- - - ! '>='
199
+ - - '>='
207
200
  - !ruby/object:Gem::Version
208
201
  version: '0'
209
202
  required_rubygems_version: !ruby/object:Gem::Requirement
210
- none: false
211
203
  requirements:
212
- - - ! '>='
204
+ - - '>='
213
205
  - !ruby/object:Gem::Version
214
206
  version: '0'
215
207
  requirements: []
216
208
  rubyforge_project:
217
- rubygems_version: 1.8.25
209
+ rubygems_version: 2.0.0
218
210
  signing_key:
219
- specification_version: 3
211
+ specification_version: 4
220
212
  summary: Robert Feldt's Common Ruby Code lib
221
213
  test_files:
222
214
  - test/helper.rb
223
- - test/long_running/multi_objective_problems.rb
224
- - test/long_running/single_objective_problems.rb
225
215
  - test/long_running/test_single_objective_optimization.rb
226
216
  - test/skip_test_array_archive.rb
227
217
  - test/test_array.rb
@@ -247,6 +237,7 @@ test_files:
247
237
  - test/test_optimize_stochastic_hill_climber.rb
248
238
  - test/test_sax.rb
249
239
  - test/test_statistics.rb
240
+ - test/test_statistics_design_of_experiments.rb
250
241
  - test/test_string_distance.rb
251
242
  - test/test_sub_qualitites_comparator.rb
252
243
  - test/test_time.rb