|
| 1 | +--- |
| 2 | +title: "Infrastructure exploration" |
| 3 | +linkTitle: "1 - Infrastructure exploration" |
| 4 | +weight: 10 |
| 5 | +--- |
| 6 | + |
| 7 | +The first thing we need to define is *how we move through the infrastructure*, |
| 8 | +without dealing with conflicts yet. |
| 9 | + |
| 10 | +We need a way to define and enumerate the different possible paths and |
| 11 | +explore the infrastructure graph, with several constraints: |
| 12 | +1. The path must be compatible with the given rolling stock |
| 13 | + (loading gauge / electrification / signaling system) |
| 14 | +2. At any point, we need to access path properties from its start up to the |
| 15 | + considered point. This includes block and route lists. |
| 16 | +3. We sometimes need to know where the train will go *after* the |
| 17 | + point being evaluated, for proper conflict detection |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +To do this, we have defined the class `InfraExplorer`. It uses blocks |
| 22 | +(sections from signal to signal) as a main subdivision. |
| 23 | +It has 3 sections: the current block, predecessors, and a "lookahead". |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +In this example, the green arrows are the predecessor blocks. |
| 30 | +What happens there is considered to be immutable. |
| 31 | + |
| 32 | +The red arrow is the current block. This is where we run |
| 33 | +train and signaling simulations, and where we deal with conflicts. |
| 34 | + |
| 35 | +The blue arrows are part of the lookahead. This section hasn't |
| 36 | +been simulated yet, its only purpose is to know in advance |
| 37 | +where the train will go next. In this example, it would tell us |
| 38 | +that the bottom right signal can be ignored entirely. |
| 39 | +**A different `InfraExplorer` would be instantiated that would |
| 40 | +go toward the bottom section instead of the top one**, |
| 41 | +but this would be the path currently being evaluated. |
| 42 | + |
| 43 | + |
| 44 | +The `InfraExplorer` is manipulated with two main functions |
| 45 | +(the accessors have been removed here for clarity): |
| 46 | + |
| 47 | +```kotlin |
| 48 | +interface InfraExplorer { |
| 49 | + /** |
| 50 | + * Clone the current object and extend the lookahead by one route, for each route starting at |
| 51 | + * the current end of the lookahead section. The current instance is not modified. |
| 52 | + */ |
| 53 | + fun cloneAndExtendLookahead(): Collection<InfraExplorer> |
| 54 | + |
| 55 | + /** |
| 56 | + * Move the current block by one, following the lookahead section. Can only be called when the |
| 57 | + * lookahead isn't empty. |
| 58 | + */ |
| 59 | + fun moveForward(): InfraExplorer |
| 60 | +} |
| 61 | +``` |
| 62 | + |
| 63 | +`cloneAndExtendLookahead()` is the method that actually enumerates the |
| 64 | +different paths, returning clones for each possibility. |
| 65 | +It's called when we need a more precise lookahead to properly identify |
| 66 | +conflicts, or when it's empty and we need to move forward. |
| 67 | + |
| 68 | +A variation of this class can also keep track of the train simulation |
| 69 | +and time information (called `InfraExplorerWithEnvelope`). |
| 70 | +This is the version that is actually used to explore the infrastructure. |
0 commit comments