How do I get the time spent for a particular agent (from MHL) at a particular node? - anylogic

I am interested in capturing the time a particular material handler(AGV in my case) spends at a particular node before it is released. Is there a way to do so?

This works in general, since I don't know anything about your model (there are many other ways depending on what you are doing):
Create a variable and make it equal to time when your AGV arrives to the node:
timeWhenArrivesToNode=time();
Create another variable and make it equal to the amount of time it spent in that node... This code should be executed at the moment when the AGV leaves the node:
timesWhenItIsReleased=time()-timeWhenArrivesToNode;
Of course the answer will have the time units of your model.

Related

Measuring system time of specific agent in anylogic

I've got 3 different product types of agent, which each go it's individual path within the fabric. How can i measure the average time the product type spends in the system?
My logic looks like this , and i wanted to implement the measurement in the first service, like this:, it will be completed in the last service like this :
Now I get some really high numbers, which are absolutely wrong. The process itself works fine, if you run the measurement with the code "//agent.enteredSystemP1 = time()", you will get a mean of 24 minutes, per product. But how can i get the mean per product type?
Just use the same if-elseif-else distinction in the 2nd service block as well.
Currently, any agent leaving the system adds time to any systemTimeDistribution

Increasing model simulation speed with big number of agents/transporters Anylogic

I've a question. In my model I want to model patients/employees in a hospital environment as agents. Due to the big amount of patients/employees in the hospital (>4000), my model runs very slow (which is logical, I know). Because I want the patients employees to block eachother and AGVs, I let them move by a transporterfleet (which has >5000 capacity), by doing this method I can make it possible to let them block eachother.
Now what I want is that when the patient or employees arrive to the location departments they disappear for hours/minutes as long as there appointment or workschedule is saying to them. The most perfect is to just delete them for example 4 hours of runtime, so that I will only have the moving agents in my model, is there a way to do this? So that when a patient/employee arrives at an appointment, the agent and transport disappears for 4 hours and returns after this delay, keeping in mind that it should speed up the run-speed of my simulation (otherwise I just can use a delay block, but than my model keeps very slow). The transporters are making the model really slow.
Or perhaps another method will be better to model the patients and employees with the feature that they are blocking AGVs? An option which I should think of is that an moving agent is constantly checking if there is an agent close to him every second, but I do not know if this will be speed up the runtime or just will slow it down even more with >4000agents.
Or another option is that I only let the AGVs check if there are agents around them every second just by coding(this will only be around 40 agents).
Also you see that it is only using 5% of my memory data..
Thanks.

Considering differences in the same materials - Stations

I am trying to simulate a manufacturing assembly process, where material items are processed following an unique line. In the quality control stations, when a failure is detected, the object is sent to the repair area (by a truckpallet) and, when it is repaired, the same resource takes it and puts it at the start of the line. Until this point, I already programmed it.
The problem is the following: when it is a repaired object, is has to follow the same conveyor but with no stops in the stations. The object must enter a station and leave it, with no delays (as the works related with the stations have already been made).
I thought the best would be to consider the difference (repaired vs. not repaired) in the Agent, but then I can't work with it in the Main agent... I have also tried alternative solutions, for example defining variables in each station 1 and consider that in the stations delays and in the following station:
triangular( 109.1*delay_bec, delaytime_bec*delay_bec, 307.6*delay_bec)
Actions - in finished process:
if(delay_bec==0){
delay_headers=0;
delay_bec=1;}
But nothing worked... Any help?
I thought the best would be to consider the difference (repaired vs. not repaired) in the Agent, but then I can't work with it in the Main agent...
This is actually the correct approach. You need to create a custom agent type, give in a boolean variable isRepaired (or similar) and then in the delay you can dynamically adjust the duration using that characteristic:
agent.isRepaired ? 0. : 100
This will delay normal agents by 100 time units and repaired agents not at all.
Obviously, you must make sure that the agents flowing through the flow blocks are of your custom agent type (see the help how to do that)

Is there a way to not start an Anylogic simulation from scratch every time?

Good day
I'm a new user trying to find my with Anylogic.
Any help with the following question will be appreciated.
Is it possible to start a model with initial values/quantities given to certain blocks/sections in a model? In other words not have the model start from 0 but from the values given.
You can run a "warmup" period manually and save that as a model snapshot. In future runs, you can start off from that snapshot by loading it. See the help on model snapshots
This is the general problem of model initialisation (e.g., if you're modelling a manufacturing facility, you may want the run to start with the facility at the state it would be at on 9am next Monday morning). There is no generic answer: what initialisation you need is 100% model-dependent (as is how easy/hard this is).
In particular, process models make this difficult because entities (agents) are expected to have flowed through the process up to the point they 'start' in. You can use things like extra initialisation-only Source/Enter blocks to 'inject' agents into the appropriate process points, but in most models it's not this easy: you will have all kinds of model state that needs to be made consistent with this (e.g., the agents flowing through the process might have attributes which have changed based on what's happened to them so far, so this would have to be made consistent).
That's why warm-up periods (letting the model run 'from empty' for a period until its state is qualitatively what you want as your starting point) is a common approach. Model snapshots can help you here (see Ben's answer) but they're not the only way of doing it. (You can also just 'reset' all your metrics/output gathering at the point when you determine the warm-up period has ended --- i.e., you are effectively establishing a new 'time zero' --- but, again, exactly what you need to do is 100% model dependent.)

Moving one agent within another agent in Anylogic

I am making simple distribution center in Anylogic.I did make truck agent and i am able to move it from one gis point to another gis point.
But I want to load some other agents(Let's say banana agent) into my truck agent and then trucks start their journey(if truck is full of banana).How can i do this?
I hope you have already solved your problem from almost a year ago. However, since there is no specific answer, I'll leave it here for anyone who might get stuck with the same problem.
Anylogic's Process Modelling Library (PML) has an element called Pickup and its opposite, Dropoff. This is used to do exactly what you asked: to load some element into a transporter (either a truck, a forklift, or even a person).
To use the block as you asked you would need a topology like in the picture:
The Queue elements are necessary to hold elements until the pickup occurs.
The Pickup element might pick elements in three modes:
While a given condition is True;
An exact amount (if available);
All available agents.
I'm assuming all trucks must be completely filled up to its maximum capacity. Hence, the chosen mode will be the second one where the exact amount will be TruckCapacity, a parameter of agent Truck.
The selected mode picks up agents (in this case Bananas) up to the desired amount. However, if nothing is available or the present amount is inferior to the desired, the native behavior of the Pickup block is to allow the container element to simply go through it and pick only what's available.
To prevent such behavior, I've created a restricted area where only 1 Truck can be at a time. Additionally, the Hold block WaitFullyLoaded (set to initially blocked) forces the container agent Truck to be fully loaded. Whenever a Banana enters the Queue waitTruck, a verification is performed to check if 1 Truck can be filled. If so, allows passage for that one truck:
if(self.size()/TruckCapacity>=1){
WaitFullyLoaded.unblock();
}
To block WaitFullyLoaded again, when the truck passes through the restrictedAreaEnd block, it performs WaitFullyLoaded.block();
The main idea is this. However, many features can be added and changed.
Hope this helps,
Luís