BaseMixing#

class BaseMixing(scenario, params)[source]#

Bases: ABC

Base class for migration models.

property migration_matrix: ndarray#

Migration matrix computed from get_migration_matrix().

Returns:

The migration matrix with lazy computation and caching.

Return type:

np.ndarray

property mixing_matrix: ndarray#

Mixing matrix computed from get_mixing_matrix().

Returns:

The mixing matrix with lazy computation and caching.

Return type:

np.ndarray

abstractmethod get_migration_matrix()[source]#

Initialize a migration/diffusion matrix for population mixing. The diffusion matrix is a square matrix where each row represents the outbound migration from a given patch to all other patches e.g., [i,j] = [from_i, to_j].

Convention is: - Trips into node j: N_i @ M[i,j] - Trips out of node i: np.sum(M[i,j] * N_i[:,np.newaxis], axis=1)

Returns:

The diffusion matrix: (N, N)

Return type:

ndarray

trips_into()[source]#

Returns the number of trips into each patch per tick.

Return type:

ndarray

trips_out_of()[source]#

Returns the number of trips out of each patch per tick.

Return type:

ndarray

get_mixing_matrix()[source]#

Initialize a mixing matrix for population mixing.

The mixing matrix is a square matrix where each row represents the mixing of a given patch to all other patches e.g., [i,j] = [from_i, to_j]. It also includes internal mixing within a patch.

Return type:

ndarray