@@ -65,6 +65,19 @@ function optimize(
6565 status
6666end
6767
68+ # Handle callable objects (non-Function types) with algorithm instances
69+ function optimize (
70+ f,
71+ search_space,
72+ method:: AbstractAlgorithm ;
73+ logger:: Function = (status) -> nothing ,
74+ )
75+ # Wrap callable object into a function
76+ wrapped_f = _wrap_objective_function (f)
77+ # Call the standard optimize function with the wrapped function
78+ optimize (wrapped_f, search_space, method; logger)
79+ end
80+
6881
6982"""
7083 optimize!(f, search_space, method;logger)
@@ -133,6 +146,19 @@ function optimize!(
133146 return method
134147end
135148
149+ # Handle callable objects (non-Function types) with optimize!
150+ function optimize! (
151+ f,
152+ search_space,
153+ method:: AbstractAlgorithm ;
154+ logger:: Function = (status) -> nothing ,
155+ )
156+ # Wrap callable object into a function
157+ wrapped_f = _wrap_objective_function (f)
158+ # Call the standard optimize! function with the wrapped function
159+ optimize! (wrapped_f, search_space, method; logger)
160+ end
161+
136162
137163function optimize (
138164 f:: Function ,
@@ -149,3 +175,17 @@ function optimize(
149175 # call optimize api
150176 optimize (f, problem. search_space, algo; logger)
151177end
178+
179+ function optimize (
180+ f,
181+ _search_space,
182+ :: Type{T} ;
183+ logger:: Function = (status) -> nothing ,
184+ kargs...
185+ ) where T <: AbstractParameters
186+
187+ # Wrap callable object into a function
188+ wrapped_f = _wrap_objective_function (f)
189+ # Call the standard optimize function with the wrapped function
190+ optimize (wrapped_f, _search_space, T; logger, kargs... )
191+ end
0 commit comments