egttools.numerical.structure.run_network_sweep

run_network_sweep(games: collections.abc.Sequence[object], betas: Annotated[numpy.typing.ArrayLike, numpy.float64], topologies: collections.abc.Sequence[collections.abc.Mapping[SupportsInt | SupportsIndex, collections.abc.Sequence[SupportsInt | SupportsIndex]]], nb_strategies: SupportsInt | SupportsIndex, mu: SupportsFloat | SupportsIndex, nb_runs: SupportsInt | SupportsIndex, avg_gens: SupportsInt | SupportsIndex, transitory: SupportsInt | SupportsIndex, init_state: Annotated[numpy.typing.ArrayLike, numpy.uint64], update_rule: str = 'PC', cache_size: SupportsInt | SupportsIndex = 100000) numpy.typing.NDArray[numpy.float64]

Run a parallel parameter sweep over multiple games and topologies using OpenMP.

Each (game, topology) combination is simulated independently with nb_runs runs. Topologies are shared read-only across threads — the adjacency list is never copied — so even a complete graph at large N uses only one copy of memory.

Parameters:
  • games (list[AbstractSpatialGame]) – One C++ game object per parameter combination (e.g. one per (T, S) grid point). Must be C++ classes such as NormalFormNetworkGame or OneShotCRDNetworkGame. Python subclasses of AbstractSpatialGame raise TypeError because calculate_fitness would be called without the GIL.

  • betas (np.ndarray, shape (n_games,)) – Selection-intensity / payoff-normalisation constant, one per game. For the LP rule pass max(T, 1.0) - min(S, 0.0) per (T, S) point.

  • topologies (list[dict[int, list[int]]]) – Network adjacency dicts (NetworkX format). Shared read-only across threads.

  • nb_strategies (int) – Number of strategies.

  • mu (float) – Mutation probability per time step.

  • nb_runs (int) – Independent simulation runs per (game, topology) combination.

  • avg_gens (int) – Generations to record after the transitory.

  • transitory (int) – Burn-in generations (discarded before recording).

  • init_state (np.ndarray[uint64], shape (nb_strategies,)) – Initial strategy counts; must sum to population_size.

  • update_rule (str, optional) – "LP" / "LinearProportional" (default for Santos 2006), "PC" / "PairwiseComparison", "BD" / "BirthDeath", "DB" / "DeathBirth".

  • cache_size (int, optional) – Per-thread LRU fitness cache capacity (default 100 000).

Returns:

Mean cooperation fraction (strategy-0 count / N) for each (game, topology) pair, averaged over nb_runs runs and avg_gens recording generations. Average over the topology axis to get a single cooperation frequency per parameter combination.

Return type:

np.ndarray, shape (n_games, n_topologies)