From 9ff7d1dd50ae287b493ef899ffece86b5b07d14b Mon Sep 17 00:00:00 2001 From: Florian Oswald Date: Thu, 8 Feb 2024 11:08:24 +0100 Subject: [PATCH] fixed replace bug and Libc missing --- spikes/experiment_framework.jl | 8 ++++---- spikes/generating_set_search.jl | 2 +- spikes/nlopt_highdim.jl | 2 +- spikes/parameter_study.jl | 4 ++-- src/archive.jl | 2 +- src/opt_controller.jl | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/spikes/experiment_framework.jl b/spikes/experiment_framework.jl index e959eb3d..a7bd2cbf 100644 --- a/spikes/experiment_framework.jl +++ b/spikes/experiment_framework.jl @@ -19,7 +19,7 @@ function format_time(t) end function unique_filename(prefix = "result", suffix = ".txt") - join([prefix, strftime("_%Y%m%d_%H%M%S_$(rand(1:int(1e6)))", time()), suffix]) + join([prefix,Libc.strftime("_%Y%m%d_%H%M%S_$(rand(1:int(1e6)))", time()), suffix]) end function csvfile(header; fileprefix = "experiment", @@ -39,7 +39,7 @@ function repeated_runs(searchf, problem_set, num_runs = 10; experiment = "exp") times = zeros(num_runs, num_problems) reason_counts = [Dict{ASCIIString, Int}() for i in 1:num_problems] - file_prefix = strftime("$(experiment)_%Y%m%d_%H%M%S", time()) + file_prefix =Libc.strftime("$(experiment)_%Y%m%d_%H%M%S", time()) run_csvfile = join([file_prefix, "_runs.csv"]) @@ -87,8 +87,8 @@ function repeated_runs(searchf, problem_set, num_runs = 10; experiment = "exp") end # Print to summary csv file - println(summary_csvfh, join([experiment, strftime("%Y-%m-%d", start_time), - strftime("%T", start_time), i, "\"$(name(prob))\"", dims, params, + println(summary_csvfh, join([experiment,Libc.strftime("%Y-%m-%d", start_time), + Libc.strftime("%T", start_time), i, "\"$(name(prob))\"", dims, params, times[i,pi], fevals[i,pi], "\"$(reason)\"", fbests[i,pi]], ",")) flush(summary_csvfh) end diff --git a/spikes/generating_set_search.jl b/spikes/generating_set_search.jl index 2aa70792..fa4d6358 100644 --- a/spikes/generating_set_search.jl +++ b/spikes/generating_set_search.jl @@ -226,7 +226,7 @@ function run_with_params(of, n) prefix_header = "StartTime,ElapsedTime,Function,N,FitnessBest,TotalFuncEvals,TerminationReason" println(join([prefix_header, map((i) -> "x$(i)", 1:length(xb))], ",")) - println(join([strftime("%Y%m%d-%H%M%S", start_time), elapsed, of, n, fb, fes, tr, xb], ",")) + println(join([Libc.strftime("%Y%m%d-%H%M%S", start_time), elapsed, of, n, fb, fes, tr, xb], ",")) end #of = rastrigin diff --git a/spikes/nlopt_highdim.jl b/spikes/nlopt_highdim.jl index dbad372a..f67a936c 100644 --- a/spikes/nlopt_highdim.jl +++ b/spikes/nlopt_highdim.jl @@ -209,7 +209,7 @@ end function compare_optimizers(optimizers, problems, dim, numreps = 10; dataframe_mapper = identity) - timestamp = strftime("%Y%m%d_%H%M%S", time()) + timestamp =Libc.strftime("%Y%m%d_%H%M%S", time()) filename = "results_nlopt_$(timestamp).csv" res = DataFrame() its = 0 diff --git a/spikes/parameter_study.jl b/spikes/parameter_study.jl index 3d936eba..7650ddcc 100644 --- a/spikes/parameter_study.jl +++ b/spikes/parameter_study.jl @@ -61,7 +61,7 @@ end @everywhere function one_run(args) run, prob, d, maxfevals, uf, s, mu, l = args - ts = strftime("%y%m%d,%H%M%S", time()) + ts =Libc.strftime("%y%m%d,%H%M%S", time()) tic() x, f, fevals = cmsa_es(d, prob; @@ -81,7 +81,7 @@ end results = pmap(one_run_and_save, Params) -fh = open(strftime("parameter_studies/%y%m%d_%H%M%S_$(machine).csv", time()), "w") +fh = open(Libc.strftime("parameter_studies/%y%m%d_%H%M%S_$(machine).csv", time()), "w") println(fh, "Date,Time,RunID,Problem,N,Machine,Sampler,Utilities,Mu,Lambda,NumFuncEvals,ExecTime,Fitness") for i in 1:length(results) println(fh, results[i]) diff --git a/src/archive.jl b/src/archive.jl index 905331d4..52b6897a 100644 --- a/src/archive.jl +++ b/src/archive.jl @@ -194,7 +194,7 @@ function save_fitness_history_to_csv_file(a::Archive, filename = "fitness_histor for af in a.fitness_history mc = magnitude_class(af.fitness) - line = [line_prefix, strftime("%Y-%m-%d,%T", af.timestamp), + line = [line_prefix,Libc.strftime("%Y-%m-%d,%T", af.timestamp), af.timestamp-a.start_time, mc[1]*mc[2], af.num_fevals, af.fitness_improvement_ratio, af.fitness] diff --git a/src/opt_controller.jl b/src/opt_controller.jl index 8c4d0974..ad2c5add 100644 --- a/src/opt_controller.jl +++ b/src/opt_controller.jl @@ -373,7 +373,7 @@ function write_result(ctrl::OptRunController, filename = "") if isempty(filename) timestamp = Libc.strftime("%y%m%d_%H%M%S", floor(Int, ctrl.start_time)) filename = "$(timestamp)_$(problem_summary(ctrl.evaluator))_$(name(ctrl.optimizer)).csv" - filename = replace(replace(filename, r"\s+", "_"), r"/", "_") + filename = replace(replace(filename, r"\s+" => "_"), r"/" => "_") end save_fitness_history_to_csv_file(ctrl.evaluator.archive, filename; header_prefix = "Problem,Dimension,Optimizer",