Skip to content

Commit b1253b6

Browse files
committed
Window scales with grid size
1 parent a63d22d commit b1253b6

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

scripts/warmup_study.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ class WarmupStudyConfig:
9191
def estimate_equilibration_trend(
9292
time_series: np.ndarray,
9393
sample_interval: int,
94-
window: int = 10,
94+
grid_size: int = 100,
95+
base_window: int = 10,
9596
n_check: int = 8,
9697
min_alternation_rate: float = 0.35,
9798
) -> int:
@@ -110,8 +111,11 @@ def estimate_equilibration_trend(
110111
Population density or count over time.
111112
sample_interval : int
112113
Number of simulation steps between samples.
113-
window : int
114-
Size of rolling window for smoothing (reduces noise in direction detection).
114+
grid_size : int
115+
Size of the grid (L). Used to scale the window size, since larger
116+
grids have longer correlation times for fluctuations.
117+
base_window : int
118+
Base window size for L=100. Actual window scales as base_window * (L/100).
115119
n_check : int
116120
Number of consecutive changes to check for alternation pattern.
117121
min_alternation_rate : float
@@ -124,6 +128,9 @@ def estimate_equilibration_trend(
124128
int
125129
Estimated equilibration step.
126130
"""
131+
# Scale window with grid size (larger grids have longer correlation times)
132+
window = max(base_window, int(base_window * (grid_size / 100)))
133+
127134
if len(time_series) < window + n_check + 10:
128135
return len(time_series) * sample_interval
129136

@@ -212,6 +219,10 @@ def set_numba_seed(seed): pass
212219
logger.info(f"Testing grid size L = {L}")
213220
logger.info(f"{'='*50}")
214221

222+
# Show scaled window size
223+
scaled_window = max(cfg.equilibration_window, int(cfg.equilibration_window * (L / 100)))
224+
logger.info(f" Window size (scaled): {scaled_window} samples")
225+
215226
# Warmup Numba kernels for this size
216227
warmup_numba_kernels(L, directed_hunting=cfg.directed_hunting)
217228

@@ -269,7 +280,8 @@ def set_numba_seed(seed): pass
269280
eq_steps = estimate_equilibration_trend(
270281
prey_densities,
271282
cfg.sample_interval,
272-
window=cfg.equilibration_window,
283+
grid_size=L,
284+
base_window=cfg.equilibration_window,
273285
)
274286

275287
size_results['time_per_step'].append(time_per_step)

0 commit comments

Comments
 (0)