Pedestrian arrival rate of 5 per h only 3 showing for 1 h during the simulation. Any reason why? - simulation

I'm trying to simulate a pedestrian flow in the entrance of an hospital.
We are installing check-in platforms and I want to know how many platforms we should get according to the patient flow.
I'm using Anylogic personal learning edition and when I put an arrival rate of 5 per hour during the simulation only 3 appears.
I'm trying to understand how anylogic works and distribute the pedestrians according to the rate we put.
For the personnal learning edition 1h equal 1min in real.
enter image description here

if you choose rate=5, the pedSource block will generate pedestrians with an exponentially distributed interarrival time with mean = 1/rate = 1/5.
Which means that the average of arrivals on the long term will be 5, but you won't get 5 every hour since it's a stochastic variable.
If you change the seed, you will have different arrivals... click on Simulation: Main and you can change the seed or use a random seed:
Now if you really want exactly 5 per hour in a deterministic way, you need to change the arrival from rate to inject function:
Then you can create an event that runs cyclically 5 times per hour.. or 1 time every 12 minutes:
and you do pedSource.inject(1);

Related

Using varying lambda with interarrival time while receiving same arrivals across models

I have learned from my previous question “Get the same arrival rate across models” that for two models with the same arrival rate input, I can get the exact same arrivals generated in both models by setting the source block in both to “Interarrival time” and in the code, use exponential(lambda, 0, rand) where rand is a user-defined random number generator (RNG), for example, Random rand = new Random(1234). If prior to setting the source block to “Interarrival time” I had it set to “Rate Schedule” in which the schedule is of type rate that is provided from the database and in my case the rate (lambda) is not constant, it depends on the time of the day, how can I overcome this when setting the source block to “Interarrival time”?
Since it is not possible to set a seed for the arrival rate, you'll need to use interarrival times instead in your source.
However, since you also need to vary the interarrival time based on the time of day, you should write a function that returns different exponential random variables depending on the time of day and use that as your interarrival times.
Here is how I did that in AnyLogic:
And I made a quick plot of how many injections were occurring per hour just to verify that the rates are actually changing.
Perhaps I'm understanding the question wrong, but interarrival times can these not be transformed to arrival rate, so for example if interarrival time = 2minutes, the arrival rate is 0.5 per minute. If this is the case for your model, you can use in the source block arrivals defined by: a rate schedule (as shown in the figure below.)
After that in the schedule you can change the different arrival rates, so for example between 00:00 and 01:00 the arrival rate should be 1 as shown in the figure below:

Source is producing too many agents

My arrival rate for my source is in hours, and I am using events to set it's rate to a distribution at different times, sourceShoppers.set_rate(triangular(1, 5, 2));. However, the source is producing roughly 3 per second, as opposed to an average of 2 an hour.
do this:
self.set_rate(triangular(1,5,2), PER_HOUR);
Nevertheless, when you do that, notice that you will get a random sample for the triangular distribution, which will set the rate to be for instance 1.2 per hour in which case the arrivals will follow a poisson distribution with an average of 1.2 per hour always unless you change the rate again...
If you want some advice, you have to say what you want to achieve...

How to determine costs for the service time and idle time in a queuing problem in anylogic?

I need to simulate a simple M/M/1 problem in Anylogic. So far, I created the model and calculated all performance measures like the average time in queue and system and the average number in queue and system. Now I need to calculate the Total Costs. The painting time for a car would be 6 hours and costs $70 per hour. The cost of idle time per car is $100 per hour. The cars arrive according to a Poisson process with a mean rate of 1 every 5 hours. Can someone help me how I can calculate the total costs in this model in annylogic?
enter image description here
Refer to this question about measuring time:
Method the measure the time an agent is not in use during a simulation
You need to create an agent type that has variables for time and cost. Then on the On Enter and On Exit fields, record time and cost for individual agents. Once you have measured time, cost is simply time multiplied by the hourly cost.
If you want to measure total cost, you can create variables in main such as totalCost and the code of the sink's On Enter would be:
totalCost += agent.totalCost
Where the second totalCost variable would be the variable inside the agent type.
Anyway, the above should give you a good idea on how to proceed...

Anylogic - How to measure work in process inventory (WIP) within simulation

I am currently working on a simple simulation that consists of 4 manufacturing workstations with different processing times and I would like to measure the WIP inside the system. The model is PennyFab2 in case anybody knows it.
So far, I have measured throughput and cycle time and I am calculating WIP using Little's law, however the results don't match he expectations. The cycle time is measured by using the time measure start and time measure end agents and the throughput by simply counting how many pieces flow through the end of the simulation.
Any ideas on how to directly measure WIP without using Little's law?
Thank you!
For little's law you count the arrivals, not the exits... but maybe it doesn't make a difference...
Otherwise.. There are so many ways
you can count the number of agents inside your system using a RestrictedAreaStart block and use the entitiesInside() function
You can just have a variable that adds +1 if something enters and -1 if something exits
No matter what, you need to add the information into a dataset or a statistics object and you get the mean of agents in your system
Little's Law defines the relationship between:
Work in Process =(WIP)
Throughput (or Flow rate)
Lead Time (or Flow Time)
This means that if you have 2 of the three you can calculate the third.
Since you have a simulation model you can record all three items explicitly and this would be my advice.
Little's Law should then be used to validate if you are recording the 3 values correctly.
You can record them as follows.
WIP = Record the average number of items in your system
Simplest way would be to count the number of items that entered the system and subtract the number of items that left the system. You simply do this calculation every time unit that makes sense for the resolution of your model (hourly, daily, weekly etc) and save the values to a DataSet or Statistics Object
Lead Time = The time a unit takes from entering the system to leaving the system
If you are using the Process Modelling Library (PML) simply use the timeMeasureStart and timeMeasureEnd Blocks, see the example model in the help file.
Throughput = the number of units out of the system per time unit
If you run the model and your average WIP is 10 units and on average a unit takes 5 days to exit the system, your throughput will be 10 units/5 days = 2 units/day
You can validate this by taking the total units that exited your system at the end of the simulation and dividing it by the number of time units your model ran
if you run a model with the above characteristics for 10 days you would expect 20 units to have exited the system.

AnyLogic "triggered by rate" implementation

Anybody has a reference for how AnyLogic implements it's rate per day? Specifically, my agent is at different locations (based on time of day) throughout the day. If there are 10 triggers a day, do they happen randomly for each agent throughout the day, or only at the beginning of a day (when agent is at home), etc.?
Thank you, Amy! Your explanation was very helpful.
The rate follows the Poisson distribution. If you divide 1/rate, you will get an inter-arrival time that follows the exponential.
As this is random, you may not actually get 10 a day - you may get 9 one day and 11 the next. If you want to get exactly 10 in a day, you need to think about writing your own code to make that happen. That might be something like generating 10 dynamic events randomly sampled times that all trigger a transition in their action code (that would not be exponential between events).