What code should I write in Drop off? ANYLOGİC - simulation

What code should I write in Drop off?
The Simulation Scenario is as follows: There are 7 passenger stroke riding stops in total. There are also passenger arrivals to all 7 stops. Every two minutes a bus arrives and takes the passengers from the stop, lowering the passengers who want to get off. My problem starts exactly here. For example, how will I determine the passengers to land at the 3rd stop? I want 10% of passengers boarding at the first stop to drop 30% of passengers boarding at the second stop.
I did not know what to write in the drop off section to do so.
I tried this way. I have appointed passengers from each stop as agents separately. Maybe I could write it that way, but it gave an error when writing to drop off.
general view error location

Thanks for the clarifications.
Easiest way would be to store where pedestrians were picked up. Add a variable "myPickUpStation" to your pedestrian agent type (ensure to have a custom type).
Also, add a collection "myPedestrians" to your bus agent type. Fill it in the pickup so the bus knows who he has.
Then at dropoff, you can first query all peds in the bus who were picked up at station 1:
findAll(container.myPedestrians, p -> p.myPickUpStation == 1) (1 is just an example)
And then, take 10% of that group's size:
0.1 * findAll(container.myPedestrians, p -> p.myPickUpStation == 1).size()
Obviously, you will need to round that to a proper int

Related

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.

Anylogic won't start simulation (stuck on "Please wait")

I've been developing a model for a car fleet service. I have the model ready and it works fine. The problem is when I try to put all the input trips it is supposed to do, during the course of a day, the simulation won't start, it will just get stuck on the white simulation window after I click play with the information "Please Wait". I have table in the database with all the trips (they are aggregated for simplicity, i.e. trips with same origin, destination and departure time only occupy one excel line, with the number of agents it represents, instead of one line for each agent), and while I was developing the model, I would have condition to only load the trips table until a certain departure time, so I could test the simulation quickly, this would correspond to about 100 lines of data. But now that I'm trying to load all the trips in the table (this corresponds to about 12000 lines of data), the simulation won't even start, it just gets stuck on the loading phase. I pressed play last night and it's been 10 hours and it is still stuck on the same windows with the info "Please wait".
What should I do ?
Any help would be really appreciated.
Thank you for your time.

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)

Pick front item from a two deep pallet rack

I'm am storing agents two deep in a single pallet rack with a rackStore block. When I take items out of the rack with rackStore it tries the take the agents at the back first and I get the error below saying it couldn't be picked as there are other agents in front of it.
Anyone know how I can pick from the front instead?
This is big fail in the AnyLogic Software and it is something they have to fix urgently. Since when it comes to deep positions, you have to control everything manually.
I will give you an example that is definitely not optimal on how to solve your particular question and it will be just a step for you to understand how to extend it to something more than this. Because even though this should be a very easy question, it is not. This will work only 2 racks with 2 levels deep, 1 level of height, and a unique row.
So this is the structure you would need:
Since I have no idea how long your products stay on the rack, I will assume something, which is that with the event, I will make the decision on wether getting or not a product from the rack every 5 seconds (this is absolutely arbitrary).
You will need a custom agent to store the deep position. I call the agent Box and I will have a population of boxes. Not in the picture that I also add agents to the custom population boxes.The box agent will have 2 variables: deep and position which will store the position and deep level of the agent in the rack (you will need also level and row if you have a more complex rack)
Now on the event, which runs cyclically every 5 seconds, I have the following action: (it activates if there is a box waiting, if there is a resource available and if there is no forklift moving a product to the pallet rack) I have to do this because I cannot know where the forklift is going to put the box until the box is already in the pallet rack. Then I check if a box is not behind another with the findFirst function and if everything ok, a box is sent to be picked.
if(wait.size()>0 && resourcePool.idle()>0 && rackStore.size()==0){
Box bx=findFirst(wait,b->b.deep==0);
if(bx!=null)
wait.free(bx);
}
On the rackStore exit I need to store the positions so in the "on exit" action, this code will help (you check if there is another box in the same position, and if there is, you update the value of the deep variable. Then you store the value of the position and deep of the new agent)
Box box=findFirst(wait,b->b.position==position);
if(box!=null){
box.deep++;
}
agent.deep=0;
agent.position=position;
Finally on the rackPick on exit action, once the product is picked and delivered, you update the deep value of the box that was behind it (if any)
Box bx2=findFirst(wait,b->b.position==agent.position);
if(bx2!=null){
bx2.deep--;
}
I know all this looks a bit crazy, but you have to create all the logic yourself when it comes to using deep levels...

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