From 30d212aae810087a5597692ec20d01c2df997281 Mon Sep 17 00:00:00 2001 From: Mohamed Tarek Date: Thu, 16 Nov 2023 07:03:04 +0200 Subject: [PATCH] minor refactor --- Project.toml | 8 ++++---- src/NonconvexMultistart.jl | 2 +- src/hyperopt.jl | 38 +++++++++++++++++++------------------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Project.toml b/Project.toml index c0e48ad..0b34af7 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "NonconvexMultistart" uuid = "11b12826-7e46-4acf-9706-be0a67f2add7" authors = ["Mohamed Tarek and contributors"] -version = "0.1.3" +version = "0.1.4" [deps] ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" @@ -14,12 +14,12 @@ Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46" Sobol = "ed01d8cd-4d21-5b2a-85b4-cc3bdc58bad4" [compat] -ChainRulesCore = "0.10, 1" +ChainRulesCore = "1" Hyperopt = "0.4" NonconvexCore = "1" -Parameters = "0.12" +Parameters = "0.12, 0.13" Reexport = "1" -Setfield = "0.7, 0.8, 1" +Setfield = "1" Sobol = "1" julia = "1" diff --git a/src/NonconvexMultistart.jl b/src/NonconvexMultistart.jl index e796d53..338fdad 100644 --- a/src/NonconvexMultistart.jl +++ b/src/NonconvexMultistart.jl @@ -7,7 +7,7 @@ import Hyperopt using Reexport, Parameters, Setfield, ChainRulesCore, Sobol @reexport using NonconvexCore using NonconvexCore: - reset!, isfeasible, @params, VecModel, AbstractOptimizer, AbstractResult + reset!, isfeasible, VecModel, AbstractOptimizer, AbstractResult import NonconvexCore: optimize!, Workspace include("hyperopt.jl") diff --git a/src/hyperopt.jl b/src/hyperopt.jl index 835e4ac..37b4c59 100644 --- a/src/hyperopt.jl +++ b/src/hyperopt.jl @@ -1,5 +1,5 @@ -@params struct HyperoptAlg <: AbstractOptimizer - sub_alg::AbstractOptimizer +struct HyperoptAlg{S <: AbstractOptimizer} <: AbstractOptimizer + sub_alg::S end """ @@ -15,14 +15,14 @@ end - `ctol`: infeasibility tolerance for accepting a solution as feasible - `keep_all`: if true, all the solutions of the sub-problems will be saved """ -@params struct HyperoptOptions - sub_options::Any - lb::Any - ub::Any - searchspace_size::Integer - iters::Integer - sampler::Hyperopt.Sampler - ctol::Any +struct HyperoptOptions{S1, L, U, S2 <: Hyperopt.Sampler, C} + sub_options::S1 + lb::L + ub::U + searchspace_size::Int + iters::Int + sampler::S2 + ctol::C keep_all::Bool end function HyperoptOptions(; @@ -47,10 +47,10 @@ function HyperoptOptions(; ) end -@params struct HyperoptWorkspace <: Workspace - sub_workspace::Workspace - x0::AbstractVector - options::HyperoptOptions +struct HyperoptWorkspace{S <: Workspace, X <: AbstractVector, O <: HyperoptOptions} <: Workspace + sub_workspace::S + x0::X + options::O end function Workspace( @@ -78,11 +78,11 @@ When using multiple x0 in [`optimize`](@ref), return this result, including foll - `results`: all the search results. - `optimal_ind`: the index of the optimal solution in `results`. """ -@params struct HyperoptResult <: AbstractResult - minimum::Any - minimizer::Any - results::Any - optimal_ind::Any +struct HyperoptResult{M1, M2, R, O} <: AbstractResult + minimum::M1 + minimizer::M2 + results::R + optimal_ind::O end function optimize!(workspace::HyperoptWorkspace)