Skip to content

Commit f4136e8

Browse files
author
Alex Rolland
committed
core, editoast, front: fix review comments
Signed-off-by: Alex Rolland <alex.rolland@reseau.sncf.fr>
1 parent a237b67 commit f4136e8

File tree

10 files changed

+74
-55
lines changed

10 files changed

+74
-55
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, false);
65-
var speedLimits = computeMRSP(trainPath, rollingStock, false, trainSchedule.tag, null, null, false);
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,5 @@ class SimulationPowerRestrictionItem(
144144

145145
class TrainScheduleOptions(
146146
@Json(name = "use_electrical_profiles") val useElectricalProfiles: Boolean,
147-
@Json(name = "ignore_infra_speed_limits") val ingoreInfraSpeedLimits: Boolean
147+
@Json(name = "use_infra_speed_limits_for_simulation") val useInfraSpeedLimits: Boolean?
148148
)

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

+34-32
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,7 +41,7 @@ fun computeMRSP(
3941
trainTag: String?,
4042
temporarySpeedLimitManager: TemporarySpeedLimitManager?,
4143
safetySpeedRanges: DistanceRangeMap<Speed>? = null,
42-
ignoreInfraSpeedLimits: Boolean = false,
44+
useInfraSpeedLimits: Boolean = true,
4345
): Envelope {
4446
return computeMRSP(
4547
path,
@@ -49,7 +51,7 @@ fun computeMRSP(
4951
trainTag,
5052
temporarySpeedLimitManager,
5153
safetySpeedRanges,
52-
ignoreInfraSpeedLimits,
54+
useInfraSpeedLimits,
5355
)
5456
}
5557

@@ -61,11 +63,11 @@ fun computeMRSP(
6163
* @param rsLength length of the rolling stock (m)
6264
* @param addRollingStockLength whether the rolling stock length should be taken into account in the
6365
* computation.
64-
* @param ignoreInfraSpeedLimits whether the speed limits coming from the infrastructure should be ignored in the
65-
* computaion
6666
* @param trainTag corresponding train.
6767
* @param safetySpeedRanges Extra speed ranges, used for safety speeds. Note: rolling stock length
6868
* 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
6971
* @return the corresponding MRSP as an Envelope.
7072
*/
7173
fun computeMRSP(
@@ -76,39 +78,39 @@ fun computeMRSP(
7678
trainTag: String?,
7779
temporarySpeedLimitManager: TemporarySpeedLimitManager?,
7880
safetySpeedRanges: DistanceRangeMap<Speed>? = null,
79-
ignoreInfraSpeedLimits: Boolean = false,
81+
useInfraSpeedLimits: Boolean = true,
8082
): Envelope {
8183
val builder = MRSPEnvelopeBuilder()
8284
val pathLength = toMeters(path.getLength())
8385

8486
val offset = if (addRollingStockLength) rsLength else 0.0
85-
val speedLimitProperties = path.getSpeedLimitProperties(trainTag, temporarySpeedLimitManager)
86-
if (!ignoreInfraSpeedLimits) { //if we take into account speedlimits coming from the infrastructure
87-
for (speedLimitPropertyRange in speedLimitProperties) {
88-
// Compute where this limit is active from and to
89-
val start = toMeters(speedLimitPropertyRange.lower)
90-
val end = min(pathLength, offset + toMeters(speedLimitPropertyRange.upper))
91-
val speedLimitProp = rangeMapEntryToSpeedLimitProperty(speedLimitPropertyRange)
92-
val speed = toMetersPerSecond(speedLimitProp.speed)
93-
val attrs =
94-
mutableListOf<SelfTypeHolder?>(
95-
EnvelopeProfile.CONSTANT_SPEED,
96-
MRSPEnvelopeBuilder.LimitKind.SPEED_LIMIT
97-
)
98-
if (speedLimitProp.source != null) {
99-
attrs.add(speedLimitProp.source)
100-
}
101-
if (attrs.any { it is UnknownTag }) attrs.add(HasMissingSpeedTag)
102-
if (speed != 0.0) {
103-
// Add the envelope part corresponding to the restricted speed section
104-
builder.addPart(
105-
EnvelopePart.generateTimes(
106-
attrs,
107-
doubleArrayOf(start, end),
108-
doubleArrayOf(speed, speed)
109-
)
87+
val speedLimitProperties =
88+
if (useInfraSpeedLimits) path.getSpeedLimitProperties(trainTag, temporarySpeedLimitManager)
89+
else distanceRangeMapOf<SpeedLimitProperty>()
90+
for (speedLimitPropertyRange in speedLimitProperties) {
91+
// Compute where this limit is active from and to
92+
val start = toMeters(speedLimitPropertyRange.lower)
93+
val end = min(pathLength, offset + toMeters(speedLimitPropertyRange.upper))
94+
val speedLimitProp = rangeMapEntryToSpeedLimitProperty(speedLimitPropertyRange)
95+
val speed = toMetersPerSecond(speedLimitProp.speed)
96+
val attrs =
97+
mutableListOf<SelfTypeHolder?>(
98+
EnvelopeProfile.CONSTANT_SPEED,
99+
MRSPEnvelopeBuilder.LimitKind.SPEED_LIMIT
100+
)
101+
if (speedLimitProp.source != null) {
102+
attrs.add(speedLimitProp.source)
103+
}
104+
if (attrs.any { it is UnknownTag }) attrs.add(HasMissingSpeedTag)
105+
if (speed != 0.0) {
106+
// Add the envelope part corresponding to the restricted speed section
107+
builder.addPart(
108+
EnvelopePart.generateTimes(
109+
attrs,
110+
doubleArrayOf(start, end),
111+
doubleArrayOf(speed, speed)
110112
)
111-
}
113+
)
112114
}
113115
}
114116

@@ -124,7 +126,7 @@ fun computeMRSP(
124126
)
125127

126128
// Add safety speeds
127-
if (!ignoreInfraSpeedLimits && safetySpeedRanges != null) {
129+
if (useInfraSpeedLimits && safetySpeedRanges != null) {
128130
for (range in safetySpeedRanges) {
129131
val speed = range.value
130132
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-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@ pub struct TrainScheduleOptions {
1414
#[derivative(Default(value = "true"))]
1515
#[serde(default = "default_use_electrical_profiles")]
1616
use_electrical_profiles: bool,
17-
#[serde(default)]
18-
ignore_infra_speed_limits: bool,
17+
#[derivative(Default(value = "true"))]
18+
#[serde(default = "default_use_speed_limits_for_simulation")]
19+
use_speed_limits_for_simulation: bool,
1920
}
2021

2122
fn default_use_electrical_profiles() -> bool {
2223
true
2324
}
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
@@ -11884,8 +11884,6 @@ components:
1188411884
options:
1188511885
type: object
1188611886
properties:
11887-
ignore_infra_speed_limits:
11888-
type: boolean
1188911887
use_electrical_profiles:
1189011888
type: boolean
1189111889
additionalProperties: false
@@ -11981,8 +11979,6 @@ components:
1198111979
TrainScheduleOptions:
1198211980
type: object
1198311981
properties:
11984-
ignore_infra_speed_limits:
11985-
type: boolean
1198611982
use_electrical_profiles:
1198711983
type: boolean
1198811984
additionalProperties: false

front/src/common/api/generatedEditoastApi.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ export type PostInfraRefreshApiResponse = /** status 200 */ {
11511151
export type PostInfraRefreshApiArg = {
11521152
force?: boolean;
11531153
/** A comma-separated list of infra IDs to refresh
1154-
1154+
11551155
If not provided, all available infras will be refreshed. */
11561156
infras?: number[];
11571157
};
@@ -1743,12 +1743,12 @@ export type PostTimetableByIdStdcmApiArg = {
17431743
steps: PathfindingItem[];
17441744
temporary_speed_limit_group_id?: number | null;
17451745
/** Margin after the train passage in milliseconds
1746-
1746+
17471747
Enforces that the path used by the train should be free and
17481748
available at least that many milliseconds after its passage. */
17491749
time_gap_after?: number;
17501750
/** Margin before the train passage in seconds
1751-
1751+
17521752
Enforces that the path used by the train should be free and
17531753
available at least that many milliseconds before its passage. */
17541754
time_gap_before?: number;
@@ -3254,7 +3254,7 @@ export type Margins = {
32543254
values: string[];
32553255
};
32563256
export type TrainScheduleOptions = {
3257-
ignore_infra_speed_limits?: boolean;
3257+
use_infra_speed_limits_for_simulation?: boolean;
32583258
use_electrical_profiles?: boolean;
32593259
};
32603260
export type PathItem = PathItemLocation & {
@@ -3312,7 +3312,7 @@ export type SearchResultItem =
33123312
export type SearchQuery = boolean | number | number | string | (SearchQuery | null)[];
33133313
export type SearchPayload = {
33143314
/** Whether to return the SQL query instead of executing it
3315-
3315+
33163316
Only available in debug builds. */
33173317
dry?: boolean;
33183318
/** The object kind to query - run `editoast search list` to get all possible values */
@@ -3613,7 +3613,7 @@ export type TrainScheduleBase = {
36133613
values: string[];
36143614
};
36153615
options?: {
3616-
ignore_infra_speed_limits?: boolean;
3616+
use_infra_speed_limits_for_simulation?: boolean;
36173617
use_electrical_profiles?: boolean;
36183618
};
36193619
path: (PathItemLocation & {

python/osrd_schemas/osrd_schemas/train_schedule.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -171,17 +171,18 @@ class PowerRestrictionRanges(RootModel):
171171

172172
class TrainScheduleOptions(BaseModel):
173173
"""Optional arguments :
174-
- `ignore_electrical_profiles` : ignore the electrical profiles for the standalone simulation
175-
- `ignore_infra_speed_limits` : ignore the speed limits coming from the infrastructure for the standalone simulation
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
176177
"""
177178

178-
ignore_electrical_profiles: bool = Field(
179+
use_electrical_profiles: bool = Field(
179180
default=False,
180-
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",
181182
)
182-
ignore_infra_speed_limits: bool = Field(
183-
default=False,
184-
description="If true, the speed limits of the infrastructure are ignored in the standalone simulation",
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",
185186
)
186187

187188

0 commit comments

Comments
 (0)