Skip to content

epymorph.data.mm.centroids

CentroidsClause

Bases: MovementClause

The clause of the centroids model.

requirements class-attribute instance-attribute

requirements = (
    AttributeDef(
        "population",
        int,
        N,
        comment="The total population at each node.",
    ),
    AttributeDef(
        "centroid",
        CentroidType,
        N,
        comment="The centroids for each node as (longitude, latitude) tuples.",
    ),
    AttributeDef(
        "phi",
        float,
        Scalar,
        default_value=40.0,
        comment="Influences the distance that movers tend to travel.",
    ),
    AttributeDef(
        "commuter_proportion",
        float,
        Scalar,
        default_value=0.1,
        comment="The proportion of the total population which commutes.",
    ),
)

The attribute definitions describing the data requirements for this function.

For advanced use-cases, you may specify requirements as a property if you need it to be dynamically computed.

predicate class-attribute instance-attribute

predicate = EveryDay()

When does this movement clause apply?

leaves class-attribute instance-attribute

leaves = TickIndex(step=0)

On which tau step does this movement clause apply?

returns class-attribute instance-attribute

returns = TickDelta(step=1, days=0)

When do the movers from this clause return home?

dispersal_kernel cached property

dispersal_kernel: NDArray[float64]

The NxN matrix or dispersal kernel describing the tendency for movers to move to a particular location. In this model, the kernel is: 1 / e ^ (distance / phi) which is then row-normalized.

evaluate

evaluate(tick: Tick) -> NDArray[int64]

Implement this method to provide logic for the clause. Use self methods and properties to access the simulation context or defer processing to another function.

Parameters:

  • tick (Tick) –

    The simulation tick being evaluated.

Returns:

  • NDArray[SimDType]

    An array describing the requested number of individuals to move from origin location (row; axis 0) to destination location (column; axis 1).

Centroids

Bases: MovementModel

The centroids MM describes a basic commuter movement where a fixed proportion of the population commutes every day, travels to another location for 1/3 of a day (with a location likelihood that decreases with distance), and then returns home for the remaining 2/3 of the day.

steps class-attribute instance-attribute

steps = (1 / 3, 2 / 3)

The length and order of tau steps.

clauses class-attribute instance-attribute

clauses = (CentroidsClause(),)

The movement clauses that make up the model.