An evidence-aware digital-twin research stack for port clusters, critical waterways, and vessel flows. It unifies macro network simulation, controlled-event orchestration, public-data gateways, replaceable port-data contracts, five-method control experiments, strict chronological holdout evaluation, recoverable checkpoints, and human approval in one React + TypeScript + Node system.
This is not an animation-only dashboard. Training progress comes from completed server-side episodes, environment steps, and parameter updates. Training does not render policy outcomes; only an explicit post-completion evaluation may read the sealed test segment and return a replayable trace.
This repository supports research, teaching, and engineering verification. It is not a VTS/TOS, ECDIS, navigation device, or autonomous production dispatcher. Public statistics, model estimates, authorized interfaces, historical replay, and synthetic scenarios remain explicitly separated.
港航态势与核心闭环:马六甲港航网络、拥堵传播、事件注入、策略回放与人工控制
位于同一业务画面;公开统计、情景船舶和授权实时数据使用不同状态标识。 Maritime command loop: network state, congestion propagation, event injection,
policy replay, and human control share one operational surface with explicit evidence modes.
为什么这个项目值得关注 / Why this project matters
从态势到证据闭环:港口、航道、船舶、拥堵、延误、碳排与韧性状态共同进入事件推演,
结果保留数据模式、时间、算法、检查点和人工确认信息。 Ports, channels, vessels, congestion, delay, carbon, and resilience enter one event simulation, whose result retains data mode, time, algorithm, checkpoint, and human confirmation.
可审计的五基线实验:Q-Learning、SARSA、Expected SARSA、Dyna-Q 与 MPC 共享状态、动作、
奖励、训练段和评估段;MPC 被明确标为控制理论基线,不伪装成 RL。 Q-Learning, SARSA, Expected SARSA, Dyna-Q, and MPC share state, action, reward, training, and evaluation contracts; MPC is identified as control theory, not disguised as RL.
防止未来信息泄漏:默认 377 条 MPA 月度记录与 ERA5 风场按时间 70%/15%/15% 切分;容量代理只用训练段
校准,验证前段调超参数、后段选算法,最终测试段保持封存。 The 377 MPA monthly records and ERA5 forcing use a 70/15/15 temporal split. Capacity proxies fit on train only; the first validation segment tunes and the second selects; final test remains sealed.
训练与展示解耦:训练过程为 headless;测试完成后才由真实留出轨迹驱动地图回放。 Training is headless; only completed holdout traces drive map replay.
受控的小懿联动:白名单界面执行器与 RL 参数顾问是两个独立层;自动步骤完成后生成执行
报告,最终由人工确认或归档异常。 The allowlisted Xiaoyi UI executor and RL advisor are separate layers. Automation produces an execution report, followed by human confirmation or exception archiving.
可替换港口而非写死港口:CSV/JSON 字段合同、港口选择、单位和质量规则独立于算法实现。 CSV/JSON contracts, port selection, units, and quality rules are independent of algorithm code.
真实任务完成态:服务器任务返回 7,200 episodes、173,348 环境步、
389,032 次参数更新、263/57/57 时间切分和 checkpoint.json;训练阶段不渲染策略效果,
最终测试仍需显式启动。 Completed backend job: the server reports episodes, environment steps, updates,
temporal isolation, and a checkpoint artifact; sealed-test replay remains explicit.
The normal sealed replay has no measurable baseline burden, so MPC holds plan for 96.49% of steps and
no normal-operation benefit is claimed. Under the explicitly bounded +5% arrival / −2% capacity stress
diagnostic, MPC changes proxy delay from 0.344h to 0.110h and effective congestion pressure from 1.435%
to 0.468%, with 99.715% throughput retention, 3.734% expected stepwise safety risk, and a 21.053%
non-hold action rate. The resulting relative percentage is blocked because the baseline denominator is
too small. See the calibrated v2 evidence;
the legacy 66% report remains available only for audit.
上海港落地合同与大数据外部验证 / Shanghai landing and scale validation
The terminal-operations.v2 manifest covers terminals, berths, yards, quay cranes, gates, rail/water
transfers, ETA, navigation/tidal windows, pilots, tugs, metocean conditions, safety/hazmat controls,
shore power, fuels, and inter-port transfer evidence. The Shanghai scene starts fail-closed until an
authorized same-origin snapshot and data manifest are configured. Malacca remains the default product
scene; Shanghai is an opt-in portability example only.
The second public benchmark processes 371,585 raw Piraeus AIS messages into 1,440 minute-level
records and runs the same five methods with three seeds and chronological holdout. Its 24-hour
coverage makes it scale evidence, not a Shanghai field KPI or a replacement for the long-horizon MPA
benchmark.
Each job trains or identifies all five methods. Every RL method compares three hyperparameter sets on early validation; the candidate selected on late validation becomes the default test policy, while the UI can evaluate other methods on the same final segment. The repository does not claim PPO, SAC, MAPPO, or a deep-neural policy.
The objective jointly constrains delay, congestion, carbon index, safety, resilience, and throughput service. Shifted demand becomes deferred backlog released in later periods; diversion, capacity expansion, and deferral all carry intervention cost, preventing near-100% “improvement” by silently dropping demand.
数据证据与替换合同 / Data evidence and replacement contract
At runtime, the system can read MPA/data.gov.sg and Open-Meteo. Without an authorized AIS interface, map vessels are explicitly labelled scenario representatives rather than live AIS. To replace the port dataset, set:
要求 Node.js 24+。一键脚本会依次使用已安装的 pnpm、Corepack 或 npx,因此不要求全局安装
pnpm;缺少 node_modules 时会按锁文件自动安装依赖并打开浏览器。
Requires Node.js 24+. The launcher uses an installed pnpm, Corepack, or npx in that order, so a global
pnpm installation is not required. It installs locked dependencies when needed and opens the browser.
bash scripts/demo/start_web_demo.sh
用于完整复现发布校验的命令:
For a complete release-gate reproduction:
一键脚本默认打开 http://127.0.0.1:5180。进入“沙盘推演”,打开“训练中心”,先完成训练,再运行训练后策略
测试或检查点推理。
The launcher opens http://127.0.0.1:5180. Enter the sandbox, open the training centre, complete
training, and only then run post-training policy evaluation or checkpoint inference.
生产式本机运行使用独立 Node 服务:
For a production-shaped local runtime, use the standalone Node service:
pnpm build
pnpm start
监听非回环地址时,系统会失败关闭,除非 PORT_API_TOKEN 是不少于 32 个字符的非占位随机密钥。
Remote binding fails closed unless PORT_API_TOKEN is a non-placeholder random secret of at least 32 characters.
GET /healthz
GET /readyz
GET /api/openapi.json
GET /api/public-data/snapshot
GET /api/rl/datasets
GET /api/rl/contracts/terminal-operations
GET /api/rl/jobs
POST /api/rl/jobs
GET /api/rl/jobs/:jobId
DELETE /api/rl/jobs/:jobId
GET /api/rl/jobs/:jobId/checkpoint
POST /api/rl/jobs/:jobId/evaluate
POST /api/rl/inference
POST /api/port-calls/validate
POST /api/xiaoyi/rl-advisor
OpenAPI is the interface-discovery entry. Stricter data and interoperability boundaries are documented in DATASET_CONTRACT.md and PORT_CALL_INTEROPERABILITY.md. Field alignment is not DCSA, IALA, or IMO compliance certification.
Release-tag workflows build the static application, SPDX SBOM, and release bundle. GitHub provenance attestation, CodeQL, and OSSF Scorecard run after public release. See SECURITY.md for security boundaries and docs/MODEL_CARD.md for model limitations.
执行报告与人工门禁:小懿完成白名单步骤后生成可复核报告,异常可归档,
最终策略应用仍由人工确认,不将界面联动等同于无人值守生产控制。 Human-governed execution: allowlisted steps produce a reviewable report;
exceptions are archived and final application remains human-confirmed.
明确不包含 / Explicit exclusions
未提供港口生产账号、实时 AIS/TOS/VTS 数据或控制权限; No production port accounts, live AIS/TOS/VTS data, or control authority.
未提供安全认证、调度 SLA、海上避碰认证或无人值守决策; No safety certification, dispatch SLA, collision-avoidance certification, or unattended decision authority.
碳排、拥堵、延误和韧性指标包含模型估算,不等同于现场实测标签; Carbon, congestion, delay, and resilience include model estimates, not measured site labels.
reports/ 会透明保存全部五种方法的留出结果及核心代码指纹,不能只挑单次最好结果冒充结论; reports/ retains all five methods’ holdout results and core-code fingerprints; one best run cannot stand in for the conclusion.
Godot Web 二进制因体积与独立资产许可不进入源码仓库,仅保留接口与重建说明; Godot Web binaries are excluded because of size and separate asset licensing; contracts and rebuild instructions remain.
外部小懿服务不可用时使用确定性规则顾问,并在界面明确显示,不伪装成大模型在线结果。 When external Xiaoyi is unavailable, the UI explicitly identifies the deterministic rule advisor rather than presenting it as an online LLM.
Read CONTRIBUTING.md, GOVERNANCE.md, and CODE_OF_CONDUCT.md before contributing. Algorithm changes must provide pinned seeds, a data fingerprint, split semantics, actual update telemetry, and reproducible tests. Cite academic or engineering use through CITATION.cff.
许可证 / License
代码与项目原创矢量资产使用 Apache-2.0;公开数据与运行时提供方仍保留各自条款,详见 NOTICE 与 docs/ASSET_PROVENANCE.md。
Code and project-original vector assets are released under Apache-2.0. Public datasets and runtime providers retain their own terms; see NOTICE and docs/ASSET_PROVENANCE.md.