thursday/thursday/candidates/dlib.py

18 lines
590 B
Python

from dlib import find_min_global
from .random import another_random_cube
from ..utilities 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)