Schedule the arrival of resources (ex. trucks) in Anylogic - simulation

I have a rackPick block where I am using Trucks as resources to pickup the agents. Is there any way to schedule the arrival of those resources? I want 2 trucks to arrive in a day. I didn't find any property in rackPick or resource Pool regarding scheduling.

Simply define your ResourcePool capacity to be driven "by schedule". Then, define a schedule to define your resources schedule:
There are several example models showing you how to do it, just search for "schedule" in the example models. And check the help, you can make this combination very powerful :)

Related

Work shift scheduling with break times for specific agents

I am building a simulation model for a production line. There are two shifts (morning and night shift, 12 hours each) daily. Within each shift, the workers are split into 4 groups and each group goes for meal breaks at a staggered timing (eg. 4 workers in morning shift, first worker goes for break at 9am, second goes at 10am, etc.). These workers will also take ad-hoc breaks at random occurrences during their shift.
Not sure which method would work:
Creating an individual schedule within the agent and let it change states according to the schedule?
Use a common schedule for the entire resource pool, but will it be possible to pick which agent goes for break at the break time? Or will the agent be picked at random? Caus my concern is that i'll need the agents to take breaks but at staggered intervals.
Or should I generate this in a different approach?
Good question!
On option 2)
If you use the resource pool you will not be able to choose a specific agent as shifts and breaks are created for the entire pool.
What you can do is to define the capacity of the resource pool using, multiple schedules
This can help you artificially define the staggered. nature of the break-taking for resources.
Refer to the help for more details - https://anylogic.help/library-reference-guides/process-modeling-library/resourcepool.html
I believe this answers your question already but here are my notes on the other option.
Option 1)
If you require more advanced flexibility and control over the breaks and you do have the required Java skills (and time!) you can create custom code that controls when to send agents on a break and when to to return. You can use StateCharts inside your agents to build this logic. But then this will not be compatible with the resource pool since the resource pool will be oblivious to the state of the agents inside the pool and it will seize units that are taking a break...
So in this case your size delay and release will also be custom.
This is a lot of work and should only be attempted if you have the time, skills and require a level of flexibility and customization not offered by the resource pool.

Give agents different priorities in a queue

In my AnyLogic simulation model, I have two sources and going through two service blocks in a closed loop. At starting time I inject 1 50T Truck and 2 20T Trucks.
Descriptive image here:
Image of Model
At the second service block, "crusher1", I want the queue to always prioritize the agent "truck50ts" over "truck20ts". How can this be done?
Replace your Service block with Seize, Queue, Delay and Release blocks (same as a Service but more options for you).
in the Queue properties, set the queue priority to "agent comparison".
In the conditional code, write agent1 instanceof Truck_50tons ? true : false as below:
This assumes your 50t truck is an agent of a custom agent type called Truck_50tons (create those at the sources)

Resources seized at different times

How can I simulate a service that requires different resources to be present at different times?
I know that worker1 is seized at time 0, and after X amount of time worker2 is seized. What blocks can I use to simulate the delayed arrival of worker2?
Service blocks do not work this way. You do not prescribe when a resource does stuff.
You are trying to model resource becoming active at pre-defined times. However, in simulation models, resource become active when they are needed, which is driven by the model dynamics upstream of the Service block.
Unless you mean how to setup shift times for resources? In that case, simply learn how to define shifts for ResourcePool elements. Lots in the help and example models and tutorials :)

Can resources carry multiple agents in Anylogic?

In the below image I am using AGV as resources to carry Containers(agents) in the rackStore and rack Pick blocks. By default, one AGV carries only one agent; Is it possible to set agent carrying capacity of resources such that it can carry multiple agents?
Sure. Just use the Batch element before the pickup and batch your containers together. Then, the AGV will pickup a batch, i.e. several containers.

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.