Use Case

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

The Rules

  1. A ship must fit in the berth (both length and draft)
  2. The berth must satisfy all the requirements of the ship.
  3. The berth must be in service.
  4. Ships that have only one possible berth assignment take priority over ships that have other choices.
  5. Ships with perishable cargo can bump those without (when they are both competing for the same berth).
  6. If two ships require the same berth and both have perishable cargo then human intervention is required.
  7. Ships with perishable cargo need to be cleared by customs. (see also rule model "Mangoes from Pakistan")

Ignore the dates when the ships require the berth for this example.

The core allocation rule sheet:

Implementation:

NOTE: This example uses the ->next operator to process the berths in a particular order (smallest ones first). See also Passenger Rebooking Rule model for a variation on resource allocation that uses a different technique for stepping through options in a particular order when two different collections must be ordered simultaneously.