Skip to content

epymorph.data.mm.pei

Commuters

Bases: MovementClause

The commuter clause of the pei model.

requirements class-attribute instance-attribute

requirements = (
    _COMMUTERS_ATTRIB,
    AttributeDef(
        "move_control",
        float,
        Scalar,
        default_value=0.9,
        comment="A factor which modulates the number of commuters by conducting a binomial draw with this probability and the expected commuters from the commuters matrix.",
    ),
)

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?

commuters_by_node cached property

commuters_by_node: NDArray[SimDType]

Total commuters living in each state.

commuting_probability cached property

commuting_probability: NDArray[float64]

Commuters as a ratio to the total commuters living in that state. For cases where there are no commuters, avoid div-by-0 errors

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).

Dispersers

Bases: MovementClause

The dispersers clause of the pei model.

requirements class-attribute instance-attribute

requirements = (
    _COMMUTERS_ATTRIB,
    AttributeDef(
        "theta",
        float,
        Scalar,
        default_value=0.1,
        comment="A factor which allows for randomized movement by conducting a poisson draw with this factor times the average number of commuters between two nodes from the commuters matrix.",
    ),
)

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?

commuters_average cached property

commuters_average: NDArray[SimDType]

Average commuters between locations.

evaluate

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

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).

Pei

Bases: MovementModel

Modeled after the Pei influenza paper, this model simulates two types of movers -- regular commuters and more-randomized dispersers. Each is somewhat stochastic but adhere to the general shape dictated by the commuters array. Both kinds of movement can be "tuned" through their respective parameters: move_control and theta.

steps class-attribute instance-attribute

steps = (1 / 3, 2 / 3)

The length and order of tau steps.

clauses class-attribute instance-attribute

clauses = (Commuters(), Dispersers())

The movement clauses that make up the model.