randomize execution

This commit is contained in:
2024-09-13 14:56:41 +02:00
parent 508ece6074
commit 7a29ea46c0
2 changed files with 7 additions and 2 deletions

View File

@@ -0,0 +1,3 @@
Run the simulation using:
uv run python -m simulation.app

View File

@@ -1,4 +1,5 @@
import os
import random
from concurrent.futures import ProcessPoolExecutor, as_completed
from dataclasses import dataclass
@@ -87,7 +88,8 @@ def run_simulation(n_servers=2, lam=40):
if __name__ == "__main__":
with ProcessPoolExecutor(max_workers=os.cpu_count()) as executor:
max_workers = max((os.cpu_count() or 0) - 1, 1)
with ProcessPoolExecutor(max_workers=max_workers) as executor:
n_servers = [n + 1 for n in range(10)]
lam = [(n + 1) * 4 for n in range(10)]
parameter_values = [
@@ -98,7 +100,7 @@ if __name__ == "__main__":
]
futures = [
executor.submit(run_simulation, **parameters)
for parameters in parameter_values
for parameters in random.sample(parameter_values, len(parameter_values))
]
results = []