Skip to content

Commit 5b4dc6f

Browse files
Alex Rollandaxrolld
Alex Rolland
authored andcommitted
core, editoast, front: add flag to ignore speed limits
Signed-off-by: Alex Rolland <alex.rolland@reseau.sncf.fr> Signed-off-by: Jean SIMARD <woshilapin@tuziwo.info>
1 parent 3bcea7c commit 5b4dc6f

File tree

10 files changed

+55
-9
lines changed

10 files changed

+55
-9
lines changed

core/src/main/java/fr/sncf/osrd/standalone_sim/StandaloneSim.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public static StandaloneSimResult run(
6161
var rollingStock = trainSchedule.rollingStock;
6262

6363
// MRSP & SpeedLimits
64-
var mrsp = computeMRSP(trainPath, rollingStock, true, trainSchedule.tag, null, null);
65-
var speedLimits = computeMRSP(trainPath, rollingStock, false, trainSchedule.tag, null, null);
64+
var mrsp = computeMRSP(trainPath, rollingStock, true, trainSchedule.tag, null, null, true);
65+
var speedLimits = computeMRSP(trainPath, rollingStock, false, trainSchedule.tag, null, null, true);
6666
mrsp = driverBehaviour.applyToMRSP(mrsp);
6767
cacheSpeedLimits.put(trainSchedule, ResultEnvelopePoint.from(speedLimits));
6868

core/src/main/kotlin/fr/sncf/osrd/api/api_v2/standalone_sim/SimulationEndpoint.kt

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class SimulationEndpoint(
9090
request.speedLimitTag,
9191
parsePowerRestrictions(request.powerRestrictions),
9292
request.options.useElectricalProfiles,
93+
request.options.useInfraSpeedLimits ?: true,
9394
2.0,
9495
parseRawSimulationScheduleItems(request.schedule),
9596
request.initialSpeed,

core/src/main/kotlin/fr/sncf/osrd/api/api_v2/standalone_sim/SimulationRequest.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -143,5 +143,6 @@ class SimulationPowerRestrictionItem(
143143
)
144144

145145
class TrainScheduleOptions(
146-
@Json(name = "use_electrical_profiles") val useElectricalProfiles: Boolean
146+
@Json(name = "use_electrical_profiles") val useElectricalProfiles: Boolean,
147+
@Json(name = "use_infra_speed_limits_for_simulation") val useInfraSpeedLimits: Boolean?
147148
)

core/src/main/kotlin/fr/sncf/osrd/envelope_sim_infra/MRSP.kt

+11-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import kotlin.math.min
3030
* @param addRollingStockLength whether the rolling stock length should be taken into account in the
3131
* computation.
3232
* @param trainTag corresponding train.
33+
* @param useInfraSpeedLimits whether the speed limits coming from the infrastructure should be
34+
* taken into account in the computation
3335
* @return the corresponding MRSP as an Envelope.
3436
*/
3537
fun computeMRSP(
@@ -39,6 +41,7 @@ fun computeMRSP(
3941
trainTag: String?,
4042
temporarySpeedLimitManager: TemporarySpeedLimitManager?,
4143
safetySpeedRanges: DistanceRangeMap<Speed>? = null,
44+
useInfraSpeedLimits: Boolean = true,
4245
): Envelope {
4346
return computeMRSP(
4447
path,
@@ -48,6 +51,7 @@ fun computeMRSP(
4851
trainTag,
4952
temporarySpeedLimitManager,
5053
safetySpeedRanges,
54+
useInfraSpeedLimits,
5155
)
5256
}
5357

@@ -62,6 +66,8 @@ fun computeMRSP(
6266
* @param trainTag corresponding train.
6367
* @param safetySpeedRanges Extra speed ranges, used for safety speeds. Note: rolling stock length
6468
* is *not* added at the end of these ranges.
69+
* @param useInfraSpeedLimits whether the speed limits coming from the infrastructure should be
70+
* taken into account in the computation
6571
* @return the corresponding MRSP as an Envelope.
6672
*/
6773
fun computeMRSP(
@@ -72,12 +78,15 @@ fun computeMRSP(
7278
trainTag: String?,
7379
temporarySpeedLimitManager: TemporarySpeedLimitManager?,
7480
safetySpeedRanges: DistanceRangeMap<Speed>? = null,
81+
useInfraSpeedLimits: Boolean = true,
7582
): Envelope {
7683
val builder = MRSPEnvelopeBuilder()
7784
val pathLength = toMeters(path.getLength())
7885

7986
val offset = if (addRollingStockLength) rsLength else 0.0
80-
val speedLimitProperties = path.getSpeedLimitProperties(trainTag, temporarySpeedLimitManager)
87+
val speedLimitProperties =
88+
if (useInfraSpeedLimits) path.getSpeedLimitProperties(trainTag, temporarySpeedLimitManager)
89+
else distanceRangeMapOf<SpeedLimitProperty>()
8190
for (speedLimitPropertyRange in speedLimitProperties) {
8291
// Compute where this limit is active from and to
8392
val start = toMeters(speedLimitPropertyRange.lower)
@@ -117,7 +126,7 @@ fun computeMRSP(
117126
)
118127

119128
// Add safety speeds
120-
if (safetySpeedRanges != null) {
129+
if (useInfraSpeedLimits && safetySpeedRanges != null) {
121130
for (range in safetySpeedRanges) {
122131
val speed = range.value
123132
val newAttrs =

core/src/main/kotlin/fr/sncf/osrd/standalone_sim/StandaloneSimulation.kt

+13-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ fun runStandaloneSimulation(
5959
speedLimitTag: String?,
6060
powerRestrictions: DistanceRangeMap<String>,
6161
useElectricalProfiles: Boolean,
62+
useInfraSpeedLimits: Boolean,
6263
timeStep: Double,
6364
schedule: List<SimulationScheduleItem>,
6465
initialSpeed: Double,
@@ -68,7 +69,16 @@ fun runStandaloneSimulation(
6869
): SimulationSuccess {
6970
// MRSP & SpeedLimits
7071
val safetySpeedRanges = makeSafetySpeedRanges(infra, chunkPath, routes, schedule)
71-
var mrsp = computeMRSP(pathProps, rollingStock, true, speedLimitTag, null, safetySpeedRanges)
72+
var mrsp =
73+
computeMRSP(
74+
pathProps,
75+
rollingStock,
76+
true,
77+
speedLimitTag,
78+
null,
79+
safetySpeedRanges,
80+
useInfraSpeedLimits
81+
)
7282
mrsp = driverBehaviour.applyToMRSP(mrsp)
7383
// We don't use speed safety ranges in the MRSP displayed in the front
7484
// (just like we don't add the train length)
@@ -79,6 +89,8 @@ fun runStandaloneSimulation(
7989
false,
8090
speedLimitTag,
8191
null,
92+
null,
93+
useInfraSpeedLimits,
8294
)
8395

8496
// Build paths and contexts

core/src/test/kotlin/fr/sncf/osrd/standalone_sim/StandaloneSimulationTest.kt

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class StandaloneSimulationTest {
9191
null,
9292
distanceRangeMapOf(),
9393
false,
94+
true,
9495
2.0,
9596
listOf(),
9697
0.0,
@@ -236,6 +237,7 @@ class StandaloneSimulationTest {
236237
null,
237238
testCase.powerRestrictions,
238239
false,
240+
true,
239241
2.0,
240242
testCase.schedule,
241243
testCase.startSpeed,

editoast/editoast_schemas/src/train_schedule/train_schedule_options.rs

+7
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@ pub struct TrainScheduleOptions {
1414
#[derivative(Default(value = "true"))]
1515
#[serde(default = "default_use_electrical_profiles")]
1616
use_electrical_profiles: bool,
17+
#[derivative(Default(value = "true"))]
18+
#[serde(default = "default_use_speed_limits_for_simulation")]
19+
use_speed_limits_for_simulation: bool,
1720
}
1821

1922
fn default_use_electrical_profiles() -> bool {
2023
true
2124
}
25+
26+
fn default_use_speed_limits_for_simulation() -> bool {
27+
true
28+
}

editoast/openapi.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -11886,6 +11886,8 @@ components:
1188611886
properties:
1188711887
use_electrical_profiles:
1188811888
type: boolean
11889+
use_speed_limits_for_simulation:
11890+
type: boolean
1188911891
additionalProperties: false
1189011892
path:
1189111893
type: array
@@ -11981,6 +11983,8 @@ components:
1198111983
properties:
1198211984
use_electrical_profiles:
1198311985
type: boolean
11986+
use_speed_limits_for_simulation:
11987+
type: boolean
1198411988
additionalProperties: false
1198511989
TrainScheduleResult:
1198611990
allOf:

front/src/common/api/generatedEditoastApi.ts

+2
Original file line numberDiff line numberDiff line change
@@ -3302,6 +3302,7 @@ export type Margins = {
33023302
};
33033303
export type TrainScheduleOptions = {
33043304
use_electrical_profiles?: boolean;
3305+
use_speed_limits_for_simulation?: boolean;
33053306
};
33063307
export type PathItem = PathItemLocation & {
33073308
/** Metadata given to mark a point as wishing to be deleted by the user.
@@ -3660,6 +3661,7 @@ export type TrainScheduleBase = {
36603661
};
36613662
options?: {
36623663
use_electrical_profiles?: boolean;
3664+
use_speed_limits_for_simulation?: boolean;
36633665
};
36643666
path: (PathItemLocation & {
36653667
/** Metadata given to mark a point as wishing to be deleted by the user.

python/osrd_schemas/osrd_schemas/train_schedule.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,19 @@ class PowerRestrictionRanges(RootModel):
170170

171171

172172
class TrainScheduleOptions(BaseModel):
173-
"""Optional arguments for the standalone simulation."""
173+
"""Optional arguments :
174+
- `use_electrical_profiles` : use the electrical profiles for the standalone simulation
175+
- `use_infra_speed_limits_for_simulation` : use the speed limits coming from the infrastructure for
176+
the standalone simulation
177+
"""
174178

175-
ignore_electrical_profiles: bool = Field(
179+
use_electrical_profiles: bool = Field(
176180
default=False,
177-
description="If true, the electrical profiles are ignored in the standalone simulation",
181+
description="If true, the electrical profiles are used in the standalone simulation",
182+
)
183+
use_infra_speed_limits_for_simulation: bool = Field(
184+
default=True,
185+
description="If false, the speed limits of the infrastructure are ignored in the standalone simulation",
178186
)
179187

180188

0 commit comments

Comments
 (0)