Permalink
Browse files

Merge remote-tracking branch 'origin/realtimeStoptime' into analystRe…

…verseOptimize

Also a little work in PatternBoard on optimization.

Does not currently work.

Conflicts:
	opentripplanner-routing/src/main/java/org/opentripplanner/routing/core/State.java
  • Loading branch information...
Matt Conway
Matt Conway committed Jul 19, 2012
2 parents e79732c + 9748a60 commit e1ad5fa04a78c7b93a58473b2a048c52b9dca410
Showing with 1,517 additions and 1,411 deletions.
  1. +0 −10 ...ner-graph-builder/src/main/java/org/opentripplanner/graph_builder/impl/GraphCoherencyChecker.java
  2. +0 −61 ...builder/src/main/java/org/opentripplanner/graph_builder/impl/OptimizeTransitGraphBuilderImpl.java
  3. +0 −2 opentripplanner-integration/src/defaults/resources/graph-builder.xml
  4. +29 −6 opentripplanner-routing/src/main/java/org/opentripplanner/routing/core/State.java
  5. +2 −1 opentripplanner-routing/src/main/java/org/opentripplanner/routing/core/StateData.java
  6. +4 −7 opentripplanner-routing/src/main/java/org/opentripplanner/routing/core/StateEditor.java
  7. +0 −356 opentripplanner-routing/src/main/java/org/opentripplanner/routing/edgetype/ArrayTripPattern.java
  8. +0 −454 opentripplanner-routing/src/main/java/org/opentripplanner/routing/edgetype/BasicTripPattern.java
  9. +1 −1 opentripplanner-routing/src/main/java/org/opentripplanner/routing/edgetype/FrequencyAlight.java
  10. +20 −31 opentripplanner-routing/src/main/java/org/opentripplanner/routing/edgetype/PatternAlight.java
  11. +68 −30 opentripplanner-routing/src/main/java/org/opentripplanner/routing/edgetype/PatternBoard.java
  12. +15 −18 opentripplanner-routing/src/main/java/org/opentripplanner/routing/edgetype/PatternDwell.java
  13. +3 −9 opentripplanner-routing/src/main/java/org/opentripplanner/routing/edgetype/PatternEdge.java
  14. +9 −8 opentripplanner-routing/src/main/java/org/opentripplanner/routing/edgetype/PatternHop.java
  15. +5 −2 ...tripplanner-routing/src/main/java/org/opentripplanner/routing/edgetype/PatternInterlineDwell.java
  16. +61 −0 opentripplanner-routing/src/main/java/org/opentripplanner/routing/edgetype/ScheduledStopPattern.java
  17. +385 −52 opentripplanner-routing/src/main/java/org/opentripplanner/routing/edgetype/TableTripPattern.java
  18. +251 −328 ...ner-routing/src/main/java/org/opentripplanner/routing/edgetype/factory/GTFSPatternHopFactory.java
  19. +22 −21 ...ipplanner-routing/src/main/java/org/opentripplanner/routing/edgetype/factory/LocalStopFinder.java
  20. +144 −0 opentripplanner-routing/src/main/java/org/opentripplanner/routing/trippattern/TripTimes.java
  21. +35 −0 opentripplanner-routing/src/main/java/org/opentripplanner/routing/trippattern/Update.java
  22. +135 −0 opentripplanner-routing/src/main/java/org/opentripplanner/routing/trippattern/UpdateList.java
  23. +6 −6 opentripplanner-routing/src/main/java/org/opentripplanner/routing/vertextype/OnboardVertex.java
  24. +2 −0 ...tripplanner-routing/src/main/java/org/opentripplanner/routing/vertextype/PatternDepartVertex.java
  25. +4 −7 opentripplanner-routing/src/main/java/org/opentripplanner/routing/vertextype/TransitVertex.java
  26. +5 −1 opentripplanner-updater/pom.xml
  27. +56 −0 ...tripplanner-updater/src/main/java/org/opentripplanner/updater/stoptime/GTFSZMQUpdateStreamer.java
  28. +111 −0 opentripplanner-updater/src/main/java/org/opentripplanner/updater/stoptime/KV8ZMQUpdateStreamer.java
  29. +84 −0 opentripplanner-updater/src/main/java/org/opentripplanner/updater/stoptime/StoptimeUpdater.java
  30. +9 −0 opentripplanner-updater/src/main/java/org/opentripplanner/updater/stoptime/UpdateStreamer.java
  31. +51 −0 opentripplanner-utils/src/main/java/org/opentripplanner/common/CTX.java
@@ -13,28 +13,18 @@
package org.opentripplanner.graph_builder.impl;
-import static org.opentripplanner.common.IterableLibrary.filter;
-
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
-import org.opentripplanner.common.geometry.SphericalDistanceLibrary;
import org.opentripplanner.graph_builder.services.GraphBuilder;
-import org.opentripplanner.routing.core.EdgeNarrative;
-import org.opentripplanner.routing.core.GraphBuilderAnnotation;
-import org.opentripplanner.routing.core.GraphBuilderAnnotation.Variety;
-import org.opentripplanner.routing.edgetype.HopEdge;
import org.opentripplanner.routing.graph.Edge;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.routing.graph.Vertex;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.vividsolutions.jts.geom.Coordinate;
-import com.vividsolutions.jts.geom.Geometry;
-
/**
* Check the every vertex and edge in the graph to make sure the edge lists and from/to
* members are coherent, and that there are no edgeless vertices. Primarily intended for debugging.
@@ -1,61 +0,0 @@
-/* This program is free software: you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License
- as published by the Free Software Foundation, either version 3 of
- the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-package org.opentripplanner.graph_builder.impl;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-
-import org.opentripplanner.graph_builder.services.GraphBuilder;
-import org.opentripplanner.routing.edgetype.BasicTripPattern;
-import org.opentripplanner.routing.edgetype.PatternEdge;
-import org.opentripplanner.routing.edgetype.TableTripPattern;
-import org.opentripplanner.routing.graph.Edge;
-import org.opentripplanner.routing.graph.Graph;
-import org.opentripplanner.routing.graph.Vertex;
-
-/**
- * Replace BasicTripPatterns with ArrayTripPatterns.
- */
-public class OptimizeTransitGraphBuilderImpl implements GraphBuilder {
-
- public List<String> provides() {
- return Collections.emptyList();
- }
-
- public List<String> getPrerequisites() {
- return Arrays.asList("transit");
- }
-
- @Override
- public void buildGraph(Graph graph, HashMap<Class<?>, Object> extra) {
- for (Vertex v : graph.getVertices()) {
- for (Edge e: v.getOutgoing()) {
- if (e instanceof PatternEdge) {
- PatternEdge pe = (PatternEdge) e;
- TableTripPattern pattern = pe.getPattern();
- if (pattern instanceof BasicTripPattern) {
- pe.setPattern(((BasicTripPattern) pattern).convertToArrayTripPattern());
- }
- }
- }
- }
- }
-
- @Override
- public void checkInputs() {
- //no inputs
- }
-}
@@ -52,7 +52,6 @@
</bean>
<bean id="transitStreetLink" class="org.opentripplanner.graph_builder.impl.TransitToStreetNetworkGraphBuilderImpl" />
- <bean id="optimizeTransit" class="org.opentripplanner.graph_builder.impl.OptimizeTransitGraphBuilderImpl" />
<bean id="checkGeometry" class="org.opentripplanner.graph_builder.impl.CheckGeometryGraphBuilderImpl" />
<bean id="graphBuilderTask" class="org.opentripplanner.graph_builder.GraphBuilderTask">
@@ -63,7 +62,6 @@
<ref bean="gtfsBuilder" />
<ref bean="streetBuilder" />
<ref bean="transitStreetLink" />
- <ref bean="optimizeTransit" />
<ref bean="checkGeometry" />
</list>
</property>
@@ -28,6 +28,7 @@
import org.opentripplanner.routing.graph.Edge;
import org.opentripplanner.routing.graph.Vertex;
import org.opentripplanner.routing.pathparser.PathParser;
+import org.opentripplanner.routing.trippattern.TripTimes;
public class State implements Cloneable {
/* Data which is likely to change at most traversals */
@@ -193,8 +194,8 @@ public long getActiveTime () {
return activeTime;
}
- public int getTrip() {
- return stateData.trip;
+ public TripTimes getTripTimes() {
+ return stateData.tripTimes;
}
public AgencyAndId getTripId() {
@@ -386,6 +387,8 @@ public RoutingRequest getOptions () {
return stateData.opt;
}
+ /* will return BICYCLE if routing with an owned bicycle, or if at this state the user is holding
+ * on to a rented bicycle */
public TraverseMode getNonTransitMode(RoutingRequest options) {
TraverseModeSet modes = options.getModes();
if (modes.getCar())
@@ -538,13 +541,20 @@ public State reverse() {
* path that passes through all the same edges, but which may have a shorter overall duration
* due to different weights on time-dependent (e.g. transit boarding) edges.
*
- * @return a state at the other end of a reversed, optimized path
+ * @param forward This is a reverse optimization inside a forward search, the returned state
+ * should be the same end the user started with.
+ * @return a state at the other end (or this end, in the case of a forward search)
+ * of a reversed, optimized path
*/
// optimize is now very similar to reverse, and the two could conceivably be combined
- public State optimize() {
+ public State optimize(boolean forward) {
State orig = this;
State unoptimized = orig;
State ret = orig.reversedClone();
+
+ // This state is kept around and returned in a forward search
+ State front = ret;
+
Edge edge = null;
try {
while (orig.getBackState() != null) {
@@ -560,9 +570,22 @@ public State optimize() {
+ " returning unoptimized path. If edge is a PatternInterlineDwell,"
+ " this is not totally unexpected; otherwise, you might want to"
+ " look into it");
- return unoptimized.reverse();
+ if (forward)
+ // since we didn't modify it, no reason to clone it.
+ return this;
+ else
+ return unoptimized.reverse();
}
- return ret;
+
+ if (forward)
+ return front;
+ else
+ return ret;
+ }
+
+ /** Default to reversing during reverse search */
+ public State optimize () {
+ return optimize(false);
}
private static void copyExistingNarrativeToNewNarrativeAsAppropriate(EdgeNarrative from,
@@ -18,6 +18,7 @@
import org.onebusaway.gtfs.model.AgencyAndId;
import org.opentripplanner.routing.edgetype.TripPattern;
import org.opentripplanner.routing.graph.Vertex;
+import org.opentripplanner.routing.trippattern.TripTimes;
/**
* StateData contains the components of search state that are unlikely to be changed as often as
@@ -30,7 +31,7 @@
protected long startTime;
// which trip index inside a pattern
- protected int trip;
+ protected TripTimes tripTimes;
protected AgencyAndId tripId;
@@ -27,6 +27,7 @@
import org.opentripplanner.routing.patch.Alert;
import org.opentripplanner.routing.patch.Patch;
import org.opentripplanner.routing.pathparser.PathParser;
+import org.opentripplanner.routing.trippattern.TripTimes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -251,9 +252,9 @@ public void incrementNumBoardings() {
/* Basic Setters */
- public void setTrip(int trip) {
+ public void setTripTimes(TripTimes tripTimes) {
cloneStateDataAsNeeded();
- child.stateData.trip = trip;
+ child.stateData.tripTimes = tripTimes;
}
public void setTripId(AgencyAndId tripId) {
@@ -351,7 +352,7 @@ public void setStartTime(long t) {
public void setFromState(State state) {
cloneStateDataAsNeeded();
child.stateData.route = state.stateData.route;
- child.stateData.trip = state.stateData.trip;
+ child.stateData.tripTimes = state.stateData.tripTimes;
child.stateData.tripId = state.stateData.tripId;
child.stateData.zone = state.stateData.zone;
child.stateData.extensions = state.stateData.extensions;
@@ -377,10 +378,6 @@ public long getElapsedTime() {
return child.getElapsedTime();
}
- public int getTrip() {
- return child.getTrip();
- }
-
public AgencyAndId getTripId() {
return child.getTripId();
}
Oops, something went wrong.

0 comments on commit e1ad5fa

Please sign in to comment.