Skip to content

Commit

Permalink
core: stdcm: set a min speed for engineering allowance check
Browse files Browse the repository at this point in the history
We used to consider that we can add any amount of time
if the train can basically stop, but this was too optimistic

Signed-off-by: Eloi Charpentier <eloi.charpentier.42@gmail.com>
  • Loading branch information
eckter committed Jan 8, 2025
1 parent cae4d30 commit 79b87f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,21 @@ class EngineeringAllowanceManager(private val graph: STDCMGraph) {
// /
// We need to set the first constant speed part to 0
// so that we can use it as floor constraint

// The min speed value isn't entirely trivial to determine:
// We need it to be strictly positive to avoid NaN issues,
// but we're also too optimistic with allowance possibility
// when we let it get close to 0. But if it's too high, we miss
// out on solutions.
// So this is a magic value that could be tweaked if needed.
val minSpeed = 1.0
builder.addPart(
EnvelopePart.generateTimes(
mutableListOf<SelfTypeHolder?>(
EnvelopeProfile.CONSTANT_SPEED,
),
doubleArrayOf(0.0, lastAccelerationPosition),
doubleArrayOf(1e-5, 1e-5) // >0 to avoid NaN time delta
doubleArrayOf(minSpeed, minSpeed)
)
)
}
Expand All @@ -168,7 +176,6 @@ class EngineeringAllowanceManager(private val graph: STDCMGraph) {
if (slowdownPartBuilder.stepCount() > 1)
slowdownBuilder.addPart(slowdownPartBuilder.build())
val slowestEnvelope = slowdownBuilder.build()
if (slowestEnvelope.minSpeed <= 1.0) return Double.POSITIVE_INFINITY
return slowestEnvelope.totalTime
} catch (e: OSRDError) {
// We can be pessimistic: simulation error = no allowance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,14 @@ private fun handlePostProcessingConflict(
updatedTimeData: TimeData,
fixedPoints: TreeSet<FixedTimePoint>,
conflictOffset: Offset<TravelledPath>,
isMareco: Boolean
isMareco: Boolean,
): Envelope {
postProcessingLogger.error(
"Conflicts detected in post-processing, mismatch with the exploration data"
)
postProcessingLogger.error(
"NOTE: look through the logs for allowance issues, they may cause mismatches."
)
val conflictTime = fixedPoints.first { it.offset == conflictOffset }.time
postProcessingLogger.info(
" conflict happened at offset=$conflictOffset/${maxSpeedEnvelope.endPos.toInt()} " +
Expand Down

0 comments on commit 79b87f4

Please sign in to comment.