in anylogic exception with Agent.setspeed() - simulation

i have a simple anylogic model for pedestrian movement from start line towards target line
i want to change the speed of the moving agents at some condition.
i test the condition using events
if the number of agents in a specific area exceeds 20, i change the speed of the agents in the previous area using agent.setspeed()
when i run the simulation and the event is triggered i get this exception:

This is an interesting problem... and this is the solution...
1) Your population people is NOT of pedestrian type... so you cannot use the pedestrian API even though you are using the pedestrian library... you have to use a pedestrian type:
2) Once you created the pedestrian type, your population "people" has to be created based on that type... only after this you will have a population that allows you to use the pedestrian API
3) In the pedestrian API, setSpeed() function doesn't exist, instead you should replace it with pers.setComfortableSpeed(0.5,MPS); Of course you can only do this once you completed at least my point 1.

Related

How to i make agents in AnyLogic avoid another moving agent?

I am trying to model an agent based model where a certain agent population of people avoid to get close to a single agent, a random moving VIP.
I have tried to useif (distanceTo(main.vip < restrictedArea)) ;moveTo(uniform(500),uniform(500))
The agent will, most of the time, move to its new random destination through the restricted area which i want to avoid
Either you use the Material-handling library (where the transporters have build-in collision avoidance).
Or you model it youself. For that, you need a cyclic event in your agent that constantly checks the distance to whatever other agent you are interested in. If below some threshold, you tell the agent to move elsewhere.
Note: the first option can be quite slow. The second is not trivial to implement. Less due to coding skills, more because having intelligent collision avoidance algorithms is not trivial

AnyLogic Error Handling: How to say if there's an error, move to the next block

I have a rail yard simulation in AnyLogic, and I create different car types based on a schedule. Then, I use TrainCouple to create one train with a dynamic, specific number of each car. However, if the number for a certain car type is 0, I run into a problem because the train is trying to couple with nothing. I was thinking I could resolve this problem by doing an error handler where every time there's an error, it would force move to the next flowchart block. Does anyone know how to do this, or have any other ideas for how to deal with this problem?

Getting specific number of pedestrians inside pedWait

I am very new to AnyLogic, and I just learned the basic Pedestrian process blocks. The problem I have right now is pulling out a specific number of pedestrians currently inside a pedWait rectangular node when a certain condition is met from a function that is called on begin wait of pedWait.

How can I create a finite calling population model?

I am trying to simulate a finite calling population model in AnyLogic. My population consists of 10 agents and I want them to come back to the Source node after they have been served.
I thought about making conditioning with the SelectOutput node but the Source node does not have any input. The best thing that I came up with is to just limit the number of customers arrivals to 10. However, in this case, the model stops running after 10 arrivals which is not an appropriate result.
What can I do to be able to simulate such a type of model in AnyLogic?
EDIT: I thought that making agents come back to the Source node could be a solution to building the finite calling population model. The main purpose of my question is to understand how can I build such type of model in AnyLogic. Here is the description of the concept of the model.
You cannot send them back to a Source element, as it only acts to create agents.
However, you can send them back to blocks that come after the source as below:
Here, all agents created by the Source block will infinitely loop through the Queue and Delay blocks.

Pedestrian Position/coordination in anylogic in certain time period

I have a simple pedestrian model where 7000 pedestrians are going from an entry line to target line. I want to know the position of the pedestrians after certain time period for predicting how much time they need for going from one point to another. In anylogic help i saw getX,getY function but where to use these and how?
Pedestrian Model and Simulation
Create a dynamic event called GetCoordinates with 1 argument called ped of type Pedestrian
in the pedGoTo block when an agent enters the block you will use this code:
create_GetCoordinates(1,SECOND,ped);
In the GetCoordinates dynamic event you can now use ped.getX() and ped.getY() to collect the information you need after 1 second.