How can I control individual pedestrian type agents behavior using statechart in anylogic? - 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?

It looks like you did not tell PedSource to create your custom ped agents of type "JayWalker". Try this:
Delete your population, not needed
Make sure your JayWalker agent type is defined as pedestrians in its properties:
In your PedSource, make sure it creates "JayWalker" agents as below. (You should select JayWalker where my screen selects "MyPed")
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 :-)

Related

Agent enters node.closed() and causes runtime exception in Anylogic

I have a rather huge model of a production system in anylogic with two agv fleets, which transport material between stations. My problem is solely with one of the fleets.
My product enters the system through a conveyor, seizes a transport agent, then waits on the agent and then drives off to the first station.
My problem is with the conveyor and my transport agent. After a while of simulating, I get error message and is what the console says.
Now I thoug myself clever:
If the agent is not on the conveyor (or does not care) it might not throw this error. So I put in the "on new transporter" of the transporter fleet an unit.ignoreCollisions(true);
But that did not help.
Then I made a restricted area around the conveyor (on a scale of 1000 % one of rectangles of the grid to small, then exactly the size, then one row of rectangles too big), but it still goes into the restricted area and then throws me this error.
I do not even understand how the agent can (a) care about this (it ignores collisions) and (b) how it can enter the restricted/forbidden area.
Does anyone else experience the same? How did you solve it?

Make agent face other agent upon MoveTo arrival?

I have a warehouse model where "Picker" agents move along the Y-axis to reach the front of a "picking slot" agent.
I would like to make it so that upon arrival in front of the picking slot, the Picker agents face the picking slot.
I am aware of the "Set rotation upon arrival" feature of the MoveTo blocks, but I am having trouble making sense out of it. What sort of value should I input here?
Is it possible to dynamically define the rotation according the the agents' relative location to each other? If so, how should I go about it? Some of the slots are on the left of the picker, and others on the right.
Thank you.
Please have a look at the Wholesale Warehouse example in the sample models (help section of AnyLogic). There they use agent.agent_image.setRotation(-PI) and then turn it into initial position with agent_image.setRotation(0) You can use this dynamically and with if conditions in your blocks.

track agent movement in anylogic

I am running a pedestrian simulation in Anylogic and want greater granularity in the agent position information that I get at the end of my model. Currently, I have it set up to show a heat map of traffic density, but I would like to trace the actual position of each agent through its time in the model, like a line or trail.
model visualization at the end of a simulation
[1]: https://i.stack.imgur.com/RwCVo.png
Add a cyclic event into your Pedestrian agent type (you cannot use the default pedestrians but must create your own agent type).
Then, every second (or whatever resolution you need), write the pedestrian coordinates (getX and getY) into a dbase table along with its index.
Then, you can do any post-processing that you need.
PS: typically, this is not really necessary, so make sure you really need this ;)

Two agents are missing from the presentation

I have 9 trench agents in my model. When I run the model, I can see that 9 agents are created but I have only 7 agents in the 2D, and 3D presentation. I tried different numbers, and two agents are always missing from the presentation.
Agents are located in a node which has exactly 9 attractors. Please see the pic.
Can Anyone help me to resolve this issue? Thank you.
The problem is I can see that presentation change after a while! Is this usually happen in AnyLogic? Please see the Pic.
Nodes are not used "exclusively", i.e. they do not have a build-in "I am full, no more agents here" capability. They simply define possible agent animation locations.
So in your case, 2 agents are on top of other agents at the same node.
You would need to make those nodes agents themselves with a given capacity. There are many ways to do it (none totally easy), depends on your model setup and what you try to achieve.

How to create connections to specific agents and show animate connections for agents in Anylogic

I am new to Anylogic and I am trying to do modeling using Anylogic. I'd like to connect 6 types of agents on a GIS environment by a network.
The condition for the connections is as follows:
agent type 1 has 10 agents
agent type 2 has 16 agents
agent type 6 has 20 agents.
I want to connect agent1 with 2 based on the nearest distance. This means that an agent of type 1 is to be connected to the nearest agent of type 2.
Also, I want to connect populations of agent1 with each other.
I used "Link to Agent" for this purpose and animated connections by clicking the "draw line connecting agents" tickbox in the properties. The line connecting among agents isn't shown when I run the model however the results show agents are connected.
Got any suggestions (to show line connecting among agents)?
Thanks.
The "draw line" functionality of the connections generated by link to agents DOES NOT work on a GIS space.
I would call this a bug in AnyLogic.
To draw lines between agents that are connected, you need to code your own thing, which is not very straight forward considering that you can zoom in and zoom out the map, there's no built in functionality in AnyLogic that allows you to do this easily. Sometimes I use Gis Regions as lines to connect agents... But that works fine with static agents...
You can so generate new agents that are lines and define the position based on the map scale, but you can't zoom in or zoom out without breaking the connections.
In other words, you have to be creative depending on what your agents are.