Assign ships to appropriate berths at a port based on matching ship size and requirements to berth size and capabilities.
A ship must fit in the berth (both length and draft)
The berth must satisfy all the requirements of the ship.
The berth must be in service.
Ships that have only one possible berth assignment take priority over ships that have other choices.
Ships with perishable cargo can bump those without (when they are both competing for the same berth).
If two ships require the same berth and both have perishable cargo then human intervention is required.
Ships with perishable cargo need to be cleared by customs. (see rule model “Mangoes from Pakistan”)
Ignore the dates when the ships require the berth for this example.
For extra points take into account the dates when berths are required.
Just a suggestion. Feel free to create your own data model.
NOTE: if a ship has no berth then it should not be cleared for docking
Note: Rule 1 will check on all requirements before rule 2 checks if they were all satisfied.
These ensure that only berths that are in service and are big enough for the ship are considered.
Line 1 simply takes the berths in ascending order of size to make sure we don’t allocate a tiny ship to a very large berth thus depriving the bigger ship of a berth.
Berths are sorted by length
When two ships are assigned to the same berth
Some possible customs rules (courtesy of John Masefield)
Download PDF version.