Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating a profile query for a day? #12

Open
frnsys opened this issue Mar 14, 2018 · 3 comments
Open

Generating a profile query for a day? #12

frnsys opened this issue Mar 14, 2018 · 3 comments

Comments

@frnsys
Copy link

frnsys commented Mar 14, 2018

Hi, thank you for writing this library! I've been playing around with it a bit and am wondering if it's possible to generate multi-criteria profiles for a day with this library? I've managed to load my GTFS data and OSM walk network data into a GTFS object, but am not sure what to do next.

@jweckstr
Copy link
Collaborator

Hello, it is nice to read that you are using the library! You can indeed produce the temporal distance profile for a day. To do this, the next steps would be: to find the date that you are interested in, and find the start and end time (universal time) of that date. Then generate transit connections (get_transit_connections) and walk network (get_walk_network) and pass these to the routing engine (MultiObjectivePseudoCSAProfiler) and run(). Pass the required data to the node profile analyzer (NodeProfileAnalyzerTimeAndVehLegs) which will be able to produce the plots.

You can find an example here:
https://github.com/CxAalto/gtfspy/blob/master/examples/example_temporal_distance_profile.py

Let us know if you have further questions!

@frnsys
Copy link
Author

frnsys commented Mar 14, 2018

Great, thank you. I've generated the profiles, but after going through the code can't figure out how to query for the Pareto-optimal journeys given a departure time and a start and end stop.

Here's what I've done so far:

G = gtfs.GTFS('/tmp/gtfs.db') 
start = datetime(year=2017, month=1, day=1, hour=0, minute=0, second=0).timestamp()
end = datetime(year=2017, month=1, day=2, hour=0, minute=0, second=0).timestamp()
tcon = get_transit_connections(G, start, end)
wnet = get_walk_network(G)
stops = G.stops().stop_I.values.tolist()
router = MultiObjectivePseudoCSAProfiler(tcon, stops, walk_network=wnet, verbose=True)
router.run()

profiles = router.stop_profiles

Sorry if this is not how the library is meant to be used!

@rmkujala
Copy link
Member

rmkujala commented Mar 15, 2018

Note: Now you are using all stops as your target(s), which probably is not what you have intended. (Stops is now a list of all the integer stop identifiers, but you probably would like to use only one node as the target)

Nonetheless, the router.stop_profiles should now be a dictionary mapping the integer stop identifiers (for the origins) to NodeProfileMultiObjective -objects. From these objects, you can get the final Pareto-optimal journey alternatives using the get_final_optimal_labels() -method.

So you could try out something like

origin_node_stop_I = 0 # the integer identifier for the stop (as defined in the imported database!) 
origin_node_profile = profiles[origin_node_stop_I]
optimal_journey_alternatives_from_origin_to_target = node_profile.get_final_optimal_labels()  # Here, label means the same as journey. Our vocabulary would need some standardization / clarification....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants