Skip to content

ChertaPro/overloaded_harbor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overloaded Harbor — Discrete Event Simulation

Discrete event simulation (DES) model of an overloaded harbor with 3 docks and 1 tugboat, implemented in pure Python without external simulation libraries.

Problem

A supertanker port operates 3 docks simultaneously with a single tugboat shared for both docking and undocking maneuvers. Tankers of three sizes (small, medium, large) arrive following an exponential inter-arrival distribution. The tugboat is the main bottleneck: it must assist every tanker both to approach a dock and to leave it, and it follows a priority-based dispatching policy.

Goal: estimate the average waiting time of tankers in the port.

Project structure

overloaded_harbor/
├── src/
│   ├── generators.py    # Random variable generators (inverse transform, Box-Muller)
│   ├── state.py         # System state: State and Tanker classes
│   ├── events.py        # Event handlers (E1–E8) and tug decision logic
│   └── simulation.py    # Simulation engine, replications and confidence intervals
├── main.py              # Entry point
├── README.md
├── .gitignore
└── LICENSE

Model summary

Parameter Value
Docks 3
Tugboat 1
Inter-arrival time Exponential (mean = 8 h)
Tanker sizes Small 25%, Medium 25%, Large 50%
Loading time (small) Normal N(9, 1) h
Loading time (medium) Normal N(12, 2) h
Loading time (large) Normal N(18, 3) h
Tug approach time Exponential (mean = 2 h)
Tug departure time Exponential (mean = 1 h)
Tug transit (empty) Exponential (mean = 0.25 h)

Random variable generation

All random variables are generated from scratch using random (Python standard library only):

  • Exponential — inverse transform: X = -mean * ln(U)
  • Normal — Box-Muller: Z = sqrt(-2*ln(U1)) * cos(2*pi*U2), then X = mu + sigma*Z
  • Discrete empirical — inverse transform on cumulative probabilities

How to run

python main.py

Runs 30 independent replications of 500 tankers each (first 50 discarded as warm-up). Each replication uses seed=r for full reproducibility.

Results (baseline)

Metric Value 95% CI
Mean waiting time 10.84 h [10.05, 11.63] h
Mean time in system 26.87 h [26.05, 27.69] h

Requirements

Python 3.8+. No external packages required.

About

This project implements a discrete event simulation (DES) model to analyze the performance of an overloaded harbor.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages