Skip to content

Commit

Permalink
Optimize transfers point using priority
Browse files Browse the repository at this point in the history
The OptimizeTransferService is run AFTER the Raptor search and find all
possible combination of transfers for all paths. This allow us to
compare the possible transfers for a path and pick the best option. We
can filter the paths based on a optimal-transfer-cost, remove
"back-travel-options" and implement a transfer priority(GTFS transfers
and NeTEx Interchanges).
  • Loading branch information
t2gran committed Apr 28, 2021
1 parent 745bfda commit aa59c3e
Show file tree
Hide file tree
Showing 123 changed files with 5,416 additions and 871 deletions.
7 changes: 6 additions & 1 deletion ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ Used to import GTFS transit data files.

Used to import NeTEx transit data files.

### Transit Routing

### [Raptor transit routing](src/main/java/org/opentripplanner/transit/raptor/package.md)
#### [Raptor transit routing](src/main/java/org/opentripplanner/transit/raptor/package.md)

This is the OTP2 new transit routing engine implemented using the Raptor algorithm. It explains how
Raptor works, the important concepts, and the design. It might be worth reading even if you are not
Expand All @@ -61,3 +62,7 @@ The performance of Raptor is important, and we care about every millisecond. All
existing Raptor coded should be tested with the
[SpeedTest](src/test/java/org/opentripplanner/transit/raptor/speed_test/package.md) and
compared with an earlier version of the code to make sure the performance is NOT degraded.

#### [Transfer path optimization](src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/package.md)
Describe the transfer functionality, the design and implementation. The logic for finding the best
transfer is distributed to the Raptor and the [OptimizeTransferService](src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/OptimizeTransferService.java).
5 changes: 5 additions & 0 deletions docs/images/TransitTimeLine.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</scm>

<properties>
<otp.serialization.version.id>7</otp.serialization.version.id>
<otp.serialization.version.id>8</otp.serialization.version.id>
<!-- Lib versions - keep list sorted on property name -->
<geotools.version>21.2</geotools.version>
<geotools.wfs.version>16.5</geotools.wfs.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
package org.opentripplanner.ext.transmodelapi;

import static java.lang.Boolean.TRUE;
import static java.util.Collections.emptyList;
import static org.opentripplanner.ext.transmodelapi.mapping.TransitIdMapper.mapIDsToDomain;
import static org.opentripplanner.ext.transmodelapi.model.EnumTypes.MULTI_MODAL_MODE;
import static org.opentripplanner.ext.transmodelapi.model.EnumTypes.TRANSPORT_MODE;
import static org.opentripplanner.ext.transmodelapi.model.EnumTypes.filterPlaceTypeEnum;
import static org.opentripplanner.model.projectinfo.OtpProjectInfo.projectInfo;

import graphql.Scalars;
import graphql.relay.DefaultConnection;
import graphql.relay.DefaultPageInfo;
Expand All @@ -17,6 +25,17 @@
import graphql.schema.GraphQLOutputType;
import graphql.schema.GraphQLSchema;
import graphql.schema.GraphQLType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.collections.CollectionUtils;
import org.opentripplanner.ext.transmodelapi.mapping.PlaceMapper;
import org.opentripplanner.ext.transmodelapi.mapping.TransitIdMapper;
Expand Down Expand Up @@ -73,32 +92,14 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.lang.Boolean.TRUE;
import static java.util.Collections.emptyList;
import static org.opentripplanner.model.projectinfo.OtpProjectInfo.projectInfo;
import static org.opentripplanner.ext.transmodelapi.mapping.TransitIdMapper.mapIDsToDomain;
import static org.opentripplanner.ext.transmodelapi.model.EnumTypes.MULTI_MODAL_MODE;
import static org.opentripplanner.ext.transmodelapi.model.EnumTypes.TRANSPORT_MODE;
import static org.opentripplanner.ext.transmodelapi.model.EnumTypes.filterPlaceTypeEnum;

/**
* Schema definition for the Transmodel GraphQL API.
* <p>
* Currently a simplified version of the IndexGraphQLSchema, with gtfs terminology replaced with corresponding terms from Transmodel.
* Currently a simplified version of the IndexGraphQLSchema, with gtfs terminology replaced with
* corresponding terms from Transmodel.
*/
public class TransmodelGraphQLSchema {

private static final Logger LOG = LoggerFactory.getLogger(TransmodelGraphQLSchema.class);

private final DefaultRoutingRequestType routing;
Expand All @@ -117,7 +118,7 @@ public static GraphQLSchema create(RoutingRequest defaultRequest, GqlUtil qglUti
return new TransmodelGraphQLSchema(defaultRequest, qglUtil).create();
}

@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked")
private GraphQLSchema create() {
/*
multilingualStringType, validityPeriodType, infoLinkType, bookingArrangementType, systemNoticeType,
Expand Down Expand Up @@ -1101,11 +1102,6 @@ private GraphQLSchema create() {
// return tripPattern.stopPattern.bookingArrangements[tripTimeShort.stopIndex];
// }

private List<FeedScopedId> toIdList(List<String> ids) {
if (ids == null) { return Collections.emptyList(); }
return ids.stream().map(id -> TransitIdMapper.mapIDToDomain(id)).collect(Collectors.toList());
}

public GraphQLObjectType createPlanType(
GraphQLOutputType bookingArrangementType,
GraphQLOutputType interchangeType,
Expand Down Expand Up @@ -1144,4 +1140,11 @@ public GraphQLObjectType createPlanType(

return TripType.create(placeType, tripPatternType, tripMetadataType, gqlUtil);
}

private List<FeedScopedId> toIdList(List<String> ids) {
if (ids == null) { return Collections.emptyList(); }
return ids.stream().map(TransitIdMapper::mapIDToDomain).collect(Collectors.toList());
}


}
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package org.opentripplanner.ext.transmodelapi.model;

import graphql.schema.GraphQLEnumType;
import org.opentripplanner.model.Direction;
import java.util.Arrays;
import java.util.function.Function;
import org.opentripplanner.model.BookingMethod;
import org.opentripplanner.model.Direction;
import org.opentripplanner.model.TransitMode;
import org.opentripplanner.model.TripAlteration;
import org.opentripplanner.model.plan.AbsoluteDirection;
import org.opentripplanner.model.plan.RelativeDirection;
import org.opentripplanner.model.plan.VertexType;
import org.opentripplanner.model.transfer.TransferPriority;
import org.opentripplanner.routing.alertpatch.StopCondition;
import org.opentripplanner.routing.api.request.StreetMode;
import org.opentripplanner.routing.core.BicycleOptimizeType;
import org.opentripplanner.routing.core.TraverseMode;
import org.opentripplanner.routing.trippattern.RealTimeState;

import java.util.Arrays;
import java.util.function.Function;

public class EnumTypes {
public static GraphQLEnumType WHEELCHAIR_BOARDING = GraphQLEnumType.newEnum()
.name("WheelchairBoarding")
Expand Down Expand Up @@ -86,14 +86,13 @@ public class EnumTypes {
//TODO QL: .value("parkAndRide", VertexType.PARKANDRIDE)
.build();

/* TODO QL
public static GraphQLEnumType serviceAlterationEnum = GraphQLEnumType.newEnum()
.name("ServiceAlteration")
.value("planned", Trip.ServiceAlteration.planned)
.value("cancellation", Trip.ServiceAlteration.cancellation)
.value("extraJourney", Trip.ServiceAlteration.extraJourney)
public static GraphQLEnumType INTERCHANGE_PRIORITY = GraphQLEnumType.newEnum()
.name("InterchangePriority")
.value("preferred", TransferPriority.PREFERRED)
.value("recommended", TransferPriority.RECOMMENDED)
.value("allowed", TransferPriority.ALLOWED)
.value("notAllowed", TransferPriority.NOT_ALLOWED)
.build();
*/

public static GraphQLEnumType STREET_MODE = GraphQLEnumType.newEnum()
.name("StreetMode")
Expand Down
Loading

0 comments on commit aa59c3e

Please sign in to comment.