Skip to content

Commit 9ff7d1d

Browse files
committed
fixed replace bug and Libc missing
1 parent 00d1c73 commit 9ff7d1d

6 files changed

+10
-10
lines changed

spikes/experiment_framework.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function format_time(t)
1919
end
2020

2121
function unique_filename(prefix = "result", suffix = ".txt")
22-
join([prefix, strftime("_%Y%m%d_%H%M%S_$(rand(1:int(1e6)))", time()), suffix])
22+
join([prefix,Libc.strftime("_%Y%m%d_%H%M%S_$(rand(1:int(1e6)))", time()), suffix])
2323
end
2424

2525
function csvfile(header; fileprefix = "experiment",
@@ -39,7 +39,7 @@ function repeated_runs(searchf, problem_set, num_runs = 10; experiment = "exp")
3939
times = zeros(num_runs, num_problems)
4040
reason_counts = [Dict{ASCIIString, Int}() for i in 1:num_problems]
4141

42-
file_prefix = strftime("$(experiment)_%Y%m%d_%H%M%S", time())
42+
file_prefix =Libc.strftime("$(experiment)_%Y%m%d_%H%M%S", time())
4343

4444
run_csvfile = join([file_prefix, "_runs.csv"])
4545

@@ -87,8 +87,8 @@ function repeated_runs(searchf, problem_set, num_runs = 10; experiment = "exp")
8787
end
8888

8989
# Print to summary csv file
90-
println(summary_csvfh, join([experiment, strftime("%Y-%m-%d", start_time),
91-
strftime("%T", start_time), i, "\"$(name(prob))\"", dims, params,
90+
println(summary_csvfh, join([experiment,Libc.strftime("%Y-%m-%d", start_time),
91+
Libc.strftime("%T", start_time), i, "\"$(name(prob))\"", dims, params,
9292
times[i,pi], fevals[i,pi], "\"$(reason)\"", fbests[i,pi]], ","))
9393
flush(summary_csvfh)
9494
end

spikes/generating_set_search.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ function run_with_params(of, n)
226226

227227
prefix_header = "StartTime,ElapsedTime,Function,N,FitnessBest,TotalFuncEvals,TerminationReason"
228228
println(join([prefix_header, map((i) -> "x$(i)", 1:length(xb))], ","))
229-
println(join([strftime("%Y%m%d-%H%M%S", start_time), elapsed, of, n, fb, fes, tr, xb], ","))
229+
println(join([Libc.strftime("%Y%m%d-%H%M%S", start_time), elapsed, of, n, fb, fes, tr, xb], ","))
230230
end
231231

232232
#of = rastrigin

spikes/nlopt_highdim.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ end
209209
function compare_optimizers(optimizers, problems, dim, numreps = 10;
210210
dataframe_mapper = identity)
211211

212-
timestamp = strftime("%Y%m%d_%H%M%S", time())
212+
timestamp =Libc.strftime("%Y%m%d_%H%M%S", time())
213213
filename = "results_nlopt_$(timestamp).csv"
214214
res = DataFrame()
215215
its = 0

spikes/parameter_study.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ end
6161
@everywhere function one_run(args)
6262
run, prob, d, maxfevals, uf, s, mu, l = args
6363

64-
ts = strftime("%y%m%d,%H%M%S", time())
64+
ts =Libc.strftime("%y%m%d,%H%M%S", time())
6565

6666
tic()
6767
x, f, fevals = cmsa_es(d, prob;
@@ -81,7 +81,7 @@ end
8181

8282
results = pmap(one_run_and_save, Params)
8383

84-
fh = open(strftime("parameter_studies/%y%m%d_%H%M%S_$(machine).csv", time()), "w")
84+
fh = open(Libc.strftime("parameter_studies/%y%m%d_%H%M%S_$(machine).csv", time()), "w")
8585
println(fh, "Date,Time,RunID,Problem,N,Machine,Sampler,Utilities,Mu,Lambda,NumFuncEvals,ExecTime,Fitness")
8686
for i in 1:length(results)
8787
println(fh, results[i])

src/archive.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ function save_fitness_history_to_csv_file(a::Archive, filename = "fitness_histor
194194
for af in a.fitness_history
195195
mc = magnitude_class(af.fitness)
196196

197-
line = [line_prefix, strftime("%Y-%m-%d,%T", af.timestamp),
197+
line = [line_prefix,Libc.strftime("%Y-%m-%d,%T", af.timestamp),
198198
af.timestamp-a.start_time,
199199
mc[1]*mc[2], af.num_fevals, af.fitness_improvement_ratio, af.fitness]
200200

src/opt_controller.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ function write_result(ctrl::OptRunController, filename = "")
373373
if isempty(filename)
374374
timestamp = Libc.strftime("%y%m%d_%H%M%S", floor(Int, ctrl.start_time))
375375
filename = "$(timestamp)_$(problem_summary(ctrl.evaluator))_$(name(ctrl.optimizer)).csv"
376-
filename = replace(replace(filename, r"\s+", "_"), r"/", "_")
376+
filename = replace(replace(filename, r"\s+" => "_"), r"/" => "_")
377377
end
378378
save_fitness_history_to_csv_file(ctrl.evaluator.archive, filename;
379379
header_prefix = "Problem,Dimension,Optimizer",

0 commit comments

Comments
 (0)