Skip to content

Commit daa8806

Browse files
committed
Move max_size into config
1 parent c05e428 commit daa8806

File tree

6 files changed

+10
-32
lines changed

6 files changed

+10
-32
lines changed

benchmarks/Snakefile

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def generate_all_runs(problem):
1616

1717
problem_data = config["problems"][problem]
1818
if problem_data is None or "size" not in problem_data:
19-
sizes = ["0"]
19+
sizes = [0]
2020
else:
2121
sizes = problem_data["size"]
2222

@@ -27,19 +27,7 @@ def generate_all_runs(problem):
2727
config["libraries"],
2828
config["solvers"]
2929
)
30-
]
31-
32-
benchmarks = [
33-
importlib.import_module(f"benchmarks.{problem}.bm_{library.lower()}").Bench
34-
if library not in ["jump"]
35-
else None
36-
for size, library, solver in runs
37-
]
38-
39-
runs = [
40-
r for r, benchmark in zip(
41-
runs, benchmarks
42-
) if benchmark is None or benchmark.MAX_SIZE == None or r[0] <= benchmark.MAX_SIZE
30+
if size <= problem_data["max_sizes"].get(library, float('inf'))
4331
]
4432

4533
return runs
@@ -84,7 +72,7 @@ rule mem_profile:
8472
"results/{problem}/{library}_{solver}_{size}_memray.html"
8573
shell:
8674
"""
87-
memray run --trace-python-allocators --native --aggregate -o results/{wildcards.problem}/{wildcards.library}_{wildcards.solver}_{wildcards.size}_memray.bin src/run_benchmark.py {wildcards.problem} --library {wildcards.library} --solver {wildcards.solver} --size {wildcards.size}
75+
memray run --trace-python-allocators --follow-fork --native --aggregate -o results/{wildcards.problem}/{wildcards.library}_{wildcards.solver}_{wildcards.size}_memray.bin src/run_benchmark.py {wildcards.problem} --library {wildcards.library} --solver {wildcards.solver} --size {wildcards.size}
8876
memray flamegraph -o results/{wildcards.problem}/{wildcards.library}_{wildcards.solver}_{wildcards.size}_memray.html results/{wildcards.problem}/{wildcards.library}_{wildcards.solver}_{wildcards.size}_memray.bin
8977
"""
9078

benchmarks/config.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
repeat: 1 # TODO repeat
1+
repeat: 1 # TODO repeat
22
problems:
33
facility_location:
44
size:
@@ -7,6 +7,11 @@ problems:
77
- 75
88
- 100
99
- 150
10+
- 200
11+
max_sizes:
12+
# jump: 150
13+
pyomo: 75
14+
gurobipy: 150
1015
# energy_problem:
1116

1217
solvers:
@@ -27,4 +32,4 @@ profile:
2732
- library: pyoframe
2833
solver: gurobi
2934
size: 150
30-
problem: facility_location
35+
problem: facility_location

benchmarks/src/facility_location/bm_gurobipy.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010

1111
class Bench(GurobiPyBenchmark):
12-
MAX_SIZE = 100
13-
1412
def build(self):
1513
if isinstance(self.size, int):
1614
G = F = self.size

benchmarks/src/facility_location/bm_pyomo.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111

1212
class Bench(PyomoBenchmark):
13-
MAX_SIZE = 75 # After that it gets too slow
14-
1513
def build(self):
1614
if isinstance(self.size, int):
1715
G = F = self.size

benchmarks/src/run_benchmark.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,6 @@ def get_problems() -> Collection[str]:
3232
f"benchmarks.{args.problem}.bm_{args.library.lower()}"
3333
).Bench
3434

35-
if (
36-
args.size is not None
37-
and benchmark.MAX_SIZE is not None
38-
and args.size > benchmark.MAX_SIZE
39-
):
40-
raise ValueError(
41-
f"Size {args.size} exceeds maximum size {benchmark.MAX_SIZE} for problem {args.problem}."
42-
)
43-
4435
benchmark(solver=args.solver, size=args.size).run()
4536
else:
4637
subprocess.run(

benchmarks/src/utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99

1010
class Benchmark(ABC):
11-
MAX_SIZE = None
12-
1311
def __init__(self, solver, size=None, block_solver=True):
1412
assert solver in self.get_supported_solvers(), (
1513
f"{solver} is not supported by {self.__class__.__name__}."

0 commit comments

Comments
 (0)