begin reorganizing into a module

This commit is contained in:
Connor Olding 2023-05-07 05:30:53 -07:00
parent 83380ea42f
commit 6be9cac743
26 changed files with 47 additions and 37 deletions

8
.gitignore vendored
View file

@ -1,3 +1,7 @@
__pycache__/*
*.old
*.bak
*.old
__pycache__/*
cache/*
EvoloPy-master/*
lesser_pyopus/*
t/*

5
thursday/__main__.py Normal file
View file

@ -0,0 +1,5 @@
from .go_benchmark_it import main
main(["thursday", "everything", "-2"])
main(["thursday", "everything", "-3"])
main(["thursday", "everything", "-4"])

View file

@ -1,6 +1,6 @@
from dlib import find_min_global
from randomcube2 import another_random_cube
from utils import wrap_untrustworthy, final
from .randomcube2 import another_random_cube
from .utils import wrap_untrustworthy, final
def dlib_cube(objective, n_trials, n_dim, with_count):

View file

@ -1,4 +1,4 @@
from utils import wrap_untrustworthy, final, ExhaustedTrialsError
from .utils import wrap_untrustworthy, final, ExhaustedTrialsError
import numpy as np

View file

@ -1,6 +1,6 @@
from scipy.optimize import Bounds
from unittest.mock import patch
from utils import wrap_untrustworthy, final
from .utils import wrap_untrustworthy, final
import numpy as np

View file

@ -1,9 +1,9 @@
from go_benchmark_lists import *
from go_benchmarks import problems_2d, problems_3d, problems_4d
from notwacube import book_of_optimizers
from prog80 import prog
from utils import OWrap, COWrap, m1, m33, m36
from utils import perform_another_experimental_scoring_method
from .go_benchmark_lists import *
from .go_benchmarks import problems_2d, problems_3d, problems_4d
from .notwacube import book_of_optimizers
from .prog80 import prog
from .utils import OWrap, COWrap, m1, m33, m36
from .utils import perform_another_experimental_scoring_method
import numpy as np
all_problems = {
@ -155,7 +155,7 @@ for problem_list in GO_BENCHMARKS.values():
), "please use Infinity instead; it's basically equivalent"
if __name__ == "__main__":
def main(argv):
from tqdm import tqdm
import sys
@ -312,9 +312,9 @@ if __name__ == "__main__":
percents = dict(frugal_percent=1.0, greedy_percent=2.0)
book = book_of_optimizers
which = book[sys.argv[1]] if len(sys.argv) > 1 else book["standard"]
n_dim = int(sys.argv[2]) if len(sys.argv) > 2 else -2
n_trials = int(sys.argv[3]) if len(sys.argv) > 3 else fib(abs(n_dim) + 4) * 10
which = book[argv[1]] if len(argv) > 1 else book["standard"]
n_dim = int(argv[2]) if len(argv) > 2 else -2
n_trials = int(argv[3]) if len(argv) > 3 else fib(abs(n_dim) + 4) * 10
place_names = ("1st", "2nd", "3rd", "4th")
assert n_dim < 0, "unsupported in this version"
@ -495,10 +495,10 @@ if __name__ == "__main__":
except PermissionError:
print("# failed to write previous.py, ignoring...")
if len(sys.argv) > 1 and sys.argv[1] in ("positive", "negative"):
if len(argv) > 1 and argv[1] in ("positive", "negative"):
all_old_opt_names = set(opt.__name__ for opt in optimizers)
C = set(("quasirandom_cube", "another_random_cube"))
if sys.argv[1] == "positive" and set(positive) - C == all_old_opt_names - C:
if argv[1] == "positive" and set(positive) - C == all_old_opt_names - C:
exit(2) # no changes
if sys.argv[1] == "negative" and set(negative) - C == all_old_opt_names - C:
if argv[1] == "negative" and set(negative) - C == all_old_opt_names - C:
exit(2) # no changes

View file

@ -1,8 +1,8 @@
from dlibcube2 import dlib_cube
from evolopycube2 import make_evolopy
from nevergradcube2 import NEVERGRAD2_OPTIMIZERS
from nloptcube2 import nlopt_neldermead_cube
from fcmaescube2 import (
from .dlibcube2 import dlib_cube
from .evolopycube2 import make_evolopy
from .nevergradcube2 import NEVERGRAD2_OPTIMIZERS
from .nloptcube2 import nlopt_neldermead_cube
from .fcmaescube2 import (
make_biteopt,
make_csma,
make_fcmaes,
@ -12,9 +12,9 @@ from fcmaescube2 import (
make_gclde,
make_lclde,
)
from notwacube2 import make_birect, make_mercury, make_soo
from randomcube2 import another_random_cube, quasirandom_cube
from scipycube2 import (
from .notwacube2 import make_birect, make_mercury, make_soo
from .randomcube2 import another_random_cube, quasirandom_cube
from .scipycube2 import (
make_shgo,
scipy_basinhopping_cube,
scipy_bfgs_2j_cube,
@ -42,7 +42,7 @@ from scipycube2 import (
# scipy_trustncg_cube,
)
import tinytweaks as tt
from . import tinytweaks as tt
BASELINE_OPTIMIZERS = [
another_random_cube,

View file

@ -1,10 +1,10 @@
from utils import wrap_untrustworthy, check, final
from .utils import wrap_untrustworthy, check, final
import numpy as np
import tinytweaks as tt
from . import tinytweaks as tt
def make_birect(deepness=23, *, longest=False, pruning=False):
from birect import birect
from .birect import birect
def f(objective, n_trials, n_dim, with_count):
feval_count = 0
@ -37,7 +37,7 @@ def make_soo(deepness=None, *, K=3):
if deepness is None:
deepness = int(31 * np.log(2) / np.log(K) - 1e-8)
assert K >= 2
from soo import soo
from .soo import soo
def f(objective, n_trials, n_dim, with_count):
feval_count = 0
@ -61,7 +61,7 @@ def make_soo(deepness=None, *, K=3):
def make_mercury(
flags, bounding="clip", *, isigma=tt.IV, popsize=2, irate=1, seed=None
):
from hg import minimize as hg
from .hg import minimize as hg
def f(objective, n_trials, n_dim, with_count):
_objective = wrap_untrustworthy(objective, n_trials, bounding=bounding)

View file

@ -1,4 +1,4 @@
from utils import phi
from .utils import phi
import numpy as np

View file

@ -1,4 +1,4 @@
from utils import wrap_untrustworthy, check, final, ExhaustedTrialsError
from .utils import wrap_untrustworthy, check, final, ExhaustedTrialsError
import numpy as np
import scipy.optimize as scopt

View file

@ -176,6 +176,7 @@ def perform_another_experimental_scoring_method(results):
if len(results) and len(something := next(iter(results.values()))[0]) == 3:
history_length = len(something[2])
each = {}
# for i in (history_length - 1,):
for i in range(history_length):
# for k, v in results.items(): for vi in v: assert len(vi) == 3, vi
l = {k: [(res[2][i], res[1]) for res in v] for k, v in results.items()}
@ -271,4 +272,4 @@ try:
except ModuleNotFoundError:
pass
else:
from utils_np import *
from .utils_np import *

View file

@ -1,6 +1,6 @@
# i've separated numpy-dependent methods from the rest of the utils.
from time import time
from utils import AcquireForWriting, merge_summaries, feps, m33, m34, m93
from .utils import AcquireForWriting, merge_summaries, feps, m33, m34, m93
import numpy as np