diff --git a/.gitignore b/.gitignore index 9f27c88..00bfcfd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ -__pycache__/* -*.old *.bak +*.old +__pycache__/* +cache/* +EvoloPy-master/* +lesser_pyopus/* +t/* diff --git a/thursday/__main__.py b/thursday/__main__.py new file mode 100644 index 0000000..7d41f8c --- /dev/null +++ b/thursday/__main__.py @@ -0,0 +1,5 @@ +from .go_benchmark_it import main + +main(["thursday", "everything", "-2"]) +main(["thursday", "everything", "-3"]) +main(["thursday", "everything", "-4"]) diff --git a/birect.py b/thursday/birect.py similarity index 100% rename from birect.py rename to thursday/birect.py diff --git a/dlibcube2.py b/thursday/dlibcube2.py similarity index 84% rename from dlibcube2.py rename to thursday/dlibcube2.py index 6bd191c..c233600 100644 --- a/dlibcube2.py +++ b/thursday/dlibcube2.py @@ -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): diff --git a/evolopycube2.py b/thursday/evolopycube2.py similarity index 96% rename from evolopycube2.py rename to thursday/evolopycube2.py index d9473b4..8e8abe3 100644 --- a/evolopycube2.py +++ b/thursday/evolopycube2.py @@ -1,4 +1,4 @@ -from utils import wrap_untrustworthy, final, ExhaustedTrialsError +from .utils import wrap_untrustworthy, final, ExhaustedTrialsError import numpy as np diff --git a/fcmaescube2.py b/thursday/fcmaescube2.py similarity index 99% rename from fcmaescube2.py rename to thursday/fcmaescube2.py index 4a21cf5..f576ac6 100644 --- a/fcmaescube2.py +++ b/thursday/fcmaescube2.py @@ -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 diff --git a/generate_lists.py b/thursday/generate_lists.py similarity index 100% rename from generate_lists.py rename to thursday/generate_lists.py diff --git a/go_benchmark_it.py b/thursday/go_benchmark_it.py similarity index 96% rename from go_benchmark_it.py rename to thursday/go_benchmark_it.py index 51020e3..5b32c63 100644 --- a/go_benchmark_it.py +++ b/thursday/go_benchmark_it.py @@ -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 diff --git a/go_benchmark_lists.py b/thursday/go_benchmark_lists.py similarity index 100% rename from go_benchmark_lists.py rename to thursday/go_benchmark_lists.py diff --git a/go_benchmarks.py b/thursday/go_benchmarks.py similarity index 100% rename from go_benchmarks.py rename to thursday/go_benchmarks.py diff --git a/hg.py b/thursday/hg.py similarity index 100% rename from hg.py rename to thursday/hg.py diff --git a/hipsterplot.py b/thursday/hipsterplot.py similarity index 100% rename from hipsterplot.py rename to thursday/hipsterplot.py diff --git a/nevergradcube2.py b/thursday/nevergradcube2.py similarity index 100% rename from nevergradcube2.py rename to thursday/nevergradcube2.py diff --git a/nloptcube2.py b/thursday/nloptcube2.py similarity index 100% rename from nloptcube2.py rename to thursday/nloptcube2.py diff --git a/notwacube.py b/thursday/notwacube.py similarity index 92% rename from notwacube.py rename to thursday/notwacube.py index 0741b13..b5bafa7 100644 --- a/notwacube.py +++ b/thursday/notwacube.py @@ -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, diff --git a/notwacube2.py b/thursday/notwacube2.py similarity index 94% rename from notwacube2.py rename to thursday/notwacube2.py index d688896..c47dd09 100644 --- a/notwacube2.py +++ b/thursday/notwacube2.py @@ -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) diff --git a/prog80.py b/thursday/prog80.py similarity index 100% rename from prog80.py rename to thursday/prog80.py diff --git a/randomcube2.py b/thursday/randomcube2.py similarity index 98% rename from randomcube2.py rename to thursday/randomcube2.py index c194d72..d9de008 100644 --- a/randomcube2.py +++ b/thursday/randomcube2.py @@ -1,4 +1,4 @@ -from utils import phi +from .utils import phi import numpy as np diff --git a/scipycube2.py b/thursday/scipycube2.py similarity index 99% rename from scipycube2.py rename to thursday/scipycube2.py index 25e8bfd..617e99c 100644 --- a/scipycube2.py +++ b/thursday/scipycube2.py @@ -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 diff --git a/solutions_1680721604.py b/thursday/solutions_1680721604.py similarity index 100% rename from solutions_1680721604.py rename to thursday/solutions_1680721604.py diff --git a/solutions_1680730206.py b/thursday/solutions_1680730206.py similarity index 100% rename from solutions_1680730206.py rename to thursday/solutions_1680730206.py diff --git a/solutions_1680975848.py b/thursday/solutions_1680975848.py similarity index 100% rename from solutions_1680975848.py rename to thursday/solutions_1680975848.py diff --git a/soo.py b/thursday/soo.py similarity index 100% rename from soo.py rename to thursday/soo.py diff --git a/tinytweaks.py b/thursday/tinytweaks.py similarity index 100% rename from tinytweaks.py rename to thursday/tinytweaks.py diff --git a/utils.py b/thursday/utils.py similarity index 99% rename from utils.py rename to thursday/utils.py index 8c4be65..84fb7e3 100644 --- a/utils.py +++ b/thursday/utils.py @@ -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 * diff --git a/utils_np.py b/thursday/utils_np.py similarity index 99% rename from utils_np.py rename to thursday/utils_np.py index 7d2bef2..6491805 100644 --- a/utils_np.py +++ b/thursday/utils_np.py @@ -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