trainline-eu / csa-challenge Goto Github PK
View Code? Open in Web Editor NEWCompare various implementations of the connections scan algorithm
License: Do What The F*ck You Want To Public License
Compare various implementations of the connections scan algorithm
License: Do What The F*ck You Want To Public License
Since https://github.com/BliksemLabs/rrrr/tree/tdata4 has a GTFS import, and the data format you have described is trivial. Would a utility to go from GTFS to your intermediate format something you wish to add to this repo?
Do you have any guidance as to how to address any of the limitations? Specifically I'm looking to address:
it computes the earliest arrival. However, a better solution might leaver later and arrive at the same time
Hi,
I have this issue running ruby test.rb *
ruby test.rb ./csa_cpp
Warning: you should require 'minitest/autorun' instead.
Warning: or add 'gem "minitest"' before 'require "minitest/autorun"'
From:
/Users/poc/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/test/unit.rb:1:in `<top (required)>'
test.rb:3:in `<main>'
MiniTest::Unit::TestCase is now Minitest::Test. From /Users/poc/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/test/unit/testcase.rb:8:in `<module:Unit>'
/Users/poc/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/test/unit.rb:676:in `<class:Runner>': undefined method `_run_suite' for class `Test::Unit::Runner' (NameError)
from /Users/poc/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/test/unit.rb:261:in `<module:Unit>'
from /Users/poc/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/test/unit.rb:15:in `<module:Test>'
from /Users/poc/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/test/unit.rb:7:in `<top (required)>'
from /Users/poc/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/poc/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from test.rb:3:in `<main>'
I can run ruby bench.rb *
Hello. I enjoyed this, thanks for sharing it.
I refactored the Rust version to be easier for me to read. That's a subjective goal, and most of the changes I made are departures from the reference implementation. I still wanted to share, though, so I'm posting a link to a gist instead of a pull request.
https://gist.github.com/m-n/8a15d864099778154529
I shortened some of the variable names and made an explicit Query struct. I use a corresponding parse function to move the query parsing logic out of the control loop. In my version (and the official Rust version), the timetable is not its own struct, though -- just a vector of connections.
The biggest change was refactoring the CSA. I kept two functions: query, which takes a timetable and a query and returns the best route as a vector of connections, and print_result, which iterates over the vector of connections and prints them.
Does the code has really to be the the "most unreadable" (see README)?
The example in the readme works fine
#input.txt
1 2 3600 7200
2 3 7800 9000
1 3 3000
$ cat input.txt | ./csa_cpp
1 2 3600 7200
2 3 7800 9000
but if the input connections are inverted, the algorithm does not output a solution.
#input2.txt
2 3 7800 9000
1 2 3600 7200
1 3 3000
$ cat input2.txt | ./csa_cpp
NO_SOLUTION
The algorithm seems very similar to the Bellman–Ford shortest path algorithm. I think to fix the algorithm you have to repeat the computation of computing the earliest arrival for the number of stations - 1, so something like:
For #station - 1
For each connection c
if arrival_timestamp[c.departure_station] < c.departure_timestamp and arrival_timestamp[c.arrival_station] > c.arrival_timestamp
arrival_timestamp[c.arrival_station] ← c.arrival_timestamp
in_connection[c.arrival_station] = c
In many implementations the pruning condition is
if connection.arrivalTime > earliestArrivalTime then break loop
This is incorrect since we can't make assumptions on arrival times.
The correct pruning condition is
if connection.departureTime >= earliestArrivalTime then break loop
Pull request that addresses the issue: #32
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.