Vehicular Networks
CS 795/895
Dr. Michele
Weigle
mweigle at cs.odu.edu
|
Spring 2008
TR 9:30-10:45 am
E&CS 2120
|
Programming Assignment #2
Accident and Traffic Jam Analysis
Assigned: Thursday, March 6
Due: Thursday, March 27 before class
Setup the following scenario in SWANS with ASH (aka X-SWANS) extensions:
- 5 km highway
- one-way traffic
- 2 lanes
- new vehicles should enter the highway about 1 second after the previous vehicle
- maximum speed is 100 km/h
- at time 300 seconds (5 minutes), a car breaks down in the right
lane 2.5 km from the beginning of the highway
- 1000 s simulated time total
Measure:
- average density of traffic (vehicles/km/lane) over entire simulation
- time it takes for traffic to back up 2 km
- time that the first vehicle behind the broken vehicle (in the same
lane) changes lanes and passes it (if it ever does)
- average density of traffic (vehicles/km/lane) every 30 seconds
- average speed of vehicles between 0-2.5 km every 30 seconds and
average speed of vehicles between 2.5-5 km every 30 seconds
Submit: (via Blackboard and via hardcopy in class)
- Graph of average density of traffic every 30 seconds
- Graph of average speed of vehicles between 0-2.5 km and between
2.5-5 km every 30 seconds (on the same graph)
- Brief report (1-2 pages) describing how you completed the
assignment and including the three required measurements (average
traffic density, time for traffic to back up 2 km and time that first
vehicle passes the broken vehicle)
Helpful Hints
- Modify Constants.java to setup the highway topology, vehicle
max speed (in m/s), and simulation runtime.
- Look at the createSim function in the
HighwayMobilitytest example to see how to control how
vehicles enter the highway.
- The easiest way to obtain the needed measurements is to have each
vehicle write its information to a trace file and post-process the
data. To do this, in HighwayMobilityInfo.java, specify the file and
write a method to output the required information to the file. This
method should be called in the Next method in
HighwayMobility.java. You might want to create a separate
file for each vehicle.
- Causing a vehicle to break down:
(Note: setting a vehicle's speed to 0 immediately, or even too quickly, will cause collisions, so be careful in how you setup the deceleration)
- Determine which vehicle should break down - put a check in
the Next method in HighwayMobility.java
- Flag the vehicle as breaking down - add an attribute in
HighwayMobilityInfo.java
- Cause the chosen vehicle to stop - add code to the beginning of the
Next method in HighwayMobility.java
if (((HighwayMobilityInfo)info).isBreakingDown) {
// this vehicle is breaking down (assuming the attribute you added is called isBreakingDown)
// adjust vehicle speed according to current accel and speed
acc = set this to some negative value and update until vehicle stops completely
((HighwayMobilityInfo)info).setAcceleration(acc); // set new acceleration
initSpd = ((HighwayMobilityInfo)info).getCurrentSpeed(); // get speed
((HighwayMobilityInfo)info).setCurrentSpeed((HighwayMobilityInfo)info).calculateFinalSpeed(Constants.TIGGERING_DISTANCE));
// set the next vehicle offset
((HighwayMobilityInfo)info.setOffset(((HighwayMobilityInfo)info).getOffset() + Constants.TIGGERING_DISTANCE);
// calculate the time the vehicle will take to reach the new offset based on adjusted speed and acc
sleeptime = ((HighwayMobilityInfo)info).calculateTravelTime(initSpd);
// convert the highway location to 2d location
_2dloc = convertHWLocto2DLoc(new HighwayLocation(false, LaneId, ((HighwayMobilityInfo)info).getOffset()));
JistAPI.sleep(sleeptime);
f.moveRadio(id, _2dloc);
return;
}