Problem with triggering agent in a activity location

All topics related to questions in Pedestrian Dynamics
Post Reply
Manon
Posts: 4
Joined: Tuesday 20 June, 2017 - 11:44

Problem with triggering agent in a activity location

Post by Manon »

Situation:
In my model a group of agents enters a building, passes acces control and wait at a waiting location until triggered.
In this waiting location I want to group to wait until everybody arrived and then move on to another waiting location.
I have groups of 30 agents every 15 minutes.

Problem:
The help file offers me to functions for triggering agents in this situation:

Code: Select all

ActivityLocation_TriggerAllWaitingAgents(e1, e2, {e3})
and

Code: Select all

ActivityLocation_TriggerAllApproachingAgents(e1, e2, {e3})
Now I created an entry trigger:

Code: Select all

{**Trigger the agents when a group is complete**}
AND(
  ActivityLocation_TriggerAllWaitingAgents(
    c, {**Current location**}
    ActivityLocation_GetNumberOfAgents(c) = 30 {**Condition**}
  ),
  ActivityLocation_TriggerAllApproachingAgents(
    c, {**Current location**}
    ActivityLocation_GetNumberOfAgents(c) = 30 {**Condition**}
  )
)
But the problem is that the last agent entering the waiting location isn't an approaching one and since he is still looking for a random spot he is neither a waiting agent. But he is in the waiting location so he is counted in my stated condition:

Code: Select all

ActivityLocation_GetNumberOfAgents(c) = 30
. This results in a group of 29 agents running off and the last one entering stays behind.*

So how to address this loner? Or does anybody have a different approach.

In the help under Availability - Trigger on start there is a mention of

Code: Select all

ActivityLocation_TriggerAllAgents
but this isn't a valid function, although this might be the function I'm looking for..

*This isn't necessarily the last one entering, it's the last one who hasn't found his spot in the waiting area yet.. sometimes this is an agent being stuck between other agents who are in his assigned spot. So the location approaching option 'random' needs some work as well.
Manon
Posts: 4
Joined: Tuesday 20 June, 2017 - 11:44

Re: Problem with triggering agent in a activity location

Post by Manon »

Another solution I tried was rerouting all the agents to their new destination when the amount of 30 agents within the waiting location was reached.
First I saved the agentIDs and then I tried calling them all in a repeat-loop, yet nothing happens and I don't know why.

Code: Select all

{**Save current AgentsIDs**}
{**Save current AgentsIDs**}
do(
gString(ActivityLocation_GetNumberOfAgents(c)) := Name(AtomByID(Agent_GetAgentID(i))), {**gString(indexnr) := string to store in gString)**}
{**Trigger the agents when a group is complete**}
  if(
    ActivityLocation_GetNumberOfAgents(c) = 30,
    repeat(30,Agent_Reroute_ToDestination(AtomByName(gString(Count),model),AtomByName([Hall1],model))
    )
  )
)
Manon
Posts: 4
Joined: Tuesday 20 June, 2017 - 11:44

Re: Problem with triggering agent in a activity location

Post by Manon »

Another try gave me a few errors, which I don't know how to solve

Code: Select all

{**Save current AgentsIDs**}
do(
gData(ActivityLocation_GetNumberOfAgents(c)) := Agent_GetAgentID(i), {**gData(indexnr) := value to store in gData)**}
{**Trigger the agents when a group is complete**}
  if(
    ActivityLocation_GetNumberOfAgents(c) = 30,
    repeat(30,Agent_Reroute_ToDestination(AtomByName(Concat([School_Class_],gData(Count)),model),AtomByName([Hall1],model))
    )
  )
)
And these errors 30 times (for every agent I assume):
  • 544 No atom currently selected: Do(Var([atmAgent], vbAtom),Var([atmDest], vbAtom),Up(atmAgent)) -> Agent (AtomID: 129), FUNCTION: Agent_Reroute_ToDestination (Ln: 6, Col: 10) "Up" | Time: 1136.60000000006, c: Lockers (AtomID: 8678), i: School_Class_10056 (AtomID: 10056), OnEntered, EventCode: 1
  • 545 No atom currently selected: Do(Var([atmAgent], vbAtom),Var([atmDest], vbAtom),Up(Up(atmAgent))) -> Agent (AtomID: 129), FUNCTION: Agent_Reroute_ToDestination (Ln: 6, Col: 7) "Up" | Time: 1136.60000000006, c: Lockers (AtomID: 8678), i: School_Class_10056 (AtomID: 10056), OnEntered, EventCode: 1
  • 546 No atom currently selected: Do(Var([atmAgent], vbAtom),Var([atmDest], vbAtom),m(Up(Up(atmAgent)))) -> Agent (AtomID: 129), FUNCTION: Agent_Reroute_ToDestination (Ln: 6, Col: 5) "m" | Time: 1136.60000000006, c: Lockers (AtomID: 8678), i: School_Class_10056 (AtomID: 10056), OnEntered, EventCode: 1
Bram de Vries
Posts: 60
Joined: Thursday 08 January, 2015 - 13:29

Re: Problem with triggering agent in a activity location

Post by Bram de Vries »

Hi Manon,

A few remarks to explain what is going on:

- The And function is meant to evaluate several statements to see if they are all true (i.e. they all return the value 1). In this case, ActivityLocation_TriggerAllWaitingAgents returns the number of agents triggered. If the first statement of the And function is not true (does not return 1), the other statements will not be evaluated. I would suggest using Do instead of And.
- If you want to trigger the approaching agents, please also make sure that you have selected "Store appr. agents" in the interface of your Activity Location.
- In your case however, all approaching agents will then be triggered, since the agents will leave the Activity Location only after the Entry Trigger has been executed (and only then the Number of Agents for the Activity Location will be adjusted).

I would suggest a different approach: if you use the following code in the Activity Time you can forget about the Entry Trigger:

Code: Select all

If(
  ActivityLocation_GetNumberOfAgents(c) <> 30,
  -1,
  Do(
    ActivityLocation_TriggerAllWaitingAgents(c, {**Current location**} TRUE),
    0
  )
)
When the 30th agent arrives, I trigger the 29 agents who are waiting and the 30th agent will get an activity time of 0 and will move on directly as well.

As for your other solutions, I'm not quite sure what is going wrong there. It all seems logical, but when I try it the agents stay in place. I will report this. I think however that the cause of your errors when you use gData is that you should write Concat([School_Class_],String(gData(Count))),model) instead of Concat([School_Class_],gData(Count)),model), because the Concat function only accepts a string as input.

Kind regards,

Bram
Manon
Posts: 4
Joined: Tuesday 20 June, 2017 - 11:44

Re: Problem with triggering agent in a activity location

Post by Manon »

Hi Bram,

That's works like a charm. :)
Only problem is that this waiting area represents 'time spend putting stuff in lockers while waiting for the whole group'.
When in this case my school class goes home they have to visit these lockers again, but in this case the whole group gathers near the exit and not in front of the lockers. When putting the code in the entry trigger I could make it an entry trigger of an agent activity instead of an entry trigger of the location and the code wouldn't form a obstacle when revisiting this waiting area.

I'm just going to think about a solution for that, for now thank you very much!
Bram de Vries
Posts: 60
Joined: Thursday 08 January, 2015 - 13:29

Re: Problem with triggering agent in a activity location

Post by Bram de Vries »

Hi Manon,

You're welcome :)

One suggestion I can give is that you could check on the current Agent Activity of the Agent in the Activity Time as well using Agent_GetCurrentAgentActivity.

You could check on the name or the ID of this Activity for example.

Kind regards,

Bram
Post Reply