Skip to content

Commit

Permalink
fix tests and use la test Setfield
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamed82008 committed Jul 15, 2022
1 parent 3280e21 commit 095ae41
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NonconvexMultistart"
uuid = "11b12826-7e46-4acf-9706-be0a67f2add7"
authors = ["Mohamed Tarek <[email protected]> and contributors"]
version = "0.1.1"
version = "0.1.2"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand All @@ -19,7 +19,7 @@ Hyperopt = "0.4"
NonconvexCore = "1"
Parameters = "0.12"
Reexport = "1"
Setfield = "0.7"
Setfield = "0.7, 0.8, 1"
Sobol = "1"
julia = "1"

Expand Down
17 changes: 15 additions & 2 deletions src/hyperopt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function optimize!(workspace::HyperoptWorkspace)
objective = objective, params = params,
candidates = candidates,
)
ho = @set _ho.objective = (args...) -> begin
ho = switch_objective(_ho, (args...) -> begin
if length(args) == 2 && sampler isa Hyperopt.Hyperband
if _sampler isa Hyperopt.GPSampler
res, _ = _ho.objective(args[1], args[2]...)
Expand All @@ -135,7 +135,7 @@ function optimize!(workspace::HyperoptWorkspace)
else
return res
end
end
end)
if _sampler isa Union{Hyperopt.LHSampler, Hyperopt.CLHSampler, Hyperopt.GPSampler}
Hyperopt.init!(_sampler, ho)
end
Expand All @@ -156,6 +156,19 @@ function optimize!(workspace::HyperoptWorkspace)
end
end

function switch_objective(ho, objective)
(; iterations, params, candidates, history, results, sampler) = ho
return Hyperopt.Hyperoptimizer(;
iterations,
params,
candidates,
history,
results,
sampler,
objective,
)
end

function get_linrange_candidates(lb, ub, n)
return Tuple(Symbol.(:x0_, 1:length(lb))), Tuple(LinRange.(lb, ub, n))
end
Expand Down

0 comments on commit 095ae41

Please sign in to comment.