#Space: TwoD(15,15)

#Parameters
hSA = 3.0;
phSA = 0.5;
hSR = 3.0;
phSR = 0.5;
d = 3.0;
hA_1 = 3.0;
pA_1 = 1.0;
hA_2 = 3.0;
pA_2 = 1.0;
hA_3 = 3.0;
pA_3 = 1.0;
hA_4 = 3.0;
pA_4 = 1.0;
hA_5 = 3.0;
pA_5 = 1.0;
hR_1 = 3.0;
pR_1 = 1.0;
hR_2 = 3.0;
pR_2 = 1.0;
hR_3 = 3.0;
pR_3 = 1.0;
hR_4 = 3.0;
pR_4 = 1.0;
hR_5 = 3.0;
pR_5 = 1.0;
at_1 = 28.8;
pat_1 = 1.0;
at_2 = 14.4;
pat_2 = 1.0;
at_3 = 9.6;
pat_3 = 1.0;
at_4 = 7.2;
pat_4 = 1.0;
at_5 = 5.76;
pat_5 = 1.0;
re_1 = 28.8;
pre_1 = 1.0;
re_2 = 14.4;
pre_2 = 1.0;
re_3 = 9.6;
pre_3 = 1.0;
re_4 = 7.2;
pre_4 = 1.0;
re_5 = 5.76;
pre_5 = 1.0;
df = 0.16667;
pdf = 1.0;
rp = 0.0625;
prp = 1.0;
iA = 0.07;
iR = 0.07;
eA = 2.0;
peA = 1.0;
eR = 2.0;
peR = 1.0;

#Agents
P(l) := <-(sigA_1,pA_1).D(l) + <-(sigA_2,pA_2).D(l) + <-(sigA_3,pA_3).D(l) +
<-(sigA_4,pA_4).D(l) + <-(sigA_5,pA_5).D(l) + <-(sigR_1,pR_1).D(l) +
<-(sigR_2,pR_2).D(l) + <-(sigR_3,pR_3).D(l) + <-(sigR_4,pR_4).D(l) +
<-(sigR_5,pR_5).D(l);

D(l):= (dup,d).C(l)||P(l);

C(l):= <-(attr_1,pat_1)|>C(new(l)) + <-(attr_2,pat_2)|>C(new(l)) + <-(attr_3,pat_3)|>C(new(l)) +
<-(attr_4,pat_4)|>C(new(l)) + <-(attr_5,pat_5)|>C(new(l)) + <-(rep_1,pre_1)|>C(new(l)) +
<-(rep_2,pre_2)|>C(new(l)) + <-(rep_3,pre_3)|>C(new(l)) + <-(rep_4,pre_4)|>C(new(l)) +
<-(rep_5,pre_5)|>C(new(l)) + <-(diff,pdf).M(l);

M(l):= <-(repair,prp)«M(l);

I(l):= <-(actSA,phSA).A(l) + <-(actSR,phSR).R(l);

A(l):= ->{N(1)}(sigA_1,hA_1).A(l) + ->{N(2)}(sigA_2,hA_2).A(l) +
->{N(3)}(sigA_3,hA_3).A(l) + ->{N(4)}(sigA_4,hA_4).A(l) +
->{N(5)}(sigA_5,hA_5).A(l) + ->{N(1)}(attr_1,at_1).A(l) +
->{N(2)}(attr_2,at_2).A(l) + ->{N(3)}(attr_3,at_3).A(l) +
->{N(4)}(attr_4,at_4).A(l) + ->{N(5)}(attr_5,at_5).A(l) +
<-(endA,peA).I(l) + (inactiveA,iA).I(l);

R(l):= ->{N(1)}(sigR_1,hR_1).R(l) + ->{N(2)}(sigR_2,hR_2).R(l) +
->{N(3)}(sigR_3,hR_3).R(l) + ->{N(4)}(sigR_4,hR_4).R(l) +
->{N(5)}(sigR_5,hR_5).R(l) + ->{N(1)}(rep_1,re_1).R(l) +
->{N(2)}(rep_2,re_2).R(l) + ->{N(3)}(rep_3,re_3).R(l) +
->{N(4)}(rep_4,re_4).R(l) + ->{N(5)}(rep_5,re_5).R(l) +
<-(endR,peR).I(l) + (inactiveR,iR).I(l);

L(l):= ->{l}(actSA,hSA).L(l) + ->{l}(actSR,hSR).L(l) + ->{l}(diff,df).L(l) +
->{l}(repair,rp).LN(l);

LN(l):= ->{l}(endA,eA).LN(l) + ->{l}(endR,eR).LN(l);


#Initial conditions
fS(L), fL(N(3)), fLN(L \ N(3)), fP(L \ N(3), d)

To define the initial conditions, we use the functions fS, fL, fLN and fP which locate respectively an agent S, L, LN and P in each location l of the given spatial domain. The function fP will locate the agents P according with the given density d, which respects the density of OPCs. We indicate with N(3) a Von Neumann neighbourhood of range 3, centred in the centre of the grid.