Skip to content

Commit

Permalink
core: sim: add speed limit anticipation back
Browse files Browse the repository at this point in the history
It was used in v1 but not v2. Includes margins before max speed
drops and after it goes up.

Signed-off-by: Eloi Charpentier <[email protected]>
  • Loading branch information
eckter committed Jan 6, 2025
1 parent 4d2a487 commit fc93efe
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableRangeMap
import com.google.common.collect.Range
import com.google.common.collect.RangeMap
import com.google.common.collect.TreeRangeMap
import fr.sncf.osrd.DriverBehaviour
import fr.sncf.osrd.api.FullInfra
import fr.sncf.osrd.api.api_v2.RangeValues
import fr.sncf.osrd.api.api_v2.standalone_sim.ElectricalProfileValue
Expand Down Expand Up @@ -60,11 +61,13 @@ fun runStandaloneSimulation(
schedule: List<SimulationScheduleItem>,
initialSpeed: Double,
margins: RangeValues<MarginValue>,
pathItemPositions: List<Offset<Path>>
pathItemPositions: List<Offset<Path>>,
driverBehaviour: DriverBehaviour = DriverBehaviour()
): SimulationSuccess {
// MRSP & SpeedLimits
val safetySpeedRanges = makeSafetySpeedRanges(infra, chunkPath, routes, schedule)
val mrsp = computeMRSP(pathProps, rollingStock, true, speedLimitTag, null, safetySpeedRanges)
var mrsp = computeMRSP(pathProps, rollingStock, true, speedLimitTag, null, safetySpeedRanges)
mrsp = driverBehaviour.applyToMRSP(mrsp)
// We don't use speed safety ranges in the MRSP displayed in the front
// (just like we don't add the train length)
val speedLimits =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fr.sncf.osrd.standalone_sim

import com.google.common.collect.ImmutableRangeMap
import fr.sncf.osrd.DriverBehaviour
import fr.sncf.osrd.api.api_v2.RangeValues
import fr.sncf.osrd.api.api_v2.standalone_sim.MarginValue
import fr.sncf.osrd.api.api_v2.standalone_sim.ReportTrain
Expand Down Expand Up @@ -229,6 +230,7 @@ class StandaloneSimulationTest {
testCase.startSpeed,
testCase.margins,
listOf(),
DriverBehaviour(0.0, 0.0),
)

// Test scheduled points
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"signalReceptionClosed": false,
"margin": {
"theoretical": "5 %",
"theoreticalS": "85 s",
"actual": "85 s",
"theoreticalS": "86 s",
"actual": "86 s",
"difference": "0 s"
},
"calculatedArrival": "11:22:40",
Expand All @@ -30,7 +30,7 @@
"actual": "",
"difference": ""
},
"calculatedArrival": "11:44:13",
"calculatedArrival": "11:44:19",
"calculatedDeparture": ""
},
{
Expand All @@ -47,8 +47,8 @@
"actual": "32 s",
"difference": "0 s"
},
"calculatedArrival": "11:52:55",
"calculatedDeparture": "11:54:59"
"calculatedArrival": "11:53:04",
"calculatedDeparture": "11:55:08"
},
{
"stationName": "South_East_station",
Expand All @@ -64,7 +64,7 @@
"actual": "",
"difference": ""
},
"calculatedArrival": "12:06:18",
"calculatedDeparture": "12:06:18"
"calculatedArrival": "12:06:27",
"calculatedDeparture": "12:06:27"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
"actual": "0 s",
"difference": "0 s"
},
"calculatedArrival": "11:39:55",
"calculatedDeparture": "11:41:59"
"calculatedArrival": "11:39:56",
"calculatedDeparture": "11:42:00"
},
{
"stationName": "South_East_station",
Expand All @@ -64,7 +64,7 @@
"actual": "",
"difference": ""
},
"calculatedArrival": "11:52:11",
"calculatedDeparture": "11:52:11"
"calculatedArrival": "11:52:12",
"calculatedDeparture": "11:52:12"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"actual": "",
"difference": ""
},
"calculatedArrival": "11:42:48",
"calculatedArrival": "11:42:55",
"calculatedDeparture": ""
},
{
Expand All @@ -47,8 +47,8 @@
"actual": "0 s",
"difference": "0 s"
},
"calculatedArrival": "11:50:48",
"calculatedDeparture": "11:52:52"
"calculatedArrival": "11:50:58",
"calculatedDeparture": "11:53:02"
},
{
"stationName": "South_East_station",
Expand All @@ -64,7 +64,7 @@
"actual": "",
"difference": ""
},
"calculatedArrival": "12:03:04",
"calculatedDeparture": "12:03:04"
"calculatedArrival": "12:03:14",
"calculatedDeparture": "12:03:14"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
"actual": "0 s",
"difference": "0 s"
},
"calculatedArrival": "11:39:55",
"calculatedDeparture": "11:41:59"
"calculatedArrival": "11:39:56",
"calculatedDeparture": "11:42:00"
},
{
"stationName": "South_East_station",
Expand All @@ -64,7 +64,7 @@
"actual": "",
"difference": ""
},
"calculatedArrival": "11:52:11",
"calculatedDeparture": "11:52:11"
"calculatedArrival": "11:52:12",
"calculatedDeparture": "11:52:12"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
"actual": "0 s",
"difference": "0 s"
},
"calculatedArrival": "11:40:27",
"calculatedDeparture": "11:42:31"
"calculatedArrival": "11:40:28",
"calculatedDeparture": "11:42:32"
},
{
"stationName": "South_East_station",
Expand All @@ -64,7 +64,7 @@
"actual": "",
"difference": ""
},
"calculatedArrival": "11:53:19",
"calculatedDeparture": "11:53:19"
"calculatedArrival": "11:53:20",
"calculatedDeparture": "11:53:20"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
"actual": "62 s",
"difference": "0 s"
},
"calculatedArrival": "11:41:40",
"calculatedDeparture": "11:43:44"
"calculatedArrival": "11:41:41",
"calculatedDeparture": "11:43:45"
},
{
"stationName": "South_East_station",
Expand All @@ -64,7 +64,7 @@
"actual": "",
"difference": ""
},
"calculatedArrival": "11:54:58",
"calculatedDeparture": "11:54:58"
"calculatedArrival": "11:54:59",
"calculatedDeparture": "11:54:59"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"signalReceptionClosed": false,
"margin": {
"theoretical": "10 %",
"theoreticalS": "104 s",
"theoreticalS": "103 s",
"actual": "105 s",
"difference": "1 s"
"difference": "2 s"
},
"calculatedArrival": "11:22:40",
"calculatedDeparture": ""
Expand Down Expand Up @@ -47,8 +47,8 @@
"actual": "62 s",
"difference": "0 s"
},
"calculatedArrival": "11:41:40",
"calculatedDeparture": "11:43:44"
"calculatedArrival": "11:41:41",
"calculatedDeparture": "11:43:45"
},
{
"stationName": "South_East_station",
Expand All @@ -64,7 +64,7 @@
"actual": "",
"difference": ""
},
"calculatedArrival": "11:54:58",
"calculatedDeparture": "11:54:58"
"calculatedArrival": "11:54:59",
"calculatedDeparture": "11:54:59"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"margin": {
"theoretical": "5 %",
"theoreticalS": "29 s",
"actual": "922 s",
"difference": "893 s"
"actual": "920 s",
"difference": "891 s"
},
"calculatedArrival": "11:22:40",
"calculatedDeparture": ""
Expand All @@ -28,11 +28,11 @@
"margin": {
"theoretical": "1 min/100km",
"theoreticalS": "9 s",
"actual": "291 s",
"difference": "282 s"
"actual": "253 s",
"difference": "244 s"
},
"calculatedArrival": "11:47:40",
"calculatedDeparture": "11:52:40"
"calculatedDeparture": "11:52:39"
},
{
"stationName": "Mid_East_station",
Expand Down

0 comments on commit fc93efe

Please sign in to comment.