Skip to content

Add long-form SIR convergence tests covering diverse topologies and parameter regimes#1389

Merged
SkBlaz merged 2 commits into
masterfrom
copilot/skblaz-1383-tests-for-long-sim
Jun 19, 2026
Merged

Add long-form SIR convergence tests covering diverse topologies and parameter regimes#1389
SkBlaz merged 2 commits into
masterfrom
copilot/skblaz-1383-tests-for-long-sim

Conversation

Copilot AI commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Existing SIR tests only ran 10–100 steps. Issue #1383 requires coverage of longer-form convergence behaviour across realistic use cases.

New test file: tests/test_sir_long_convergence.py

30 tests across 9 classes, running 200–500 steps against both SIRDynamics and simulate_sir_multiplex_discrete:

  • ConservationS + I + R = N holds throughout 200-step runs on ER, BA, grid, and path graphs
  • Monotonic recoveryR[t] is non-decreasing for 300 steps (absorbing-state invariant)
  • Extinction — infected count reaches zero by step 500 (SIR always extinguishes)
  • Prevalence bounds — prevalence ∈ [0, 1] throughout all long runs
  • Phase transition — super-threshold (β ≫ γ, dense graph) grows outbreak; sub-threshold fizzles
  • Final-size relation — higher β produces a strictly larger final R
  • Multi-replicate consistency — independent seeds all converge to extinction
  • Multiplex long-runsimulate_sir_multiplex_discrete conserves population over 200 steps
  • Result lengthlen(results) == steps + 1 for various step counts
# Example: conservation over 200 steps on a BA graph
G = nx.barabasi_albert_graph(80, 3, seed=0)
sir = SIRDynamics(G, beta=0.3, gamma=0.05, initial_infected=0.05)
sir.set_seed(7)
results = sir.run(steps=200)
counts = results.get_measure("state_counts")
N = G.number_of_nodes()
for t in range(201):
    assert counts["S"][t] + counts["I"][t] + counts["R"][t] == N

Copilot AI changed the title [WIP] Add tests for long form convergence in SIR Add long-form SIR convergence tests covering diverse topologies and parameter regimes Jun 18, 2026
Copilot AI requested a review from SkBlaz June 18, 2026 20:46
@SkBlaz SkBlaz marked this pull request as ready for review June 19, 2026 18:01
@SkBlaz SkBlaz merged commit c279fcc into master Jun 19, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants