PortSimEnv / README.md
AdithyaSK's picture
AdithyaSK HF Staff
Card: link the code at 07-simulation-environments/portsim-v1
5304899 verified
|
Raw History Blame Contribute Delete
5.23 kB
metadata
license: cc-by-sa-4.0
pretty_name: PortSimEnv v1
language:
  - en
task_categories:
  - reinforcement-learning
  - text-generation
tags:
  - openenv
  - rl-environment
  - simulation
  - logistics
  - scheduling
  - operations-research
  - berth-allocation
  - real-world-data
size_categories:
  - 1K<n<10K
configs:
  - config_name: tasks
    default: true
    data_files:
      - split: train
        path: tasks/train.parquet
      - split: eval
        path: tasks/eval.parquet
  - config_name: rollouts
    data_files:
      - split: eval
        path: rollouts/eval.parquet
  - config_name: calls
    data_files:
      - split: train
        path: calls/train.parquet

PortSimEnv v1

Re-plan container-ship dockings at the Port of Barcelona. Each task is a real week (or two or three) at one container quay, built from the port's own 2024 records, with disruptions added: late and bunched ships, closed quay sections, crane breakdowns, gales under the port's wind rules, traffic diverted from the other terminal, emergencies and priority cargo. The agent decides when and where each ship docks and with how many cranes, and is graded once, deterministically, against the plan a CP-SAT solver proved optimal.

Environment (OpenEnv Space, 3D viewer, eval explorer) FineEnvs/PortSimEnv
Article Simulation RL Environments
Bucket (3D twin data, raw eval rollouts) FineEnvs/PortSimEnv
Code adithya-s-k/FineEnvs: 07-simulation-environments/portsim-v1
Ideas for v2, v3, post-training, data GitHub Discussions

Configs

config split rows what
tasks train 1,050 training tasks
tasks eval 50 held-out tasks: whole week groups that never appear in train
rollouts eval 300 6 models x 50 eval tasks: transcript, tool calls, final plan, grade
calls train 1,784 the 2024 container calls at quays 36A (BEST) and 24B (APM Terminals) the tasks are built from

tasks: system_prompt and situation are exactly what the environment sends (the rules, then the opening message, which is also what get_situation() returns). task is the full task as JSON (ships, closures, disruptions, rules). optimal_plan / optimal_cost are the CP-SAT reference (proven_optimal says whether optimality was proven); naive_plan / naive_cost re-plan by pushing ships later. A plan is a JSON list of {"ship": id, "berth_hour": h, "section": s, "cranes": c}.

rollouts: one row per (model, task) from the eval run dock-eval50: 12 turns and 32k output tokens per turn, the same three tools. messages is the full transcript, steps the tool calls with each check_plan result, grade the final grade.

Results on the 50 eval tasks

model mean reward standard busy storm extreme submitted valid optimal
GPT-6.1 Sol 0.888 1.00 0.90 0.86 0.82 50 50 26
Claude Sonnet 5.5 0.782 0.92 0.80 0.68 0.77 49 49 10
GLM-5.3-Flash 0.470 0.77 0.50 0.46 0.24 36 25 9
Qwen3.8-2.4T 0.380 0.58 0.45 0.33 0.21 34 23 5
GLM-5.3 0.313 0.62 0.34 0.22 0.15 17 16 10
Qwen3.8-27B 0.211 0.40 0.27 0.22 0.00 16 13 3

Reward

Deterministic, no LLM judge. A plan that breaks any rule scores at most 0.2 (0.2 x the share of ships placed cleanly). A valid plan's cost (hours each ship leaves after its due time x its size x its priority, plus penalties for late emergency dockings and moved ships) is compared with the optimum: gap = (cost - optimum) / (optimum - unavoidable + 100), reward = 0.2 + 0.8 * exp(-gap / 0.5). No submission scores 0.

Use

import json
from datasets import load_dataset

tasks = load_dataset("FineEnvs/PortSimEnv", "tasks", split="eval")
task = tasks[0]
print(task["system_prompt"], task["situation"], sep="\n\n")

Every task can be played on the environment Space (OpenEnv; MCP tools get_situation, check_plan, submit_plan). Submitting the reference optimum scores 1.0:

from openenv.core.env_server.mcp_types import CallToolAction
from openenv.core.mcp_client import MCPToolClient

env = MCPToolClient("https://fineenvs-portsimenv.hf.space").sync()
env.reset(task_id=task["task_id"])
step = env.step(CallToolAction(tool_name="submit_plan", arguments={"plan": json.loads(task["optimal_plan"])}))
print(step.reward)  # 1.0

Source and licence

Contains data from the Port de Barcelona open data portal (https://opendata.portdebarcelona.cat/), via the 2024 snapshot in alberto-santini/berth-allocation-problems, licensed CC BY-SA 4.0. This dataset is shared under the same licence. Crane fleets, wind rules and handling rates come from the terminals' and the port's published information; disruptions are generated. Work in progress (v1).