diff --git a/latextable.py b/latextable.py index 85bf292397b031227c0b496c545a0cd276cf5e9c..da011a80604baa5b30afd8995c5e0c4ab493b365 100644 --- a/latextable.py +++ b/latextable.py @@ -32,7 +32,10 @@ syn = { "instructions" : "circuit size", "homotopycontinuation": "HomotopyContinuation.jl", "macaulay2": "Macaulay2", - "sirocco": "SIROCCO" + "sirocco": "SIROCCO", + "pathjump": "jump", + "maxwmeanprec": "w. mean", + "maxprec": "max.", } def title(D, key): diff --git a/packages/adaptive b/packages/adaptive index 0a0ac5b099e0ba362bd1bcc260232f545aa514b2..521047c6e118081f9ea86f9ce154e9164bef8e56 160000 --- a/packages/adaptive +++ b/packages/adaptive @@ -1 +1 @@ -Subproject commit 0a0ac5b099e0ba362bd1bcc260232f545aa514b2 +Subproject commit 521047c6e118081f9ea86f9ce154e9164bef8e56 diff --git a/synthesize.sage b/synthesize.sage index 272838425773adb71483cdf588e7f4776fab9161..3426e9c3697f204e8d36a94c5805bf6484624fa3 100644 --- a/synthesize.sage +++ b/synthesize.sage @@ -5,8 +5,9 @@ import argparse import math from pathlib import Path -parser = argparse.ArgumentParser(description = "A python script to generate a table of results out of given entries.") -parser.add_argument("entries", help = "A JSON file containing entries.") +parser = argparse.ArgumentParser( + description="A python script to generate a table of results out of given entries.") +parser.add_argument("entries", help="A JSON file containing entries.") args = parser.parse_args() @@ -39,7 +40,8 @@ def time_format(t): return str(int(t/60)) + " min" else: return str(int(t/3600)) + " h" - + + def time_format_2(t): t = float(t) if t == 0: @@ -54,7 +56,8 @@ def time_format_2(t): return str(int(t/60)) + " min" else: return str(int(t/3600)) + " h" - + + def steps_format(N): if N == 0: return "" @@ -63,6 +66,7 @@ def steps_format(N): else: return str(math.ceil(N/1_000.0)) + "\\,k" + def steps_format_2(N): if N == 0: return "" @@ -74,7 +78,8 @@ def steps_format_2(N): return "{0:.1f}".format(N/1_000.0) else: return str(math.ceil(N/1_000.0)) - + + def bytes_format(N): if N == 0: return "" @@ -106,7 +111,8 @@ def fusion(LT1, LT2): for _ in range(m - n) ] return [l1 + l2 for l1, l2 in zip(LT1, LT2)] - + + def _header(header_dict): res = [] if header_dict["children"] != 0: @@ -135,35 +141,50 @@ def get_leaves(D): L += get_leaves(child) return L + def degrees(data): data_path = (Path("data") / Path(data)).with_suffix(".json") if not data_path.exists(): return [-1] - + data_file = open(data_path, "r") try: d = json.load(data_file) except: return [-1] - - - A = PolynomialRing(CC, names = d["parameters"] + d["variables"]) + + A = PolynomialRing(CC, names=d["parameters"] + d["variables"]) t = A.gens()[0] - return [A(f).subs(t = 0).degree() for f in d["system"]] - -def instructions(data, derivative = False): + return [A(f).subs(t=0).degree() for f in d["system"]] + + +def instructions(data, derivative=False): function = "f" if not derivative else "df" for pkg in ["algpath", "adaptive"]: - pkg_out = Path("benchmarks") / Path(data) / Path(pkg) / Path("out.json") + pkg_out = Path("benchmarks") / Path(data) / \ + Path(pkg) / Path("out.json") if pkg_out.exists(): return json.load(open(str(pkg_out), "r"))["instructions"][function] return -1 - -#. Formulas for the different statistics to computes + +def name(data): + data_names = data.split("/") + if data_names[0] in ["linear", "newton"]: + name = data_names[1] + else: + name = data_names[0] + + name = name.split("-")[0] + name += " *"*("random" in data) + \ + " \\textsuperscript{N}"*("newton" in data) + " \\textsuperscript{F}"*("factorized" in data) + return name + + +# . Formulas for the different statistics to computes data_stats = { "raw name": lambda data: data.replace("/", "\_"), - "name": lambda data: data.split("/")[1].split("-")[0] + " *"*(not "all" in data) + " \\textsuperscript{N}"*("newton" in data), + "name": name, "dimension": lambda data: len(json.load(open(f"data/{data}.json", "r"))["system"]), "max deg": lambda data: int(max(degrees(data))), "paths": lambda data: len(json.load(open(f"data/{data}.json", "r"))["fiber"]), @@ -194,11 +215,13 @@ result_stats = { "maxmeanprec": lambda res: steps_format(max([int(p) for p in res["meanpreclist"]])), "wmeanprec": lambda res: steps_format(numpy.mean([int(p) for p in res["weightedmeanpreclist"]])), "maxwmeanprec": lambda res: steps_format(max([int(p) for p in res["weightedmeanpreclist"]])), + "pathjump": lambda res: "" + ("ncertified" in res and "failures" in res and int(res["ncertified"]) != len(res["steplist"]) - int(res["failures"]))*"X" } + def _table(data, branch, node): key = node["val"] - + # Data stats if key in data_stats: try: @@ -208,44 +231,51 @@ def _table(data, branch, node): # Local stats if key in result_stats: - pkg_name = branch[0] - results = json.load(open(f"benchmarks/{data}/{pkg_name}/out.json", "r")) + pkg_name = branch[1] try: + results = json.load( + open(f"benchmarks/{data}/{pkg_name}/out.json", "r")) return [{"str": str(result_stats[key](results)), "w": int(1)}] except: - return [{"str": "", "w": int(1)}] - + return [{"str": "err", "w": int(1)}] + # Packages handling if key in ["homotopycontinuation", "algpath", "macaulay2", "sirocco", "adaptive"]: dir = f"benchmarks/{data}/{key}/" if not (Path(dir) / "info.json").exists(): return [{"str": "not benchmarked", "w": len(get_leaves(node))}] - - info_dict = json.load(open(f"{dir}info.json")) + + try: + info_dict = json.load(open(f"{dir}info.json")) + except: + return [{"str": "err", "w": len(get_leaves(node))}] + if info_dict["timeout error"]: timeout = info_dict["timeout"] return [{"str": f"$>$ {time_format(timeout)}", "w": len(get_leaves(node))}] - + if info_dict["memory error"]: memory = info_dict["memory"] return [{"str": f"$>$ {bytes_format(memory)}", "w": len(get_leaves(node))}] if info_dict["script error"]: return [{"str": "script error", "w": len(get_leaves(node))}] - + if info_dict["killed manually"]: return [{"str": "killed", "w": len(get_leaves(node))}] # By default, compute recursively the table # This is the case for the following node values: "instructions" - return sum([_table(data, [key] + branch, child) for child in node["children"]], []) - + return sum([_table(data, branch + [key], child) for child in node["children"]], []) + + def table(data, dict): return _table(data, [], dict) # Computing the table and writing it in a .json file -table_dict = {"header": header(header_dict), "table": [table(data, header_dict) for data in data_list]} +table_dict = {"header": header(header_dict), "table": [ + table(data, header_dict) for data in data_list]} table_file = open(f"{os.path.dirname(args.entries)}/table.json", "w") -json.dump(table_dict, table_file, indent = 2) -table_file.close() \ No newline at end of file +json.dump(table_dict, table_file, indent=2) +table_file.close() diff --git a/tables/issac_2025/entries.json b/tables/issac_2025/entries.json index 786d88d775ba48daafd919cb6e1bc3d7d2b733d9..668b880725e7b4ec05ad23fce2c05b2ae1417cd4 100644 --- a/tables/issac_2025/entries.json +++ b/tables/issac_2025/entries.json @@ -49,8 +49,21 @@ "children": [] }, { - "val": "maxsteps", + "val": "pathjump", "children": [] + }, + { + "val": "steps", + "children": [ + { + "val": "medsteps", + "children": [] + }, + { + "val": "maxsteps", + "children": [] + } + ] } ] }, @@ -62,15 +75,33 @@ "children": [] }, { - "val": "maxprec", - "children": [] + "val": "prec", + "children": [ + { + "val": "maxprec", + "children": [] + }, + { + "val": "maxwmeanprec", + "children": [] + } + ] }, { - "val": "maxsteps", - "children": [] + "val": "steps", + "children": [ + { + "val": "medsteps", + "children": [] + }, + { + "val": "maxsteps", + "children": [] + } + ] } ] } ] } -} +} \ No newline at end of file