A Permutation-based algorithm to optimally reschedule trains in railway traffic network

CHAPTER - 1
INTRODUCTION

1

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
In this paper we discuss dynamic traffic management of railway traffic networks at
an operational level. We design a model predictive controller based on measurements of
the actual train positions. The core of the model predictive control approach is the railway
traffic model, for which a switching max-plus linear system is proposed. If the model is
affine in the controls, the optimisation problem can be recast as a mixed-integer linear
programming problem. To this end we present a permutation-based algorithm to model
the rescheduling of trains running on the same track. We apply the algorithm to a simple
railway traffic network simulation model and show a significant reduction of delays
compared to the uncontrolled case.

1.1 MOTIVATION
The motivation for the research is to provide signallers with better decision support
than is currently available in operational control systems. In this thesis, existing
algorithms for optimal train rescheduling are reviewed and a new algorithm is
developed. In which rescheduling approaches discussed in this thesis, only deal with
timetable disturbances and does not include rerouting of trains.
In certain circumstances, if only one train is delayed, and only a small local area is
considered, train rescheduling can be a straightforward problem. However, as the
number of trains and the geographic area under consideration increase, the problem
becomes more complex. Furthermore, each of the trains may be of a different type
(high speed, commuter or freight). This means that each train will have different
accelerating and braking rates and a different top speed. The problem of deciding
upon an optimal solution then becomes even more complex, even for a simple
scenario.
There are many different algorithms that can be used for optimisation; each has its
own strengths and weaknesses. For real-time train control, in practice, there is a trade
off between computation time and the identification of an optimal solution, i.e., the best
possible solution. It is not straightforward to choose the most suitable algorithm to reduce
the delay. The early chapters of this thesis therefore aim to compare and discuss a number
of potential algorithms suitable for real-time railway control, in terms of required
computation time and solution optimality. Eight optimization algorithms are selected for
testing on four railway rescheduling benchmark scenarios.
Based on a comparison and discussion of the algorithms’ implementation, the
strengths and weaknesses of these algorithms are concluded with respect to the
2

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
railway rescheduling problem. The approach with the best performance is selected for
further study. In order to have a better resolution in a shorter computing time, further
research and analysis is carried out on the selected approach.
Finally, a new approach to optimal multi-junction rescheduling for a control region is
developed and tested, and then refined.
For all of the rescheduling approaches discussed in this thesis, it is very important to
estimate the running time as accurately as possible. Therefore, a multi train simulator
is designed and built is this thesis. Since a significant amount of work was conducted
on this simulator, the concepts and functions are introduced and the techniques and the
equations are illustrated in detail in Appendix A. In addition, the rescheduling solutions
are further examined by means of the Railway Traffic Controller (RTC) software which is
the American standard software to plan and control railway traffic.

1.2 PROBLEM DEFINITION
Railway timetabling and rescheduling play a central role in day-to-day railway
operations. Trains on a railway network are scheduled and controlled according to a
timetable. Timetables are designed to be conflict free, that is, they should not contain
any situations where a train is restricted in its scheduled movement by another train.
However, in practice not all trains run according to the timetable due to delays such as
excessive dwell times at stations, infrastructure and/or train faults, and the late arrival
of crew. When trains do not operate according to the timetable, even by only a few
seconds, there is an increased likelihood that they will cause conflicts with other trains,
resulting in those trains also being delayed. Railway operators therefore attempt to run
trains to timetable, or, failing this, they try to minimise the cost of delays.
Generally, in today’s railways, most train control is carried out by human operators –
signallers. They are able to control the operation of signals to reschedule and prioritise
traffic flows. In simple scenarios, signallers are able to manage the flow of traffic
effectively. However, it has been shown that, as situations become more complex,
there is an increased likelihood of signallers making sub-optimal traffic management
decisions. This is particularly likely in significantly disturbed situations (Balfe et al.,
2007).
In the UK, 49% of trains arrive at their destination ‘on time’ i.e., on or before their
scheduled timetable time (Best and Hyland, 2012). This means that 51% of trains are
late. Signallers need support in deciding upon the most appropriate train rescheduling
(train speed and sequences) to minimise the potential for further delays.
3

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

Figure 1-1: Statistics of train lateness in 2010/11by Network Rail (Best and Hyland, 2012)

In recent years, railway operators have sought to find technology based solutions that
can help signallers make improved decisions. Such decision support or automatic
control systems have been deployed on many networks . In general they
rely on straightforward heuristic algorithms. These simple algorithms are able to
provide useful solutions in many cases, but, as situations become more complex, they
do not perform well .Therefore, many researchers throughout the
world have considered the use of more advanced algorithms as part of real-time
optimisation systems for railway traffic management.

1.3 OBJECTIVE OF THE PROJECT
We have presented a control design method for a railway network. The control action
consists in breaking certain connections or changing the order of departure to prevent
delays from accumulating. These control moves can only be done at a certain cost. We
4

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
have shown that the resulting optimization problem is a mixed integer linear
programming (MILP) problem,that can be solved using existing commercial and free
solvers for MILP problems, orby other integer optimization methods, for example genetic
algorithms or tabu search.
Good initial values for the integer optimization are obtained by first solving a
lowdimensionalreal-valued optimization problem using a structured input sequence. This
structuredinput sequence is based on a decision mechanism, where we use thresholds on
(expected)delays to decide whether a connection should be broken or the order of the
trainsshould be switched.
Due to the use of a receding horizon this method can be used in on-line applications
and it can deal with (predicted) changes in the system parameters. So if we can predict
thedelays that will occur due to an incident or to works, then we can include this
information when determining the optimal control input for the next cycles of the
operation of the network.
The main objective of the project is we present a permutation-based algorithm to
model the rescheduling of trains running on the same track.
we design a predictive feedback controller that computes the most effective actions,
based on measurements of the actual train positions. The control measures are restricted
to changing the order of trains running on the same track.

1.4

LIMITATION S OF PROJECT
The Limitation of the project is,When the trains running on the same track, there is a

problem arised of conflicting of trains may be in two ways either in opposite direction or
same direction.

1.5 ORGANIZATION OF DOCUMENT
In this project documentation we have initially put the definition and objective of the
project as well as the design of the project which is followed by the implementation and
testing phases. Finally the project has been concluded successfully and also the future
enhancements of the project were given in this documentation.

5

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

CHAPTER - 2
6

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

LITERATURE SURVEY

2.1 INTRODUCTION
The operational-level management of railway traffic networks is mostly based on
predefined rules and on the ability of traffic controllers and train dispatchers to detect and
avoid conflicting situations. Delays caused by technical failures, fluctuation of passenger
volumes, and/or weather conditions can be partly absorbed by a stable and robust
timetable In the case of large delays, network managers might be forced to re-route or to
change the order of trains, break connections, or even cancel a scheduled service to
prevent the accumulation of delays in the network. In this paper we design a predictive
feedback controller that computes the most effective actions, based on measurements of
the actual train positions. The control measures are restricted to changing the order of
trains running on the same track. A railway network with rigid connection constraints and
a fixed routing schedule can be modeled using max-plus linear (MPL) models. An MPL
odel is linear in the max-plus algebra, which has maximisation and addition as its basic
7

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
operations.. In the railway context, synchronization means that some trains should give
predefined connections to other trains, and a fixed routing schedule means that the order
of departure is fixed. In this paper we model a controlled railway system using the
switching max-plus-linear system description of. In this description we use a number of
MPL models, each model corresponding to a specific mode, describing the network by a
different set ofconnection and order constraints. We control the system by switching
between different modes, allowing us to change the order of trains to minimise the delays
of all trains in the network while considering the cost of the control actions.

2.2 EXISTING SYSTEM:
Current practice in the operational-level management of railway traffic networks
is mostly based on predefined rules and on the ability of traffic controllers and train
dispatchers to detect and avoid conflicting situations. Delays caused by technical failures,
fluctuation of passenger volumes, and/or weather conditions can be partly absorbed by a
stable and robust timetable. In the case of large delays, network managers might beforced
to re-route or to change the order of trains, break connections, or even cancel a scheduled
service to prevent the accumulation of delays in the network.

2.3 DISADVANTAGES OF EXISTING SYSTEM
1) In this we use traffic controllers ,train dispatchers , network managers .
2) Using of manual power more.
3) Time complexity is high.
4) Exactness of problem is difficult.
5) Problem solution is not sufficient in some cases including small delays and large

delays

2.4 PROPOSED SYSTEM

8

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
In this paper we design a predictive feedback controller that computes the most
effective actions, based on measurements of the actual train positions. The control
measures are restricted to changing the order of trains running on the same track.

2.5 ADVANTAGES OF PROPOSED SYSTE
1) Time complexity is reduced.
2)

Manual power is lowered.

3)

Exact throughputs are obtained.

4)

Problem identification is very easier and solution to the problem became very fast.

2.6 CONCLUSION
We have presented an approach to optimally reschedule trains on a railway network
based on a permutation method.We have modeled the system based on the switching
max-plus framework and showed how the control problem can be recast as a mixedinteger linear programming problem. Compared to previous results we have extended the
control actions to change the departure and arrival order of non-subsequent trains. For a
simple railway network we have shown that by optimally rescheduling trains using the
proposed approach delays can be substantiallyreduced.

9

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

CHAPTER-3
ANALYSIS

3.1 FEASIBILITY STUDY
A feasibility study is a test of the system proposal regarding to its work ability, impact
on the organization, ability to meet user needs, and effective use of resources. Thus when
a new application is proposed, it normally goes through a feasibility study before it’s is
approved for development.
An important outcome of the preliminary investigation is the determination that the
system requested is feasible.

TECHNICAL FEASIBILITY:
10

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
Evaluating the technical feasibility is the trickiest part of a feasibility study. This is
because , at this point in time, not too many detailed design of the system, making it
difficult to access issues like performance, costs on ( account of the kind of technology to
be deployed) etc. A number of issues have to be considered while doing a technical
analysis.
1) Understand the different technologies involved in the proposed system :
Before commencing the project, we have to be very clear about what are the technologies
that are to be required for the development of the new system.
2) Find out whether the organization currently possesses the required technologies:
1) Is the required technology available with the organization?
2) If so is the capacity sufficient?

ECONOMIC FEASIBILITY:
Economic feasibility attempts 2 weigh the costs of developing and implementing a
new system, against the benefits that would accrue from having the new system in place.
This feasibility study gives the top management the economic justification for the new
system.
A simple economic analysis which gives the actual comparison of costs and benefits
are much more meaningful in this case. In addition, this proves to be a useful point of
reference to compare actual costs as the project progresses. There could be various types
of intangible benefits on account of automation. These could include increased customer
satisfaction, improvement in product quality better decision making timeliness of
information, expediting activities, improved accuracy of operations, better documentation
and record keeping, faster retrieval of information, better employee morale.

OPEARTIONAL FEASIBILITY:
Proposed projects are beneficial only if they can be turned into information systems
that will meet the organizations operating requirements. Simply stated, this test of
11

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
feasibility asks if the system will work when it is developed and installed. Are there
major barriers to Implementation? Here are questions that will help test the operational
feasibility of a project:
1) Is there sufficient support for the project from management from users? If the
current system is well liked and used to the extent that persons will not be able to
see reasons for change, there may be resistance.
2) Are the current business methods acceptable to the user? If they are not, Users
may welcome a change that will bring about a more operational and useful
systems.
3) Have the user been involved in the planning and development of the project?
4) Early involvement reduces the chances of resistance to the system and in
5) General and increases the likelihood of successful project.
Since the proposed system was to help reduce the hardships encountered. In the existing
manual system, the new system was considered to be operational feasible.

3.2 SOFTWARE SYSTEM SPECIFICATION
3.2.1 PURPOSE OF THE PROJECT
In recent years a lot of research effort has been oriented towards the design of
timetables that are robust against propagation of delays in the network, caused by
technical failures, fluctuation of passenger volumes, measures of railway personnel and
weather influence .
In this paper we concentrate on the operational-level management, and design a feedback
controller that takes the most effective actions, based on measurements of the actual train
positions. The measures we can take are changing the train speed, breaking train
connections, or changing the order of trains.
3.2.2 SCOPE OF THE PROJECT
Before estimating the train journey times one by one according to the order of passing
12

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
a junction area in the simulation when sequence is known, it is essential to introduce
the time superposition method first. This time superposition method is used when
more than one train could pass the junction area at the same time. By using this
method, the right of way signal time for each train can be given by the time one of the
front trains leaves the junction area, and the results of the superposition method will
show which train is the front train. Figure A-2 shows an example junction and Figure
A-3 presents the related right of way signal time of the sequence 1-2-3-4-5-6-7-8-910-11-12; the white block is the right of way signal time for each train; the black
block is the train running time of passing the junction area. The outputs of using the
superposition method are finding the exact front train that the current train should
follow.

13

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

3.3 SYSTEM CONFIGURATION
3.3.1 Software Specification
Operating System

:

Windows XP

Technology

:

JAVA 1.6

Application Server :

Tomcat5.0/6.X

Front End

:

HTML, Java, Jsp

Scripts

:

JavaScript.

Server side Script

:

Java Server Pages.

Database

:

MysQl

Database Connectivity : JDBC.

14

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
3.3.2 Hardware Specification
Processor

:

Pentium IV

RAM

:

256 MB

Hard Disk

:

80GB

Key Board

:

Standard Windows Keyboard

Mouse

:

Two or Three Button Mouse

3.4 PROJECT SOFTWARE SPECIFICATION
3.4.1 INTRODUCTION TO JAVA
CREATION OF JAVA:
Java was conceived by James Gosling, Patrick Naughton, Chris Warth, Ed Frank
and Mike Sheridan at SUN Microsystems Incorporation in the year 1991.It took 18
months to develop the 1st working version. This language was initially called “OAK”, but
was renamed “JAVA” in 1995, many more contributed to the design and evolution of the
language.
JAVA OVERVIEW:
Java is a powerful but lean object-oriented programming language. It has
generated a lot of excitement because it makes it possible to program for Internet by
creating Applets. Programs that can be embedded in web page. The context of an applet
can be an animation with sound, an interactive game or a ticker tape. With constantly
updated stock prices. Applets can be just little decorations to liven up web page, or they
can be serious applications like Word processor or Spreadsheet.
But Java is more than a programming language for writing Applets. It is being
used more and more for writing standalone applications as well. It is becoming so
popular that many people believe it will become standard language for both general
purpose and Internet programming.
There are many buzzwords associated with Java, but because of its spectacular
growth in popularity, a new buzzword has appeared ubiquitous. Indeed, all indications are
that it will soon be everywhere.
Java builds on the strength of C++. It has taken the best features of C++ and
discarded the more problematic and error prone parts. To this lean core, it has added
15

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
garbage collection (automatic memory management), multithreading (the capacity for
one program to do more than one thing at a time), security capabilities. This result is that
Java is simple, elegant, and powerful and easy-to-use.
Java is actually a platform consisting of 3 components:
1) Java Programming Language.
2) Java Library of Classes and Interfaces.
3) Java Virtual Machine
3.4.2 FEATURES OF JAVA
Distributed
Java has an extensive library of routines for coping with TCP/IP protocols like
HTTP and FTP Java applications can open and access across the Net via URLs with the
same ease as when accessing local file system.
We have found the networking capabilities of Java to be both strong and easy to
use. Anyone who has tries to do Internet programming using another language will revel.
How simple Java makes onerous tasks will like opening a socket connection.
Robust
Java is intended for writing programs that must be readable in a Variety ways. Java
puts a lot of emphasis on early checking for possible problems, later dynamic checking,
and eliminating situations that are error prone. The single biggest difference between
The Java compiler detects many problems that in other languages would only show
up at runtime. As for the second point, anyone who has spent hours chasing a memory
leak cost by a printer bug will be very happy with this feature of Java.
Java gives you the best of both worlds. You need not pointers for everyday constructs like
string and arrays. You have the power of pointers if you need it, for example, for like
lists. And you have always-complete safety, since you can never access a bad pointer or
make memory allocation errors.
Secure
Java is intended to be used in networked/distributed environment toward that end; a
lot of emphasis has been placed on security. Java enables the contraction of virus-free,
temper-free systems.
16

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
Here is a sample of what Java’s security features are supposed to keep a Java
programming from doing:
1. Overrunning the runtime stack.
2. Corrupting memory outside its own process space.
3. Reading or writing local files when invoked through a securityConscious class loaders like Web browser.
Portable
Unlike C and C++, they are no "implementation dependent" aspects of the
specifications. The sizes of the primitive’s data types are specified, as is the behavior of
arithmetic on them.
For example, an int in Java is always a 32-bit integer. In C/C++, int can mean a 16-bit
integer, a 32-bit integer, or any size the compiler vendor likes. The only restriction is that
it must have at least as many bytes int and cannot have more bytes than a long int.
The libraries that are a part of the system define portable interfaces. For example, there is
an abstract window class and implementations of it UNIX, Windows, and the Macintosh.
Interpreted
The Java interpreters can execute Java byte codes directly on any machine to which
the interpreter has been ported. Since linking is a more incremental and lightweight
process, the development process can be much more rapid and explanatory.
One problem is that the JDK is fairly slow at compiling your source code to the bytecode
that will, ultimately, be interpreted in the current version
Multithreaded
In a number of ways, Java is more dynamic language than C or C++. It was designed
to adapt to an evolving environment. Libraries can freely add new methods and instance
variables without any effect on their clients.... In Java, finding out run time type
information is straightforward.
This is an important feature in those situations where code needs to be added to a running
program. A prime example is code that is downloaded from the Internet to run in browser.
3.4.3 SERVLETS

17

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
Servlets provides a Java-Based solution used to address the problems currently
associated with doing server side programming, including inextensible scripting
solutions, platform specific APIs, and incomplete interfaces. Servlets are objects conform
to a specific interface that can be plugged into a Java-based server. Servlets are to the
server-side what applets are to the client-side-object byte codes that can be dynamically
loaded off the net. They differ from applets in that they are faceless objects (without
graphics or a GUI component). They serve as platform independent, dynamically
loadable, plug gable helper byte code objects on the server side that can be used to
dynamically extend server-side functionality.
THE ATTRACTIVE OF SERVLETS:
There are many features of servlets that make them easy and attractive to

use.

These include:
Easily configured using the GUI-based Admin Tool.
Can be loaded and invoked from a local disk or remotely across the network.
Can be linked together, or chained, so that one servlet can call another servlets, or several
servlets in sequence.
Can be called dynamically from within HTML pages, using server-side include tags
INVOKING THE SERVLET:
To invoke a servlet you call it by creating a URL with “/servlet/” pretended to the
servlet name. Then enter this URL in your favorite browser to see the output of the
Servlet.
Example:
After installing according to the directions above, access the HelloServlet by entering
the following URL in your favorite browser:
http://server-host-name:8080/servlet/hell
18

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
INTERNAL SERVLETS:
The Java Server servlet architecture is very flexible and the server takes
advantage of this by dividing up its work among several internal servlets. These are
File Servlet
Invoker Servlet
Server side include servlet
Admin Servlet
CGI Servlet
Image map servlet
3.4.4 INTRODUCTION TO JDBC
JDBC (Java Database connectivity) is a front-end tool for connecting to a server to
ODBC in that respect, however JDBC can connect only java client and it uses ODBC for
the connectivity. JDBC is essentially a low-level API since any data manipulation,
storage and retrieval has to be done by the program itself. Some tools, which provide a
higher-level abstraction, are expected shortly.
The next question that needs to be answered is why we need JDBC, once we have ODBC
on hand. We can use the same ODBC to connect the entire database and ODBC is a
proven technology.
Problem for doing this is ODBC gives a ‘c’ language API, which uses pointers
extensively. Since java does not have any pointes and is object-oriented sun
Microsystems, inventor of java developed to suit its needs.
REQUIREMENTS TO USE JDBC:
To use JDBC you need a basic knowledge of databases and SQL.A part from this you
need the jdk1.1 (Java Development Kit1.1 available javasoft’s website) or a version of
Java since jdk1.1 and above come bundled with JDBC software.
After that you need to have a back-end database engine for which a JDBC driver is
available. When JDBC drivers are not available JDBC-ODBC bridge drivers are used to
access the database through ODBC.Back-end is not needed when JDBC driver is capable

19

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
of storing and retrieving the data itself, or if JDBC-ODBC Bridge and the ODBC driver
can be used to store and retrieve the information.
3.4.6 DATA BASE MODELS
JDBC and accessing the database through applets and JDBC.API via an intermediate
server resulted server resulted in a new type of database model which is different from
the client-server model. Based on number of intermediate server through the request
should go it is named as single tire, two tire and multi tire architecture
SINGLE TIER:
In a single tier the server and client are the same in the sense that a client program
that needs information (client) and the source of this type of architecture is also possible
in java, in case flat files are used to store the data. However this is useful only in case of
small applications. The advantage with this is the simplicity and portability of the
application developed.

TWO TIER (CLIENT-SERVER):
In two architecture the database resides in one machine the network. In this type of
architecture a database management takes control of the database and provides access to
clients in a network. This software bundle is also called as the server. Software in
different machines, requesting for information are called as the clients.

20

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

THREE TIER AND N-TIER:
In the three-tier architecture, any number servers can access the database that
resides on server. Which in turn serve clients in a network. For example, you want to
access the database using java applets, the applet running in some other machine, can
send request only to the server from which it is down loaded. For this reason we will need
to have a intermediate server which will accept the requests from applets and them to the
actual database server. This intermediate server acts as a two-way communication
channel also. This is the information or data from the database is passed on to the applet
that is requesting it. This can be extended to make n tiers of servers, each server carrying
to specific type of request from clients, however in practice only 3 tiers architecture is
popular.

3.5 CONCLUSION
In this phase, we understand the software requirements specifications for the
project. We arrange all the required components to develop the project in this phase
itself so that we will have a clear idea regarding the requirements before designing the
project. Thus we will proceed to the design phase followed by the implementation phase
of the project.

21

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

CHAPTER – 4
DESIGN

4.1 INTRODUCTION
4.1.1 INPUT DESIGN
The input design is the link between the information system and the user. It
comprises the developing specification and procedures for data preparation and those
steps are necessary to put transaction data in to a usable form for processing can be
22

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
achieved by inspecting the computer to read data from a written or printed document or it
can occur by having people keying the data directly into the system. The design of input
focuses on controlling the amount of input required, controlling the errors, avoiding
delay, avoiding extra steps and keeping the process simple. The input is designed in such
a way so that it provides security and ease of use with retaining the privacy. Input Design
considered the following things:
1) What data should be given as input?
2) How the data should be arranged or coded?
3) The dialog to guide the operating personnel in providing input.
4) Methods for preparing input validations and steps to follow when error occur.
4.1.2 OBJECTIVES
Input Design is the process of converting a user-oriented description of the input
into a computer-based system. This design is important to avoid errors in the data input
process and show the correct direction to the management for getting correct information
from the computerized system.
It is achieved by creating user-friendly screens for the data entry to handle large
volume of data. The goal of designing input is to make data entry easier and to be free
from errors. The data entry screen is designed in such a way that all the data manipulates
can be performed. It also provides record viewing facilities
When the data is entered it will check for its validity. Data can be entered with the
help of screens. Appropriate messages are provided as when needed so that the user will
not be in maize of instant. Thus the objective of input design is to create an input layout
that is easy to follow
4.1.3 OUTPUT DESIGN
A quality output is one, which meets the requirements of the end user and presents the
information clearly. In any system results of processing are communicated to the users
and to other system through outputs. In output design it is determined how the
information is to be displaced for immediate need and also the hard copy output. It is the
most important and direct source information to the user. Efficient and intelligent output
design improves the system’s relationship to help user decision-making.
1. Designing computer output should proceed in an organized, well thought out manner;
the right output must be developed while ensuring that each output element is designed so
that people will find the system can use easily and effectively. When analysis design
computer output, they should Identify the specific output that is needed to meet the
requirements.
2. Select methods for presenting information.
23

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
3. Create document, report, or other formats that contain information produced by the
system.
The output form of an information system should accomplish one or more of the
following objectives.
1) Convey information about past activities, current status or projections of the
2) Future.
3) Signal important events, opportunities, problems, or warnings.
4) Trigger an action.
5) Confirm an action

4.2 UML DIAGRAMS
4.2.1 INTRODUCTION
UML is a method for describing the system architecture in detail using the
blueprint.UML represents a collection of best engineering practices that have proven
successful in the modeling of large and complex systems.
UML is a very important part of developing objects oriented software and the
software development process.
UML uses mostly graphical notations to express the design of software projects.
Using the UML helps project teams communicate, explore potential designs, and validate
the architectural design of the software.
Definition
UML is a general-purpose visual modeling language that is used to specify, visualize,
construct, and document the artifacts of the software system.
UML is a language
It will provide vocabulary and rules for communications and function on
conceptual and physical representation. So it is modeling language.
UML Specifying
Specifying means building models that are precise, unambiguous and complete. In
particular, the UML address the specification of all the important analysis, design and
implementation decisions that must be made in developing and displaying a software
intensive system.
UML Visualization
The UML includes both graphical and textual representation. It makes easy to
visualize the system and for better understanding.
24

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
UML Constructing
UML models can be directly connected to a variety of programming languages
and it is sufficiently expressive and free from any ambiguity to permit the direct
execution of models.
UML Documenting
UML provides variety of documents in addition raw executable codes.

Fig 4.1: Modeling a System Architecture using views of UML
The use case view of a system encompasses the use cases that describe the
behavior of the system as seen by its end users, analysts, and testers. The design view
of a system encompasses the classes, interfaces, and collaborations that form the
vocabulary of the problem and its solution. The process view of a system
encompasses the threads and processes that form the system's concurrency and
synchronization mechanisms. The implementation view of a system encompasses the
components and files that are used to assemble and release the physical system. The
deployment view of a system encompasses the nodes that form the system's hardware
topology on which the system executes.

Uses of UML
The UML is intended primarily for software intensive systems. It has been used
effectively for such domain as
Enterprise Information System
Banking and Financial Services
Telecommunications
25

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
Transportation
Defense/Aerospace
Retails
Medical Electronics
Scientific Fields
Distributed Web
Building blocks of UML
The vocabulary of the UML encompasses 3 kinds of building blocks
Things
Relationships
Diagrams
Things
Things are the data abstractions that are first class citizens in a model. Things are of 4
types
Structural Things, Behavioral Things , Grouping Things, An notational Things
Relationships
Relationships tie the things together. Relationships in the UML are
Dependency, Association, Generalization, Specialization
UML Diagrams
A diagram is the graphical presentation of a set of elements, most often rendered as a
connected graph of vertices (things) and arcs (relationships).
There are two types of diagrams, they are
Structural and Behavioral Diagrams

Structural Diagrams
The UML‘s four structural diagrams exist to visualize, specify, construct and
document the static aspects of a system. View the static parts of a system using one of
the following diagrams. Structural diagrams consist of Class Diagram, Object Diagram,
Component Diagram, and Deployment Diagram.
Behavioral Diagrams

26

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
The UML’s five behavioral diagrams are used to visualize, specify, construct, and
document the dynamic aspects of a system. The UML’s behavioral diagrams are roughly
organized around the major ways which can model the dynamics of a system.
Behavioral diagrams consists of
Use case Diagram, Sequence Diagram, Collaboration Diagram, State chart Diagram,
Activity Diagram
4.2.2 CLASS DIAGRAM
Class diagrams are widely used to describe the types of objects in a system and
their relationships. Class diagrams model class structure and contents using design
elements such as classes, packages and objects. Class diagrams describe three different
perspectives when designing a system, conceptual, specification, and implementation.
These perspectives become evident as the diagram is created and help solidify the design.
Class diagrams are arguably the most used UML diagram type. It is the main building
block of any object oriented solution. It shows the classes in a system, attributes and
operations of each class and the relationship between each class. In most modeling tools a
class has three parts, name at the top, attributes in the middle and operations or methods
at the bottom..

Attribute

Shape
-origin

Name

Move ( )
Resize ( )

Fig 4.2 : Example Class Diagram

27

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

Train simulation

Simulation

+simulation: int
+statistics: int

+default direction: int
+speed control: int

+checks the details(): void
+consist of overall details(): void
+maintainence(): void

+checks the speed(): void
+changes the direction(): void

Default direction

Train Simulation
+auxilary counter: int
+track circuits: int
+slots: int

Speed control

+changes the direction(): void
+of the track(): void

+change the speed(): void

+controls the devices(): void
+collects the information(): void
+sends the simulator(): void
24 slots
+generate signals(): void
+stops the train(): void

Auxilary counter
+Counts the no.of wheels(): void

Track circuit
+change sthe track(): void

Fig 4.3 : Class Diagram
4.2.3 USE-CASE DIAGRAM
A use case is a set of scenarios that describing an interaction between a user and a
system. A use case diagram displays the relationship among actors and use cases. The
two main components of a use case diagram are use cases and actors.

Fig 4.4: Elements of use-case Diagram

28

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
An actor is represents a user or another system that will interact with the system you
are modeling. A use case is an external view of the system that represents some action
the user might perform in order to complete a task.
Contents:

Use cases

Actors

Dependency, Generalization, and association relationships

System boundary

Observes

Train Simulation

Sends the details

user

+Passes the details

Simulation

Default direction

Train statistics

Auxilary counter

Simulation speed

Track circuit

24 Slots

Fig 4.5 : Use-Case Diagram(1)

29

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

Set Parameters

Start Simulation

Division Head

Simulation started by parameters

System

Train status

Fig 4.6 : Use Case diagram(2)
4.2.4 SEQUENCE DIAGRAM
Sequence diagrams in UML shows how object interact with each other and the
order those interactions occur. It’s important to note that they show the interactions
for a particular scenario. The processes are represented vertically and interactions are
show as arrows
1) Show the dynamic collaboration between objects for a sequence of messages sent
between them in a sequence of time

2) Time sequence is easier to see in the sequence diagram, read from top to bottom

3) Choose sequence diagram when only the sequence of operations needs to be
shown

30

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

Object2

Object1

1

Fig 4.7 : Example Sequence Diagram

Division Head

Simulation

Train Status

Paramter Initialization

1 : View trains Movement by map()

2 : Can view current station info,direction,platform()

3 : Can intialize trains count,speed,direction,min&max insertion time()

Fig 4.8 : Sequence Diagram(1)

31

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

User

Train Simulation

Simulation

Train Statistics

Auxilary Corner

Track Circuit

24 Slots

Section

Default Direction

1 : Simulate()
2 : Simulate()

3 : Status()

4 : Location Of tarin()

5 : Changes the Direction()
6

7
8 : Sends the information of train()

9 : Changes the track()
10

11 : Changes the signal()
12

13 : Passes Information about Train()
14 : Details()
15
16

Fig 4.9 : Sequence Diagram(2)
4.2.5 COLLABORATION DIAGRAM
Communication diagram was called collaboration diagram in UML. It is similar
to sequence diagrams but the focus is on messages passed between objects. The same
information can be represented using a sequence diagram and different objects.

32

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

Fig 4.10 : Collaboration Diagram(1)

Fig 4.11 : Collaboration Diagram(2)

33

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
4.2.6 ACTIVITY DIAGRAM
Activity diagrams describe the workflow behavior of a system. Activity diagrams
are similar to state diagrams because activities are the state of doing something. The
diagrams describe the state of activities by showing the sequence of activities
performed. Activity diagrams can show activities that are conditional or parallel
Activity diagrams should be used in conjunction with other modeling techniques
such as interaction diagrams and state diagrams. The main reason to use activity
diagrams is to model the workflow behind the system being designed. Activity
Diagrams are also useful for: analyzing a use case by describing what actions need to
take place and when they should occur; describing a complicated sequential
algorithm; and modeling applications with parallel processes.
1) Show the sequential flow of activities
2) Typically in an operation
3) Also in a use case or event trace
4) Complement the class diagram by showing the workflow of the business (aka
“Flowchart”)
5) Encourage discovery of parallel processes which helps eliminate unnecessary
sequences in business processes
Elements

Symbols

Initial state

Final state

Action state

Control flow
34

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

Fig 4.12 : Activity Diagram
4.2.7 STATE CHART DIAGRAMS
State chart diagrams are similar to activity diagrams although notations and usage
changes a bit. They are sometime known as state diagrams or start chart diagrams as
well.. Below State machine diagram show the basic states and actions.

Train Simulation

Train Status

Track Circuits

lB section

Fig 4.13 : State Chart Diagram
35

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
4.2.8 COMPONENT DIAGRAM
A component diagram displays the structural relationship of components of a
software system. These are mostly used when working with complex systems that have
many components.. Below images shows a component diagram.

Train Simulation

Train Status

Track circuit
Auxilary Counter

Division Head

Fig 4.14 : Component Diagram
4.2.9 DEPLOYMENT DIAGRAM
A deployment diagrams shows the hardware of your system and the software in those
hardware. Deployment diagrams are useful when your software solution is deployed
across multiple machines with each having a unique configuration

Train Simulation1
Train Status1

Parameter Initilization

Fig 4.15 : Deployment Diagram

36

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

4.3 LOGICAL DESIGN
Logical design is a process through which requirements are translated into a
representation of software. Initially the representation depicts a holistic view of software.
Subsequent refinement leads to a design representation that is very close to source code.
The conceptual structure of a database is called a schema. Schema shows the kinds of
data that exists in a database and how the kinds of data are logically related to each other.
A schema can be regarded as a blueprint that portrays both kind of data used in building a
database and logical relationship that exist among various kinds of data. At the minimum,
the schema must represent all needed data items, must correctly represent their
interrelationships, and must be able to support all reports. Schema is frequently depicted
pictorially using Data Flow Diagrams (DFD).
4.3.1 DATA FLOW DIAGRAMS
Data Flow Diagrams (DFD) depicts information flow and transforms that are applied
as data move from input to output. The DFD is also known as Data Flow Graph or
Bubble Chart. It is the starting point of the design phase that functionality decomposes
the requirement specification down to the lowest level of details. Thus, a DFD describes
what data flows (logical) rather than how they are processed. Data Flow Diagrams are
made up of number of symbols which represent system components. Data Flow modeling
methods used for kinds of symbols. These symbols are used to represent four kinds of
system components. Processes, Data Stores, External Entities, Data Flows.
Processes
Processes show what system does. Each process has one or more data inputs and
produces one or more data outputs. Processes are represented by round rectangles in
DFD.
Data Stores
A file or data stores is repository of data. Processes can enter data into a store or
retrieve data from data store. The line in the DFD and each store represents each data
store as a unique name.

37

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

External Entities
External entities are outside the system but they supply either input data into the
system or used for the system output. They are entities on which the designer has no
control. There may be an organization or other bodies with which system interacts.
Data Flows
Data Flows model the passage of data on the system and represented by the lines
joining the system components. An arrow indicates the direction of flow and line is
labeled by the name of data flow. Flow of data in the system can take place
1) Between two processes
2) From a data store to a process
3) From a process to a process
4) From source to a process
Data flow diagrams are used to describe how the system transforms information. They
define how information is processed and stored and identify how the information flows
through the process.
When building a data flow diagram, the following items should be considered:
1) Where does the data that passes through the system come from and where
does it go.
2) What happens to the data once it enters into the system (i.e., the inputs) and
before it leaves the system (i.e., the outputs).
3) What delays occur between the inputs and outputs (i.e. identifying the needs
for data stores).
Steps to Draw a Data Flow Diagram:
1) Start from the context diagram Identify the parent process and external entities
with their net inputs and outputs.
2) Place the external entities on the diagram. Draw the boundary.
38

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
3)

Identify the data flows needed to generate the net inputs and outputs to the external

entities.
4)

Identify the business processes to perform the work needed to generate the input and

output data flows.
5)

Connect the data flows from the external entities to the processes.

6)

Identify the data stores.

7)

Connect the processes and data stores with data flows.

8)

Apply the processes Model Paradigm to verify that the diagram addresses the

processing needs of all external entites.
9)

Apply the processes Model Paradigm to further validate that the flows to the external

entites are correct.
10) Connect the data flows from the external entites to the process.
11) Identify the data stores.
12) Connect the data stores and processes with data flows.
13) Apply the processes Model Paradigm to verify that the diagram addresses the
processing needs of all external entites.
14) Apply the External Control Paradigm to further validate that the flows to the external
entites are correct.
15) Continue to decompose to the nth level DFD. Draw all DFDs at one level before
moving to the next level of decomposing detail. You should decompose horizontally first
to a sufficient nth level to ensure that the processes are partitioned correctly; then you can
begin to decompose vertically.

39

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
DFD SYMBOLS:
In the DFD, there are four symbols
1) A square defines a source(originator) or destination of system data
2) An arrow identifies data flow. It is the pipeline through which the information
flows
3) A circle or a bubble represents a process that transforms incoming data flow into
outgoing data flows.
4) An open rectangle is a data store, data at rest or a temporary repository of data

Process that transform data flow

Source or Destination of data

Data flow

Data Store

40

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
CONSTRUCTING A DFD:
Several rules of thumb are used in drawing DFD’S:
1) Process should be named and numbered for an easy reference. Each name should
be representative of the process.
2) The direction of flow is from top to bottom and from left to right. Data
traditionally flow from source to the destination although they may flow back to
the source. One way to indicate this is to draw long flow line back to a source.
An alternative way is to repeat the source symbol as a destination. Since it is used
more than once in the DFD it is marked with a short diagonal.
3) When a process is exploded into lower level details, they are numbered.
4) The names of data stores and destinations are written in capital letters. Process
and dataflow names have the first letter of each work capitalized
A DFD typically shows the minimum contents of data store. Each data store should
contain all the data elements that flow in and out.
Questionnaires should contain all the data elements that flow in and out. Missing
interfaces redundancies and like is then accounted for often through interviews.
SAILENT FEATURES OF DFD’S:
1) The DFD shows flow of data, not of control loops and decision are controlled
considerations do not appear on a DFD.
2) The DFD does not indicate the time factor involved in any process whether the
dataflow take place daily, weekly, monthly or yearly.
3) The sequence of events is not brought out on the DFD.

41

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

4.3.2 LEVEL 0:
CONTEXT LEVEL DIAGRAM:

Fig 4.16 : Context Level Diagram

4.3.3 LEVEL 1:
TOP LEVEL 0:

Fig 4.17 : Top Level 0 Diagram

42

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

4.3.4 LEVEL 2:
DETAIL LEVEL 0:

Fig 4.18 : Detail Level 0 Diagram
DETAIL LEVEL 1:

Fig 4.19 : Detail Level 1 Diagram
43

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

4.4 CODING
CTS.JAVA
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class CTS { //implements ActionListener, MouseListener
// variables
private CTSParameters ctsp;
private CTSScreen ctsScreen;
private CTSEngine ctsEngine;
private CTSStats stats;
/**
* Constructor of this class.
*/
public CTS() {
ctsp = new CTSParameters();
stats = new CTSStats(ctsp);
ctsScreen = new CTSScreen(ctsp,this,stats);
ctsEngine = new CTSEngine(ctsp,ctsScreen,stats);
}
/**
* Starts the simulation.
**/
public void start() {
ctsEngine.start();
ctsEngine.setTimer('s');
}
/**
* Restarts the simulation.
**/
public void restart() {
ctsEngine.setTimer('s');
}
/**
* Pause the simulation.
**/
public void pause() {
ctsEngine.setTimer('p');
}
/**
* Sets the station status to be true or false.
*
* @param st: The station number.
* @param status: The status.
**/

44

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
public void setStationStatus(int st,boolean status) {
ctsEngine.setStationStatus(st,status);
}
/**
* The main method of this class.
*
* @param: The arguments.
**/
public static void main(String args[]){
try {
CTS Obj = new CTS();
} catch(Exception e) {
System.out.println(e);
}
} // end of main method.
} // end of class CTS.

CTSENGINE.JAVA
import java.util.*;
import java.lang.Thread.*;
import java.awt.event.*;
import javax.swing.Timer;
public class CTSEngine implements ActionListener {
private int simSecs, prevSecs, countTrains, nextTrIns, totalTrains;
private long startTime;
private boolean trIns;
private Timer timer;
private ArrayList trains;
private Random rnd;
private Date date;
private CTSStation[] stations;
private int[][] pathLocks;
private int[][][] platLocks;
private int[][][] waitingQueue;
private int[][][] exitStatPos;
private CTSTrain[][][] map;
private ThreadGroup thrGroup;
private CTSScreen ctsScreen;
private CTSStats ctsStats;
private CTSParameters ctsp;
/**
* Constructor
*
* @param ctsP: An object of class CTSParameters
* @param ctsScr: An object of class CTSScreen.It will be used for updating info on screens.
* @param sts: An object of class CTSStats. It will be used for updating stats.
**/
public CTSEngine(CTSParameters ctsP,CTSScreen ctsScr, CTSStats sts) {
ctsp=ctsP;

45

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
date = new Date();
rnd = new Random();
trains = new ArrayList();
ctsStats = sts;
ctsScreen = ctsScr;
trIns = false;
prevSecs=0;
startTime = System.currentTimeMillis();
thrGroup = new ThreadGroup("Stations");
timer = new Timer(ctsp.DELAY,this);
stations = new CTSStation[4];
pathLocks = new int[2][6];
platLocks = new int[2][4][2];
waitingQueue = new int[2][4][2];
exitStatPos = new int[2][4][2];
map = new CTSTrain[2][3][370];
setArrays();
}
/**
* Sets some extra action when we start the simulation.<br>
* e.g : updates the correct parameters in stats and screen objects.
**/
public void start() {
// update arrays in stats obj according to parameters.
ctsStats.setStartup();
ctsScreen.setStartup();
for(int i=0; i<stations.length; i++) {
stations[i].start();
}
}
/**
* This is the main method of this class and this simulation.<br>
* Controls the cycles and define the main logic in this simulation.
**/
synchronized private void simulate() {
setTime();
CTSTrain train;
for(int i=0; i<trains.size(); i++) {
train = (CTSTrain)trains.get(i);
train.simulate();
}
// if time to insert a train;
if(trIns && simSecs>=nextTrIns) {
boolean safeInsertion=false;
switch(ctsp.DIRECTION) {
case 0:
if((getPathLock((1-ctsp.DIRECTION),1)==0) &&
getSafeMove(ctsp.DIRECTION,0,-1)) {
safeInsertion=true;
}
break;
case 1:

46

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
if((getPathLock((1-ctsp.DIRECTION),5)==0) &&
getSafeMove(ctsp.DIRECTION,0,-1)) {
safeInsertion=true;
}
break;
}
// if it is safe to insert train, insert one.
if(safeInsertion) {
insertTrain();
}
}
ctsScreen.updateScreens(trains, simSecs);
// update timer if changed.
timer.setDelay(ctsScreen.getTimerValue());
}
/**
* Inserts a new train on the map.
**/
synchronized public void insertTrain() {
if(totalTrains <ctsp.NUM_OF_TRAINS) {
int rndDir=ctsp.DIRECTION;
int sYpos=0;
switch(rndDir) {
case 0: sYpos=137; break;
case 1: sYpos=427; break;
}
// add a new express train.
if(countTrains == 4){
CTSTrain train = new CTSTrain("images/expTr.gif",'x',rndDir,
trains.size(), this,stations,50, sYpos);
trains.add(train);
map[0][0][0] = train;
countTrains = 0;
} else {
CTSTrain train = new CTSTrain("images/T"+
(rnd.nextInt(6)+1)+".gif",'n',rndDir, trains.size(), this,stations,50, sYpos);
trains.add(train);
map[0][0][0] = train;
countTrains++;
}
trIns=false;
totalTrains++;
}
}
/**
* Sets correctly the arrays when we start the application.
**/
private void setArrays() {
stations[0] = new CTSStation(this,ctsStats,thrGroup,"Station-A",0);
stations[1] = new CTSStation(this,ctsStats,thrGroup,"Station-B",1);
stations[2] = new CTSStation(this,ctsStats,thrGroup,"Station-C",2);
stations[3] = new CTSStation(this,ctsStats,thrGroup,"Station-D",3);

47

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
// set station exit point
exitStatPos[0][3][1]=0;
exitStatPos[1][0][1]=0;
exitStatPos[0][3][0]=5;
exitStatPos[1][0][0]=5;
exitStatPos[0][0][1]=47;
exitStatPos[1][3][1]=47;
exitStatPos[0][0][0]=65;
exitStatPos[1][3][0]=65;
exitStatPos[0][1][1]=94;
exitStatPos[1][2][1]=94;
exitStatPos[0][2][1]=140;
exitStatPos[1][1][1]=140;
exitStatPos[0][1][0]=179;
exitStatPos[1][2][0]=179;
exitStatPos[0][2][0]=241;
exitStatPos[1][1][0]=241;
}
/**
* Keeps track of trains position in the map.
*
* @param train: The current train.
* @param odir: The old direction.
* @param ndir: The new direction.
* @param opos: The old position
* @param npos: The new position
* @param oloc: The old location
* @param nloc: The new location
**/
synchronized public void setMapInfo(CTSTrain train, int odir,int ndir ,int opos, int npos, int
oloc,int nloc) {
map[odir][oloc][opos] = null;
map[ndir][nloc][npos] = train;
}
/**
* Sets the total running time for this simulation.
*/
synchronized public void setTime() {
Long l = new Long(System.currentTimeMillis() - startTime);
simSecs = (l.intValue() / 1000)+prevSecs;
if(!trIns) {
int min = ctsp.MIN_INSERTION_TIME;
int max = ctsp.MAX_INSERTION_TIME;
nextTrIns = simSecs+rnd.nextInt(max-min+1)+min;
trIns=true;
}
}
/**
* Sets the locks on the platforms.
*

48

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
* @param dir: The current direction.
* @param station: The station to set the lock.
* @param plat: The plat to set the lock.
* @param status: The action on those locks.
*/
synchronized public void setPlatLock (int dir, int station, int plat, int status) {
platLocks[dir][station][plat] += status;
//System.out.println(" SetPlatLock: movDir/station/plat/status: "+dir+" / "+station+" /
"+plat+" / "+platLocks[dir][station][plat]);
}
/**
* Sets the locks on the paths.
*
* @param dir: The current direction.
* @param path: The path to set the lock.
* @param status: The action on those locks.
*/
synchronized public void setPathLock(int dir,int path, int status) {
pathLocks[dir][path-1] += status;
}
/**
* Sets the locks on the paths.
*
* @param action: The action on this timer.<br>
*
- case's': start timer <br>
*
- case'p': stop timer
*/
synchronized public void setTimer(char action) {
switch (action) {
case 's':
startTime = System.currentTimeMillis();
timer = new Timer(ctsp.DELAY,this);
startTime = System.currentTimeMillis();
timer.start();
break;
case 'p':
prevSecs=simSecs;
timer.stop();
break;
}
}
/**
* Keeps track of waitingTimes on platforms for trains.
*
* @param moveDir: The current direction.
* @param station: The current station.
* @param plat:
The current plat.
* @param status: The action.
*/
synchronized public void setQueue(int moveDir,int station, int plat, int status) {

49

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
waitingQueue[moveDir][station][plat] = status;
}
/**
* Activate or deactivate stations.
*
* @param st: The current station.
* @param status: False to deactivate, true to activate.
*/
synchronized public void setStationStatus(int st, boolean status) {
stations[st].setStatus(status);
}
/**
* Returns information about the queue of trains.
*
* @param moveDir: The current direction.
* @param station: The current station.
* @param plat:
The current plat.
*
* @return an integer specifying the number of cycles that the train in this position waits.
*/
synchronized public int getQueue(int moveDir, int station, int plat) {
return waitingQueue[moveDir][station][plat];
}
/**
* Returns information about locks on platforms.
*
* @param dir: The current direction.
* @param station: The current station.
* @param plat:
The current plat.
*
* @return an integer specifying the number of trains on that platform.
*/
synchronized public int getPlatLock(int dir, int station, int plat) {
return platLocks[dir][station][plat];
}
/**
* Returns information about locks on paths.
*
* @param dir: The current direction.
* @param path:
The current path.
*
* @return an integer specifying the number of trains on that path.
*/
synchronized public int getPathLock(int dir,int path) {
return pathLocks[dir][path-1];
}
/**
* Returns information about exit positions on the map.

50

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
*
* @param dir: The current direction.
* @param station: The current station.
* @param plat:
The current plat.
*
* @return an integer specifying the value of the exit position.
*/
synchronized public int getExitPos(int dir, int station, int plat) {
return exitStatPos[dir][station][plat];
}
/**
* Returns information about exit positions on the map.
*
* @param dir: The current direction.
* @param loc: The current location.
* @param pos:
The current position of the train.
*
* @return a boolean specifying true for safe move or false for unsafe move.
*/
synchronized public boolean getSafeMove(int dir,int loc, int pos) {
if (map[dir][loc][pos+1] == null & map[dir][loc][pos+2] == null)
return true;
else
return false;
}
/**
* Returns information about the total runing time of the simulation.
*
* @return an integer of the current seconds specifying the total simulation time.
*/
synchronized public int getTime() {
return simSecs;
}
/**
* Haddles actionevents thrown by the timer of this class.
*/
public void actionPerformed(ActionEvent evt) {
String command = evt.getActionCommand();
if (command == null) {
simulate();
}
}
} // end of class CTSEngine.

CTS STATION.JAVA
import java.util.*;

51

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
public class CTSStation extends Thread {
private int stationNo, curTrP0, curTrP1, sleepTime,test;
private CTSEngine ctsEngine;
private CTSStats stats;
private boolean active;
/**
* Constructor
*
* @param ctsEng: The engine of this application
* @param st An object of class CTSStats. It will be used for updating stats.
* @param thGroup The group of this thread object.
* @param name The name of this Object.
* @param stNo The number of this station.
**/
public CTSStation(CTSEngine ctsEng, CTSStats st, ThreadGroup thGroup, String name, int stNo)
{
super(thGroup, name);
ctsEngine = ctsEng;
stats=st;
stationNo=stNo;
active=true;
test=0;
}
/**
* Sets the status of this station to be active or disabled.
*
* @param status True to activate station, false to deactivate.
*/
public synchronized void setStatus(boolean status) {
active=status;
}
/**
* Sets the actions related to a train arrival.
*
* @param plat The current plat.
* @param train The current train.
*/
public synchronized void setArrival(int plat, CTSTrain train) {
switch(plat) {
case 0:
curTrP0++;
break;
case 1:
curTrP1++;
break;
}
/* update stats on CTSStats */
// 1: stationStats.
stats.setStats(1,stationNo,plat,0,1,train.getNo());
stats.setStats(0,stationNo,plat,0,ctsEngine.getTime(),train.getNo());
if(train.getType() == 'x') {

52

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
stats.setStats(1,stationNo,plat,2,1,train.getNo());
}
}
/**
* Sets the actions related to a train departure.
*
* @param plat The current plat.
* @param train The current train.
*/
public synchronized void setDeparture(int plat, CTSTrain train) {
switch(plat) {
case 0:
curTrP0--;
break;
case 1:
curTrP1--;
break;
}
/* update stats on CTSStats */
stats.setStats(1,stationNo,plat,1,1,train.getNo());
stats.setStats(0,stationNo,plat,1,ctsEngine.getTime(),train.getNo());
}
/**
* Sets the actions related to a train departure.
*
* @return a boolean indicating the status of this station.
*/
public synchronized boolean getStatus() {
return active;
}
} // end of class Station.

53

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

CHAPTER – 5
IMPLEMENTATION

54

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

5.1 INTRODUCTION
Implementation is the stage of the project when the theoretical design is turned out
into a working system. Thus it can be considered to be the most critical stage in achieving
a successful new system and in giving the user, confidence that the new system will work
and be effective.
The Implementation stage involves careful planning, investigation of the existing
system and it’s constraints on implementation, designing of methods to achieve
changeover and evaluation of changeover methods. Implementation can be preceded
through JSP.JSP will be more suitable for dynamic page designing, data sharing and
mining concepts. For maintaining data information we go for MS-SQL as database back
end.
Implementation is the stage of the project when the theoretical design is turned out
into a working system. Thus it can be considered to be the most critical stage in achieving
a successful new system and in giving the user, confidence that the new system will work
and be effective.
The Implementation stage involves careful planning, investigation of the existing
system and it’s constraints on implementation, designing of methods to achieve
changeover and evaluation of changeover methods.
Implementation is the process of converting a new system design into operation. It is
the phase that focuses on user training, site preparation and file conversion for installing a
candidate system. The important factor that should be considered here is that the
conversion should not disrupt the functioning of the organization.

The main purpose of Internet-based productivity applications, such as share
values, is to promote the productivity of human users as a group.

It is accepted in this context that high local responsiveness and high concurrency
are conducive to individual and group productivity.

Share amount is calculated for all value.

55

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

Consistency control in this environment must not only guarantee convergence of
replicated data, but also attempt to preserve intentions of operations.

Operational transformation (OT) is a well-established method for optimistic
consistency control.

This paper analyzes the root of correctness problems in OT and establishes a
novel operational transformation framework for developing OT algorithms and
proving their correctness.

Operational Transformation (OT) has been well accepted in group editors for
archive high local responsiveness and unconstrained collaboration.

Remote operations are transformed before they are executed such that
inconsistencies are repaired.

5.2 METHOD OF IMPLEMENTATION
When the system is ready for implementation, emphasis switches to communicate
with the finance department staff. Open discussion with the staff is important from the
beginning of the project. Staff can be expected to be concerned about the effect of the
automation on their jobs and the fear of redundancy or loss of status must be allayed
immediately. During the implementation phase it is important that all staff concerned be
apprised of the objectives of overall operation of the system. They will need shinning on
how computerization will change their duties and need to understand how their role
relates to the system as a whole. An organization-training program is advisable; this can
include demonstrations, newsletters, seminars etc.
The department should allocate a member of staff, who understands the system and
the equipment, and should be made responsible for the smooth operation of the system.
An administrator should coordinate the users to the system.
Users should be informed about new aspects of the system that will, affect them. The
features of the system explained with the adequate documentation. New services such as
security, on-line application form and back-ups must be advertised on the staff when the
time is ripe.

56

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
Existing documents such as employee loan details should be entered into the new
system. Since these files are very large, conversion of these may continue long after the
system based on current files has been implemented. Hence we need to assign
responsibility for each activity.
The system may come into full operation via number of possible routes. Complete
change over at one point time is conceptually the most tidy. But this approach requires
careful planning and coordination, particularly during the changeover. A phased
approach, possible implementing the system of the section relating to one operation or
procedure first and progressing to more novel or complex subsystems in the fullness of
time. These likely to be less traumatic. A phased approach gives the staff time to adjust to
the new system. But depends on being able to split the system, without reliance on it.
Thus approach is sensible when the consequences of failure are disastrous, but will
require extra staff time. The fourth angle, is pilot operation permits any problems to be
tackled on a smaller scale operation. Pilot operation generally means the implementation
of the complete system, but at one location or branch only.

57

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
5.2.1 OUTPUT SCREENS

Fig 5.1 : Simulation

Fig 5.2 : Credits

58

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

Fig 5.3 : Train Status

Fig 5.4 : Paramter Initialization

59

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

Fig 5.5 : Train Simulation(1)

Fig 5.6 : Train Simulation(2)

60

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

Fig 5.7 : Train Simulation(3)

Fig 5.8 : Train Simulation(4)

61

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

Fig 5.9 : Train Simulation(5)

Fig 5.10 : Train Simulation(6)
62

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

Fig 5.11 : Train Status(Active State-Yes)

Fig 5.12 : Stop(1)
63

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

Fig 5.13 : Train Status(Active State-No)

Fig 5.14 : Train Simulation(Active State-No)(1)
64

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

Fig 5.15 : Train Simulation(Active State-No)(2)

Fig 5.16 : Stop(2)

65

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

CHAPTER – 6
TESTING

66

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

6.1 SYSTEM TESTING
6.1.1 INTRODUCTION:
Testing is the process of detecting errors. Testing performs a very critical role for
quality assurance and for ensuring the reliability of software. The results of testing are
used later on during maintenance also.
The aim of testing is often to demonstrate that a program works by showing that it
has no errors. The basic purpose of testing phase is to detect the errors that may be
present in the program. Hence one should not start testing with the intent of showing that
a program works, but the intent should be to show that a program doesn’t work. Testing is
the process of executing a program with the intent of finding errors.
6.1.2 TESTING OBJECTIVES
The main objective of testing is to uncover a host of errors, systematically and
with minimum effort and time. Stating formally, we can say,
1)

Testing is a process of executing a program with the intent of finding an error.

2)

A successful test is one that uncovers an as yet undiscovered error.

3)

A good test case is one that has a high probability of finding error, if it exists.

4)

The tests are inadequate to detect possibly present errors.

67

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
6.1.3 LEVELS OF TESTING
In order to uncover the errors present in different phases we have the concept of
levels of testing. The basic levels of testing are as shown below…
Acceptance
Testing

Client Needs

Requirements

System Testing

Design

Integration Testing

Unit Testing

Code

6.2 TESTING STRATEGIES:
A strategy for software testing integrates software test case design methods into a
well-planned series of steps that result in the successful construction of software.
Unit Testing
Unit Testing focuses verification effort on the smallest unit of software i.e. the
module. Using the detailed design and the process specifications testing is done to
uncover errors within the boundary of the module. All modules must be successful in the
unit test before the start of the integration testing begins.
White Box Testing
White Box Testing mainly focuses on the internal performance of the product.
Here a part will be taken at a time and tested thoroughly at a statement level to find the
maximum possible errors. Also construct a loop in such a way that the part will be tested

68

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
with in a range. That means the part is execute at its boundary values and within bounds
for the purpose of testing.
Black Box Testing
This Testing method considers a module as a single unit and checks the unit at
interface and communication with other modules rather getting into details at statement
level. Here the module will be treated as a block box that will take some input and
generate output. Output for a given set of input combinations are forwarded to other
modules.
Integration Testing
After the unit testing we have to perform integration testing. The goal here is to
see if modules can be integrated properly or not. This testing activity can be considered
as testing the design and hence the emphasis on testing module interactions. It also helps
to uncover a set of errors associated with interfacing. Here the input to these modules
will be the unit tested modules.
Integration testing is classifies in two types…
1. Top-Down Integration Testing.
2. Bottom-Up Integration Testing.
In Top-Down Integration Testing modules are integrated by moving downward
through the control hierarchy, beginning with the main control module.
In Bottom-Up Integration Testing each sub module is tested separately and then
the full system is tested.
System Testing
Project testing is an important phase without which the system can’t be released to
the end users.

It is aimed at ensuring that all the processes are according to the

specification accurately.

69

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
Alpha Testing
This refers to the system testing that is carried out by the test team with the
organization.
Beta Testing
This refers to the system testing that is performed by a select group of friendly customers.
Acceptance Testing
Acceptance Test is performed with realistic data of the client to demonstrate that
the software is working satisfactorily. Testing here is focused on external behavior of the
system; the internal logic of program is not emphasized.

6.3 CONCLUSION
In this way we also completed the testing phase of the project and ensured that the system
is ready to go live. Thus we developed a new technology courier system so that people
will have tracking details of their consignments.

70

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

CHAPTER – 7
CONCLUSION

71

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
We have presented an approach to optimally reschedule trains on a railway
network based on a permutation method.We have modeled the system based on the
switching max-plus framework and showed how the control problem can be recast as a
mixed-integer linear programming problem. Compared to previous results we have
extended the control actions to change the departure and arrival order of non-subsequent
trains. For a simple railway network we have shown that by optimally rescheduling trains
using the proposed approach delays can be substantially reduced. Further research will
concentrate on reducing the complexity of the mixed-integer linear programming
problem by considering only a reduced number of relevant decision variables based for
example on the delay propagation algorithm proposed in (Goverde, 2010).

72

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

CHAPTER – 8
BIBILOGRAPHY

73

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network

8.1 REFERENCES
Baccelli, F., Cohen, G., Olsder, G., and Quadrat, J. (1992). Synchronization and
Linearity: An Algebra for Discrete
Event Systems. Wiley.
Goverde, R.M.P. (2007). Railway timetable stability analysis using max-plus system
theory. Transportation Research Part B, 41(2), 179–201.
Goverde, R. (2010). A delay propagation algorithm for large-scale railway traffic
networks. Transportation Research Part C: Emerging Technologies, 18(3), 269–287.
Heidergott, B. and de Vries, R. (2001). Towards a (max,+) control theory for public
transportation networks. Discrete
Event Systems: Theory and Applications, 11(4), 371–398. van den Boom, T. and De
Schutter, B. (2006). Modelling and control of discrete event systems using switching
max-plus-linear systems. Control Engineering Practice, 14(10), 1199–1211.
[1] A. Atamt¨urk and M. W. P. Savelsbergh. Integer-programming software systems.
Annals
of Operations Research, 2005. To appear.
[2] F. Baccelli, G. Cohen, G.J. Olsder, and J.P. Quadrat. Synchronization and Linearity.
John Wiley & Sons, New York, 1992.
[3] A. Bemporad and M. Morari. Control of systems integrating logic, dynamics, and
constraints. Automatica, 35(3):407–427, March 1999.
[4] J.G. Braker. Max-algebra modelling and analysis of time-table dependent
transportation
networks. In Proceedings of the 1st European Control Conference, pages 1831–
1836, Grenoble, France, July 1991.
[5] J.G. Braker. Algorithms and Applications in Timed Discrete Event Systems. PhD
thesis,

74

Department Of CSE

GDMM , Nandigama

A Permutation-based algorithm to optimally reschedule trains in railway traffic network
Department of Technical Mathematics and Informatics, Delft University of Technology,
Delft, The Netherlands, December 1993.
[6] J.G. Braker. An extended algorithm for performance evaluation of timed event graphs.
In Proceedings of the 2nd European Control Conference, pages 524–529, Groningen,
The Netherlands, June 1993.
[7] R.A. Cuninghame-Green. Minimax Algebra, volume 166 of Lecture Notes in
Economics
and Mathematical Systems. Springer-Verlag, Berlin, Germany, 1979.
[8] L. Davis, editor. Handbook of Genetic Algorithms. Van Nostrand Reinhold, New
York,
1991.
[9] B. De Schutter, W.P.M.H. Heemels, and A. Bemporad. On the equivalence of linear
Complementarity problems.

75

Department Of CSE

GDMM , Nandigama