egttools.numerical.numerical_.NetworkEvolver

class NetworkEvolver

Bases: pybind11_object

Methods

estimate_time_dependent_average_gradients_of_selection

Estimates the time-dependent gradient of selection for the specified states.

estimate_time_independent_average_gradients_of_selection

Estimates time-independent gradients of selection for given states.

evolve

Evolves the network population and returns the final state.

run

Simulates the full trajectory of the population states.

__init__(*args, **kwargs)
__new__(**kwargs)
static estimate_time_dependent_average_gradients_of_selection()

Estimates the time-dependent gradient of selection for the specified states.

This method simulates evolution starting from each state and calculates the average gradient of selection between generation_start and generation_stop.

Parameters:
  • states (List[NDArray[np.int64]]) – List of population states (strategy counts) to evaluate.

  • nb_simulations (int) – Number of simulations per state.

  • generation_start (int) – First generation to include in averaging.

  • generation_stop (int) – Last generation to include in averaging.

  • network (egttools.numerical.structure.AbstractNetworkStructure) – A network structure for population evolution.

Returns:

Averaged gradient matrix for all given states.

Return type:

NDArray[np.float64]

Example

>>> avg_grad = NetworkEvolver.estimate_time_dependent_average_gradients_of_selection(
...     states, 50, 100, 200, my_network)

Same as the single-network version but averages over multiple networks.

Parameters:
  • states (List[NDArray[np.int64]]) – Initial population states.

  • nb_simulations (int) – Number of simulations per state.

  • generation_start (int) – First generation to consider.

  • generation_stop (int) – Last generation to consider.

  • networks (List[egttools.numerical.structure.AbstractNetworkStructure]) – Multiple network structures for averaging.

Returns:

Averaged gradients for each initial state.

Return type:

NDArray[np.float64]

Example

>>> avg_grad = NetworkEvolver.estimate_time_dependent_average_gradients_of_selection(
...     states, 100, 50, 100, [net1, net2])
static estimate_time_independent_average_gradients_of_selection()

Estimates time-independent gradients of selection for given states.

Parameters:
  • states (List[NDArray[np.int64]]) – Initial states to evaluate.

  • nb_simulations (int) – Number of simulations per state.

  • nb_generations (int) – Total generations to evolve per simulation.

  • network (AbstractNetworkStructure) – Network describing the evolutionary interactions.

Returns:

A matrix with one row per initial state and one column per strategy.

Return type:

NDArray[np.float64]

Example

>>> gradients = NetworkEvolver.estimate_time_independent_average_gradients_of_selection(
...     states, 100, 200, my_network)

Estimates time-independent gradients of selection across multiple networks.

Parameters:
  • states (List[NDArray[np.int64]]) – Initial population states.

  • nb_simulations (int) – Number of simulations per state.

  • nb_generations (int) – Number of generations per simulation.

  • networks (List[AbstractNetworkStructure]) – List of network structures for averaging.

Returns:

Matrix of averaged gradients, one row per state.

Return type:

NDArray[np.float64]

Example

>>> gradients = NetworkEvolver.estimate_time_independent_average_gradients_of_selection(
...     states, 50, 100, [net1, net2, net3])
static evolve()

Evolves the network population and returns the final state.

This simulates the dynamics over the given network structure and returns the final strategy counts after a number of generations.

Parameters:
  • nb_generations (int) – Number of generations to simulate.

  • network (egttools.numerical.structure.AbstractNetworkStructure) – The network structure describing the population and its interactions.

Returns:

Final strategy counts after evolution.

Return type:

NDArray[np.int64]

Example

>>> final = NetworkEvolver.evolve(1000, my_network)

Evolves the network population from a given initial state.

Parameters:
  • nb_generations (int) – Number of generations to simulate.

  • initial_state (NDArray[np.int64]) – Initial counts of each strategy in the population.

  • network (egttools.numerical.structure.AbstractNetworkStructure) – The network structure containing the population.

Returns:

Final strategy counts after evolution.

Return type:

NDArray[np.int64]

Example

>>> final = NetworkEvolver.evolve(1000, initial_state, my_network)
static run()

Simulates the full trajectory of the population states.

This method runs the simulation and returns all population states after the transitory period.

Parameters:
  • nb_generations (int) – Total number of generations to simulate.

  • transitory (int) – Number of generations to discard before returning results.

  • network (egttools.numerical.structure.AbstractNetworkStructure) – The network structure containing the population.

Returns:

A matrix of shape (nb_generations - transitory, nb_strategies) representing the strategy counts over time.

Return type:

NDArray[np.int64]

Example

>>> trace = NetworkEvolver.run(1000, 100, my_network)

Runs the simulation from a custom initial state.

Parameters:
  • nb_generations (int) – Total number of generations.

  • transitory (int) – Number of initial generations to discard.

  • initial_state (NDArray[np.int64]) – Initial counts of strategies in the population.

  • network (egttools.numerical.structure.AbstractNetworkStructure) – A network structure containing the population.

Returns:

Trajectory of population states after the transitory phase.

Return type:

NDArray[np.int64]

Example

>>> trace = NetworkEvolver.run(1000, 100, init_state, my_network)
__annotations__ = {}