Repository navigation
到着時間推定に運転余裕率を導入し実ダイヤとの系統誤差を補正する - #1577
Conversation
運動学モデルは「最大加速→最高速度で巡航→最大減速」の理想走行を仮定するため、 実ダイヤに含まれる途中の速度制限・惰行・回復余裕のぶん、全路線で所要時間を 13〜25%過小に見積もっていた(旧実装では迂回係数が1.6に張り付くバグが偶然 これを相殺していたため、修正後に過小評価が顕在化した)。 実時刻表が既知の6区間(都営大江戸線 落合南長崎→光が丘、銀座線 浅草→渋谷、 丸ノ内線 池袋→荻窪、山手線 池袋→東京、中央・総武線各停 三鷹→新宿、 両毛線 伊勢崎→国定)で較正し、以下を調整: - 走行時間に運転余裕率 run_margin(1.15)を導入 - 中間停車時間 dwell を 0.4分 → 0.6分(出発余裕込みの実効値) - 在来線の基本最高速度を 85km/h → 80km/h 検証セットの平均絶対誤差は 16.7% → 約3% に改善。 大江戸線 落合南長崎→光が丘 は 8.9分 → 10.8分(実車11分)、 両毛線 伊勢崎→国定 は 4.5分 → 5.4分(実車5〜6分)となる。 大江戸線の実座標・実測時刻を使った回帰テストを追加。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvuzKrssremkx9vuHTu7BZ
📝 WalkthroughWalkthrough到着時刻推定モデルの Changesrun_margin導入と走行時間補正
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
stationapi/src/domain/arrival_estimation.rs (1)
478-486: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winClippy の
field_reassign_with_defaultを回避するため構造体リテラルで初期化してください。
EstimationParams::default()の直後にp.run_margin = ...で上書きする書き方は、Clippy のfield_reassign_with_default(warn-by-default)で警告されます。コーディングガイドラインに従い、新規 Clippy 警告は解消してください。♻️ 提案する修正
- let mut p = EstimationParams::default(); - p.run_margin = 1.0; - let base = segment_run_minutes(5_000.0, 80.0, &p); - p.run_margin = 1.15; - let with_margin = segment_run_minutes(5_000.0, 80.0, &p); + let base = segment_run_minutes( + 5_000.0, + 80.0, + &EstimationParams { run_margin: 1.0, ..Default::default() }, + ); + let with_margin = segment_run_minutes( + 5_000.0, + 80.0, + &EstimationParams { run_margin: 1.15, ..Default::default() }, + ); approx(with_margin, base * 1.15);As per coding guidelines: "Run
cargo clippy --all-targets --all-featuresbefore committing. Resolve new Clippy warnings unless an existing#![allow]covers the case."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@stationapi/src/domain/arrival_estimation.rs` around lines 478 - 486, The test in run_margin_scales_run_time_but_not_dwell should avoid Clippy’s field_reassign_with_default warning by not creating EstimationParams with default() and then mutating run_margin. Update the setup in this test to initialize EstimationParams with a struct literal (using default values for the other fields as needed) and use that value for the two segment_run_minutes calls, keeping the same assertions.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@stationapi/src/domain/arrival_estimation.rs`:
- Around line 478-486: The test in run_margin_scales_run_time_but_not_dwell
should avoid Clippy’s field_reassign_with_default warning by not creating
EstimationParams with default() and then mutating run_margin. Update the setup
in this test to initialize EstimationParams with a struct literal (using default
values for the other fields as needed) and use that value for the two
segment_run_minutes calls, keeping the same assertions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 00dc9157-973f-4b02-900c-1c30d7bab34d
📒 Files selected for processing (1)
stationapi/src/domain/arrival_estimation.rs
概要
EstimateArrivalTimes の運動学モデルが理想走行(最大加速→最高速度で巡航→最大減速)を仮定しているため、実ダイヤに含まれる途中の速度制限・惰行・回復余裕のぶん全路線で所要時間を13〜25%過小に見積もっていた問題を、実時刻表との較正で補正する。
#1576 以前は迂回係数が上限1.6に張り付くバグによる距離水増しが偶然この過小評価を相殺していたため、バグ修正後に過小評価が顕在化していた(例: 都営大江戸線 落合南長崎→光が丘 実車11分に対し8.9分)。
変更の種類
変更内容
run_margin(既定 1.15)を導入。segment_run_minutesとassign_segment_timesの両経路で走行時間のみに乗算し、停車時間には掛けないdwell_minutesを 0.4分 → 0.6分(出発余裕込みの実効値)に変更テスト
cargo fmt --all -- --checkが通ることcargo clippy -- -D warningsが通ることcargo test(SQLX_OFFLINE=true)が通ること関連Issue
スクリーンショット(任意)
🤖 Generated with Claude Code
https://claude.ai/code/session_01SvuzKrssremkx9vuHTu7BZ
Generated by Claude Code
Summary by CodeRabbit
新機能
バグ修正