diff --git a/Project.toml b/Project.toml index 99b7ea8..6ecc5a0 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Hyperopt" uuid = "93e5fe13-2215-51db-baaf-2e9a34fb2712" author = ["Fredrik Bagge Carlson "] -version = "0.3.4" +version = "0.3.5" [deps] BayesianOptimization = "4c6ed407-134f-591c-93fa-e0f7c164a0ec" diff --git a/src/Hyperopt.jl b/src/Hyperopt.jl index 2d91dee..be2cb9e 100644 --- a/src/Hyperopt.jl +++ b/src/Hyperopt.jl @@ -50,7 +50,8 @@ function Base.iterate(ho::Hyperoptimizer, state=1) state > ho.iterations && return nothing samples = ho.sampler(ho, state) push!(ho.history, samples) - [state;samples], state+1 + nt = (; Pair.([:i, ho.params...], [state; samples])...) + nt, state+1 end function preprocess_expression(ex) diff --git a/src/samplers.jl b/src/samplers.jl index 6e2f30f..a6fd1cb 100644 --- a/src/samplers.jl +++ b/src/samplers.jl @@ -147,7 +147,7 @@ function (s::GPSampler)(ho, iter) # iters = 3000 ho2 = Hyperoptimizer(iterations=iters, params=ho.params, candidates=s.candidates) for params in ho2 - params2 = params[2:end] + params2 = collect(params)[2:end] res = -Inf try res = acqfunc(params2) diff --git a/test/runtests.jl b/test/runtests.jl index 178b737..fd87863 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -111,6 +111,11 @@ f(a,b=true;c=10) = sum(@. 100 + (a-3)^2 + (b ? 10 : 20) + (c-100)^2) # This func println(i, "\t", a, "\t", b, "\t", c) end + ho = Hyperoptimizer(10, a = range(1, stop=2, length=50), b = [true, false], c = randn(100)) + for vals in ho + println(vals.i, "\t", vals.a, "\t", vals.b, "\t", vals.c) + end + end