Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: stdcm: set a min speed for engineering allowance check #10289

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,24 @@ 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.
//
// Eventually, when we'll have actual capacity stops, we should
// use the actual minimum speed on the network.
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 +179,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
Loading