thursday/thursday/dlibcube2.py

18 lines
590 B
Python

from dlib import find_min_global
from .randomcube2 import another_random_cube
from .utils import wrap_untrustworthy, final
def dlib_cube(objective, n_trials, n_dim, with_count):
if n_dim > 35:
return another_random_cube(objective, n_trials, n_dim, with_count)
_objective = wrap_untrustworthy(objective, n_trials)
def __objective(*args):
return _objective(list(args))
find_min_global(__objective, [0.0] * n_dim, [1.0] * n_dim, n_trials)
fopt, xopt, feval_count = _objective(final)
return (fopt, xopt, feval_count) if with_count else (fopt, xopt)