Beruflich Dokumente
Kultur Dokumente
Final Report
Krishna Dutt AE11B017
3rd Undergraduate Dept. of Aerospace Engineering IIT Madras
May 2, 2014
While choosing Project for Object Oriented Programming,topics that use
a variety of design patterns, interaction between objects, and provide an opportunity to make a realistic design are always welcomed. Object oriented
languages were designed initially for simulations. This report summarises
the design concepts, methodology and processes involved in developing a code
to simulate Traffic at an Intersection.
Part I
Introduction :
This report documents the Final Project , titled Traffic Flow Simulation
At An Intersection, to be submitted as part of the coursework on Object Oriented Programming .It summarizes the concepts, methodology and
implementation of Traffic simulation, limited to a single intersection.
Motivation :
The class concept allowed me to map my application concepts
directly into the language constructs in a direct way that made
my code more readable than I had seen in any other language
- Bjarne Stroustrup
The above is a quote from Bjarne Stroustrup, who when he first started
designing C++ ,wanted to develop a better tool for simulation. He was one
of the pioneers who found out how effective, it was to use object oriented
approach in coding simulations.
The motivation behind choosing Traffic simulation is it is ideally suited
to implement object oriented design. Each component of the Traffic, be it a
vehicle or a road or a traffic light or an intersection can be modelled using an
object, which specifies both its characteristics and behaviour. The simulation
models the interaction of each individual object with its surrounding, thus
making the design more realistic .
Objective :
Part II
Classes :
Component Design
The following section deals with the structure and design of individual classes
.
4.1
Coordinate :
4.2
Trafficlight :
4.3
Vehicle :
11. Max
Methods
Apart from the regular methods to provide access and return the value
of a data, it contains, a method called compute() which computes the next
Database Vehicle :
4.4
Vehicle encapsulates :
Data
1. count - stores the no of types of vehicles whose data is currently stored
2.
Methods
All basic methods like Add() , edit() ,Delete() are provided, which
helps in modifying the database. The database is initialised with data of
3 types of vehicles namely, Car, Bus and Scooter.But, no hard copy of the
database is maintained as of now.
4.5
Lane :
4.6
Incoming Lane :
The class Incoming Lane inherits publicly from class Lane and has the
following extra behaviour :
Data
1. frequency - stores the frequency at which vehicles need to be generated.
Methods
1. generate() - generates vehicles, assigns initial values to the vehicle at
random from the database .
2. exit boundary() - stops the vehicles at the end of the lane if the
signal turns Red.
8
4.7
Intersection :
4.8
Simulator :
4.9
Environment :
The class Environment encapsulates the objects of all other classes and
facilitates the interaction between them.
Architecture
The following section deals with the basic architecture of the design.
Figure 1: Design Flow Chart
The above flow chart gives the design flow of the code .The MAIN function
initially obtains the user input, passes them onto the object of environment.
The environment class invokes the simulator to display the initial layout of
the intersection.
10
After finding which Incoming Lane is free the control then passes to
intersection ,which facilitates the transfer between the Incoming Lane and
Lane .Finally, the new positions of the vehicles are displayed by invoking the
simulator and the control passes to the next time iteration.
11
Part III
12
Part IV
Conclusion :
The project was aimed at modelling the traffic flow at an intersection.The
results couldnt be obtained properly due to lack of proper graphics tools.
Overall, this project gave me a good insight into the design process involved
in an object oriented design.It, also reconfirmed once again that simulations
are one of the best areas to use Object oriented design.
13