Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d1edcdf
Initial skeleton
t2gran Dec 16, 2022
e61b05b
Initial timetable implementation
t2gran May 6, 2022
4a95c16
refactor: Delete DepartureTripSearch
t2gran Jan 13, 2023
2cb72ee
Remove Stop and StopService
vpaturet Jan 13, 2023
ed51675
refactor: Delete TransitService
t2gran Jan 13, 2023
ba57268
refactor: Add OperationDay
t2gran Jan 17, 2023
588708c
refactor: Refactor calendar package to match suggested model
t2gran Jan 17, 2023
ccd2ddc
doc: Add design doc and more TODOs
t2gran Jan 17, 2023
6f37022
doc: Add design doc calendar
t2gran Jan 18, 2023
5d0ae94
Fixed CalendarDays tests
vpaturet Jan 23, 2023
d8a741d
Added unit tests
vpaturet Jan 24, 2023
9238332
Fill in some gaps
t2gran Jan 26, 2023
e68fcd3
Fix code formatting
vpaturet Jan 31, 2023
b43a9db
Add dummy stop coordinates
vpaturet Jan 31, 2023
e92eeff
Rename RoutingTripPattern to V2
vpaturet Jan 31, 2023
5d007fe
Partial implementation of PatternsOnDay
vpaturet Jan 31, 2023
c5c34b6
Rename method
vpaturet Feb 3, 2023
8aabdd1
Add test transit calendar
vpaturet Feb 3, 2023
8ceca9f
Add index on active patterns by list of stops
vpaturet Feb 3, 2023
9fdfc91
Add index on PatternOnDay
vpaturet Feb 3, 2023
c054199
Implement RaptorRouteAdaptor.tripSearch
vpaturet Feb 7, 2023
e95e8cc
Implement TripScheduleSearchOnDays.search
vpaturet Feb 7, 2023
c13ae62
feat: Implement the RaptorTripScheduleSearch and use it in RaptorRout…
t2gran Feb 7, 2023
864fdf7
refactor: Add toString to Timetable and ForwardSearch
t2gran Feb 8, 2023
5aecc8b
fix: Board first trip if earliest-board-time is before first trip (no…
t2gran Feb 8, 2023
d55cedf
fix: Trip index returned from search was wrong
t2gran Feb 8, 2023
25bc469
todo: Added tests, witch fails - TODO fix the code and tests
t2gran Feb 8, 2023
21bae68
Rename parameter stop to stopIndex
vpaturet Feb 8, 2023
9a52d16
Fixed unit tests
vpaturet Feb 8, 2023
b234a04
Fix timetable test data
vpaturet Feb 9, 2023
552de6c
Fix formatting
vpaturet Feb 9, 2023
e038ca9
Added unit tests on Timetable
vpaturet Feb 10, 2023
3cc6081
refactor: Give TripIndexSearch classes better names
t2gran Feb 15, 2023
713eef9
Added fix for AlightTripIndexSearch and BoardTripIndexSearch
vpaturet Feb 15, 2023
48e4951
Simplify AlightTripIndexSearch and BoardTripIndexSearch
vpaturet Feb 15, 2023
a5b3231
Return test data in TripOnDay.pattern()
vpaturet Feb 20, 2023
871662e
Rename test stops to match test expectation
vpaturet Feb 20, 2023
e2cc503
Fix reverse search
vpaturet Feb 20, 2023
b63391f
Fix cost value in unit test
vpaturet Feb 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ Be sure to also read the [developer documentation](docs/Developers-Guide.md).
## Modules/Components

Below is a list of documented components in OTP. Not every component is documented at a high level,
but this is a start and we would like to expand this list in the future.
but this is a start, and we would like to expand this list in the future.


### [OTP Transit Model](src/main/java/org/opentripplanner/transit/model/package.md)

Sometimes also referred to as the internal transit model. This is OTPs internal model witch is a
unified model of GTFS and Transmodel(NeTEx) relevant for OTP. The model is optimized for transit
routing.

### [OTP Configuration design](src/main/java/org/opentripplanner/standalone/config/package.md)

Expand Down
29 changes: 29 additions & 0 deletions src/main/java/org/opentripplanner/framework/lang/IntUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ public static int[] intArray(int size, int initialValue) {
return array;
}

/**
* Check if each value in the array is equal to the given {@code value}. If all values
* are the same and equals to {@code value} or the array is empty this method returns
* {@code true}.
*/
public static boolean arrayEquals(int[] array, int value) {
for (int i : array) {
if (value != i) {
return false;
}
}
return true;
}

/**
* Concatenate list a and b and convert them to int arrays.
*/
Expand All @@ -49,4 +63,19 @@ public static double standardDeviation(List<Integer> v) {

return Math.sqrt(sum / v.size());
}

/**
* Add a given {@code delta} value to all elements in an array, except {@code notSet}
* elements.
*/
public static int[] arrayPlus(int[] array, int delta) {
if (array.length == 0) {
return array;
}
int[] newArray = new int[array.length];
for (int i = 0; i < array.length; i++) {
newArray[i] = array[i] + delta;
}
return newArray;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.opentripplanner.raptor.api.model;

import java.util.concurrent.atomic.AtomicInteger;
import org.opentripplanner.raptor.spi.RaptorSlackProvider;

/**
Expand All @@ -8,6 +9,8 @@
* no gaps, as the trips visit the stops.
*/
public interface RaptorTripPattern {
AtomicInteger INDEX_COUNTER = new AtomicInteger(0);

int patternIndex();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ public BestTimes(int nStops, TransitCalculator<?> calculator, WorkerLifeCycle li
lifeCycle.onPrepareForNextRound(round -> prepareForNextRound());
}

public int time(int stop) {
return times[stop];
public int time(int stopIndex) {
return times[stopIndex];
}

public int transitArrivalTime(int stop) {
return transitArrivalTimes[stop];
public int transitArrivalTime(int stopIndex) {
return transitArrivalTimes[stopIndex];
}

/**
Expand Down Expand Up @@ -91,25 +91,25 @@ public boolean isStopReachedLastRound(int stop) {
}

/**
* @return return true if stop is reached.
* @return return true if stopIndex is reached.
*/
public boolean isStopReached(int stop) {
return time(stop) != calculator.unreachedTime();
public boolean isStopReached(int stopIndex) {
return time(stopIndex) != calculator.unreachedTime();
}

/**
* @return return true if stop is reached.
* @return return true if stopIndex is reached.
*/
public boolean isStopReachedByTransit(int stop) {
return transitArrivalTime(stop) != calculator.unreachedTime();
public boolean isStopReachedByTransit(int stopIndex) {
return transitArrivalTime(stopIndex) != calculator.unreachedTime();
}

/**
* @return true iff new best time is updated
*/
public boolean updateBestTransitArrivalTime(int stop, int time) {
if (isBestTransitArrivalTime(stop, time)) {
setBestTime(stop, time);
public boolean updateBestTransitArrivalTime(int stopIndex, int time) {
if (isBestTransitArrivalTime(stopIndex, time)) {
setBestTime(stopIndex, time);
return true;
}
return false;
Expand All @@ -118,9 +118,9 @@ public boolean updateBestTransitArrivalTime(int stop, int time) {
/**
* @return true iff new best time is updated
*/
public boolean updateNewBestTime(int stop, int time) {
if (isBestTime(stop, time)) {
setTime(stop, time);
public boolean updateNewBestTime(int stopIndex, int time) {
if (isBestTime(stopIndex, time)) {
setTime(stopIndex, time);
return true;
}
return false;
Expand All @@ -144,10 +144,10 @@ public String toString() {
}

/**
* @return true if the given stop was reached by on-board in the current round.
* @return true if the given stopIndex was reached by on-board in the current round.
*/
boolean isStopReachedOnBoardInCurrentRound(int stop) {
return reachedByTransitCurrentRound.get(stop);
boolean isStopReachedOnBoardInCurrentRound(int stopIndex) {
return reachedByTransitCurrentRound.get(stopIndex);
}

/**
Expand All @@ -171,22 +171,22 @@ private void prepareForNextRound() {

/* private methods */

private void setTime(final int stop, final int time) {
times[stop] = time;
reachedCurrentRound.set(stop);
private void setTime(final int stopIndex, final int time) {
times[stopIndex] = time;
reachedCurrentRound.set(stopIndex);
}

private boolean isBestTime(int stop, int time) {
return calculator.isBefore(time, times[stop]);
private boolean isBestTime(int stopIndex, int time) {
return calculator.isBefore(time, times[stopIndex]);
}

private boolean isBestTransitArrivalTime(int stop, int time) {
return calculator.isBefore(time, transitArrivalTimes[stop]);
private boolean isBestTransitArrivalTime(int stopIndex, int time) {
return calculator.isBefore(time, transitArrivalTimes[stopIndex]);
}

private void setBestTime(int stop, int time) {
transitArrivalTimes[stop] = time;
reachedByTransitCurrentRound.set(stop);
private void setBestTime(int stopIndex, int time) {
transitArrivalTimes[stopIndex] = time;
reachedByTransitCurrentRound.set(stopIndex);
}

private void swapReachedCurrentAndLastRound() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
* trip-schedule, so even for long time-tables the Raptor search perform quite well.
* <p>
* @param <T> The TripSchedule type defined by the user of the raptor API.
* @deprecated TODO RTM - The trip search is modved out of Raptor, so we do not need this class any
* more. Move the tripSeach() method the RaptorRoute - Try to remove the two
* other methods.
*/
@Deprecated
public interface RaptorTimeTable<T extends RaptorTripSchedule> {
/**
* Get trip schedule by index. Trip schedules should be listed in order by the departure time for
Expand All @@ -24,7 +28,12 @@ public interface RaptorTimeTable<T extends RaptorTripSchedule> {

/**
* Number of trips in time-table.
* @deprecated TODO RTM - We should get rid of this, it is specific to the period we extract data,
* but we get into problems when we want to support unbounded periods. Use
* the trip search instead to find a start point (index) and iterate from
* there.
*/
@Deprecated
int numberOfTripSchedules();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

/**
* This {@link java.util.Collection} store all pareto-optimal elements. The {@link #add(Object)}
* method returns {@code true} if and only if the element was added successfully. When an element is
* added other elements which are no longer pareto-optimal are dropped.
* method returns {@code true} if and only if the element was added successfully. When an element
* is added other elements which are no longer pareto-optimal are dropped.
* <p/>
* Like the {@link java.util.ArrayList} the elements are stored internally in an array for
* performance reasons, and the order is guaranteed to be the same as the order the elements are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.opentripplanner.raptor.spi.RaptorSlackProvider;
import org.opentripplanner.routing.api.request.framework.DurationForEnum;
import org.opentripplanner.transit.model.basic.TransitMode;
import org.opentripplanner.transit.model.network.TripPattern;

/**
* This class provides transferSlack, boardSlack and alightSlack for the Raptor algorithm.
Expand Down Expand Up @@ -64,6 +65,10 @@ private static int[] slackByMode(DurationForEnum<TransitMode> slack) {
return result;
}

public static int slackIndex(TripPattern pattern) {
return slackIndex(pattern.getMode());
}

public static int slackIndex(final TransitMode mode) {
return mode.ordinal();
}
Expand Down
Loading