Skip to content

Commit

Permalink
core: throw a dedicated error when relaxed path search timed out
Browse files Browse the repository at this point in the history
  • Loading branch information
bougue-pe committed Jul 30, 2024
1 parent 94a492a commit 9c4f82a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public enum ErrorType {
ErrorCause.USER),
PathfindingTimeoutError(
"no_path_found:timeout", "Pathfinding timed out: no path could be found", ErrorCause.INTERNAL),
PathfindingRelaxedPathTimeoutError(
"no_path_found:relaxed_path_timeout",
"Relaxed pathfinding timed out: no path could be found, then relaxed path search timed out",
ErrorCause.INTERNAL),
InvalidInfraDiscontinuousRoute(
"invalid_infra:discontinuous_route", "Route track path isn't contiguous", ErrorCause.USER),
InvalidInfraMissingDetectorsRoute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import fr.sncf.osrd.api.pathfinding.makePathProps
import fr.sncf.osrd.graph.*
import fr.sncf.osrd.graph.Pathfinding.EdgeLocation
import fr.sncf.osrd.railjson.schema.rollingstock.RJSLoadingGaugeType
import fr.sncf.osrd.reporting.exceptions.ErrorType
import fr.sncf.osrd.reporting.exceptions.OSRDError
import fr.sncf.osrd.reporting.warnings.DiagnosticRecorderImpl
import fr.sncf.osrd.sim_infra.api.*
Expand Down Expand Up @@ -155,18 +156,25 @@ private fun computePaths(
// Handling errors
// Check if pathfinding failed due to incompatible constraints
val elapsedSeconds = Duration.between(start, Instant.now()).toSeconds()
val incompatibleConstraintsResponse =
buildIncompatibleConstraintsResponse(
infra,
waypoints,
constraints,
remainingDistanceEstimators,
mrspBuilder,
initialRequest,
timeout?.minus(elapsedSeconds)
)
if (incompatibleConstraintsResponse != null) {
throw NoPathFoundException(incompatibleConstraintsResponse)
try {
val incompatibleConstraintsResponse =
buildIncompatibleConstraintsResponse(
infra,
waypoints,
constraints,
remainingDistanceEstimators,
mrspBuilder,
initialRequest,
timeout?.minus(elapsedSeconds)
)
if (incompatibleConstraintsResponse != null) {
throw NoPathFoundException(incompatibleConstraintsResponse)
}
} catch (error: OSRDError) {
if (error.osrdErrorType == ErrorType.PathfindingTimeoutError) {
throw OSRDError(ErrorType.PathfindingRelaxedPathTimeoutError)
}
throw error
}
// It didn’t fail due to an incompatible constraint, no path exists
throw NoPathFoundException(NotFoundInBlocks(listOf(), Length(0.meters)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
"maximumRunTime": "Maximum running time",
"maximumRunTimeError": "Travel time must not exceed 12h",
"No path could be found": "No path found",
"Pathfinding timed out: no path could be found": "Time limit exceeded, no path found",
"Relaxed pathfinding timed out: no path could be found, then relaxed path search timed out": "No path found, then exceeded time limit while searching unconstrained path",
"No path could be found after loading Electrification constraints": "No path found for a rolling stock with this type of electrification",
"No path could be found after loading Gauge constraints": "No path for this rolling stock gauge",
"noPlaceChosen": "No stop/waypoint defined",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
"maximumRunTime": "Temps de parcours maximum",
"maximumRunTimeError": "Le temps de parcours ne doit pas excéder 12h",
"No path could be found": "Aucun itinéraire trouvé",
"Pathfinding timed out: no path could be found": "Limite de temps dépassée, aucun itinéraire trouvé",
"Relaxed pathfinding timed out: no path could be found, then relaxed path search timed out": "Aucun itinéraire trouvé, puis limite de temps dépassée lors de la recherche d'itinéraire sans contrainte",
"No path could be found after loading Electrification constraints": "Aucun itinéraire trouvé pour un matériel avec ce type d’électrification",
"No path could be found after loading Gauge constraints": "Aucun itinéraire trouvé avec ce gabarit de matériel",
"noPlaceChosen": "Aucun point de passage/arrêt défini",
Expand Down

0 comments on commit 9c4f82a

Please sign in to comment.