Package: propagsim
py-propagsimAuthor: Manuel CapelThis is the implementation in Python of a propagation model that we propose to callCASTasCell Agent State Transitions. Its purpose is modeling the propagation of epidemics and the impact of actions to counter it.:fr:For French, see thisblog articleInstallationpip install propagsimUsageSee thisnotebookfor a (toy) example of an implementation of this modelModel descriptionBasic objectsBasically, this model considers three types of object:Cell. Acellcan contain 0, 1 or manyagents at any time. It has also aposition(Euclidean coordinates on a plan)Agent. An agent has one (and only one)stateat a given moment, and is also in one (and only one) cell. Thecellwhere anagentis initially is considered to be itshome_cell.State. A state has a predefinedseverity,contagiousityandsensitivity, all in (0, 1)ContagionA contagion happens within a cell, when it contains several agents at the same time and one of them is contagious.
When an agent has a state withcontagiousity> 0, then the other agents in the same cell can get infected.
The probability ofAgent_Ato contaminateAgent_Bincellis given by:NB:The highest contagiousity in the cell is taken to computep.Theunsafetyof acellmeasures how a cell is unsafe for contagion (social distancing respected or not inside etc.)IfAgent_Bgets infected, it gets to its own state having the least strictly positiveseverity(it can't jump directly to a more severe state).State transitionAstate transition matrixandstate durationsare attached to eachagent. Thestate transition matrixis a Markovian matrix describing the transition probabilities between the states an agent can take. Thestate durationsare the duration of each state. If a agent is in a givenstate, it will switch to another one sampled according to itsstate transition matrixNB: Differentagents can share the same states and the samestate transition matrixbut have differentstate durations, or have have the samestate, the samestate durationsbut a differentstate transition matrix, or etc.MovesA move consists in movingagents to other cells. When a move is done, allagents are concerned. It happens it two steps:Selectingagents that will movemoving the selectedagents to their new cellsAgent selectionThe probability of anagentto be selected for a move is:The first factor represents the mobility of theagentso to say. The second factor represents the fact that the more severe the state of anagent, the less the probability that it will move.Cell selectionThecellwhere to move a selectedagentis sampled according to a probabilityNB:a limitation of this model is that the attractivity of eachcellis the same for allagent. An extension / refinement of this model would be to havecellattractivities personalized by agent.The distance is always computed from thehome_cellof an agent, not from itscurrent_cell. Anagentis considered wandering around itshome_cellTheagents not selected for a move will be moved to theirhome_cellafterwardTemporalityEach timeperiodcontains move rounds (they don't have to have all the same number of moverounds). During each moveround,agents are selected and moved as described above. Id they are infected, they can infect other agents in the samecellthan themselves. A timeperiodfinishes when all agents are simultanouslyforwarded. Eachagentis actually in a given state, that has a given duration. By aforward, the time in this state is incremented by 1. If this time then exceeds the duration of the current state of the agent, the agent moves to the next state according to itstransitiondescribed above.ContributingPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.Please make sure to update tests as appropriate.LicenseMIT