metawards.mixers.InteractionMatrix

class metawards.mixers.InteractionMatrix(n: int, value: float = 0.0)[source]

This is an interaction matrix, which is used to control how the FOIs of different demographics are merged together.

An interaction matrix is just a square matrix, with a list[][] being perfectly acceptable. This is really a convenience class that makes it easier to create more complex interaction matrixes

__init__(n: int, value: float = 0.0)[source]

Construct an interaction matrix that is n x n in size, where all values equal ‘value’

Methods

__init__(n, value) Construct an interaction matrix that is n x n in size, where all values equal ‘value’
detach(n) Detach the ‘nth’ demographic from interacting with any other demographics.
diagonal(n, value, off_diagonal) Return a n x n matrix where each diagonal element equals ‘value’ and each off-diagonal element equals ‘off_diagonal’
identity(n, value, off_diagonal) Return a n x n matrix where each diagonal element equals ‘value’ and each off-diagonal element equals ‘off_diagonal’
ones(n, value) Return a n x n matrix where each element equals ‘value’
resize(n, value) Resize this matrix to ‘n x n’, adding in extra values equal to ‘value’ if needed
zeroes(n, value) Return a n x n matrix where each element equals ‘value’
__eq__(other)[source]

Return self==value.

__getitem__(i: int)[source]

Return the ith row of the matrix

__init__(n: int, value: float = 0.0)[source]

Construct an interaction matrix that is n x n in size, where all values equal ‘value’

__setitem__(i: int, row: List[int])[source]

“Set the ith row of the matrix equal to ‘row’

__str__()[source]

Return str(self).

detach(n: int)[source]

Detach the ‘nth’ demographic from interacting with any other demographics. This sets the ith row and ith column equal to zero (which not changing m[n][n])

static diagonal(n: int, value: float = 1.0, off_diagonal: float = 0.0)[source]

Return a n x n matrix where each diagonal element equals ‘value’ and each off-diagonal element equals ‘off_diagonal’

static identity(n: int, value: float = 1.0, off_diagonal: float = 0.0)[source]

Return a n x n matrix where each diagonal element equals ‘value’ and each off-diagonal element equals ‘off_diagonal’

static ones(n: int, value: float = 1.0)[source]

Return a n x n matrix where each element equals ‘value’

resize(n: int, value: float = 0.0)[source]

Resize this matrix to ‘n x n’, adding in extra values equal to ‘value’ if needed

static zeroes(n: int, value: float = 0.0)[source]

Return a n x n matrix where each element equals ‘value’