solvers.deliveries
Not for the user: deliveries in a compartmental run
ss.Event (and its subclass ss.Delivery) is the one class for events and deliveries, and its methods are how it runs as agents. In a compartmental run, a delivery also makes a CompartmentalDelivery (delivery.in_compartments), which holds what only that needs: a selection is the fraction of the people in each state and group, so who is reached, served, moved, cured, or tested is a fraction of each, and moving them moves fractions of the engine’s compartments between groups, carrying the events of the step along. The schedule, coverage, capacity, conditions, products, and results stay the delivery’s.
Used with: compartments; declared modules
Classes
| Name | Description |
|---|---|
| CompartmentalDelivery | A delivery in a compartmental run (delivery.in_compartments): what differs from agents, where a selection is the fraction of the people in each state and group |
CompartmentalDelivery
solvers.deliveries.CompartmentalDelivery(delivery)A delivery in a compartmental run (delivery.in_compartments): what differs from agents, where a selection is the fraction of the people in each state and group
Made by ss.Event.init_pre() when the sim is compartmental; the delivery’s own methods call it where they differ.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| delivery | ss.Delivery |
the delivery | required |
Methods
| Name | Description |
|---|---|
| arrived | The people who have just moved into a state (a number per group), as a fraction of those in it |
| carry_events | Carry the events of this step (see ss.Event.fire()) along a move the delivery has just made, between groups (to |
| cure | Move the people treated along the transitions of the treatment; returns those treated as they now are, in parts (see ss.Event.cure()) |
| cure_groups | The treatment of one disease: each move in turn, from those in its sources |
| cure_joint | The treatment of several diseases: the people chosen in each compartment and group are moved as a population of their |
| follow | Move the selected people to other levels of some dimensions; returns those chosen among them, as they now are |
| force_part | Move some of the people of an engine (C, by compartment and group) along transitions, with their probability; returns them after, and of them, the cured (where they are now) and those who failed |
| give | Give what is delivered to the people chosen, and record them (and the outcomes) as its events; see ss.Event.give() |
| hold | Those chosen now hold the product: at level 1, or with doses (doses=), the next dose; returns them, as they now are |
| many_shifts | The results of many runs, as store_shifts() but with runs first: each series as runs by time points, and (as out.groups) by group too, if kept |
| n_selected | The number of people selected |
| plain_move | Whether a move between states (move=S >> I) keeps everyone in their group, so the kernels can take it: no strain to arrive with, no record of who was offered it, and states of the same dimensions |
| relocate | Move some people (by state and group) to other levels; returns where they are now |
| relocated | Move the chosen up one level of some dimensions (the last kept); returns them, as a fraction of where they now are |
| respell | For routine delivery that records who has been offered it: the fraction of the people in each state and group who start a new |
| same_people | A selection made from the people in each state and group as they were (before), as a fraction of them as they are now that some have moved |
| shift | Move the selected people to other levels of some dimensions, in every declared disease (mover is the event they are, if known: see carry_events()) |
| shifts | The delivery as the kernels take it (see ss.kernels.Shifts): the steps it happens on; the fraction of the people in each state and group |
| store_shifts | The results of a whole run, from the number reached and eligible in each group at each time point |
| tabulated | Whether the kernels can take the delivery in a whole run: see ss.Event.tabulated |
| take | Choose n people from the candidates: whole cells in the order of the priority (key) and how long they have waited, and pro rata within a tie (see ss.Event.take()) |
| tally | Add the people selected to a result, in total and by group; returns the total |
| test | The results of a test, every one now (a delay is agents only): the fraction of those tested with each, from the probability of each result or a more severe one (tails) |
arrived
solvers.deliveries.CompartmentalDelivery.arrived(dst, total)The people who have just moved into a state (a number per group), as a fraction of those in it
carry_events
solvers.deliveries.CompartmentalDelivery.carry_events(
frac,
before,
mover=None,
target=None,
dst=None,
)Carry the events of this step (see ss.Event.fire()) along a move the delivery has just made, between groups (to target) or into a state (dst), so that the steps that read them later in the step find their people where they now are. Of the people of an event, those moved are: all the movers, if the movers are within the event (e.g. a step it triggered, mover); none, if they are disjoint from it; and otherwise the same fraction as of everyone in their state and group.
cure
solvers.deliveries.CompartmentalDelivery.cure(chosen)Move the people treated along the transitions of the treatment; returns those treated as they now are, in parts (see ss.Event.cure())
cure_groups
solvers.deliveries.CompartmentalDelivery.cure_groups(chosen)The treatment of one disease: each move in turn, from those in its sources
cure_joint
solvers.deliveries.CompartmentalDelivery.cure_joint(chosen, diseases)The treatment of several diseases: the people chosen in each compartment and group are moved as a population of their own (with force()), so the fraction forced is chosen × probability in each, and the rest of them have failed. Diseases tracked jointly (see ss.solvers.JointStates) pass the same people on, by way of the joint array, so each sees those the others treated. Its outcomes are events as fractions of this disease’s states and groups; someone cured of one disease and failed for another counts in both, and anyone in both outcomes for two diseases counts twice (clipped at all)
follow
solvers.deliveries.CompartmentalDelivery.follow(
sel,
chosen,
changes,
mover=None,
)Move the selected people to other levels of some dimensions; returns those chosen among them, as they now are
force_part
solvers.deliveries.CompartmentalDelivery.force_part(eng, C, edges)Move some of the people of an engine (C, by compartment and group) along transitions, with their probability; returns them after, and of them, the cured (where they are now) and those who failed
give
solvers.deliveries.CompartmentalDelivery.give(chosen)Give what is delivered to the people chosen, and record them (and the outcomes) as its events; see ss.Event.give()
hold
solvers.deliveries.CompartmentalDelivery.hold(chosen)Those chosen now hold the product: at level 1, or with doses (doses=), the next dose; returns them, as they now are
many_shifts
solvers.deliveries.CompartmentalDelivery.many_shifts(
tally,
tally_g=None,
group_ti=None,
)The results of many runs, as store_shifts() but with runs first: each series as runs by time points, and (as out.groups) by group too, if kept
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| tally | array |
runs by time points by 2 by groups (or by one group, the total) | required |
| tally_g | array |
the same by group, as runs by rows by 2 by groups, if they are kept apart from the totals | None |
| group_ti | array |
the time point of each row of tally_g, if they are not every time point (see ss.solvers.group_rows()) |
None |
n_selected
solvers.deliveries.CompartmentalDelivery.n_selected(sel)The number of people selected
plain_move
solvers.deliveries.CompartmentalDelivery.plain_move()Whether a move between states (move=S >> I) keeps everyone in their group, so the kernels can take it: no strain to arrive with, no record of who was offered it, and states of the same dimensions
relocate
solvers.deliveries.CompartmentalDelivery.relocate(amount, changes)Move some people (by state and group) to other levels; returns where they are now
relocated
solvers.deliveries.CompartmentalDelivery.relocated(chosen, bumps)Move the chosen up one level of some dimensions (the last kept); returns them, as a fraction of where they now are
respell
solvers.deliveries.CompartmentalDelivery.respell()For routine delivery that records who has been offered it: the fraction of the people in each state and group who start a new spell of being eligible (offered it, and no longer eligible), and the group they go back to (see ss.Event.new_spells()); None for any other. The kernels take it as a delivery of its own that reaches nobody, with everyone eligible going to rest.
same_people
solvers.deliveries.CompartmentalDelivery.same_people(sel, before)A selection made from the people in each state and group as they were (before), as a fraction of them as they are now that some have moved
shift
solvers.deliveries.CompartmentalDelivery.shift(sel, changes, mover=None)Move the selected people to other levels of some dimensions, in every declared disease (mover is the event they are, if known: see carry_events())
shifts
solvers.deliveries.CompartmentalDelivery.shifts()The delivery as the kernels take it (see ss.kernels.Shifts): the steps it happens on; the fraction of the people in each state and group who are eligible, and of those, who are reached; the group that each group’s people move to if reached, and if not; and for a move between states, the fraction of those reached who land in each compartment (by compartment and group; otherwise all zero)
store_shifts
solvers.deliveries.CompartmentalDelivery.store_shifts(tally, start=0, done=True)The results of a whole run, from the number reached and eligible in each group at each time point
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| tally | array |
time points by 2 by groups | required |
| start | int |
the time point of its first row, for a run stored a part at a time (see ss.solvers.Compartmental.run_parts()) |
0 |
| done | bool |
whether this is the last part | True |
tabulated
solvers.deliveries.CompartmentalDelivery.tabulated()Whether the kernels can take the delivery in a whole run: see ss.Event.tabulated
take
solvers.deliveries.CompartmentalDelivery.take(cands, n, key=None, wait=None)Choose n people from the candidates: whole cells in the order of the priority (key) and how long they have waited, and pro rata within a tie (see ss.Event.take())
tally
solvers.deliveries.CompartmentalDelivery.tally(key, sel, weight=1.0)Add the people selected to a result, in total and by group; returns the total
test
solvers.deliveries.CompartmentalDelivery.test(chosen, tails)The results of a test, every one now (a delay is agents only): the fraction of those tested with each, from the probability of each result or a more severe one (tails)
Functions
| Name | Description |
|---|---|
| carry_moved | In a compartmental run: carry the events of this step along a move of the people of one of them (by a transition that |
| current_groups | In a compartmental run: the people an event happened to on this step (entries, see ss.products.EventSource.fire()), as a fraction of each state and group of a module’s selector |
| memory_layout | In a compartmental run: the stratification that keeps whether an event happened (.ever, the only memory with a compartmental form: see ss.solvers.init_capabilities()), or None if nothing reads it |
| memory_strats | In a compartmental run: the properties of people that keep whether the events of a delivery, and of its product (by its first delivery), happened, if something reads it |
| remember_levels | In a compartmental run: move the people an event happened to (a fraction of the people in each state and group of eng as they were in before) to the level of its memory that says it happened |
| trigger_groups | In a compartmental run: the transition tr of mod, triggered by an event of a delivery or product, moves the fraction of the people it happened to who are in its sources (see ss.interventions.trigger_moves()) |
| water_fill | Take n people from cells holding amount each: whole cells in the order of their keys (lowest first, the first key before the second), and pro rata within a tie |
carry_moved
solvers.deliveries.carry_moved(owner, outcome, eng, before)In a compartmental run: carry the events of this step along a move of the people of one of them (by a transition that event triggered: see trigger_groups()), from the people it took out of each state and group to those it put in, so a step that reads them later in the step finds them where they are now. An event with the same people (e.g. a delivery’s outcome, and its product’s) moves as they did; any other, the same fraction as of everyone in their state and group
current_groups
solvers.deliveries.current_groups(owner, outcome, entries, selector)In a compartmental run: the people an event happened to on this step (entries, see ss.products.EventSource.fire()), as a fraction of each state and group of a module’s selector
memory_layout
solvers.deliveries.memory_layout(sim, key)In a compartmental run: the stratification that keeps whether an event happened (.ever, the only memory with a compartmental form: see ss.solvers.init_capabilities()), or None if nothing reads it
memory_strats
solvers.deliveries.memory_strats(delivery, sim=None)In a compartmental run: the properties of people that keep whether the events of a delivery, and of its product (by its first delivery), happened, if something reads it
remember_levels
solvers.deliveries.remember_levels(owner, outcome, sel, before, eng)In a compartmental run: move the people an event happened to (a fraction of the people in each state and group of eng as they were in before) to the level of its memory that says it happened
trigger_groups
solvers.deliveries.trigger_groups(
owner,
outcome,
mod,
tr,
event,
cond,
sel,
eng,
before,
)In a compartmental run: the transition tr of mod, triggered by an event of a delivery or product, moves the fraction of the people it happened to who are in its sources (see ss.interventions.trigger_moves())
water_fill
solvers.deliveries.water_fill(amount, n, keys)Take n people from cells holding amount each: whole cells in the order of their keys (lowest first, the first key before the second), and pro rata within a tie
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| amount | array |
the people that can be taken from each cell | required |
| n | float |
the number to take | required |
| keys | list |
arrays of the same shape as amount (or that broadcast to it) |
required |