Pandemics

Description

This example try to solve a case study about Pandemics. The problem is extensively described in the paper listed in References.

Model

The corresponding P-Lingua file is the following:

@model<probabilistic>

def Pandemia_(CO,F)
{
        /* Membrane structure */

        @mu= [ [[ []'1 ]'0 ]'101,101 [[ []'1 ]'0 ]'102,102 [[ []'1 ]'0 ]'103,103  ]'p;

        /* Initial multisets */

        @ms(1,{100+c}) += X{f,j,0} * q{f,j,c} : 1<=f<=4*F, 1<=j<=7, 1<=c<=CO;
        @ms(1,{100+c}) += a{n} * I{n,c} : 1<=n<=4, 1<=c<=CO;
        @ms(1,{100+c}) += R{0} : 1<=c<=CO;

        /*r1*/ [X{f,j,0},a{n}  --> XS{f,j,i}, S{f,j}*20]'1 :: ps/4:F*(n-1)<f<=F*n,1<=j<=7,2<=i<=5,1<=n<=4;
        /*r2*/ [X{f,j,0},a{n}  --> XA{f,j,i},XM, A{f,j}*20]'1 :: (1-ps)/4:F*(n-1)<f<=F*n,1<=j<=7,2<=i<=5,1<=n<=4;

        /*r3*/ [R{0}-->R{1}]'1:: 1;

        /*r4*/ [S{f,k},X{f,j,0}]'1 --> -[S{f,k},X{f,j,1},XM]'1 ::1 :1<=f<=4*F,1<=j<=7,1<=k<=7;
        /*r5*/ [A{f,k},X{f,j,0}]'1 --> -[A{f,k},X{f,j,1},XM]'1 ::1 :1<=f<=4*F,1<=j<=7,1<=k<=7;
        /*r6*/ [S{f,k},XM]'1 --> -[S{f,k},XM]'1 ::1 :1<=f<=4*F,1<=k<=7;
        /*r7*/ [A{f,k},XM]'1 --> -[A{f,k},XM]'1 ::1 :1<=f<=4*F,1<=k<=7;

        /*r8*/ [R{1}]'1-->-[R{2}]'1:: 1;

        /*r9*/ -[X{f,j,0}]'1-->[Y{f,j,0}]'1:: 1: 1<=f<=4*F,1<=j<=7;
        /*r10*/ -[XM]'1-->[YM]'1:: 1;
        /*r11*/ -[S{f,j}]'1-->[#]'1:: 1: 0<f<=4*F,1<=j<=7;
        /*r12*/ -[R{2}]'1-->[R{3}]'1:: 1;

        /*r13*/ [A{f,j},Y{k,r,0}]'1 --> -[A{f,j},X{k,r,1},YM]'1 ::1:1<=f<=F,1<=k<=F,1<=j<=7,1<=r<=7;
        /*r14*/ [A{f,j},Y{k,r,0}]'1 --> -[A{f,j},X{k,r,1},YM]'1 ::1 :F<f<=2*F,F<k<=2*F,1<=j<=7,1<=r<=7;
        /*r15*/ [A{f,j},Y{k,r,0}]'1 --> -[A{f,j},X{k,r,1},YM]'1 ::1 :2*F<f<=3*F,2*F<k<=3*F,1<=j<=7,1<=r<=7;
        /*r16*/ [A{f,j},Y{k,r,0}]'1 --> -[A{f,j},X{k,r,1},YM]'1 ::1 :3*F<f<=4*F,3*F<k<=4*F,1<=j<=7,1<=r<=7;
        /*r17*/ [A{f,j},YM]'1 --> -[A{f,j},YM]'1 ::1 :1<=f<=4*F,1<=j<=7;

        /*r18*/ [R{3}]'1-->-[R{4}]'1:: 1;

        /*r19*/ -[Y{f,j,0}]'1-->[Z{f,j,0}]'1:: 1: 1<=f<=4*F,1<=j<=7;
        /*r20*/ -[YM]'1-->[ZM]'1:: 1;

        /*r21*/ -[R{4}]'1-->[R{5}]'1:: 1;

        /*r22*/ [A{f,j},Z{k,r,0}]'1 --> -[A{f,j},X{k,r,1},ZM]'1 ::1:0<f<=4*F,0<k<=4*F,1<=j<=7,1<=r<=7;
        /*r23*/ [A{f,j},ZM]'1 --> -[A{f,j},ZM]'1 ::1 :0<f<=4*F,1<=j<=7;

        /*r24*/ [R{5}]'1-->-[R{6}]'1:: 1;

        /*r25*/ -[Z{f,j,0}]'1-->[V{f,j,0}]'1:: 1: 1<=f<=4*F,1<=j<=7;
        /*r26*/ -[ZM]'1-->[VM]'1:: 1;

        /*r27*/ -[R{6}]'1-->[R{7}]'1:: 1;

        /*r28*/ [A{f,j},V{k,j,0}]'1 --> +[A{f,j},X{k,j,1},VM]'1 ::1 :0<f<=4*F,0<k<=4*F,1<=j<=7;
        /*r29*/ [A{f,j},VM]'1 --> +[A{f,j},VM]'1 ::1 :0<f<=4*F,1<=j<=7;

    /*r30*/ [R{7}]'1-->+[R{8}]'1:: 1;

        /*r31*/ +[V{f,j,0}]'1-->V{f,j,0} []'1:: 1: 0<f<=4*F,1<=j<=7;
        /*r32*/ +[VM]'1-->VM[]'1:: 1;
        /*r33*/ +[A{f,j}]'1-->A{f,j}[]'1:: 1: 0<f<=4*F,1<=j<=7;


    /*r34*/ +[X{f,j,1}]'1-->X{f,j,1} []'1:: 1: 0<f<=4*F,1<=j<=7;
        /*r35*/ +[XA{f,j,i}]'1-->XA{f,j,i} []'1:: 1: 0<f<=4*F,1<=j<=7, 2<=i<=5;
        /*r36*/ +[XS{f,j,i}]'1-->XS{f,j,i} []'1:: 1: 0<f<=4*F,1<=j<=7, 2<=i<=5;
        /*r37*/ +[XR{f,j}]'1-->XR{f,j} []'1:: 1: 0<f<=4*F,1<=j<=7;

        /*r38*/ +[R{8}]'1-->[R{9}]'1:: 1;

        /*r39*/ [V{f,j,0}]'0--> Vp{f,j,0,e}[]'0:: (1/CO): 0<f<=4*F,1<=j<=7,1<=e<=CO;
        /*r40*/ [VM]'0--> VMp{e}[]'0:: (1/CO): 1<=e<=CO;
        /*r41*/ [A{f,j}]'0--> Ap{f,j,e}[]'0:: (1/CO): 0<f<=4*F,1<=j<=7, 1<=e<=CO;

        /*r42*/ [R{9}-->R{10}]'1:: 1;

        /*re1*/ [[Vp{f,j,0,i}]'{e+100} []'{100+i} --> []'{e+100} [W{f,j,0,e}]'{100+i}]'p::1:0<f<=4*F,1<=j<=7,1<=e<=CO, 1<=i<=CO, e<>i;
        /*re2*/ [[Ap{f,j,i}]'{e+100} []'{100+i} --> []'{e+100} [Aw{f,j}]'{100+i}]'p::1:0<f<=4*F,1<=j<=7,1<=e<=CO,1<=i<=CO, e<>i;
        /*re3*/ [[VMp{i}]'{e+100} []'{100+i} --> []'{e+100} [WM]'{100+i}]'p::1:1<=e<=CO,1<=i<=CO, e<>i;
        /*re1*/ [[Vp{f,j,0,e}]'{100+e} -->  [W{f,j,0,e}]'{100+e}]'p::1:0<f<=4*F,1<=j<=7,1<=e<=CO;
        /*re2*/ [[Ap{f,j,e}]'{100+e} -->  [Aw{f,j}]'{100+e}]'p::1:0<f<=4*F,1<=j<=7,1<=e<=CO;
        /*re3*/ [[VMp{e}]'{100+e} -->  [WM]'{100+e}]'p::1:1<=e<=CO;

        /*r43*/ [R{10}-->R{11}]'1:: 1;

        /*r44*/ W{f,j,0,e}[]'0 -->  [W{f,j,0,e}]'0::1:0<f<=4*F,1<=j<=7,1<=e<=CO;
        /*r45*/ Aw{f,j}[]'0  -->  [Aw{f,j}]'0::1:0<f<=4*F,1<=j<=7;
        /*r46*/ WM[]'0 --> [WM]'0::1;

        /*r47*/ [R{11}-->R{12}]'1:: 1;

        /*r48*/ W{f,j,0,e}[]'1 -->  [W{f,j,0,e}]'1::1:0<f<=4*F,1<=j<=7,1<=e<=CO;
        /*r49*/ Aw{f,j}[]'1  -->  [Aw{f,j}]'1::1:0<f<=4*F,1<=j<=7;
        /*r50*/ WM[]'1 --> [WM]'1::1;

        /*r51*/ [R{12}-->R{13}]'1:: 1;

        /*r52*/ [Aw{f,j},W{k,r,0,e}]'1 --> -[Xp{k,r,1,e}]'1 ::1 :0<f<=4*F,0<k<=4*F,1<=j<=7,1<=r<=7,1<=e<=CO;
        /*r53*/ [Aw{f,j},WM]'1--> -[#]'1 ::1 :0<f<=4*F,1<=j<=7;

        /*r54*/ [R{13}]'1-->-[R{14}]'1:: 1;

        /*r55*/ -[Aw{f,j}]'1 --> [#]'1 ::1 :0<f<=4*F,1<=j<=7;
        /*r56*/ -[WM]'1 --> [#]'1 ::1;
        /*r57*/ -[W{f,j,0,e}]'1 --> Wp{f,j,0,e}[]'1 ::1 :0<f<=4*F,1<=j<=7,1<=e<=CO;
        /*r58*/ -[Xp{f,j,1,e}]'1 --> Xp{f,j,1,e}[]'1 ::1 :0<f<=4*F,1<=j<=7,1<=e<=CO;

        /*r59*/ -[R{14}]'1-->[R{15}]'1:: 1;

        /*r60*/ [Wp{f,j,0,e}]'0 --> Xp{f,j,0,e}[]'0 ::1 :0<f<=4*F,1<=j<=7,1<=e<=CO;
        /*r61*/ [Xp{f,j,1,e}]'0 --> Xp{f,j,1,e}[]'0 ::1 :0<f<=4*F,1<=j<=7,1<=e<=CO;

        /*r62*/ [R{15}]'1-->[R{16}]'1:: 1;

        /*re1*/ [[Xp{f,j,i,e}]'{100+ep} []'{100+e} --> []'{100+ep} [X{f,j,i}]'{100+e}]'p::1:0<f<=4*F,1<=j<=7,0<=i<=1,1<=e<=CO, 1<=ep<=CO, ep<>e;
        /*re1*/ [[Xp{f,j,i,e}]'{100+e} -->  [X{f,j,i}]'{100+e}]'p::1:0<f<=4*F,1<=j<=7,0<=i<=1,1<=e<=CO;


        /*r63*/ [R{16}]'1-->[R{17}]'1:: 1;

        /*r64*/ X{f,j,i}[]'0  -->  [X{f,j,i}]'0::1:0<f<=4*F,1<=j<=7,0<=i<=1;

        /*r65*/ [R{17}]'1-->+[R{18}]'1:: 1;

        /*r66*/ X{f,j,0}+[]'1 --> [X{f,j,0}]'1 ::1 :0<f<=4*F,1<=j<=7;
        /*r67*/ X{f,j,1}+[]'1 --> [XS{f,j,2},S{f,j}*20]'1 ::(ps*p{j}) :0<f<=4*F,1<=j<=7;
        /*r68*/ X{f,j,1}+[]'1 --> [XA{f,j,2}, A{f,j}*20,XM]'1 ::p{j}*(1-ps) :0<f<=4*F,1<=j<=7;
        /*r69*/ X{f,j,1}+[]'1 --> [X{f,j,0}]'1 ::(1-p{j}) :0<f<=4*F,1<=j<=7;
        /*r70*/ XS{f,j,i}+[]'1 --> [XS{f,j,i+1},S{f,j}*20 ]'1 ::1:0<f<=4*F,1<=j<=7, 2<=i<=4;
        /*r71*/ XA{f,j,i}+[]'1 --> [XA{f,j,i+1},A{f,j}*20, XM ]'1 ::1 :0<f<=4*F,1<=j<=7, 2<=i<=4;
        /*r72*/ XA{f,j,5}+[]'1 --> [XR{f,j}, XM ]'1 ::1 :0<f<=4*F,1<=j<=7;
        /*r74*/ XS{f,j,5}+[]'1 --> [XR{f,j}, XM ]'1 ::pr{j} :0<f<=4*F,1<=j<=7;
        /*r75*/ XS{f,j,5}+[]'1 --> [#]'1 ::(1-pr{j}) :0<f<=4*F,1<=j<=7;
        /*r76*/ XR{f,j}+[]'1 --> [XR{f,j},XM ]'1 ::1 :0<f<=4*F,1<=j<=7;

        /*r77*/ +[R{18}]'1-->[R{1}]'1:: 1;
}
def main()
{
        call Pandemia_(3,5);
}

Files

  • Custom application, defining the needed input and output tables for partition problem.
  • Model file, P-Lingua file with the parametrized file specifying the family of P systems for solving the problem. The custom interface enable the user to introduce the data corresponding to each different scenario.
  • Scenario file, for a specific instance of the problem.

Simulation

MeCoSim is available in this download url. Go there and press Install.

To run the examples, simply do the following from MeCoSim main window:

  • Load a new app: in MeCoSim initial screen, option New > choose the custom app file (.xls).
  • Run the app, by double-clicking the app (or alternatively by pressing button or menu option Run).
  • Set a model inside an app: from the running app, option Model > Set Model > choose the model file (.pli).
  • Set a scenario inside an app: from the running app, option Scenario > Open > choose the scenario file (.ec2).
  • Simulate the model in Simulation > Simulate!.

That’s all! The simulation will run until a halting configuration is reached. Then the user will see a message like this:

../../_images/SimulationEnd.png

Interaction and results

The data for the specific instance of the problem is given by the proper input tables:

../../_images/SimulationInputPopulation.png ../../_images/SimulationInputSymptomatologyInfection.png

After the simulation, the output is provided by means of tables and charts:

../../_images/SimulationOutput.png