Skip to content

estimateArrivalTimesをtrainRouteのEstimatedと同じ計算にし、経路検索は元の計算のまま残した - #1715

Merged
TinyKitten merged 1 commit into
devfrom
feature/align-estimated-train-route-with-eta
Oct 1, 2026
Merged

TinyKitten merged 1 commit into
devfrom
feature/align-estimated-train-route-with-eta

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

概要

estimateArrivalTimes を、trainRoute の Estimated と同じ計算にしました。駅間の距離に線路の長さを使い、その距離で求め直した較正(#1712)で推定します。legs のあり・なしの両方が対象です。

MobileApp のオートモードと GPX の生成は、Estimated の見込みで走るようになります(TrainLCD/MobileApp 側の PR)。この PR で ETA も同じ値になるので、オートモード・ETA・GPX の所要時間がそろいます。

経路検索(connectedRoutes)は、元の計算のままです。探索の結果と並び順は変わりません。trainRoute の Legacy も変えていません。配布済みのアプリのオートモードが使い続けるためです。

変更の種類

  • バグ修正
  • 新機能
  • データの修正・追加
  • リファクタリング
  • ドキュメント
  • CI/CD
  • その他

変更内容

  • 到着見込みの計算(query.rs)
    • estimateArrivalTimes(legs なし)は、系統ごとに線路の長さを引き、求め直した較正で推定します。
    • estimate_legs から、較正と距離を切り替える引数を外しました。estimateArrivalTimes の legs と trainRoute の Estimated は、同じ計算を通ります。
    • estimated_model_params を arrival_estimation_params に改名しました。
  • 経路検索
    • connectedRoutes の系統網は、これまでどおり元の較正と直線距離 × 迂回係数で組み立てます。コードは変えていません。
    • そのため、経路検索の所要時間(ArrivalTime の並べ替えに使う値)と ETA は一致しなくなります。ConnectedRouteSort::ArrivalTime と JourneySort::ArrivalTime の説明を直しました。
  • 計算量
    • estimateArrivalTimes(legs なし)で、系統ごとに隣り合う駅の組の線路の長さを引くようになりました。埋め込みの表(connections.bin)を二分探索するだけなので、系統の駅数を n、表の行数を m として O(n log m) 増えます。legs ありと Estimated は、これまでも同じ処理をしていました。
  • テスト
  • ドキュメント
    • AGENTS.md、docs/architecture.md、scripts/README.md、travel_times/README.md、各テーブルの先頭のコメントを、ETA も求め直した較正を使う形に直しました。
    • 所要時間のベンチマークは引き続き Estimated を測ります。Estimated の値は変わらないので、記録(baseline.csv)は更新していません。

本番との比較

このブランチをローカルの Worker で起動し、本番に同じ問い合わせを送って比べました。問い合わせは、無作為に選んだ 60 の種別グループと、その始点・終点の駅グループの組から作りました。

問い合わせ 比べ方 一致
trainRoute の Legacy 本番と比べる 60 / 60
connectedRoutes(30 組 × 並べ方 3 通り) 本番と比べる 90 / 90
estimateArrivalTimes(MobileApp と同じ引数)と trainRoute の Estimated 見込みを比べる 60 / 60
legs を渡した estimateArrivalTimes と trainRoute の Estimated 見込みを比べる 30 / 30

環状線(山手線 363、大阪環状線の普通 686、都営大江戸線 1000099301)も、格納順と逆順の両方向で、ETA と Estimated の見込みが一致しました。Legacy は本番と一致しました。

ETA は意図して変えています。比べた 60 件では、終点の見込みがすべて変わりました。変化は平均 2.4%、最大 15.3% です。

テスト

  • make fmt が通ること
  • make clippy が通ること(wasm32 ターゲットを含む)
  • make test が通ること

cargo fmt --all -- --check、make clippy、make test を実行し、すべて成功しました(stationapi 443 件、stationapi-worker 28 件ほか、失敗なし)。generated/ がある状態で実行しています。

関連Issue

Refs #1710, #1712, #1714

スクリーンショット(任意)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 変更点
    • 「到着時刻の見積もり」と trainRoute の「Estimated」モデルで、線路距離と再較正済み速度を使った推定結果が一貫するようになりました。
    • connectedRoutes と trainRoute の「Legacy」モデルは従来の所要時間推定を維持します。
    • 到着時刻の見積もりと経路検索の所要時間は異なる場合があります。

…edRoutesは元の計算のまま残した

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TinyKitten TinyKitten self-assigned this Oct 1, 2026
@github-actions github-actions Bot added feature 要望対応や課題解決 deploy-dev rust labels Oct 1, 2026
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: 47d6a018-bbd6-4b14-b6ed-cc6519101fa0

📥 Commits

Reviewing files that changed from the base of the PR and between bac7f10 and b76a901.

📒 Files selected for processing (15)
  • AGENTS.md
  • docs/architecture.md
  • scripts/README.md
  • scripts/travel_time_report.py
  • src/graphql/enums.rs
  • src/repository.rs
  • src/travel_times.rs
  • stationapi/src/domain/arrival_estimation.rs
  • stationapi/src/domain/legacy_speed_table.rs
  • stationapi/src/domain/route_search.rs
  • stationapi/src/domain/segment_speed_table.rs
  • stationapi/src/domain/speed_table.rs
  • stationapi/src/model.rs
  • stationapi/src/use_case/interactor/query.rs
  • travel_times/README.md

Included review availability: This review used your included allowance. 2 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.


📝 Walkthrough

Walkthrough

到着時刻推定と trainRoute の Estimated は、再較正済みパラメータと線路距離を使うよう変更されました。connectedRoutes と trainRoute の Legacy は従来の較正を維持します。関連するテスト、コメント、ドキュメントも更新されました。

Changes

到着時刻推定

Layer / File(s) Summary
推定パラメータと線路距離の共通化
stationapi/src/domain/..., stationapi/src/use_case/interactor/query.rs, src/repository.rs
推定パラメータの呼び出し元による切り替えを削除し、到着時刻推定と trainRoute の Estimated で共通の再較正済みパラメータと線路距離を使うよう変更しました。テストは到着・出発時刻を推定結果と照合します。
経路検索との違いの明確化
AGENTS.md, docs/architecture.md, scripts/README.md, scripts/travel_time_report.py, src/graphql/enums.rs, src/repository.rs, src/travel_times.rs, stationapi/src/domain/..., stationapi/src/model.rs, travel_times/README.md
connectedRoutes と trainRoute の Legacy が従来の較正を使うこと、および経路検索の所要時間が到着時刻推定と異なる場合があることを説明とテストに反映しました。

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to b76a9

The change aligns arrival estimates with trainRoute’s Estimated model while preserving route-search calculations and Legacy behavior. No actionable merge-blocking issue is established by the supplied evidence; merge after normal checks pass.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed タイトルは、estimateArrivalTimes を trainRoute の Estimated と同じ計算に変更し、経路検索の計算を維持するという主な変更を正確かつ簡潔に示しています。
Description check ✅ Passed 説明はテンプレートの必須セクションを含み、変更内容、影響範囲、テスト結果、関連Issueを具体的に記載しています。
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 11 files. (4 skipped: 4…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


うさぎは線路の距離をたどる
到着の見込みに耳を立てる
再較正の表をそっと開く
古い道筋はそのまま残る
月夜の駅でぴょんと祝う

Comment @coderabbitai help to get the list of available commands.

@TinyKitten
TinyKitten merged commit 3dd6ab3 into dev Oct 1, 2026
13 checks passed
@TinyKitten
TinyKitten deleted the feature/align-estimated-train-route-with-eta branch October 1, 2026 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deploy-dev feature 要望対応や課題解決 rust

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant