Limit the number of resources (forklifts) used in tasks - anylogic

I have pallets shipments arrive at a warehouse. Once the arrive, forklifts are used to unload then and move the shipments to storage units. The current capacity of the forklift pool is 50. What happens now that when pallets arrive with a number of shipments to be unloaded and stored, let's say 10 shipments, then ten forklifts go to the pallets and unload the 10 shipments at once. Since the flowchart a pallet arrives and a forklift is seized consequently. I want to have one of two forklifts to be associated with a pallet at until all shipments are unloaded. I tried to use restricted Area Start and End between the forklift seize block and the shipment moveTo block but that limited the number of forklifts assigned to all pallets not only the one at the time.
Thank you

This is a lot, so i will just give you the hints necessary to do what you want
step 1. You need for each pallet to have a variable associated with that shipment. This varaiable can be an id integer, or maybe a variable of type Shipment.
step 2. Then on the on seize block, you have to specify a custom resource selection that defines the forklift you can use for that pallet. It would be either a forklift that is already assigned to that shipment, or a forklift that is free and no other forklift is connected to that shipment... here the logic depends on your own case and on how many forklifts should be used per shipment
step 3. When the resource is chosen, You connect that resource to your shipment through a variable or through a link to agents, if that resource was not previously connected to it.
step 4. When there are no more pallets available, you disconnect the forklift from the shipment so you have a new forklift free for any new shipment coming through

Related

removing a specific number of pallets from a pallet rack

i would like to pick a certain amount of pallets from my racks but I have no idea how to actually do that. For example, I would like to deliver 5 pallets but i have 25 stored, if i use a wait or a queue that I release all agents get picked up.
to release 5 agents from the wait block so they can be delivered you have to do the following
List <MyAgent> deliverables=findAll(waitBlock,w->true).subList(0,5);
for(MyAgent x : deliverables){
waitBlock.free(x);
}

How to don’t seize resource units that are not needed?

I’m simulating an unloading process of a ship. The complete unloading of the ship can be perfectly done with only two resources making round trips (load, move to destination, unload, go back to loading) and the ship would never be idle waiting for trucks to load.
I need to demonstrate that if I increase the number of resource units (trucks) to 3, the third one will never be seized because it’s not needed, the problem is that the seize block seizes all units evenly, so at the end, all units end up with a utilization percentage greater than 0.
How can I configure the seize block to only use the needed resources and leave the “excess” units with utilization of zero?
(The real model by default will have many resources available, and ships could need more than two trucks. What I want with this is to determine the best amount of resources needed).
Thank you.
In the ResourcePool there is an options Customize request choice which when set to True will allow Request choice condition function to be created. There it is possible to make sure that the resources taken first are the ones with utilisation > 0. If your assumption is correct then the 3rd truck will never be taken.
you just need to run two experiments. One with 2 trucks and another with three. Then compare them in terms of ship waiting time and truck pool utilization.
I solved the question in a very easy way:
In the Seize block use the option "Customize Resource Choice" with "Resource selection" equal to "Units with top rating" and "Unit rating" = unit.getUtilization().
In the way, Anylogic sorts the idle resources by utilization rating and chooses the most utilized resource, this means that unneeded resources will never be seized.

Assign priorities for multiple Seize Blocks for the same resource in AnyLogic

I have a not so typical scenario for which I am not sure how to proceed:
There are two stations located at two different locations.
Both stations require the same resource.
The resource moves from station to station once released. So it keeps going from station 1 to station 2 to station 1, etc. until it is seized again. This is modeled by adding a link from the resource process port of the release block. So it is not completely released unless a condition applies. The condition is that there are agents waiting in the queue of the seize block of that same resource. So it should keep moving until it is needed again. The tricky part is that there are two seize blocks for that resource, one for each station. It is possible that agents are ready and waiting in the resource's seize element at both stations. I am adding an image of the resource's process at release. So at "selectOuput4" it checks whether station 1's seize element has agents waiting, if so, the resource is released and can be seized. Otherwise, it moves to station 2 and checks the same but for station 2.
My concern is that there might be a situation where both stations have agents waiting in their respective seize blocks. How can I make sure the resource will be seized by station 1's seize element and not station 2's, and vice versa. Is there a way to control where the resource is going in a case where two seize elements are waiting for it? Or is it always random?
I apologize for the long post, and I hope I managed to deliver my idea properly.
First, I think your design is a bit weird because you keep the resource always seized.
What I would do is first have a statechart in the resource that controls the resource movement from one place to the next so you have more control over it. The statechart would be used to move your resource ONLY when it's not seized. This will allow a case in which your resource is moving from station 1 to station 2 but something comes to station 1 queue and the resource can immediately react and come back to station 1 before it reaches station 2 (if you think it would be a good idea to do that)
The second is that the seize block defines the priority for a task when the agent arrives to the seize block, and your situation requires changing that priority dynamically, which can't be done as far as I know, so the wait block before the seize block is unfortunately a good option.

to use a resource pool of forklifts for different process flows and different tasks to the same time

Is it possible to use a resource pool with forklifts for different process flows? I would like to have a resource pool of 100 forklifts which I use for different tasks to the same time. So for example forklift 1 should transport pallets at 6 am to pallet rack 1 and forklift nr2 should transport pallets at 6 am to pallet rack 2. So currently I have a lot of resource pools for different tasks and I would like to know if it is also possible with only one resource pool.
It's possible... on the seize or service block, on the advanced section of the properties you can check the box "customize resource choice" and you will be able to select the resource you want to use for each one of the tasks.
Your resources will need at least an id, so you can do ((YourResourceType)unit).id==2 for example as the resource condition for your resource to be used for what you want. This condition you will see it as soon as you check the "customize resource choice" box.

Create a database with an arrival time and access to it in the process flow

I would like to create a database with different arrival times that my forklifts pick the pallets (rack pick) to the certain times. How could I do this? Which process blocks could I use to access to a database with arrival times?
For example at 10am on May 20 45 pallets should pick out of the pallet rack. I tested it with a delay block and it works but only with different hours where the pallets get picked and not an specific date. The important thing is the date which I get from a database.
process
Probably the easiest way is to have your in-rack agents (after your RackStore block) sit in a Wait block, and be freed from there (using the Wait block's free function) --- to then carry on to a RackPick block --- via AnyLogic dynamic events whose timings come from a database table.
(Your model as-is will just have your agents immediately exiting the rack and going to the Sink because the Queue does not stop them leaving.)
Your model startup would loop through the rows in the table and create dynamic event instances with the appropriate timeouts (delays from model start), and with a dynamic event parameter which specified the number of pallets to pick (and thus the number to free from the Wait block).