Getting specific number of pedestrians inside pedWait - anylogic

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.

Related

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.

Is there a way to record when (and how often) Transporters get within a certain distance of each other?

I have an AnyLogic simulation model using trucks and forklifts as agents (Transporter type), and among other things would like to identify each time one of them becomes within a certain distance of another one (example within 5 meters). I will record this count as a variable within the main space of the model. I am using path-guided navigation.
I have seen a method "agentsInRange" which will probably be able to do the trick, but am not sure where to call this from. I assume I should be able to use the AL functionality of "Min distance to obstacle" (TransporterFleet) and "Collision detection timeout" (TransporterControl)?
Thanks in advance!
Since there don't seem to be pre-built functions for this, afaik, the easiest way is to:
add an int variable to your transporter agent type counter
add an event to your transporter type checkCollision that triggers every second or so
in the event, loop across the entire population of transporters and count the number that are closer than X meters (use distanceTo(otherTransporter) and write your own custom code)
add that number to counter
Note that this might be very inefficient computationally as it is quite brute-force. But might be good enough :)

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.

Anylogic - Measuring time through multiple layers of a model

I'm simulating a train system and want to measure the time a passenger spends from entering the system to boarding. Entering the system happens on a higher, boarding on a lower level of the model. The problem is that the TimeMeasureEnd block doesn't see the TimeMeasureStart blocks on a different level. Does anyone have experience with this problem or an idea for a solution?
Edit:
I call set_startObjects(TimeMeasureStart[]) in an event occuring once at the creation of the agent in the lower level and set either the start blocks of the one or the other parent, depending on what the parent is. The data is being collected in all child agents separately and displayed in separate histograms in each child agent. How can I accumulate all of them in one single histogram to display in main which is two layers above the child agent where the data is being collected?
you can always define the 'TimeMeasureStart' block dynamically in your 'TimeMeasureEnd' block. Just switch the entry mode for defining it to "static value" as below:
Now you can call on any 'TimeMeasureStart' object anywhere in the model, similar to below where it sits in 'Main':

in anylogic exception with Agent.setspeed()

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.