// This is a SIR model for disease spread in communities #params //define parameters here param p =0.5; #states //define states here //an agent in state "S" at location "(0,0)" can receive a "contact" msg and become infected, or move to another location. //"|S(0,0)|" refers to the number of agents in state "S" at location "(0,0)". S(0,0):= ?(contact,p)@Pr{1/(|S(0,0)|+|I(0,0)|+|R(0,0)|)}.I(0,0)+(move_0_1,0.01).S(0,1)+(move_0_2,0.03).S(1,0); S(0,1):= ?(contact,p)@Pr{1/(|S(0,1)|+|I(0,1)|+|R(0,1)|)}.I(0,1)+(move_1_0,0.01).S(0,0)+(move_1_3,0.03).S(1,1); S(1,0):= ?(contact,p)@Pr{1/(|S(1,0)|+|I(1,0)|+|R(1,0)|)}.I(1,0)+(move_2_0,0.02).S(0,0)+(move_2_3,0.01).S(1,1); S(1,1):= ?(contact,p)@Pr{1/(|S(1,1)|+|I(1,1)|+|R(1,1)|)}.I(1,1)+(move_3_1,0.03).S(0,1)+(move_3_2,0.03).S(1,0); //an agent in state "I" at location "(0,0)" can send out "contact" broadcast msg to its current location I(0,0):= !(contact,0.03)@IR{local}.I(0,0)+(recover,0.2).R(0,0)+(move_0_1,0.01).I(0,1)+(move_0_2,0.03).I(1,0); I(0,1):= !(contact,0.03)@IR{local}.I(0,1)+(recover,0.2).R(0,1)+(move_1_0,0.01).I(0,0)+(move_1_3,0.03).I(1,1); I(1,0):= !(contact,0.04)@IR{local}.I(1,0)+(recover,0.2).R(1,0)+(move_2_0,0.02).I(0,0)+(move_2_3,0.01).I(1,1); I(1,1):= !(contact,0.01)@IR{local}.I(1,1)+(recover,0.2).R(1,1)+(move_3_1,0.03).I(0,1)+(move_3_2,0.03).I(1,0); R(0,0):= (move_0_1,0.01).R(0,1)+(move_0_2,0.03).R(1,0); R(0,1):= (move_1_0,0.01).R(0,0)+(move_1_3,0.03).R(1,1); R(1,0):= (move_2_0,0.02).R(0,0)+(move_2_3,0.01).R(1,1); R(1,1):= (move_3_1,0.03).R(0,1)+(move_3_2,0.03).R(1,0); #agents S(0,0)[150] || I(0,0)[11] || R(0,0)[12] || S(0,1)[142] || I(0,1)[12] || R(0,1)[12] || S(1,0)[184] || I(1,0)[10] || R(1,0)[11] || S(1,1)[178] || I(1,1)[13] || R(1,1)[11]