1

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.

View descriptive image here: enter image description here


  1. 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?

  2. 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?

Jaco-Ben Vosloo
  • 3,770
  • 2
  • 16
  • 33
Telso
  • 131
  • 8

2 Answers2

1

Yes, apply priorities. A new ship should have a higher priority and your second crane (still busy with ship 1) can be seized by the higher priority ship using task preemption. (Check how these work in the help and example models)

Only difficulty will be to compute the remaining time on ship 1 if service time depends on the number of cranes serving it in any time unit. Not impossible but will need some coding.

Benjamin
  • 10,603
  • 3
  • 16
  • 28
1

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

enter image description here

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)

enter image description here

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.

Jaco-Ben Vosloo
  • 3,770
  • 2
  • 16
  • 33
  • Thanks for the possible solutions. How specifically do you recommend me implementing it? Via a function maybe? I understood that you cannot dynamically increase/decrease capacity of a given resourcePool by entering code in the "capacity" field ( self.set_capacity(n) ). I would also think that doing it via a cyclical event is very unelegant. – Telso Aug 23 '21 at 06:09
  • Use it as I described , you simply call `resourcePool.set_capacity(numberOfUnits)` to set the new units, as the cranes move from one dock to the other. You are right that the field is not dynamically evaluated, only during initialization and yes don't use one cyclic event. I would create a new agent called dock and then use that agent for each doct. If you have any other specific implementations questions try asking a new question. Else give it a go and see how it goes! – Jaco-Ben Vosloo Aug 23 '21 at 09:33
  • Setting the capacity programmatically was a great help. Solved it now. – Telso Aug 28 '21 at 22:03
  • @Tellef Remember to accept my answer if you found it helpful, and upvote if you think it deserving ;-) – Jaco-Ben Vosloo Dec 21 '21 at 08:53
  • Sure. Will note that for future help too :) – Telso Dec 21 '21 at 18:06