Prolog

2 DESIGN SUBMISSION

A train can stop at any station.
two trains must stop at either the two stations
trains can change direction using the red turntable
All trains must pass through the desired direction.
No halting on the tracks for any train.
No trains should run into each other.
Two trains may use the same track and must be able to stop at either the two stations

Question one
onSimpletrack(oneTrain)
One train is allowed on simple track.

Question two
onSeperatetrack(oneTrain)
One train is allowed on seperate track

Question three
track(trainA,stationA):-track(trainB,stationB) .
Both trains can use same track and stop at either stations

Question four
track(trainA):-trainB(track) .
Trains can bypass

Question five
track(trainA,stationA):-track(trainB,stationB) .
:-turntable(red)
can bypass and turn

No halting
haltOntrack(notrain) .

allowed(X):-onSimpletrack(X).
?- allowed(oneTrain).

allowed(X):-onSeperatetrack(X).
?- allowed(oneTrain).

3.REPORT SUBMISSION

As the controller of the Rodos railway system I have developed a system that ensures no trains collide using several constraints for each layout. I first developed pseudo code for the following tracks the simple track that ensures one train is only permitted, the seperate track in question two that also permits one train, two trains using same track and having permission to stop at any track. Finally i developed pseudo code for the final tracks having switches and a red turntable. I then developed predicates suitable for the requirements using prolog 7.6.4.I then tested the predicates and axioms.
System requirements
No signaling at the tracks.
Determine accessible tracks automatically
All stations open for all trains
Correct switching
No running past rails
No halting on the rails
Seperate track for rails
The design was not changed for the system
To enable the implementation of the specifications I defined rules or facts as per the clauses. I developed appropriate predicates and axiom for each case for question one the predicate was simpleTrack and the axiom was the train itself.For question two the predicate was seperateTrack with train as the axiom also.The rest of the questions had tracks as predicates and additional rules to handle the complexity.
allowed(X):-onSimpletrack(X).
?- allowed(oneTrain).

allowed(X):-onSeperatetrack(X).
?- allowed(oneTrain).
The above tests yielded a yes
The above system can prevent simple train collisions that Rodos wants to eliminate. Its true that crashes lead to financial loss and even death which reduces its effectiveness leading to losses. It is important for any transport system to have automated checks for safety
%commands to the interpreter are submitted from stdin input (‘show input’ box below)
%’halt.’ will be automatically appended to stdin input.
%swi-prolog 7.6.4

program :- write(‘Rodos railway’).
:- program.
onSimpletrack(oneTrain).
onSeperatetrack(oneTrain) .
track(trainA,stationA):-track(trainB,stationB) .
track(trainA):-trainB(track) .
track(trainA,stationA):-track(trainB,stationB) .
:-turntable(red) .
allowed(X):-onSimpletrack(X).
?- allowed(oneTrain).

allowed(X):-onSeperatetrack(X).
?- allowed(oneTrain).

Tags: