Re: simple london underground query system




sheddy wrote:
Hello everyone,

I'm trying to teach myself prolog by attempting to program a system
that stores information about stations on one london underground line
and allows the user to ask simple questions. For example, how many
stops from station x to station y? How long will it take to get to
station x from station y? Which stations allow me to connect to line x?
and which one is closest?

The information i need to store is the station name (obviously), the
time it takes to travel between one station and the next (e.g. 3 mins)
and the names of the lines that the station interchanges with (e.g.
circle or northern). Some stations can interchange with more than one
line but then some don't interchange with any.

How would i go about this? I did some very basic prolog during a-level
computing and that was a few years ago now.

Any pointers would be greatly appreciated!

Thanks
You also need to record adjacent stations in given directions.
eg
station(5,tottenham_court_road,zone1,underground,354,feet,no_disabled).
segment(tottenham_court_road,[northern],south,leicester_square,2).
segment(tottenham_court_road,[northern],north,goodge_street,3).
segment(tottenham_court_road,[central],east,holborn,1).
segment(tottenham_court_road,[central],west,oxford_circus,2).

There are some multiple choices eg kennington:-

station(3,kennington,zone2,undergound,212,feet,no_disabled).
segment(kennington,[northern],south,oval,2).
segment(kennington,[northern,charing_cross_branch],north,waterloo,3).
segment(kennington,[northern,bank_branch],north,elephant_and_castle,4).

I suggest using the list for the lines so you can add sublines as shown
but as easily this can be added as "line,," or "line, subline" (since
there are no subsublines).

Obviously it may be more efficient in search time to use the station
numbers instead of the atomic names in the segment clauses.

This is just a serving sample and all data is fictitious. Note that the
technique for doing this is data analysis and entity-relationships
(diagrams or other). I have not verified that the data model suggested
is suitable for your purpose and you should do this before you start
coding in earnest. Maybe you would want to add platform numbers to
"segments" so you could print out detailed directions. Good luck
finding this information!

For the simple purpose you have in mind it may be ok to de-normalise
the segment relation and store it with the station-fact but I think
this would bind you in knots in the central zone.

Note that the tube network is a network and not a tree - so be sure you
program in something to prevent looping when searching for routes.

google suggests:
<http://www.informatik.uni-freiburg.de/~ml/teaching/ws02/lll/lll2_small.pdf>
I couldnt find it, but I feel sure this has been done before....

HTH
JJ

.



Relevant Pages

  • Re: Soccer Mom drivers
    ... I'll tell you how stupid drivers are in Las Vegas. ... the store at the gasoline station I was unloading at. ... inside the car. ...
    (misc.transport.trucking)
  • Newbie: Need advice with database manipulation decision
    ... I created a small application that is supposed to manipulate meteorological ... save them in a text file to be imported later into Excel. ... Scan through all the data from a specific station and through Date/Time ... therefore store the data locally. ...
    (microsoft.public.dotnet.languages.vb)
  • Newbie: Need advice with database manipulation decision
    ... I created a small application that is supposed to manipulate meteorological ... save them in a text file to be imported later into Excel. ... Scan through all the data from a specific station and through Date/Time ... therefore store the data locally. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Trap BrowserClose event so can Logout Session
    ... I suppose you could store the remote IP Address of the machine when they ... first log in (you could store it in Cache with a key that matches the ... They move to another station and want to login. ... We don't want concurrent logins from different stations. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Fuel Prices, dont let the facts get in the way.
    ... > experiences of delivering gasoline. ... > a station to become a major seller the station needs a store where the soda ... of gas station / convenience stores where the gas is expensive and store items ...
    (misc.transport.trucking)