Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed replace bug and Libc missing #232

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions spikes/experiment_framework.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"])

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spikes/generating_set_search.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spikes/nlopt_highdim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spikes/parameter_study.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion src/archive.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion src/opt_controller.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading