Skip to content

Commit

Permalink
core: stdcm: initialize fixed points with engineering allowances
Browse files Browse the repository at this point in the history
Signed-off-by: Eloi Charpentier <[email protected]>
  • Loading branch information
eckter committed Jan 16, 2025
1 parent 5e1ed69 commit 7613b19
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import fr.sncf.osrd.envelope.part.EnvelopePart
import fr.sncf.osrd.envelope.part.EnvelopePartBuilder
import fr.sncf.osrd.envelope.part.constraints.EnvelopeConstraint
import fr.sncf.osrd.envelope.part.constraints.EnvelopePartConstraintType
import fr.sncf.osrd.envelope.part.constraints.PositionConstraint
import fr.sncf.osrd.envelope.part.constraints.SpeedConstraint
import fr.sncf.osrd.envelope_sim.EnvelopeProfile
import fr.sncf.osrd.envelope_sim.overlays.EnvelopeAcceleration
Expand Down Expand Up @@ -117,7 +118,7 @@ class EngineeringAllowanceManager(private val graph: STDCMGraph) {
ConstrainedEnvelopePartBuilder(
speedupPartBuilder,
SpeedConstraint(0.0, EnvelopePartConstraintType.FLOOR),
EnvelopeConstraint(maxEffort, EnvelopePartConstraintType.CEILING)
PositionConstraint(maxEffort.beginPos, maxEffort.endPos),
)
EnvelopeAcceleration.accelerate(
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,25 @@ private fun initFixedPoints(
}
if (hasStandardAllowance && res.none { it.offset == length })
res.add(makeFixedPoint(res, edges, length, length, updatedTimeData, 0.0))

// Add points at the end of each engineering allowance
var prevEdgeLength = 0.meters
for (edge in edges) {
if (edge.afterEngineeringAllowance) {
if (res.none { it.offset.distance == prevEdgeLength }) {
res.add(
makeFixedPoint(
res,
edges,
Offset(prevEdgeLength),
length,
updatedTimeData,
)
)
}
}
prevEdgeLength += edge.length.distance
}
return res
}

Expand Down
3 changes: 3 additions & 0 deletions core/src/main/kotlin/fr/sncf/osrd/stdcm/graph/STDCMEdge.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ data class STDCMEdge(
// How long it takes to go from the beginning to the end of the block, taking the
// standard allowance into account
val totalTime: Double,
// Set to true if a conflict in the current edge required an engineering allowance.
// Used for initial placement of fixed time points in post-processing.
val afterEngineeringAllowance: Boolean,
) {
val block = infraExplorer.getCurrentBlock()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ internal constructor(

var maximumDelay = 0.0
var departureTimeShift = delayNeeded
if (delayNeeded > prevNode.timeData.maxDepartureDelayingWithoutConflict) {
val needEngineeringAllowance =
delayNeeded > prevNode.timeData.maxDepartureDelayingWithoutConflict
if (needEngineeringAllowance) {
// We can't just shift the departure time, we need an engineering allowance
// It's not computed yet, we just check that it's possible
if (!graph.allowanceManager.checkEngineeringAllowance(prevNode, actualStartTime))
Expand Down Expand Up @@ -212,6 +214,7 @@ internal constructor(
envelope!!.endSpeed,
Length(fromMeters(envelope!!.endPos)),
envelope!!.totalTime / standardAllowanceSpeedRatio,
needEngineeringAllowance,
)
res = graph.backtrackingManager.backtrack(res!!, envelope!!)
return if (res == null || graph.delayManager.isRunTimeTooLong(res)) null else res
Expand Down

0 comments on commit 7613b19

Please sign in to comment.