Mean statistics about agents in Anylogic - anylogic

I'm working on a family practitioner model, my goal is to model the population of a city and all of the family practitioners in that given city by taking into account the distribution of the treatment time and the arrival schedule of patients etc... So far i've managed to create an agent that contains a bloc diagram to model the whole process
With a source and a delay bloc to generate patients according to a fixed schedule, a service bloc and two sinks.
Now i've put a population of this agent "process" in the main and i've simulated the model for 3 months.
Lets say i've started with a population of 10 process which represents the number of practitioners. My goal now to to collect some Mean statistics, like the Mean number of treated patients (treated patients goes to the sink "Served") of the 10 practitioners, the Mean waiting time of patients at the service bloc, the mean utilization ratio of the resource of the service bloc...
I want to also know if is it possible to limit the total number of Patients (or to at least count them), for exemple, instead of simulating the model for 3 months, i wanna limit the total number of patients that goes to the 10 process to 10k and i want to know how much time does it take to serve all of them. (is it possible with this architecture of the model or do i have to make major changes)
Thank you

Related

AnyLogic - How to define and redefine Agent's Parameters?

We’re generating the data that we might get from a shop floor to run, test, and validate our machine learning models. We first have here a discrete event simulation model for our manufacturing system. Each production order is seen as an agent, which then goes through different processes with a queue (waiting time) and delays (firstly production time, secondly logistics time).
enter image description here
But sometimes we have one process, for example, printing (code 5A, after the second Select5Output), with three different machines, which do not have a particular capacity. It’s time when we divide our order into parts and send them to those machines (very randomly, subjectively).
The data we take is from flowchart_process_states_log in Database.
The data we take is from flowchart_process_states_log in Database.
My questions here are:
How can we define the number of products in each order? Ex. we’re printing card, for one order it may be 10k, for another 8k or 33k. Can we define it as agent’s parameter? Then how can we vary them (stochastically, no exact number needed).
How can we split those 10k cards into three different machines? And then how to get back an complete agent with 10k? The Agent ID should remain the same as we trace and analyse them in ML model. Is it reasonable to see an order as an agent?
How can we multiply the number of our agent after a process? Ex. After cutting 10k pieces we have 20k.
We have the distribution for delay ex. triangle distribution. But we want some disturbances, when it suddenly takes 2 days for that delay instead of 3-4 hours as normal. How to do it?
Thank you in advance for your effort. Every help is highly appreciated, because we're here and learning together. Thank you !!

Arrivals for different delivery locations with same poisson rate Anylogic

My question is:
Is there a simple an proper way to create arrivals for multiple deliverylocations with the same poisson rate without using a source block for every delivery location?
So an example to make it perhaps a bit more understandable:
I've 30 delivery location nodes (node1, node2, node3, node4 etc). For all those 30 delivery location there should be something transported to those nodes with the same poission arrival rate for simplicity say 1 and they all have different intermediate points where they have to pass (so say delivery location node1, first need to go to intermediate point2 and than to location node 1, see figure for example of database values).
Now ofcourse I can create 30 source blocks with this arrival rate and the intermediate points as parameters of the agent created in that source, but this is kind of time intensive, so is there a quick solution to model this quickly?
Since it happens randomly, arrivals according to database can not be used, since there is not a specified time of arrival it just happens randomly based on a poisson rate.

Agents instead of dimensions in system dynamics stocks

Currently I have a stock of Grade 1 learners. The stock is arrayed so that Gr1_learners[..] = {10,10} means that there are 10 high performing learners and 10 low performing learners in this stock. These learners progress to Grade 2 so that Gr2_learners[..] = {20,0} are the first graders having progressed after one year and some intervention improved all the learners to high performing.
My idea is to create learners as agents and place them in the stocks. Then Gr1_learners = 20 is a stock with 20 agents, half in state high_performing, and half in state low_performing. They progress, a state change is triggered so that Gr2_learners = 20 is then a stock with 20 agents, all in state high_performing and none in state low_performing.
Is this possible?
Yes, by not using stocks at all. You are probably familiar with SD modelling and now see the benefit of agent-based modelling.
Go all in and model your agents. Instead of stocks, you use agent populations and make your agents change states.
See the agent example models, especially the SIR one (there is an SD version and an ABM version, great to see how you can model any SD model with agents)
But you cannot have agents inside SD stocks, they are not actual stocks but just mathematical equations :)

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.

Gathering statistics on agent population

I have some issues with gathering statistics on the population level in a model I've been working with.
In the model I have an agent type Company and RawMaterial. Within Company a process flow exists, where on some blocks costs are assigned to a variable in Company upon entry of RawMaterial (e.g. cost = gamma(3, 125, 0);)
To calculate the Company-level cumulative costs I use a Statistics object with cost in the value field of this object.
So far so good it seems.
However, when I want to sum the cumulative costs of all Company agents into one value I run into trouble. Ideally, I want the cumulative costs for each Company agent to be plotted in Main.
I've looked at the Help file (section "Functions to collect statistics on agent population") with no success.
what about doing this in main? (you can even put this function in your time plot)
sum( companies, c->c.cost );
This function calculates the sum of the costs of all company agents (as long as you have a population of agents called companies in main, and not only an agent type)
If you don't have companies as a population of agents, you have to create it, otherwise it's very difficult to calculate anything. How to create it depends on your model.