From 8ebd87e9654eda5996b7c56019673ddd874a0206 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Thu, 4 May 2023 15:08:14 -0700 Subject: [PATCH] add dlib optimizer --- dlibcube2.py | 17 +++++++++++++++++ notwacube.py | 1 + 2 files changed, 18 insertions(+) create mode 100644 dlibcube2.py diff --git a/dlibcube2.py b/dlibcube2.py new file mode 100644 index 0000000..6bd191c --- /dev/null +++ b/dlibcube2.py @@ -0,0 +1,17 @@ +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) diff --git a/notwacube.py b/notwacube.py index aadc69f..6ea06a5 100644 --- a/notwacube.py +++ b/notwacube.py @@ -1,3 +1,4 @@ +from dlibcube2 import dlib_cube from nloptcube2 import nlopt_neldermead_cube from randomcube2 import another_random_cube, quasirandom_cube