Skip to content

Commit f537125

Browse files
committed
core: stdcm: account for previous margins when checking for new ones
Signed-off-by: Eloi Charpentier <eloi.charpentier.42@gmail.com>
1 parent c2228f0 commit f537125

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

core/src/main/kotlin/fr/sncf/osrd/stdcm/graph/EngineeringAllowanceManager.kt

+1
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ class EngineeringAllowanceManager(private val graph: STDCMGraph) {
216216
return ArrayList(res)
217217
}
218218
mutDelayNeeded += mutEdge.timeData.delayAddedToLastDeparture
219+
mutDelayNeeded += mutEdge.engineeringAllowance?.extraDuration ?: 0.0
219220
mutEdge = mutEdge.previousNode.previousEdge!!
220221
}
221222
}

core/src/main/kotlin/fr/sncf/osrd/stdcm/graph/PostProcessingSimulation.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ private fun initFixedPoints(
211211
}
212212
var prevEdgeLength = 0.meters
213213
for (edge in edges) {
214-
val engineeringAllowanceLength = edge.engineeringAllowanceLength
214+
val engineeringAllowanceLength = edge.engineeringAllowance?.length
215215
if (engineeringAllowanceLength != null) {
216216
val engineeringAllowanceStart = prevEdgeLength - engineeringAllowanceLength
217217
// Edges can have overlapping engineering allowance, only the last one is relevant.

core/src/main/kotlin/fr/sncf/osrd/stdcm/graph/STDCMEdge.kt

+11-3
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,24 @@ data class STDCMEdge(
3535
// How long it takes to go from the beginning to the end of the block, taking the
3636
// standard allowance into account
3737
val totalTime: Double,
38-
// If this edges starts after the end of an engineering allowance, this contains its length, or
39-
// null otherwise. Used for initial placement of fixed time points in postprocessing.
40-
val engineeringAllowanceLength: Distance?,
38+
// If this edges starts after the end of an engineering allowance, this contains
39+
// some data like its length and extra time. Null if there's no engineering allowance
40+
// ending here. Overrides any allowance spanning part of the range from previous edges.
41+
val engineeringAllowance: EngineeringAllowanceData?,
4142
) {
4243
val block = infraExplorer.getCurrentBlock()
4344

4445
init {
4546
assert(!isNaN(timeData.earliestReachableTime)) { "STDCM edge starts at NaN time" }
4647
}
4748

49+
data class EngineeringAllowanceData(
50+
/** How long is the allowance section. It always ends at the start of the current edge. */
51+
val length: Distance,
52+
/** How much extra time was added on this current allowance range. */
53+
val extraDuration: Double,
54+
)
55+
4856
/** Returns the node at the end of this edge */
4957
fun getEdgeEnd(graph: STDCMGraph): STDCMNode {
5058
var newWaypointIndex = waypointIndex

core/src/main/kotlin/fr/sncf/osrd/stdcm/graph/STDCMEdgeBuilder.kt

+5-3
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,15 @@ internal constructor(
161161
var departureTimeShift = delayNeeded
162162
val needEngineeringAllowance =
163163
delayNeeded > prevNode.timeData.maxDepartureDelayingWithoutConflict
164-
var allowanceLength: Distance? = null
164+
var allowanceData: STDCMEdge.EngineeringAllowanceData? = null
165165
if (needEngineeringAllowance) {
166166
// We can't just shift the departure time, we need an engineering allowance
167167
// It's not computed yet, we just check that it's possible
168-
allowanceLength =
168+
val allowanceLength =
169169
graph.allowanceManager.checkEngineeringAllowance(prevNode, actualStartTime)
170170
?: return null
171+
val extraTime = delayNeeded - prevNode.timeData.maxDepartureDelayingWithoutConflict
172+
allowanceData = STDCMEdge.EngineeringAllowanceData(allowanceLength, extraTime)
171173
// We still need to adapt the delay values
172174
departureTimeShift = prevNode.timeData.maxDepartureDelayingWithoutConflict
173175
} else {
@@ -217,7 +219,7 @@ internal constructor(
217219
envelope!!.endSpeed,
218220
Length(fromMeters(envelope!!.endPos)),
219221
envelope!!.totalTime / standardAllowanceSpeedRatio,
220-
allowanceLength,
222+
allowanceData,
221223
)
222224
res = graph.backtrackingManager.backtrack(res!!, envelope!!)
223225
return if (res == null || graph.delayManager.isRunTimeTooLong(res)) null else res

0 commit comments

Comments
 (0)