Skip to content

Commit 81486cc

Browse files
committed
core: stdcm: add speed limit composition parameter
1 parent f44e7ab commit 81486cc

File tree

12 files changed

+135
-67
lines changed

12 files changed

+135
-67
lines changed

api/openapi.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,9 @@ components:
997997
description: |
998998
How much longer the total run time can be compared to the shortest path on an empty timetable.
999999
Defaults to 2 if unspecified, meaning that the result can't take more than twice the minimum time.
1000+
speed_limit_composition:
1001+
type: string
1002+
description: Train category for speed limits
10001003
Path:
10011004
properties:
10021005
id:

api/osrd_infra/views/stdcm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def make_stdcm_core_payload(request):
8888
optional_forwarded_parameters = [
8989
"maximum_departure_delay",
9090
"maximum_relative_run_time",
91+
"speed_limit_composition"
9192
]
9293
for parameter in optional_forwarded_parameters:
9394
if parameter in request:

core/openapi.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,9 @@ components:
554554
description: |
555555
How much longer the total run time can be compared to the shortest path on an empty timetable.
556556
Defaults to 2 if unspecified, meaning that the result can't take more than twice the minimum time.
557+
speed_limit_composition:
558+
type: string
559+
description: Train composition used for speed limit
557560
SimulationRequest:
558561
required:
559562
- infra

core/src/main/java/fr/sncf/osrd/api/stdcm/STDCMEndpoint.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ public Response act(Request req) throws
7979
var occupancies = request.routeOccupancies;
8080
var startLocations = findRoutes(infra, request.startPoints);
8181
var endLocations = findRoutes(infra, request.endPoints);
82+
Set<String> tags = Set.of();
83+
if (request.speedLimitComposition != null)
84+
tags = Set.of(request.speedLimitComposition);
8285

8386
assert Double.isFinite(startTime);
8487

@@ -100,7 +103,8 @@ public Response act(Request req) throws
100103
unavailableSpace,
101104
request.timeStep,
102105
request.maximumDepartureDelay,
103-
request.maximumRelativeRunTime * minRunTime
106+
request.maximumRelativeRunTime * minRunTime,
107+
tags
104108
);
105109
if (res == null) {
106110
var error = new NoPathFoundError("No path could be found");
@@ -110,7 +114,7 @@ public Response act(Request req) throws
110114
// Build the response
111115
var simResult = new StandaloneSimResult();
112116
simResult.speedLimits.add(ResultEnvelopePoint.from(
113-
MRSP.from(res.trainPath(), rollingStock, false, Set.of())
117+
MRSP.from(res.trainPath(), rollingStock, false, tags)
114118
));
115119
simResult.baseSimulations.add(ScheduleMetadataExtractor.run(
116120
res.envelope(),

core/src/main/java/fr/sncf/osrd/api/stdcm/STDCMRequest.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ public final class STDCMRequest {
9191
@Json(name = "maximum_relative_run_time")
9292
public double maximumRelativeRunTime = 2;
9393

94+
/**
95+
* Train category for speed limits
96+
*/
97+
@Json(name = "speed_limit_composition")
98+
public String speedLimitComposition = null;
99+
94100
/**
95101
* Create a default STDCMRequest
96102
*/
@@ -103,7 +109,8 @@ public STDCMRequest() {
103109
null,
104110
null,
105111
Double.NaN,
106-
Double.NaN
112+
Double.NaN,
113+
null
107114
);
108115
}
109116

@@ -118,7 +125,8 @@ public STDCMRequest(
118125
Collection<PathfindingWaypoint> startPoints,
119126
Collection<PathfindingWaypoint> endPoints,
120127
double startTime,
121-
double endTime
128+
double endTime,
129+
String speedLimitComposition
122130
) {
123131
this.infra = infra;
124132
this.expectedVersion = expectedVersion;
@@ -128,6 +136,7 @@ public STDCMRequest(
128136
this.endPoints = endPoints;
129137
this.startTime = startTime;
130138
this.endTime = endTime;
139+
this.speedLimitComposition = speedLimitComposition;
131140
}
132141

133142
public static class RouteOccupancy {

core/src/main/java/fr/sncf/osrd/api/stdcm/graph/STDCMEdgeBuilder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ public Collection<STDCMEdge> makeAllEdges() {
126126
startOffset,
127127
graph.rollingStock,
128128
graph.timeStep,
129-
STDCMUtils.getStopsOnRoute(graph, route, startOffset)
129+
STDCMUtils.getStopsOnRoute(graph, route, startOffset),
130+
graph.tags
130131
);
131132
if (envelope == null)
132133
return List.of();

core/src/main/java/fr/sncf/osrd/api/stdcm/graph/STDCMGraph.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class STDCMGraph implements Graph<STDCMNode, STDCMEdge> {
2828
final DelayManager delayManager;
2929
final AllowanceManager allowanceManager;
3030
final BacktrackingManager backtrackingManager;
31+
final Set<String> tags;
3132

3233
/** Constructor */
3334
public STDCMGraph(
@@ -37,7 +38,8 @@ public STDCMGraph(
3738
Multimap<SignalingRoute, OccupancyBlock> unavailableTimes,
3839
double maxRunTime,
3940
double minScheduleTimeStart,
40-
Set<Pathfinding.EdgeLocation<SignalingRoute>> endLocations
41+
Set<Pathfinding.EdgeLocation<SignalingRoute>> endLocations,
42+
Set<String> tags
4143
) {
4244
this.infra = infra;
4345
this.rollingStock = rollingStock;
@@ -46,6 +48,7 @@ public STDCMGraph(
4648
this.delayManager = new DelayManager(minScheduleTimeStart, maxRunTime, unavailableTimes);
4749
this.allowanceManager = new AllowanceManager(this);
4850
this.backtrackingManager = new BacktrackingManager(this);
51+
this.tags = tags;
4952
}
5053

5154
@Override

core/src/main/java/fr/sncf/osrd/api/stdcm/graph/STDCMPathfinding.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public static STDCMResult findPath(
3838
Multimap<SignalingRoute, OccupancyBlock> unavailableTimes,
3939
double timeStep,
4040
double maxDepartureDelay,
41-
double maxRunTime
41+
double maxRunTime,
42+
Set<String> tags
4243
) {
4344
var graph = new STDCMGraph(
4445
infra,
@@ -47,7 +48,8 @@ public static STDCMResult findPath(
4748
unavailableTimes,
4849
maxRunTime,
4950
startTime,
50-
endLocations
51+
endLocations,
52+
tags
5153
);
5254

5355
// Initializes the constraints

core/src/main/java/fr/sncf/osrd/api/stdcm/graph/STDCMUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,16 @@ public static Envelope simulateRoute(
8181
double start,
8282
RollingStock rollingStock,
8383
double timeStep,
84-
double[] stops
84+
double[] stops,
85+
Set<String> tags
8586
) {
8687
try {
8788
var context = makeSimContext(List.of(route), start, rollingStock, timeStep);
8889
var mrsp = MRSP.from(
8990
route.getInfraRoute().getTrackRanges(start, start + context.path.getLength()),
9091
rollingStock,
9192
false,
92-
Set.of()
93+
tags
9394
);
9495
var maxSpeedEnvelope = MaxSpeedEnvelope.from(context, stops, mrsp);
9596
return MaxEffortEnvelope.from(context, initialSpeed, maxSpeedEnvelope);

core/src/test/java/fr/sncf/osrd/api/STDCMEndpointTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ public void simpleEmptyTimetable() throws Exception {
3535
EdgeDirection.START_TO_STOP
3636
)),
3737
0,
38-
0
38+
0,
39+
"foo"
3940
));
4041

4142
var result = readBodyResponse(

0 commit comments

Comments
 (0)