0
votes

I have an agent-based simulation of an epidemic in which I use a standard SEIR model. I define the infection parameters in the main class. I now want to be able to change some agents during model runtime.

For example: I have defined 'contact rate' as a parameter in the 'main' class. I now want to be able to say that once an agent gets hospitalised, its contact rate now becomes 0. I tried writing a function within the 'agent' class that said:

if (hospitalise == true) {
main.ContactsPerDay = 0.0;
}

But this just sets the overall contact rate to 0 as soon as the first hospitalisation occurs, which is obviously wrong.

How could I write a function within agents that would only modify the contact rate for specific agents?

2

2 Answers

0
votes

I don't think you want to do that... this is a structural error... the number of contacts is defined by the contact rate and you shouldn't change that (unless you are isolating the agents who were hospitalized forever so they can never talk with anybody else ever again)

What I think you really want to do, is making the agent immune to the infection... this means that in your patient statechart, when a patient is recovered, he should never go back to the susceptible state.

Or another way of doing it is in the exposed or infected statechart, when you infect randomly another agent, you have the action send( "Infection", RANDOM_CONNECTED ); You can replace that by

if(!hospitalise)//same as hospitalize==false
    send( "Infection", RANDOM_CONNECTED );
0
votes

Structure correctness, or logic/reasoning aside, main.ContactsPerDay refers to the parameter in Main. That is why the code you have posted sets the overall contact rate to zero.

Using this.ContactsPerDay = 0 should produce the result you described.