This repository was archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodelTimeStep.m
More file actions
46 lines (45 loc) · 2.53 KB
/
modelTimeStep.m
File metadata and controls
46 lines (45 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
%this function is responsible for running a single timestep of the SIR
%model. it will loop through each node, and check if any other node is
%infected or if any node can be infected by it, based on a range threshold.
%it will then have a certain probability of infecting or being infected,
%based on a probability distribution that will deiffer between diseases
%being modeled
function modelTimeStep(t, numberOfMovements, maxTime, rangeThreshold)
%global nodeStatus
%[currentMovements]=loadOldMovements(t);
%delay();
for firstNodeIndex = 1:numberOfMovements;%iterate through each node
firstNode = loadCurrentMovements(firstNodeIndex, t);%load the current state of the nodes
for secondNodeIndex = 1:numberOfMovements;%iterate through each set of nodes in current time step
secondNode = loadCurrentMovements(secondNodeIndex,t);%load a new node from the old movements
%for newNodeIndex = 1:length(newMovements);%iterate through each of the new movements
% newNode = newMovements(newNodeIndex);%get a new movement
%check that it is not the same node as in the old movements
if((firstNodeIndex~=secondNodeIndex)&&(isInfected(firstNodeIndex)||isInfected(secondNodeIndex)))
%check if the current node is in the infectable range of the next node
inInfectableRange = checkDistance(firstNode, secondNode, rangeThreshold);
%if was in the range of the node
if(inInfectableRange)
%determine the length of time of the infection if the node was infected
infected = probabilityFunction(firstNodeIndex, secondNodeIndex, t, maxTime);
%if the node was infected, mark it as infected
%TODO: remove. marking of infected nodes occurs in
%probabilityFunction
if(infected)
markInfected(firstNodeIndex);
markInfected(secondNodeIndex);
end
end
end
%check if an infected node has become cured
if(infectedTimeExpired(firstNodeIndex, t))
markCured(firstNodeIndex, t);
end
if(infectedTimeExpired(secondNodeIndex, t))
markCured(secondNodeIndex, t);
end
%end
end
%oldMovements = newMovements;
end
end