2023-05-04 15:08:14 -07:00
|
|
|
from dlibcube2 import dlib_cube
|
2023-05-04 15:52:08 -07:00
|
|
|
from nevergradcube2 import NEVERGRAD2_OPTIMIZERS
|
2023-05-04 08:22:54 -07:00
|
|
|
from nloptcube2 import nlopt_neldermead_cube
|
2023-05-04 15:47:06 -07:00
|
|
|
from notwacube2 import make_birect, make_mercury, make_soo
|
2023-05-04 08:22:54 -07:00
|
|
|
from randomcube2 import another_random_cube, quasirandom_cube
|
2023-05-04 15:13:36 -07:00
|
|
|
from scipycube2 import (
|
2023-05-04 15:18:49 -07:00
|
|
|
make_shgo,
|
2023-05-04 15:13:36 -07:00
|
|
|
scipy_basinhopping_cube,
|
|
|
|
scipy_bfgs_2j_cube,
|
|
|
|
scipy_bfgs_3j_cube,
|
|
|
|
scipy_cg_2j_cube,
|
|
|
|
scipy_cg_3j_cube,
|
|
|
|
scipy_cobyla_cube,
|
|
|
|
scipy_direct_cube,
|
|
|
|
scipy_direct_l_cube,
|
|
|
|
# scipy_dogleg_cube,
|
|
|
|
scipy_lbfgsb_2j_cube,
|
|
|
|
scipy_lbfgsb_3j_cube,
|
|
|
|
scipy_neldermead_cube,
|
|
|
|
# scipy_newtoncg_cube,
|
|
|
|
scipy_powell_cube,
|
|
|
|
scipy_slsqp_2j_cube,
|
|
|
|
scipy_slsqp_3j_cube,
|
|
|
|
scipy_tnc_2j_cube,
|
|
|
|
scipy_tnc_3j_cube,
|
|
|
|
scipy_trustconstr_2j_cube,
|
|
|
|
scipy_trustconstr_3j_cube,
|
|
|
|
# scipy_trustexact_2j_cube,
|
|
|
|
# scipy_trustexact_3j_cube,
|
|
|
|
# scipy_trustkrylov_cube,
|
|
|
|
# scipy_trustncg_cube,
|
|
|
|
)
|
2023-05-04 08:22:54 -07:00
|
|
|
|
2023-05-04 15:35:23 -07:00
|
|
|
import tinytweaks as tt
|
|
|
|
|
2023-05-04 08:22:54 -07:00
|
|
|
BASELINE_OPTIMIZERS = [
|
|
|
|
another_random_cube,
|
|
|
|
nlopt_neldermead_cube,
|
|
|
|
quasirandom_cube,
|
|
|
|
]
|
|
|
|
|
2023-05-04 15:18:49 -07:00
|
|
|
SHGO_OPTIMIZERS = [
|
|
|
|
make_shgo(method="cobyla"),
|
|
|
|
make_shgo(method="slsqp"),
|
|
|
|
make_shgo(method="cobyla", mei=True),
|
|
|
|
make_shgo(method="slsqp", mei=True),
|
|
|
|
]
|
|
|
|
|
2023-05-04 15:35:23 -07:00
|
|
|
NOTWA_OPTIMIZERS = [
|
|
|
|
make_birect(deepness=38, longest=True, pruning=False),
|
|
|
|
make_mercury(13, isigma=tt.S3),
|
|
|
|
make_mercury(29, isigma=tt.S3),
|
|
|
|
make_soo(deepness=23, K=4),
|
|
|
|
make_soo(deepness=35, K=3),
|
|
|
|
make_soo(deepness=53, K=2),
|
|
|
|
]
|
|
|
|
|
2023-05-04 15:02:08 -07:00
|
|
|
|
|
|
|
def collect_everything():
|
|
|
|
G = globals().values()
|
|
|
|
λ = lambda G: [
|
|
|
|
g for g in G if callable(g) and getattr(g, "__name__", "").endswith("_cube")
|
|
|
|
]
|
|
|
|
_seen = {}
|
|
|
|
for thing in sum((λ(g) for g in G if type(g) is list), λ(G)):
|
|
|
|
key = thing.__name__
|
|
|
|
if key in _seen and _seen[key] is not thing:
|
|
|
|
pass # print(f"Ignored: seen twice: {key}", file=sys.stderr)
|
|
|
|
_seen[key] = thing
|
|
|
|
# return list(_seen.values())
|
|
|
|
return [v for k, v in sorted(_seen.items(), key=lambda t: t[0])]
|
|
|
|
|
|
|
|
|
|
|
|
FUCKING_EVERYTHING = collect_everything()
|
|
|
|
|
|
|
|
try:
|
|
|
|
from previous import PREVIOUSLY_POSITIVE, PREVIOUSLY_NEGATIVE
|
|
|
|
except ModuleNotFoundError:
|
|
|
|
PREVIOUSLY_POSITIVE, PREVIOUSLY_NEGATIVE = [], []
|
|
|
|
else:
|
|
|
|
g = {v.__name__: v for v in FUCKING_EVERYTHING} # globals()
|
|
|
|
|
|
|
|
def refind(stuff):
|
|
|
|
_temp = []
|
|
|
|
for opt in stuff:
|
|
|
|
_old_len = len(_temp)
|
|
|
|
if opt in g:
|
|
|
|
_temp.append(g[opt])
|
|
|
|
elif opt.startswith("ng_") or opt.startswith("ngx_"):
|
|
|
|
if opt.startswith("ng_"):
|
|
|
|
ngx = "ngx_" + opt.removeprefix("ng_")
|
|
|
|
else:
|
|
|
|
ngx = "ng_" + opt.removeprefix("ngx_") # whatever
|
|
|
|
if ngx in g:
|
|
|
|
_temp.append(g[ngx])
|
|
|
|
else:
|
|
|
|
for ng_opt in NEVERGRAD2_OPTIMIZERS:
|
|
|
|
if ng_opt.__name__ == opt or ng_opt.__name__ == ngx:
|
|
|
|
_temp.append(ng_opt)
|
|
|
|
if len(_temp) == _old_len:
|
|
|
|
# FIXME: this text is not necessarily for PREVIOUSLY_POSITIVE!
|
|
|
|
print(
|
|
|
|
f"Ignored: failed to find {opt} for PREVIOUSLY_POSITIVE",
|
|
|
|
file=sys.stderr,
|
|
|
|
)
|
|
|
|
return _temp
|
|
|
|
|
|
|
|
PREVIOUSLY_POSITIVE = refind(PREVIOUSLY_POSITIVE)
|
|
|
|
PREVIOUSLY_NEGATIVE = refind(PREVIOUSLY_NEGATIVE)
|
|
|
|
del g
|
|
|
|
|
|
|
|
for opt in (another_random_cube, quasirandom_cube):
|
|
|
|
if opt not in PREVIOUSLY_POSITIVE:
|
|
|
|
PREVIOUSLY_POSITIVE.append(opt)
|
|
|
|
for opt in (another_random_cube, quasirandom_cube):
|
|
|
|
if opt not in PREVIOUSLY_NEGATIVE:
|
|
|
|
PREVIOUSLY_NEGATIVE.append(opt)
|
|
|
|
|
|
|
|
try:
|
|
|
|
from elo_blacklist import blacklisted
|
|
|
|
except ModuleNotFoundError:
|
|
|
|
WHITELISTED_OPTIMIZERS = FUCKING_EVERYTHING.copy()
|
|
|
|
else:
|
|
|
|
WHITELISTED_OPTIMIZERS = [
|
|
|
|
opt
|
|
|
|
for opt in FUCKING_EVERYTHING
|
|
|
|
if opt.__name__.removesuffix("_cube") not in blacklisted
|
|
|
|
]
|
|
|
|
|
2023-05-04 08:22:54 -07:00
|
|
|
book_of_optimizers = dict(
|
|
|
|
baseline=BASELINE_OPTIMIZERS,
|
2023-05-04 15:02:08 -07:00
|
|
|
everything=FUCKING_EVERYTHING,
|
2023-05-04 15:18:49 -07:00
|
|
|
shgo=SHGO_OPTIMIZERS,
|
2023-05-04 15:02:08 -07:00
|
|
|
negative=PREVIOUSLY_NEGATIVE,
|
|
|
|
positive=PREVIOUSLY_POSITIVE,
|
|
|
|
whitelisted=WHITELISTED_OPTIMIZERS,
|
2023-05-04 08:22:54 -07:00
|
|
|
)
|