2
votes

I am trying to do an epidemic spread modeling where all the agents are moving in a continuous space. All the agents have a certain "fieldOfVision" area. If within this "fieldOfVision" of a "susceptible" agent another agent who is "exposed" comes & stays for 5 or more minutes, then that susceptible agent will also become "exposed". If that "exposed" agent comes & stays for less then 5 min, then the "susceptible" agent will remain in "susceptible" state.

My agent's statechart is like below:

agent's statechart

Initially 6 agents will be "exposed" by sending some msg from main. As the agent is also a pedestrian type agent, at time zero, there is no agent to receive the msg. So, I had to send the msg from main after 3 min of model startup so that someone is receiving the msg. That is working well.

The first transition action from "susceptible" state is as below. I put transition timeout 3.1 min because at 3 min there will be some exposed agent for the first time.

checkExposedNearby transition

If no one is nearby or within "fieldOfVision" then "noExposedNearby" transition will be executed as below.

noExposedNearby

If there is someone "exposed" within "fieldOfVision" then "foundExposedNearby" transition will be executed as below and will again go through the same loop until that exposed person is out of the "fieldOfVision"

foundExposedNearby transition

if that exposed person left from the "fieldOfVision" triangle then "exposedNearbyLeft" transition will be executed as below and will calculate the final time.

exposedNearbyLeft transition]5

then the "probablyExposed" state will calculate the total exposure time that "exposed" agent was near that "susceptible" agent & will check whether it's more than 5 or not. If it's more than 5 then it will go through "enoughExposure" transition otherwise it will go through "notEnoughExposure" & will be back to susceptible state again.

probablyExposed state

problem is, during runtime after the 7 min, I am getting this error. It seems, my code is not able to get the value of pedX & pedY after sometime. My question is how I can continue that loop & look for the duration that nearest exposed agent and statechart's susceptible agent are within each other's "fieldOfVision"? Is there any suggestion to do so?

It's a long post to read through. If you have come this far, first of all I thank you for your patience. Moreover, I will be really grateful if you can share some thoughts on how I can get the agent's dynamical distance to check whether someone is newly exposed or not. Will really appreciate your feedback.

javascript of error

runtime error

2

2 Answers

0
votes

As Felipe says, this is caused because thisPed is null in your code.

Simply check for this and do not execute this code, as below:

if (myPed != null) {
    your code doing stuff with myPed...;
}

You can add an else section to do something when myPed is null, but that depends on your model (i.e. throw an error if this should actually never happen...)

0
votes

what is actually happening is that thisPed is null, which can happen because at some point there was no agent found that was in the the exposed state during the checkExposedNearby transition.

I don't see other option with the info provided.