anylogic

Anylogic - Combining a schedule and a threshold


In my AnyLogic port simulation, I am modeling forklifts and workers as ResourcePools for loading and unloading trucks.

The number of available forklifts and workers varies throughout the day based on shift schedules. These schedules consider both shift changes and breaks — meaning that during certain hours, fewer resources are available due to planned breaks (like lunch or coffee breaks). (using a seize block for the resourcePools)

I am using the Schedule block in AnyLogic to model this, setting the resource availability at different times of day depending on the shift and break patterns.

In addition to the scheduled availability, I want to implement threshold-based dynamic capacity control:

When the truck queue length exceeds a certain threshold (for example, more than 10 trucks waiting), I want to temporarily increase the number of available forklifts and workers — simulating management decisions like calling in extra help or temporarily accelerating operations.

The Problem:

However, AnyLogic does not allow me to combine Schedule-based capacity control with dynamic setCapacity() control in the same ResourcePool.

If I set the ResourcePool capacity to be controlled by a Schedule, I cannot use setCapacity() dynamically in the code.

If I set the ResourcePool capacity control to Direct (manual), I lose the built-in benefits of the Schedule block handling shift changes and breaks.

Any help would be appreciated!


Solution

  • In this case, you have to use manual setting of the resource capacity, as you have already guessed. However, it should be easy to adjust your current model.

    In the Schedule block, under Action, you have a function that is called any time the scheduled value is changed. So you should configure the ResourcePool to have a fixed resource, and on the resources schedules you currently have you should set forklifts.setCapacity(value). This way, the resource pool will be increased/decreased according to the schedule, and you keep manual control of the capacity if needed.