Skip to content

Commit 4be0cce

Browse files
committed
core: stdcm: initialize fixed points with engineering allowances
Signed-off-by: Eloi Charpentier <[email protected]>
1 parent 7019051 commit 4be0cce

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import fr.sncf.osrd.envelope.part.EnvelopePart
77
import fr.sncf.osrd.envelope.part.EnvelopePartBuilder
88
import fr.sncf.osrd.envelope.part.constraints.EnvelopeConstraint
99
import fr.sncf.osrd.envelope.part.constraints.EnvelopePartConstraintType
10+
import fr.sncf.osrd.envelope.part.constraints.PositionConstraint
1011
import fr.sncf.osrd.envelope.part.constraints.SpeedConstraint
1112
import fr.sncf.osrd.envelope_sim.EnvelopeProfile
1213
import fr.sncf.osrd.envelope_sim.overlays.EnvelopeAcceleration
@@ -117,7 +118,7 @@ class EngineeringAllowanceManager(private val graph: STDCMGraph) {
117118
ConstrainedEnvelopePartBuilder(
118119
speedupPartBuilder,
119120
SpeedConstraint(0.0, EnvelopePartConstraintType.FLOOR),
120-
EnvelopeConstraint(maxEffort, EnvelopePartConstraintType.CEILING)
121+
PositionConstraint(maxEffort.beginPos, maxEffort.endPos),
121122
)
122123
EnvelopeAcceleration.accelerate(
123124
context,

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

+19
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,25 @@ private fun initFixedPoints(
194194
}
195195
if (hasStandardAllowance && res.none { it.offset == length })
196196
res.add(makeFixedPoint(res, edges, length, length, updatedTimeData, 0.0))
197+
198+
// Add points at the end of each engineering allowance
199+
var prevEdgeLength = 0.meters
200+
for (edge in edges) {
201+
if (edge.afterEngineeringAllowance) {
202+
if (res.none { it.offset.distance == prevEdgeLength }) {
203+
res.add(
204+
makeFixedPoint(
205+
res,
206+
edges,
207+
Offset(prevEdgeLength),
208+
length,
209+
updatedTimeData,
210+
)
211+
)
212+
}
213+
}
214+
prevEdgeLength += edge.length.distance
215+
}
197216
return res
198217
}
199218

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

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ data class STDCMEdge(
3434
// How long it takes to go from the beginning to the end of the block, taking the
3535
// standard allowance into account
3636
val totalTime: Double,
37+
// Set to true if a conflict in the current edge required an engineering allowance.
38+
// Used for initial placement of fixed time points in post-processing.
39+
val afterEngineeringAllowance: Boolean,
3740
) {
3841
val block = infraExplorer.getCurrentBlock()
3942

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ internal constructor(
158158

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

0 commit comments

Comments
 (0)