← BACK TO PORTFOLIO
VIEW PDF → DOWNLOAD PDF ↓

Deep Reinforcement Learning for Weather-Aware Maritime Route Optimisation:
A Hexagonal Grid Approach

From heuristic baselines to a DDQN agent on an isotropic H3 grid over the Mediterranean Sea

Imperial College London
MSc Environmental Science & Engineering
RLSS 2026 · Milan
Author: Bilal Saleem  |  Supervisor: Prof. Matthew Piggott & Dr. Samaneh Mofrad  |  Imperial College London
ELLIS Unit Milan  ·  Reinforcement Learning Summer School 2026
1 The Challenge: Decarbonising Maritime Shipping

International shipping accounts for approximately 3% of global greenhouse gas emissions. The IMO's 2023 revised strategy targets net-zero emissions by 2050, with an interim 20–30% reduction by 2030 relative to 2008 levels. Voyage optimisation — choosing the safest, most fuel-efficient route through dynamic, weather-varying ocean conditions — is one of the most tractable near-term levers available to fleet operators today.

2 Gap in Current Approaches

Classical methods (A*, Dijkstra, Tabu Search) are fast and interpretable, but static: they plan once and cannot adapt to evolving weather mid-voyage. Reinforcement learning agents, by contrast, learn a policy that can be continuously updated online as new forecasts arrive.


Latinopoulos et al. (JMSE, 2025) is the state of the art: DDQN and DDPG agents on a uniform 0.25° lat/lon grid, achieving 8.7–12.6% fuel savings over a shortest-path baseline on a real Mediterranean route. It is a strong result — and it was this paper that motivated this project. But it has two structural limitations:


  • The uniform 28 km grid cannot navigate straits narrower than one cell. Canals are handled with teleportation shortcuts, not actual navigation.
  • The rectangular grid introduces diagonal bias (NE step = 41% longer than N step), forcing the Q-network to learn a geometry correction.
Research Question: Can a DDQN agent on an adaptive H3 hexagonal grid — with isotropic movement and genuine strait/canal navigation — match or exceed the Latinopoulos fuel savings, validated across three Mediterranean routes of increasing difficulty?
3 Step 1 — Heuristic Baselines

Before training any neural network, a full suite of heuristic pathfinding algorithms was implemented on the same routes, mirroring the baseline comparison in Latinopoulos et al.


Three Test Routes (increasing difficulty)
RouteDistanceChallenge
Port Torres ↔ Marseille371 kmOpen water, Sardinia–France
Cagliari ↔ Marseille552 kmLonger, coastal navigation
Piraeus ↔ Marseille1,647 kmGreece–France via Corinth Canal

Heuristic Methods Implemented
MethodDescription
Searoute APIIndustry maritime routing service (reference baseline)
Dijkstra (H3 graph)Optimal shortest path on hexagonal grid
A* (H3 graph)Haversine heuristic, 20 kt cruise speed
Tabu SearchMeta-heuristic, 500 iterations, avoids cycling; best heuristic fuel performance (−13.8% vs baseline)
"Tabu Search saves ~14% fuel but commits to a plan at departure. An RL agent keeps learning — even during the voyage."
4 Ensuring Reproducibility
Three Sources of Non-Determinism Fixed
  • Neighbour ordering: H3's grid_ring() returns neighbours in unspecified order. Fix: sorted by bearing (clockwise from North), hex-ID as tiebreaker. Cached per cell. Action semantics stable across entire training run.
  • Global RNG state: NumPy and Python's random module seeded at grid construction (seed=42) and at each episode reset. Environment transitions fully reproducible for a given seed.
  • BFS potential function: Precomputed once after canal integration, cached as a static dict. Every episode uses the identical distance-to-goal mapping — the reward signal does not drift.

Combined effect: given the same seed, two training runs produce identical environment transitions. Variance in results reflects only policy learning, not environment noise.

5 Step 2 — Rethinking the Grid: Rectangles → Adaptive Hexagons
Latinopoulos 0.25° Grid

Uniform 28 km per cell everywhere. Aligns with ERA5 data. But: diagonal step = √2 × cardinal step = 1.41× longer. 8 actions with two distinct step lengths. Q-values encode a geometric artefact. Straits <28 km inaccessible. Corinth Canal: teleportation shortcut.

Adaptive H3 Hexagonal Grid

All 6 neighbours equidistant — always. 6 actions, all equal cost. Q(s,"move NE") = Q(s,"move N") under same progress. Reward shaping geometrically unambiguous. Coastal resolution 3.7 km. Straits and canals navigable.

6 Adaptive Multi-Resolution Design
ZoneResolutionCell sizePurpose
Open oceanRes-5~9.85 km edge / ~28 km c-to-cMatches Latinopoulos. Efficient BFS.
Within 40 km of coastRes-6~3.7 km edge / ~10 km c-to-cStraits, canal approaches, harbours become navigable corridors

The adaptive boundary is computed automatically: any res-5 water cell adjacent to a land cell is replaced by its 7 res-6 children, each independently classified by polygon land-fraction (threshold ≥ 0.20 → excluded). This is a polygon-level check, not a centroid check. Result: 10,937 water/coastal cells across the Mediterranean.

7 Corinth Canal — Explicit Modelling, Not Teleportation

The 6.3 km wide, 6 km long Corinth Canal connects the Aegean to the Ionian. Rather than teleporting the agent, we model it as a navigable res-6 hex corridor extracted from OpenStreetMap geometry:

  • Sample canal centreline at ~80 m resolution
  • Snap to res-6 hexes → compact corridor of water cells
  • Add ring-1 buffer (neighbouring hexes) for stability
  • Bridge corridor endpoints to open-sea res-5 cells with explicit bidirectional edges

The agent learns to enter, traverse, and exit the canal as part of its policy — no special-case logic in the reward or step function. Other straits handled automatically by res-6 refinement: Bonifacio (~12 km), Gibraltar (~14 km), Messina (~3 km, borderline).

8 MDP Formulation & State Space
MDP: ⟨S, A, P, R, γ⟩
S : ℝ⁸ observation vector (below) γ = 0.99 A : 7 discrete actions P : deterministic graph transitions R : potential-based shaped reward Episodic, finite-horizon
State Vector s ∈ ℝ⁸ (all normalised)
DimFeatureRange
φ̂Normalised latitude[0, 1]
λ̂Normalised longitude[0, 1]
BFSBFS hops to goal / initial hops[0, 1]
havHaversine dist / initial dist[0, 1]
tfracStep count / max steps[0, 1]
ψ̂Last action bearing / 360°[0, 1]
Δd̂Progress this step (normalised)[−1, 1]
Visit count at current hex (norm)[0, 1]

Action space: 7 discrete actions — 6 H3 ring-1 neighbours sorted clockwise from North + STAY. Binary action mask m ∈ {0,1}⁷ prevents stepping onto land; computed once and cached per hex.

9 Step 3 — Reward Engineering
Old Reward — Reward Hacking Failure
r_old = r_progress_km + r_step_efficiency + r_shaping + r_penalties + r_terminal r_step_efficiency: (max_steps − step_count)/max_steps × 3.0 ← NON-MARKOVIAN r_pingpong/loop3: −10.0 ← 100× larger than refactored Clip: [−5.0, +3.0] (asymmetric → agent exploits oscillation)

Failure on Piraeus: reward rose from −773 → +315/episode over 1,500 episodes while success rate stayed at exactly 0%. Agent farmed the progress signal through oscillation. The non-Markovian step-efficiency term violated the MDP assumption entirely.

Refactored Reward — Potential-Based Shaping (Ng et al., 1999)
r(s,a,s') = α·[Φ(s') − Φ(s)] + r_terminal + Σ r_guardrails Φ(s) = −BFS_dist(s, goal) / initial_BFS_dist α = 25.0 r_terminal = +10.0 iff BFS_dist(s', goal) ≤ 2 hops (sparse) Guardrails (route-normalised by λ = min(0.4, BFS_hops/100)): time: −0.05·λ/step land: −1.0·λ ping-pong: −0.1 3-cycle: −0.2 revisit: −0.05·count (cap −1.0) λ: PortTorres=0.133 Cagliari=0.197 Piraeus=0.400 (capped)
Evidence: Cross-reward validation on Port Torres — policy trained on refactored reward, tested on old reward: 100% success. Policy trained on old reward, tested on old reward: 49.7% success. The refactored policy generalises; the old policy is fragile.
10 Double DQN Architecture
Target: y_t = r_t + γ · Q_θ⁻(s_{t+1}, argmax_{a': m_{a'}=1} Q_θ(s_{t+1},a')) Loss: ℒ(θ) = 𝔼_𝒟 [SmoothL1(y_t − Q_θ(s_t, a_t))] δ=1.0 Network: ℝ⁸ → [Linear(8→400) + LayerNorm + ReLU] → [Linear(400→300) + LayerNorm + ReLU] → Linear(300→7) LayerNorm (not BatchNorm): no dependency on batch statistics.
HyperparameterValue
OptimizerAdam, lr = 5×10⁻⁴
Replay buffer1,000,000 transitions (numpy ring buffer)
Mini-batch128 transitions, sampled uniformly
Gradient clip‖∇θ‖₂ ≤ 1.0
Explorationε-greedy, ε: 1.0 → 0.01 (×0.995/ep)
Soft updateτ = 0.001, every 5 gradient steps
Discount γ0.99
11 Optuna Bayesian Hyperparameter Search

The reward function has 13 interacting parameters. Manual grid search is infeasible. Optuna's TPE sampler (Tree-structured Parzen Estimator) was run in parallel on NVIDIA L4 GPUs via Modal cloud compute (~$50 / 50 trials). Search space: progress_scale [8–30], goal_reward [20–100], land_penalty, ping-pong/loop3 coefficients, revisit_multiplier, time_penalty, gamma [0.93–0.999], clip bounds.

Fitness: success_rate − 0.2×clipping_rate − 0.05×orbit_rate. H3 grid built once per worker; only env.reset() between trials.

12 Curriculum Learning — Piraeus (1,647 km)

Cold-start problem: random-walk exploration covers ≈√500 ≈ 22 hops in a 500-step episode; the goal is 107 hops away — effectively invisible.

StageSegmentStepsEpisodesThreshold
1Origin → Midpoint15020080%
2Midpoint → Destination15020080%
…NSegment pairs combined80%
FinalFull route30040070%

BFS-seeded replay buffer pre-populates with optimal trajectories, bootstrapping Q-values before exploration begins.

13 Results
100%Port Torres → Marseille
371 km · 1,500 ep
99%Cagliari → Marseille
552 km · 1,500 ep
In prog.Piraeus → Marseille
1,647 km · 3,000 ep
Piraeus — Root Causes Identified & Fixed
  • Bug 1 — goal_threshold = 0: Required landing on 1 exact hex out of 10,937. P(cold-start success in 500 steps) ≈ 1.6×10⁻⁵. Fix: threshold = 2 hops (19 hexes within ~56 km count as success).
  • Bug 2 — Canal exit asymmetry: res-6 canal hexes could not exit to res-5 open sea. BFS debug confirmed a hard wall at exactly 54 hops — 661 episodes reached that boundary; zero crossed it in 1,500 episodes. Fix: symmetric bidirectional cross-resolution edges using max(res5_edge, res6_edge) threshold.
Comparison with Latinopoulos et al. (2025)
FeatureLatinopoulos (2025)This Work
Grid typeOrthogonal lat/lonH3 hexagonal
Resolution0.25° uniform (~28 km)Adaptive res-5/6 (10–28 km)
Coastal resolution28 km everywhere3.7 km near coastline
Canal handlingTeleportation shortcutExplicit corridor + BFS
Neighbour distances8 dirs, unequal6 dirs, always equal
Action space285 (speed × heading)7 discrete directions
Routes validated1 route2 routes (100%, 99%)
DDQN fuel saving−8.7% vs baselineTo be evaluated
14 Weather Pipeline & Future Work
ERA5 Weather Pipeline — Built, Integration Next

Data: ECMWF ERA5 (Copernicus CDS) — 10m wind (U,V), significant wave height, mean wave direction & period, SST, MSLP. Resolution: 0.25°×0.25°, 3-hourly. Coverage: 34°N–46°N, −6°E–30°E. Processing: WeatherProcessor — load GRIB, spatial interpolation onto H3 nodes, temporal interpolation for ship ETA at each hex, cache as NetCDF.

Integration plan: (1) Add weather features to 8D state vector; (2) Wave-heading penalty; (3) Validate weather-aware vs weather-agnostic agent; (4) Online fine-tuning every 6 hours (Latinopoulos: ~15 min GPU update — viable for operational shipping).

Neural Fuel Oil Consumption Model (Proposed)

Current limitation (shared with Latinopoulos): fuel modelled with fixed analytical formula. Real ships burn non-linearly as a function of sea state, heading, loading, and hull fouling. Proposed: MLP or LSTM trained on AIS voyage logs + ERA5 (no proprietary data required). Inputs: trim, speed, currents, wave height/direction/period, SST. Output: L/hour. Integration: replace r_fuel = fixed × distance with r_fuel = FOC_model(state, action, weather) × Δt — closing the loop so the agent directly optimises real predicted fuel burn.

15 Conclusions
  • H3 hexagons eliminate diagonal bias — Q-values directly encode navigational value, not a geometry correction artefact. All 6 moves are equidistant.
  • Adaptive resolution unlocks coastal navigation — 3.7 km res-6 cells make the Strait of Bonifacio (12 km) and Corinth Canal (6 km) naturally navigable without teleportation.
  • Reward hacking is real and detectable — potential-based shaping (Ng et al. 1999) with a BFS-derived potential eliminates this class of failure by construction.
  • Penalty scaling is not optional — the same values that work on 371 km produce an 818% burden on 1,647 km; λ = min(0.4, BFS_hops/100) makes reward portable across route lengths.
  • Short and medium routes are solved — Port Torres 100%, Cagliari 99%. Piraeus bugs identified, fixed, re-run in progress.
  • The remaining work is integration, not invention — weather pipeline built, canal model corrected, reward validated, Optuna infrastructure proven.
"The biggest lesson: in maritime DRL, the environment is the algorithm. Getting the grid geometry, canal topology, and penalty scaling right matters more than the network architecture."