Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
5c895cf
Remove wrr bench and utils from project dependencies
daniprec Mar 2, 2026
8c4dedd
Remove Git credentials section from README.md
daniprec Mar 2, 2026
ac1545c
Remove wrr-bench and wrr-utils from project dependencies
daniprec Mar 2, 2026
a88b7a2
Copy wrr_bench raw
daniprec Mar 3, 2026
486b7f6
Import wrr_utils from folder
daniprec Mar 3, 2026
1da5286
Refactor import statements and improve assertion error messages in be…
daniprec Mar 3, 2026
2877a79
Copy wrr_utils: polygon
daniprec Mar 3, 2026
27bef39
wrr_utils hexagonal grid
daniprec Mar 3, 2026
10e5771
wrr_utils benchmark
daniprec Mar 3, 2026
ae067c5
wrr_utils simulation
daniprec Mar 3, 2026
abb016d
wrr_utils init
daniprec Mar 3, 2026
f06db75
wrr_bench ocean typing
daniprec Mar 3, 2026
0979f16
Add libraries for new tools
daniprec Mar 3, 2026
9f559a7
Add test function inside benchmark
daniprec Mar 3, 2026
2f7bae3
wrr_utils route
daniprec Mar 3, 2026
bdfa0af
wrr_utils vectorfield
daniprec Mar 3, 2026
a36cea7
wrr_utils base optimizer
daniprec Mar 3, 2026
5690a06
wrr_utils dnj
daniprec Mar 3, 2026
020e35e
wrr_utils base astar
daniprec Mar 3, 2026
4376cb1
wrr_utils circumnavigate
daniprec Mar 3, 2026
e84f47f
wrr_utils results
daniprec Mar 3, 2026
bb7bc1e
refactor: update import for auto_bounding_box and clean up __all__ de…
daniprec Mar 3, 2026
6fdec71
chore: update dependencies in pyproject.toml and uv.lock for netcdf4 …
daniprec Mar 3, 2026
0121feb
refactor: streamline assertions and enhance main function parameters …
daniprec Mar 3, 2026
cc18b78
fix: update data_path to use relative path for consistency in figures…
daniprec Mar 3, 2026
371d9fa
refactor: simplify assertion statements in circumnavigate and optimiz…
daniprec Mar 3, 2026
8491da9
refactor: replace warnings with ValueError for route optimization fai…
daniprec Mar 3, 2026
f1854c5
refactor: clean up assertions and remove unused Route import in bench…
daniprec Mar 3, 2026
2720972
refactor: remove unused vector field utilities from wrr_utils
daniprec Mar 3, 2026
80a506a
refactor: remove unused add_mid_points and compute_speeds_given_coord…
daniprec Mar 3, 2026
d2b1416
refactor: remove unused evaluate_csv function and auto_bounding_box f…
daniprec Mar 3, 2026
267857c
refactor: remove unused beaufort_scale function and clean up imports …
daniprec Mar 3, 2026
9823443
feat: Implement A* pathfinding and optimization framework
daniprec Mar 3, 2026
86ebdb2
refactor: update type hints from np.array to np.ndarray in simulation.py
daniprec Mar 3, 2026
096cede
Remove Route and Simulation modules
daniprec Mar 3, 2026
1838333
Remove unused modules and classes from wrr_utils
daniprec Mar 3, 2026
8ab01fc
refactor: remove benchmark loading functionality and main entry point…
daniprec Mar 3, 2026
8befd6e
refactor: streamline assertions and update circumnavigate initializat…
daniprec Mar 3, 2026
72c1429
refactor: update bounding box type hints and optimize circumnavigate …
daniprec Mar 3, 2026
6700a84
refactor: remove unused functions and streamline Circumnavigate class…
daniprec Mar 3, 2026
46868be
refactor: update route initialization parameters in Circumnavigate class
daniprec Mar 3, 2026
3fc7f72
Remove simulation.py module and its associated functions for waypoint…
daniprec Mar 3, 2026
c6f7956
refactor: streamline parameter handling and assertions in Circumnavig…
daniprec Mar 3, 2026
155e2fb
refactor: improve parameter type hints and assertions in Ocean class
daniprec Mar 3, 2026
c1922d4
refactor: rename circumnavigate function and streamline route optimiz…
daniprec Mar 3, 2026
1a08e55
dict_bench always have vel_ship
daniprec Mar 3, 2026
6f5c8fb
feat: add port and benchmark data structures for route optimization
daniprec Mar 3, 2026
13c980a
refactor: remove unused parameters
daniprec Mar 3, 2026
676d150
Add new ports
daniprec Mar 3, 2026
92ba2e1
Replace USNYC
daniprec Mar 3, 2026
8cb6506
Add new benchmarks and test them
daniprec Mar 3, 2026
66877b8
feat: add swopp_demo script for benchmark testing and visualization
daniprec Mar 3, 2026
d9ce1b5
fix: correct import path
daniprec Mar 3, 2026
b6ba144
feat: enhance swopp_demo with distance calculations and cleanup
daniprec Mar 3, 2026
b3759e8
Rename "benchmark" to "instance" and include __init__
daniprec Mar 4, 2026
72e7d60
Import invert_polygon to avoid redundancies
daniprec Mar 4, 2026
da641b1
Move all polygon related code to polygons
daniprec Mar 4, 2026
a1ba452
Remove s3fs
daniprec Mar 4, 2026
d7667ab
Update uv lock after removing s3fs
daniprec Mar 4, 2026
db2fdfe
Remove redundant lines
daniprec Mar 4, 2026
7b91dec
Remove redundant lines
daniprec Mar 4, 2026
722be3e
Remove unused libraries
daniprec Mar 4, 2026
260aa9d
Add new code
daniprec Mar 4, 2026
2584071
Merge pull request #31 from IEResearchDatalab/feature/wrr_bench_utils
fjsuarez Mar 4, 2026
b01de0e
feat(land): raise penalty to 1e10, handle missing land_file in Ocean …
daniprec Mar 4, 2026
f455e39
fix(benchmark): improve instance loading, flatten DICT_INSTANCES, add…
daniprec Mar 4, 2026
374094e
feat: ERA5 weather data ingestion
fjsuarez Mar 4, 2026
876a4b2
feat: weather constraint evaluation
fjsuarez Mar 4, 2026
8f408f3
feat: time-variant cost function and RISE energy cost
fjsuarez Mar 4, 2026
25ed346
feat: CMA-ES optimizer enhancements
fjsuarez Mar 4, 2026
276f7dc
feat: SWOPP3 competition core modules
fjsuarez Mar 4, 2026
11555d0
feat: SWOPP3 runner, plotting and deployment scripts
fjsuarez Mar 4, 2026
bcb6dc7
docs: CMA-ES diagnostic guide and misc cleanup
fjsuarez Mar 4, 2026
e99cfc5
fix: address Copilot review comments
fjsuarez Mar 4, 2026
e6c2e38
fix: address Copilot review comments
fjsuarez Mar 4, 2026
e1ba213
fix: address Copilot review comments
fjsuarez Mar 4, 2026
49b9e59
fix: address Copilot review comments (critical bugs)
fjsuarez Mar 4, 2026
cab5833
fix: address Copilot review comments
fjsuarez Mar 4, 2026
02046a8
fix: address Copilot review comments
fjsuarez Mar 4, 2026
1d442f6
fix: handle ts longer than lat in wind/wave field lookup
fjsuarez Mar 4, 2026
52b4559
fix: address second-round Copilot review comments
fjsuarez Mar 4, 2026
c0d174f
fix: address second-round Copilot review comments
fjsuarez Mar 4, 2026
8129fac
feat(era5): add download script, benchmark example, wrr_bench depreca…
fjsuarez Mar 5, 2026
5e7a020
fix: evaluate weather at correct elapsed time instead of t=0
fjsuarez Mar 5, 2026
1a448e9
fix: address review feedback on ERA5 benchmark
fjsuarez Mar 5, 2026
8cd4936
feat: RISE parametric performance model (#42)
fjsuarez Mar 5, 2026
01b837c
docs: RISE performance model documentation and benchmark (#43)
fjsuarez Mar 5, 2026
d107761
Merge pull request #41 from IEResearchDatalab/feat/era5
daniprec Mar 9, 2026
a009a25
Merge pull request #44 from IEResearchDatalab/feat/weather-constraints
daniprec Mar 9, 2026
8390905
Reformat file to meet hooks
daniprec Mar 10, 2026
338e8da
Merge pull request #46 from IEResearchDatalab/feat/cmaes-updates
daniprec Mar 10, 2026
53d236e
refactor: streamline imports and enhance cost function documentation
daniprec Mar 10, 2026
e9de470
Merge pull request #45 from IEResearchDatalab/feat/cost-improvements
daniprec Mar 10, 2026
d09ebe3
refactor: update datetime usage to use UTC consistently across modules
daniprec Mar 10, 2026
1ffd1dd
feat: enhance SWOPP3 modules with improved port definitions and valid…
daniprec Mar 10, 2026
1f4eb3a
Merge pull request #47 from IEResearchDatalab/feat/swopp3-core
daniprec Mar 10, 2026
6532670
chore(scripts): fix lint docs and shebang executables
daniprec Mar 10, 2026
4a4fd56
chore(era5): resolve hooks and typing across weather stack
daniprec Mar 10, 2026
6ad5a8e
docs: add repository copilot instructions
daniprec Mar 10, 2026
135167d
Update scripts/era5_benchmark.py
daniprec Mar 10, 2026
ded4b8c
Update routetools/era5/loader.py
daniprec Mar 10, 2026
e06f868
Update routetools/era5/loader.py
daniprec Mar 10, 2026
dfb993b
fix: update type checks and improve deprecation warnings in loader an…
daniprec Mar 10, 2026
7f3d747
Merge branch 'swopp' into feat/swopp3-runner
daniprec Mar 10, 2026
f915058
make hooks and make test pass
daniprec Mar 10, 2026
7a05d97
Refactor code structure for improved readability and maintainability
daniprec Mar 10, 2026
8050258
Merge pull request #52 from IEResearchDatalab/fix/make_hooks
daniprec Mar 10, 2026
73bb2a6
Merge branch 'swopp' into feat/swopp3-runner
daniprec Mar 10, 2026
152ccd1
fix(swopp3-runner): resolve hook issues for runner scripts
daniprec Mar 10, 2026
0041702
fix(swopp3): address PR review comments
daniprec Mar 10, 2026
179afc2
docs: add clarification on repository push permissions
daniprec Mar 10, 2026
038c120
refactor: extract generic SWOPP3 helpers into core modules
daniprec Mar 10, 2026
09afbd4
Merge pull request #48 from IEResearchDatalab/feat/swopp3-runner
daniprec Mar 11, 2026
04e1118
Merge pull request #49 from IEResearchDatalab/feat/docs-misc
daniprec Mar 11, 2026
78090d7
docs: prettier formatting for cmaes_diagnostic.md
daniprec Mar 11, 2026
808d272
Merge pull request #57 from IEResearchDatalab/prettier-format-cmaes-d…
daniprec Mar 12, 2026
d652661
Fail fast when SWOPP3 optimized inputs are missing
daniprec Mar 12, 2026
af4da41
Validate SWOPP3 ERA5 inputs before execution
daniprec Mar 12, 2026
2428562
Document the default SWOPP3 ERA5 pipeline
daniprec Mar 12, 2026
0ef0411
Change plot script input to match the output of runner
daniprec Mar 12, 2026
73a9beb
Merge branch 'swopp' into docs/swopp3-era5-pipeline
daniprec Mar 12, 2026
447d3fd
fix: let shared SWOPP3 paths override defaults
daniprec Mar 16, 2026
31a49b9
refactor: lazy-load heavy SWOPP3 CLI imports
daniprec Mar 16, 2026
00d8c95
Merge pull request #59 from IEResearchDatalab/docs/swopp3-era5-pipeline
daniprec Mar 16, 2026
d4ec892
feat: physical coefficient derivations and validate_routes script (#54)
fjsuarez Mar 16, 2026
44e06e2
feat: multi-file ERA5 loading and GCS/CDS comparison (#56)
fjsuarez Mar 16, 2026
2d29822
feat(codabench): add CodaBench SWOPP3 competition scorer (#61)
fjsuarez Mar 16, 2026
905c2a2
feat(era5): default to hourly temporal resolution
fjsuarez Mar 16, 2026
34e40de
feat(swopp3): enforce operational weather constraints in CMA-ES
fjsuarez Mar 16, 2026
b55d85a
feat(land): smooth distance-to-land penalty via EDT precomputation
fjsuarez Mar 16, 2026
25934c2
fix: address PR #62 review comments
fjsuarez Mar 16, 2026
235bd70
fix(land): add _edt to Land bypass constructors in era5 loader
fjsuarez Mar 16, 2026
4da1f20
perf(swopp3): reuse windfield closure as vectorfield
fjsuarez Mar 16, 2026
2060916
fix(swopp3): free corridor data on GPU when switching corridors
fjsuarez Mar 16, 2026
fd9627b
fix(cost): use per-segment speed in evaluate_route_energy
fjsuarez Mar 16, 2026
7b3fe38
feat(swopp3): split SLURM jobs by corridor with hourly n-points
fjsuarez Mar 17, 2026
dea4c7a
fix(swopp3): repeat --cases flag for typer list option
fjsuarez Mar 17, 2026
1bdce69
fix(cmaes): add geographic bounds and strengthen land penalties
fjsuarez Mar 17, 2026
97f3db1
Potential fix for pull request finding
daniprec Mar 17, 2026
633f5a7
Potential fix for pull request finding
daniprec Mar 17, 2026
f46cea6
Potential fix for pull request finding
daniprec Mar 17, 2026
ed541db
Potential fix for pull request finding
daniprec Mar 17, 2026
a0ec7a0
fix(land): import distance_transform_edt for distance calculations
daniprec Mar 17, 2026
320c32f
fix(swopp3): reduce K=6 and remove bounds to prevent loops
fjsuarez Mar 17, 2026
00138fb
perf(swopp3): stage repo onto /scratch SSD for faster I/O
fjsuarez Mar 17, 2026
3cff22c
refactor(slurm): single staging job for /scratch rsync + submission w…
fjsuarez Mar 17, 2026
81e66e6
refactor(slurm): git pull instead of rsync for code updates on /scratch
fjsuarez Mar 17, 2026
e0157da
fix(slurm): use cp -rv to copy tracks subdirectory back to /home
fjsuarez Mar 17, 2026
658c3d8
feat(swopp3): add n-points resample comparison script
fjsuarez Mar 17, 2026
e7c5981
fix(slurm): handle existing /scratch dir without .git in staging
fjsuarez Mar 17, 2026
886266d
fix(npoints): fix timezone-aware datetime subtraction
fjsuarez Mar 17, 2026
c8c8998
fix(scripts): lint fixes and executable permissions for npoints scripts
fjsuarez Mar 17, 2026
faaa9ea
fix(scorer): resampling, trapezoidal rule, violations, interpolation …
fjsuarez Mar 18, 2026
1ea68a9
feat(cmaes): configurable weather penalty type and control points
fjsuarez Mar 18, 2026
b822abf
fix(slurm): run CPU job from /scratch, fix lint in test_resample_track
fjsuarez Mar 18, 2026
0fdd5b3
fix(validate): add magnitude check to strategy pair validation
fjsuarez Mar 18, 2026
9c4967c
feat: parameter sweep scripts for Stage A/B tuning
fjsuarez Mar 19, 2026
4354652
fix: revert ERA5 interpolation to order=1 (JAX limit)
fjsuarez Mar 19, 2026
f9742a5
feat: Atlantic parameter sweep + Pacific sweep results summary
fjsuarez Mar 19, 2026
78a9853
feat: cubic B-spline interpolation in JAX + no-constraint run script
fjsuarez Mar 19, 2026
3b53df0
feat: add --temporal-stride to reduce ERA5 JIT constant size
fjsuarez Mar 19, 2026
c459cc6
fix: use CPU mode for no-constraint run (avoids stride=3 artifacts)
fjsuarez Mar 19, 2026
2915abe
add: comparison plots for no-constraint experiment
fjsuarez Mar 19, 2026
a989627
feat(slurm): add SLURM script for 0526 fixed-penalty pipeline run
daniprec Jun 1, 2026
7294e65
Merge pull request #62 from IEResearchDatalab/feat/swopp3-final-results
daniprec Jun 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copilot Instructions for routetools

This repository implements weather-routing optimization with JAX and CMA-ES. Keep changes focused, reproducible, and validated.

Write and reason in English.

## Required Workflow

1. Read relevant source files and matching tests before editing.
2. Make the smallest change that satisfies the request.
3. Add or update tests when behavior changes.
4. After each update, run both commands:
- `make hooks`
- `make test`
5. If either command fails, fix the issues and rerun both commands.
6. Do not finalize work until both commands pass.

## Code Conventions

- Use the repository toolchain (`uv` via `make` targets).
- Preserve existing public APIs unless the request explicitly requires a breaking change.
- Follow `ruff` and `pytest` settings in `pyproject.toml`.
- Keep docstrings in NumPy style for public functions.
- Prefer vectorized/JAX-friendly implementations in performance-sensitive code paths.

## Testing Conventions

- Place tests in `tests/` near the relevant domain file.
- For bug fixes, add a regression test first whenever practical.
- Keep tests deterministic and lightweight unless a larger benchmark is explicitly requested.

## Data and Artifacts

- Do not commit large generated outputs.
- Treat `data/` contents as potentially large and optional in local environments.
- Fail with clear error messages when optional datasets are missing.

## Permissions

- Make sure you have the necessary permissions to push to the repository. If you do not have permissions, stop and ask for them, guiding the user to the appropriate process to gain access.
- You can add, commit and push changes to this repository. Never commit to 'main' or 'swopp' branches directly.
- If you are on 'main' or 'swopp', create a new branch for your changes and open a pull request for review.
- Create tests before implementing new features or fixing bugs. Tests should be in the `tests/` directory and follow existing patterns.
- Make sure to run all tests and hooks before pushing your changes. If you encounter any issues, please fix them before pushing.
- Do small commits, preferably one per logical change. This makes it easier to review and understand the history of changes.
10 changes: 5 additions & 5 deletions .github/workflows/pre-commit-pr.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: pre-commit-pr
name: post-commit-push

on:
pull_request:
push:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
pre-commit:
post-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -30,5 +30,5 @@ jobs:
uv pip install pip
- uses: pre-commit/action@v3.0.1
with:
# Ejecutar solo en ficheros que hayan cambiado https://github.com/pre-commit/action/issues/7
extra_args: --color=always --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}
# Run hooks after commits are pushed
extra_args: --color=always --all-files --hook-stage post-commit
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,16 @@ output*
# User files
nohup.out
*.zip
output/

# CodaBench competition — large data & build artifacts
codabench/reference_data/*.nc
codabench/reference_data/*.shp
codabench/reference_data/*.shx
codabench/reference_data/*.dbf
codabench/reference_data/*.prj
codabench/logo/
codabench/test_submission/

# Separate repo
routingviz/
131 changes: 73 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Tools:
- [prettier](https://prettier.io/): format YAML and Markdown
- [codespell](https://github.com/codespell-project/codespell): check spelling in source code

## Documentation

- [Parametric Performance Model](docs/parametric_model.md) — closed-form RISE model for ship power prediction (hull, wind, wave, and wingsail components).

## Installation

### Application
Expand All @@ -38,7 +42,18 @@ Install package and pinned dependencies with the [`uv`](https://docs.astral.sh/u
uv sync
```

4. Run any command or Python script with `uv run`, for instance:
4. (Optional) Install the SWOPP3 performance model:

```{bash}
uv sync --extra swopp3 --find-links release_package/wheels
```

If the pre-built wheels are available locally in `release_package/wheels/`,
`uv` will resolve `swopp3-performance-model` from that directory. Wheels are
available for Python 3.10 – 3.13 on Linux (manylinux) and Windows
(win_amd64).

5. Run any command or Python script with `uv run`, for instance:

```{bash}
uv run routetools/cmaes.py
Expand All @@ -50,63 +65,6 @@ Install package and pinned dependencies with the [`uv`](https://docs.astral.sh/u
source .venv/bin/activate
```

### Git credentials for VCS dependencies

When `uv` installs a package from a git repository (VCS dependency), Git may need credentials to fetch the remote. On non-interactive environments this commonly fails with:

```bash
fatal: could not read Username for 'https://github.com': terminal prompts disabled
```

Use one of the following approaches to make VCS fetches non-interactive.

**Option A: SSH (preferred)**

Generate an SSH key (WSL / Linux):

```bash
ssh-keygen -t ed25519 -C "your_email@example.com" -f ~/.ssh/id_ed25519 -N ""
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519.pub
```

Add the printed public key to GitHub (Settings → SSH and GPG keys). Test access:

```bash
ssh -T git@github.com
git ls-remote git@github.com:Weather-Routing-Research/weather-routing-benchmarks.git refs/heads/main
```

Then use an SSH pip URL when adding or declaring the dependency:

```bash
uv add 'git+ssh://git@github.com/Weather-Routing-Research/weather-routing-benchmarks.git@main#egg=wrr_bench'
uv sync
```

If you run `uv` from PowerShell on Windows, ensure the Windows SSH agent is running and the key is loaded (Start-Service ssh-agent; ssh-add $env:USERPROFILE\\.ssh\\id_ed25519), or run `uv` from WSL where the key was created.

**Option B: HTTPS with credentials (fallback)**

Use Git Credential Manager or GitHub CLI to cache credentials so Git won't prompt:

PowerShell (Windows):

```powershell
git config --global credential.helper manager-core
gh auth login --hostname github.com --git-protocol https
```

WSL / Linux (use gh or configure a credential helper that works in your environment):

```bash
gh auth login --hostname github.com --git-protocol https
# or configure `git config --global credential.helper cache` for short-term caching
```

After configuring credentials, retry the `uv add` / `uv sync` command.

### Library

Install a specific version of the package with `pip` or `uv pip`:
Expand Down Expand Up @@ -157,6 +115,63 @@ If your computer does not have a GPU, you can force JAX to use the CPU with `JAX
JAX_PLATFORMS=cpu uv run scripts/single_run.py
```

### ERA5 weather data pipeline

The `routetools.era5` module provides real-world ERA5 wind and wave fields
for weather routing. Two download backends are available:

- **GCS** (default) — Google Cloud archive, no API key required.
- **CDS** — Copernicus Climate Data Store (requires `cdsapi` + API key).

**1. Download ERA5 data** for the Atlantic corridor (USNYC ↔ DEHAM):

```bash
uv run scripts/download_era5.py --corridor atlantic --year 2023
```

This creates `data/era5/era5_wind_atlantic_2023.nc` and
`data/era5/era5_waves_atlantic_2023.nc`.

**2. Run the real-world benchmark** (New York → Hamburg, Jan 8 2023):

```bash
uv run scripts/era5_benchmark.py --departure 2023-01-08T00:00:00
```

See `scripts/download_era5.py --help` and `scripts/era5_benchmark.py --help`
for all available options.

### SWOPP3 ERA5 pipeline

The default SWOPP3 competition pipeline is:

```bash
uv run scripts/download_era5.py
uv run scripts/swopp3_run.py
```

These two commands line up without extra path flags. The downloader writes the
four default 2024 files that `scripts/swopp3_run.py` expects:

```text
data/era5/era5_wind_atlantic_2024.nc
data/era5/era5_waves_atlantic_2024.nc
data/era5/era5_wind_pacific_2024.nc
data/era5/era5_waves_pacific_2024.nc
```

`scripts/swopp3_run.py` validates these files before running any case. If one
or more inputs are missing, it exits immediately with a precise error message
instead of silently substituting a great-circle route or running without
weather data. This is intentional:

- GC cases still require wind and wave data for SWOPP3 energy evaluation.
- Optimised cases require wind data for the CMA-ES vectorfield and wind/wave
data for the final SWOPP3 energy evaluation.

If you download a different year or only one corridor, pass matching
`--wind-path*` and `--wave-path*` options to `scripts/swopp3_run.py`.

## Reproduce the results (paper)

To reproduce the results from the paper, run the following command:
Expand Down
121 changes: 121 additions & 0 deletions codabench/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# SWOPP3 Weather Routing Benchmark — CodaBench Setup

This directory contains everything needed to host the SWOPP3 Weather Routing
Benchmark on [CodaBench](https://www.codabench.org/).

## Directory Structure

```
codabench/
├── README.md ← You are here
├── competition.yaml ← Competition configuration (title, phases, leaderboard)
├── scoring_program/
│ ├── scoring.py ← Evaluates submissions (validation + scoring)
│ └── metadata.yaml ← CodaBench scoring program metadata
├── pages/
│ ├── overview.md ← Competition description
│ ├── data.md ← Data download & API instructions
│ ├── submission.md ← Submission format specification
│ ├── evaluation.md ← How submissions are scored
│ └── terms.md ← Terms and conditions
├── starting_kit/
│ └── starting_kit.py ← Great-circle baseline (example submission)
└── logo.png ← Competition logo
```

## Step-by-Step Setup

### 1. Create the Competition Bundle

CodaBench requires a `.zip` bundle containing the competition definition.
Build it from this directory:

```bash
cd codabench
bash build_bundle.sh
```

This creates `scoring_program.zip`, `starting_kit.zip`, `reference_data.zip`,
and a combined `competition_bundle.zip`. See `build_bundle.sh` for details.

### 2. Create the Competition on CodaBench

1. Go to **[codabench.org](https://www.codabench.org/)** and sign in.
2. Click **Benchmarks/Competitions** → **Create**.
3. Fill in the **Details** tab:
- **Title:** `SWOPP3 Weather Routing Benchmark`
- **Logo:** Upload a logo (PNG)
- **Description:** Copy from `pages/overview.md` or write a summary
- **Competition Docker Image:** Use `fjsuarez/swopp3-scorer:latest`
- **Competition Type:** Competition
4. **Pages** tab:
- Add pages from the `pages/` directory (Overview, Data, Submission, Evaluation, Terms)
5. **Phases** tab:
- Create one phase ("Main Phase")
- Upload `scoring_program.zip` as the Scoring Program
- Upload `reference_data.zip` as the Reference Data
- Set start/end dates, max submissions per day (3), total max (100)
6. **Leaderboard** tab:
- Add columns matching the keys in `competition.yaml` → `leaderboard`
- Primary ranking column: `total_energy_mwh` (ascending)
7. **Publish** the competition.

### 3. Reference Data

The `reference_data/` directory must contain the 6-hourly ERA5 NetCDF files
(~3.1 GB total) and the Natural Earth land shapefile before building the
bundle. See `build_bundle.sh` for the full list of required files.

The scoring program is **self-contained** — it uses only `numpy`, `netCDF4`,
`pyshp`, `shapely`, and `matplotlib` (listed in `scoring_program/requirements.txt`).
No `routetools` or JAX installation is needed on the CodaBench worker.
The Docker image `fjsuarez/swopp3-scorer:latest` has all dependencies pre-installed.

### 4. Starting Kit

Upload `starting_kit.zip` to CodaBench so participants can download a working
baseline. The `starting_kit.py` script generates a valid submission using
great-circle routes.

## Scoring

The scoring program validates submission format and **re-evaluates every
route** using the RISE performance model with the official ERA5 data from
`reference_data/`. This guarantees all energy values are computed with the
same model and weather data.

If the ERA5 files are not present in `reference_data/`, the scorer falls back
to self-reported energy values from the participants' CSVs.

## Testing Locally

Test the scoring program locally before deploying:

```bash
# Create a mock submission using the starting kit
cd starting_kit
python starting_kit.py --output-dir /tmp/test_submission

# Simulate CodaBench's invocation
mkdir -p /tmp/codabench_input/res /tmp/codabench_input/ref /tmp/codabench_output
cp -r /tmp/test_submission/* /tmp/codabench_input/res/
cp reference_data/config.json /tmp/codabench_input/ref/

cd ../scoring_program
python scoring.py /tmp/codabench_input /tmp/codabench_output

# Check results
cat /tmp/codabench_output/scores.json
cat /tmp/codabench_output/scoring_log.txt
```

## Key CodaBench Concepts

| Concept | Meaning in SWOPP3 |
| ------------------- | ------------------------------------------------------ |
| **Phase** | Single evaluation phase (all 366 departures × 8 cases) |
| **Scoring Program** | `scoring.py` — validates and scores submissions |
| **Reference Data** | ERA5 NetCDF files + Natural Earth shapefile (~3.1 GB) |
| **Input Data** | The submission zip uploaded by participants |
| **Starting Kit** | `starting_kit.py` — great-circle baseline code |
| **Leaderboard** | Ranked by total energy (MWh), lower = better |
Loading