Use Case

Assign ships to appropriate berths at a port based on matching ship size and requirements to berth size and capabilities.

The Rules

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.

Data Model

Just a suggestion. Feel free to create your own data model.

Sample Input Data






Expected Results

NOTE: if a ship has no berth then it should not be cleared for docking


The Basic Allocation Decision Table

Natural Language View

Implementation View

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

Ancillary Rule Sheet for Resolving Conflicts

When two ships are assigned to the same berth

Rule Statements


Ancillary rule sheets for Customs

Some possible customs rules (courtesy of John Masefield)

Alternative natural language view of the Assignment rules


Download PDF version.