Tariq
Tariq

Reputation: 57

How can I control individual pedestrian type agents behavior using statechart in anylogic?

I am trying to do a pedestrian modeling where individual pedestrian agent behavior needs to be controlled. Can I do that using the pedestrian agent's statechart?

Update: Sorry that my initial question wasn't clear enough

main

jaywalker (agent)statechart

runtime screenshot

jaywalker agent from padsource

In the first picture (main) I have a simple pedestrian model where jaywalker (pedestrian agent) moves through 2 road crossing. Initially all the jaywalker agents are in "walking" state & colored yellow (pic: 2), but whenever some agents are near another agent (near means within the triangular shown in jaywalker agent representation), they send the message "HI" to them & socialize. If someone is socialized, then they move from "walker" state to "socializing" state (and turn red) & send messages to others who are within his triangular range("field of vision" triangle). The first 11 socializing is done directly by a message from main (on model startup) & 11 jaywalker agents are receiving it & moving to "socializing" state. The problem is in my graph it's showing the first 11 socializing but during model runtime the agent's color is not changing. Secondly, after those 11 socializing, agents aren't socializing or sending any message to others who are within his triangle.

So, I am confused about how I can make my agents move from one statechart to another while modeling the movement behavior using the pedestrian library. Am I missing any step to connect the pedestrian library & agent statechart?

Upvotes: 0

Views: 300

Answers (1)

Benjamin
Benjamin

Reputation: 1

It looks like you did not tell PedSource to create your custom ped agents of type "JayWalker". Try this:

  1. Delete your population, not needed
  2. Make sure your JayWalker agent type is defined as pedestrians in its properties: enter image description here
  3. In your PedSource, make sure it creates "JayWalker" agents as below. (You should select JayWalker where my screen selects "MyPed") enter image description here

Optionally, you can make the PedSource add the created "MyPed" agents to a custom population, but likely not necessary for you.

PS: Please understand that PedSource is creating agents, do not use your population for that. Read some more about PedSource and populations and do some tutorials to understand these basic concepts better :-)

Upvotes: 0

Related Questions