# # Welcome to the RuleStudio Editor # # This editor will improve the speed of entering valid kappa by using auto completion and basic syntax checking as you write each line. # Auto completion of agents and rules will drop down when you are creating initial conditions, observables or rules that reuse agents in prior rules. # # This code simulates a Cellular Automaton for diverse purposes. ########## Rules 'inject' -> Rz(Type~Tg,State~F) @ 0.0 # The inject rule is for use in a perturbation, it will be triggered to add transgenic rhizobia 'Rz_TgDiv' Rz(Type~Tg,State~F) -> Rz(Type~Tg,State~F), Rz(Type~Tg,State~F) @ 0.3 'Rz_WtDiv' Rz(Type~Wt,State~F) -> Rz(Type~Wt,State~F), Rz(Type~Wt,State~F) @ 0.2 'Rz_F_Dth' Rz(Type,State~F) -> @ 0.1 'Rz_S_Dth' Rz(Type,State~S?) -> @ 0.05 # These rules are for cellular division and cellular death, for WildType and TransGenic strains 'Rz_Sym_1' Rz(Type,State~F), Plnt(S1~F,S2,S3) -> Rz(Type,State~S!1), Plnt(S1~S!1,S2,S3) @ 0.1 'Rz_Sym_2' Rz(Type,State~F), Plnt(S1,S2~F,S3) -> Rz(Type,State~S!1), Plnt(S1,S2~S!1,S3) @ 0.1 'Rz_Sym_3' Rz(Type,State~F), Plnt(S1,S2,S3~F) -> Rz(Type,State~S!1), Plnt(S1,S2,S3~S!1) @ 0.1 # These rules represent the symbiosis process 'Wt_N_Fix' Rz(Type~Wt,State~S?), Carbon() -> Rz(Type~Wt,State~S?), Nitrogen() @ 0.1 'TG_N_Fix' Rz(Type~Tg,State~S?), Carbon() -> Rz(Type~Tg,State~S?) @ 0.1 # These rules represent the economy of the niche, supply of C sources in exchange for nitrous compounds # A more thorough version would have different "weights" to the carbon intake of the rhizobia, however this would require more computing power due to the finer rates 'Plnt_C_P' Plnt(S1,S2,S3) -> Plnt(S1,S2,S3), Carbon() @ 0.1 # This is the fixation of carbon by plants through photosynthesis 'Plnt_Rep' Plnt(S1~S,S2~S,S3~S), Carbon(), Nitrogen() -> Plnt(S1~F,S2~F,S3~F), Plnt(S1~F,S2~F,S3~F) @ 0.1 # This rule represents plant reproduction through the use of C and N related compounds ########## Initialize %init: 300 * Rz(Type~Wt,State~F) %init: 30 * Plnt(S1~F,S2~F,S3~F) # We initialize the system with 300 rhizobia and 30 plants ########## Observables %obs: 'Rz_Wt_F' Rz(Type~Wt,State~F) %obs: 'Rz_Tg_F' Rz(Type~Tg,State~F) #%obs: 'Rz_Wt_S' Rz(Type~Wt,State~S?) %obs: 'N_Wt' Nitrogen() %obs: 'Plant' Plnt(S1?,S2?,S3?) #%obs: 'Rz_Tg_S' Rz(Type~Tg,State~S?) ########## Perturbations %mod: ['Rz_Wt_F'] > 500 do 'Rz_WtDiv' := 0.1 %mod: ['Rz_Tg_F'] > 500 do 'Rz_TgDiv' := 0.1 # These rules are to prevent the system from entering infinite growth, the maximum population under which exponential growth occurs is 500 elements. #%mod: $T > 10 do 'inject' := 0 %mod: $T > 10 do 'inject' := 500 %mod: ['Rz_Tg_F'] > 300 do 'inject' := 0 # At time 10, we introduce around 300 transgenic rhizobia, or not. This depends on which scenario we are running: pure vs. transgenic