So, the problem I'm facing is the following.
I have a simple arcitechture where I simulate an unloading process where 2 cranes unload incoming docked ships. Using a seize-delay-release design, one incoming ship binds up one capcity point from the "cranes" resourcePool.
In the event of only one arriving ship, how can I make both cranes work on one ship and from there cut the processing time in half?
If a second ship docks in, I want one of the two busy cranes to help out the newly arrived ship with unloading.
Are there any elegant ways of solving this issue?
Another option would be to model the offloading process in a bit more detail. This will negate the requirement of computing the remaining offloading time on a ship if service time depends on the number of cranes serving it in any time unit.
You can model the berths or docks where ships can park to be offloaded as waiting blocks or queues
When a ship enters the docks or berth they will generate a number of containers or what ever units that need to be offloaded in a separate logic stream, using source.inject(numberOfUnits)
You can model the number of cranes available at each berth programmatically by either increasing or decreasing the number of resources in the resource pool using resourcePool.set_capacity(numberOfUnits)
Thus if a ship arrives at a dock A and there is no ship at dock B, you increase the capacity of the cranes at dock A to 2. If a new ship then arrives at dock B you set the capacity for the resource pool at both docks to 1.
If the ship at dock A leaves, then you assign the cranes in the resource pool at dock B to 2 and at dock A to 0, thus simulating the movement of a crane from one dock to another.
The only minor issue here is that if you want to track the utilization of individual cranes you will need to store them separately as you will be destroying and creating resource units the whole time.