@@ -109,8 +109,10 @@ function report_from_result_dict(statsdict)
109
109
report_on_values (" Fitness" , statsdict[:fitnesses ], " " )
110
110
report_on_values (" Time" , statsdict[:times ], " " )
111
111
report_on_values (" Num function evals" , statsdict[:numevals ], " " )
112
- println (" Success rate: " , round (pdict[" Within fitness tolerance of optimum" ], 3 ), " %\n " )
113
- pdict[" Within fitness tolerance of optimum" ]
112
+
113
+ success_rate = round (get (pdict, " Within fitness tolerance of optimum" , 0.0 ), 3 )
114
+ println (" Success rate: " , success_rate, " %\n " )
115
+ success_rate
114
116
end
115
117
116
118
function rank_result_dicts_by (result_dicts, byfunc, desc; rev = false ,
@@ -139,42 +141,41 @@ function report_on_methods_results_on_one_problem(problem, result_dicts, numrepe
139
141
rank_result_dicts_by (result_dicts, (d) -> median (d[:fitnesses ]), " fitness" ; descsummary = " median" )
140
142
rank_result_dicts_by (result_dicts, (d) -> median (d[:times ]), " time (in seconds)" ;
141
143
descsummary = " median" , rpad = " secs" )
142
- rank_result_dicts_by (result_dicts, (d) -> int ( median (d[:numevals ])), " num function evals" ; descsummary = " median" )
144
+ rank_result_dicts_by (result_dicts, (d) -> round (Int, median (d[:numevals ])), " num function evals" ; descsummary = " median" )
143
145
144
146
for rd in result_dicts
145
147
report_from_result_dict (rd)
146
148
end
147
149
148
150
end
149
151
150
- function repeated_bboptimize (numrepeats, problem, dim, methods, max_time, ftol = 1e-5 , parameters :: Parameters = EMPTY_PARAMS)
152
+ function repeated_bboptimize (numrepeats, problem, dim, methods, max_time, ftol = 1e-5 , extraparams :: Parameters = EMPTY_PARAMS)
151
153
152
154
fp = instantiate (problem, dim)
153
155
result_dicts = ParamsDict[]
154
156
155
157
# Just so they are declared
156
158
ps = best_so_far = nothing
157
159
158
- params = chain (parameters , ParamsDict (:FitnessTolerance => ftol))
160
+ params = chain (extraparams , ParamsDict (:FitnessTolerance => ftol))
159
161
160
162
for m in methods
161
163
162
164
ts, fs, nes = zeros (numrepeats), zeros (numrepeats), zeros (Int, numrepeats)
163
- rcounts = Dict {String,Int} (" Within fitness tolerance of optimum " => 0 )
165
+ rcounts = Dict {String,Int} ()
164
166
165
- for i in 1 : numrepeats
166
- p = fp # BlackBoxOptim.ShiftedAndBiasedProblem(fp)
167
- best, fs[i], reason, ts[i], ps, nes[i] = bboptimize (p; max_time = max_time,
168
- method = m, parameters = params)
169
- rcounts[reason] = 1 + get (rcounts, reason, 0 )
170
- end
167
+ results = map (1 : numrepeats) do i
168
+ result = bboptimize (fp, params; MaxTime = max_time, Method = m)
171
169
172
- if best_so_far == nothing
173
- best_so_far = worst_fitness (ps[:Evaluator ])
174
- end
170
+ # Save key data about this run:
171
+ ts[i] = elapsed_time (result)
172
+ fs[i] = best_fitness (result)
173
+ nes[i] = f_calls (result)
175
174
176
- # ???
177
- best_so_far =
175
+ # And count only the general stop reasons
176
+ reason = general_stop_reason (result)
177
+ rcounts[reason] = 1 + get (rcounts, reason, 0 )
178
+ end
178
179
179
180
rdict = ParamsDict (:method => m, :fitnesses => fs, :times => ts, :numevals => nes, :reasoncounts => rcounts)
180
181
rdict[:success_rate ] = report_from_result_dict (rdict)
0 commit comments