SlideShare a Scribd company logo
1 of 6
Download to read offline
Simulation of traffic queues in a junction with lights
It has been determined that the traffic flow in the junction below is not satisfactory, there are
often long queues.
The junction is controlled by the four light signals s1, s2, s3 and s4.
A significant part of the traffic that comes from E, to the right in the figure, is to turn left towards
S in the junction but they are often blocked by vehicles that comes from W. To solve this
problem, an additional lane for vehicles that comes from E respective W that are
to turn left in the junction, i.e. we would like to have a junction like this:
This junction does have additional lanes controlled by the light signals s2 and s5.
To determine the length of these lanes, we would like to have a program that simulates the traffic
flow in the crossing at different lengths of these turning" lanes, different traffic intensity and
different cycles of the light signals. To do this it is enough to study the flow in one direction, i.e.
in a system like this:
Since traffic from E aiming to both N and W are controlled by the same light signal (s1) we dont
need to separate these. We treat this traffic as aiming to W. We dont need to track the vehicles
when they have left the crossing.
Computer model
We represent a lane with an array where each element is either empty (null) or a vehicle (all
vehicles are assumed to have the same size).
The system consists of the lanes (r0, r1 and r2) and two light signals (s1 and s2):
In a time step one or more of the following events may occur:
_ a signal changes color.
_ a vehicle passes a signal (if it shows green).
_ a vehicle advances one step in a lane (if the place before it is free).
_ the vehicle immediately before X (i.e. in link list r0[0]) is moved to r1 or r2 depending on its
destination (W or S),
_ a vehicle arrives to the system at the point E.
A simulation consists of a time stepping where the events above occur.
The function of the light signals
A signal is green or red (no yellow light is needed). A signal is characterized by two parameters:
_ a period i.e. the number of time steps from the start of one green cycle to the start of the next.
_ a greenperiod i.e. the number of timesteps the signal is green.
These parameters are assigned when the light signal is built (ie as parameters to the constructor).
A signal needs an internal clock that is ticked by a step-method. It is a good idea (but not
necessary) to let the clock be circular, ie when it reaches the end of the period, it is reset to zero.
You also need a method that decides whether the signal is green or not.
Both signals should have the same period and start as green.
Example: If the period is 7 and the green period for s1 is 3 and fore s2 is 2, the table below
shows how the internal clock should tick and what color they show
Simulation
The program is controlled by the following parameters:
_ The length of the lanes. The lanes r1 and r2 always have the same length.
_ Probability of an arrival, i.e. the probability that a vehicle arrives at E at a time step.
_ The probability that a created vehicle has S as its destination.
_ The parameters of the light signals (period and green period).
For the purpose of this assignment it is sufficient that these parameters are set in the code in a
way so it is easy to change them.
The result of a run
_ Average time (number of time steps) and maximal time for a vehicle to pass the light signal s1
resp. s2
_ Number of time steps when the queue at either light signal is longer than r1 and r2, i.e. the time
that the junction at X has been blocked by a queue.
_ A simple illustration of the system.
Example:
Design and sequence of work
You must follow the design (classes, methods- and name of attributes) that is found in the code
skeleton attached.
Solve the problem stepwise:
1. Create a folder for the files and copy the code skeleton into it.
2. Implement the Vehicle- and the Lane-classes.
NOTE: Dont forget the toString() methods!
3. Implement the Light-class.
4. Implement the class TrafficSystem that defines a traffic system as described above.
Leave the collection of statistics until the complete system is running.
5. Add the collection of the statistics.
public class Lane {
private Vehicle[] theLane;
public Lane(int n) {
}
public void step() {
}
public Vehicle removeFirst() {
return null;
}
public Vehicle getFirst() {
return null;
}
public boolean lastFree() {
return true;
}
public void putLast(Vehicle v) {
}
public String toString() {
return null;
}
}
public class Simulation {
public static void main(String [] args) {
TrafficSystem tf = new TrafficSystem();
while (true) {
try {
// If the printouts are done each timestep, a pause is needed
Thread.sleep(100);
}
catch (InterruptedException e) {
}
tf.step();
tf.print();
}
}
}
public class Light {
private int period;
private int green;
private int time;
public Light(int p, int g) {
}
public void step() {
}
public boolean isGreen() {
return true;
}
public String toString() {
return null;
}
}
public class Vehicle {
private int bornTime;
private char destination;
public Vehicle(int b, char d) {
}
public String toString()
{
return null;
}
}
/** TrafficSystem *
* Defines the lanes and signals that is to be studied. Collects statistics
*
* Model for traffic simulation
* ============================
*
* The following classes are used:
*
* Vehicle Represents a vehicle
* Time of arrival and destination are set when create.
*
* Light Represents the light signals
* See below
*
* Lane Represents a piece of a road
* A lane is represented by an array where each element
* either is empty or contain a reference to a
* vehicle-object.
*
* TrafficSystem
* Defines the components, ie the lanes and signals that
* build the system. See below
*
* Simulation
* main-method the controls the simulation
*
*
* The situation that is to be simulated looks schematically like
*
* C X E
* W s1<----r1-----<---------r0---------------------
* S s2<----r2-----<
*
* A lane (a piece of a road) r0 split into two files r1 and r2 at X.
* The signal s1 controls the lane r1 and the signal s2 the lane r2.
*
* Vehicles are create at E. The probability that a vehicle arrives to E
* at a certain time is called "the intensity of arrival".
*
* At a time step the vehicles move one step forward (if possible).
* At C, the vehicles are removed from the system if the resp signal is green.
* At X, vehicles are move from r0 to either r1 or r2 depending of its
* destination (if there are space for them).
*
*
*/
public class TrafficSystem {
// Attributes that describe the elements of the system
private Lane r0;
private Lane r1;
private Lane r2;
private Light s1;
private Light s2;
private int time = 0;
public TrafficSystem() {
}
public void step() {
}
public void printStatistics() {
}
public void print() {
}
}
" (1) | s (C)
begin{tabular}{|l|c|c|c|c|c|c|c|c|c|c|c|c|} hline Timestep: & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8
& 9 & 10 &  hline Internal clock: & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 0 & 1 & 2 & 3 &  hline
Color s1: & G & G & G & R & R & R & R & G & G & G & R &  hline Color s2: & G & G
& R & R & R & R & R & G & G & R & R &  hline end{tabular}
R:[WWW[WW[SWWSWWSSSWS]R:[SSSSSSSS]R:[WWWW][SWWSSWSSSWSW]R:[Ssss
SSSS]

More Related Content

Similar to Simulation of traffic queues in a junction with lightsIt has been .pdf

Research on The Control of Joint Robot Trajectory
Research on The Control of Joint Robot TrajectoryResearch on The Control of Joint Robot Trajectory
Research on The Control of Joint Robot TrajectoryIJRESJOURNAL
 
1. BooleanSourceHW4 classpublic BooleanSourceHW4(double initProbab.pdf
1. BooleanSourceHW4 classpublic BooleanSourceHW4(double initProbab.pdf1. BooleanSourceHW4 classpublic BooleanSourceHW4(double initProbab.pdf
1. BooleanSourceHW4 classpublic BooleanSourceHW4(double initProbab.pdfagaramjareld
 
1 BooleanSourceHW4 class public BooleanSourceHW4double ini.pdf
1 BooleanSourceHW4 class public BooleanSourceHW4double ini.pdf1 BooleanSourceHW4 class public BooleanSourceHW4double ini.pdf
1 BooleanSourceHW4 class public BooleanSourceHW4double ini.pdfatwaytvl
 
Cab travel time prediction using ensemble models
Cab travel time prediction using ensemble modelsCab travel time prediction using ensemble models
Cab travel time prediction using ensemble modelsAyan Sengupta
 
I have compilation errors that I'm struggling with in my code- please.pdf
I have compilation errors that I'm struggling with in my code- please.pdfI have compilation errors that I'm struggling with in my code- please.pdf
I have compilation errors that I'm struggling with in my code- please.pdfColinjHJParsonsa
 
Design principles of traffic signal
Design principles of traffic signalDesign principles of traffic signal
Design principles of traffic signalBhavya Patel
 
Multi-Vehicle Path Planning In Dynamically Changing Environments - 2012-11-19
Multi-Vehicle Path Planning In Dynamically Changing Environments - 2012-11-19Multi-Vehicle Path Planning In Dynamically Changing Environments - 2012-11-19
Multi-Vehicle Path Planning In Dynamically Changing Environments - 2012-11-19Aritra Sarkar
 
T2-ETA Presentation
T2-ETA PresentationT2-ETA Presentation
T2-ETA Presentationmimenarrator
 
1. BooleanSourceHW4 classpublic BooleanSourceHW4(double initProbab.pdf
1. BooleanSourceHW4 classpublic BooleanSourceHW4(double initProbab.pdf1. BooleanSourceHW4 classpublic BooleanSourceHW4(double initProbab.pdf
1. BooleanSourceHW4 classpublic BooleanSourceHW4(double initProbab.pdfalimacal
 
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...Khoa Mac Tu
 
Matrices and row operations 12123 and applications of matrices
Matrices and row operations 12123 and applications of matricesMatrices and row operations 12123 and applications of matrices
Matrices and row operations 12123 and applications of matricesmayaGER
 
Hybrid Ant Colony Optimization for Real-World Delivery Problems Based on Real...
Hybrid Ant Colony Optimization for Real-World Delivery Problems Based on Real...Hybrid Ant Colony Optimization for Real-World Delivery Problems Based on Real...
Hybrid Ant Colony Optimization for Real-World Delivery Problems Based on Real...csandit
 
IntroductionTopological sorting is a common operation performed .docx
IntroductionTopological sorting is a common operation performed .docxIntroductionTopological sorting is a common operation performed .docx
IntroductionTopological sorting is a common operation performed .docxmariuse18nolet
 
Modern Control System (BE)
Modern Control System (BE)Modern Control System (BE)
Modern Control System (BE)PRABHAHARAN429
 
TRANSFER FUNCTION (4).pptx
TRANSFER FUNCTION (4).pptxTRANSFER FUNCTION (4).pptx
TRANSFER FUNCTION (4).pptxankit317032
 
Discrete-wavelet-transform recursive inverse algorithm using second-order est...
Discrete-wavelet-transform recursive inverse algorithm using second-order est...Discrete-wavelet-transform recursive inverse algorithm using second-order est...
Discrete-wavelet-transform recursive inverse algorithm using second-order est...TELKOMNIKA JOURNAL
 
APLICACIONES DE ESPACIO VECTORIALES
APLICACIONES DE ESPACIO VECTORIALESAPLICACIONES DE ESPACIO VECTORIALES
APLICACIONES DE ESPACIO VECTORIALESJoseLuisCastroGualot
 

Similar to Simulation of traffic queues in a junction with lightsIt has been .pdf (20)

Research on The Control of Joint Robot Trajectory
Research on The Control of Joint Robot TrajectoryResearch on The Control of Joint Robot Trajectory
Research on The Control of Joint Robot Trajectory
 
1. BooleanSourceHW4 classpublic BooleanSourceHW4(double initProbab.pdf
1. BooleanSourceHW4 classpublic BooleanSourceHW4(double initProbab.pdf1. BooleanSourceHW4 classpublic BooleanSourceHW4(double initProbab.pdf
1. BooleanSourceHW4 classpublic BooleanSourceHW4(double initProbab.pdf
 
1 BooleanSourceHW4 class public BooleanSourceHW4double ini.pdf
1 BooleanSourceHW4 class public BooleanSourceHW4double ini.pdf1 BooleanSourceHW4 class public BooleanSourceHW4double ini.pdf
1 BooleanSourceHW4 class public BooleanSourceHW4double ini.pdf
 
Pass&fr trains planning
Pass&fr trains planningPass&fr trains planning
Pass&fr trains planning
 
Cab travel time prediction using ensemble models
Cab travel time prediction using ensemble modelsCab travel time prediction using ensemble models
Cab travel time prediction using ensemble models
 
I have compilation errors that I'm struggling with in my code- please.pdf
I have compilation errors that I'm struggling with in my code- please.pdfI have compilation errors that I'm struggling with in my code- please.pdf
I have compilation errors that I'm struggling with in my code- please.pdf
 
4267
42674267
4267
 
4267
42674267
4267
 
Design principles of traffic signal
Design principles of traffic signalDesign principles of traffic signal
Design principles of traffic signal
 
Multi-Vehicle Path Planning In Dynamically Changing Environments - 2012-11-19
Multi-Vehicle Path Planning In Dynamically Changing Environments - 2012-11-19Multi-Vehicle Path Planning In Dynamically Changing Environments - 2012-11-19
Multi-Vehicle Path Planning In Dynamically Changing Environments - 2012-11-19
 
T2-ETA Presentation
T2-ETA PresentationT2-ETA Presentation
T2-ETA Presentation
 
1. BooleanSourceHW4 classpublic BooleanSourceHW4(double initProbab.pdf
1. BooleanSourceHW4 classpublic BooleanSourceHW4(double initProbab.pdf1. BooleanSourceHW4 classpublic BooleanSourceHW4(double initProbab.pdf
1. BooleanSourceHW4 classpublic BooleanSourceHW4(double initProbab.pdf
 
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
 
Matrices and row operations 12123 and applications of matrices
Matrices and row operations 12123 and applications of matricesMatrices and row operations 12123 and applications of matrices
Matrices and row operations 12123 and applications of matrices
 
Hybrid Ant Colony Optimization for Real-World Delivery Problems Based on Real...
Hybrid Ant Colony Optimization for Real-World Delivery Problems Based on Real...Hybrid Ant Colony Optimization for Real-World Delivery Problems Based on Real...
Hybrid Ant Colony Optimization for Real-World Delivery Problems Based on Real...
 
IntroductionTopological sorting is a common operation performed .docx
IntroductionTopological sorting is a common operation performed .docxIntroductionTopological sorting is a common operation performed .docx
IntroductionTopological sorting is a common operation performed .docx
 
Modern Control System (BE)
Modern Control System (BE)Modern Control System (BE)
Modern Control System (BE)
 
TRANSFER FUNCTION (4).pptx
TRANSFER FUNCTION (4).pptxTRANSFER FUNCTION (4).pptx
TRANSFER FUNCTION (4).pptx
 
Discrete-wavelet-transform recursive inverse algorithm using second-order est...
Discrete-wavelet-transform recursive inverse algorithm using second-order est...Discrete-wavelet-transform recursive inverse algorithm using second-order est...
Discrete-wavelet-transform recursive inverse algorithm using second-order est...
 
APLICACIONES DE ESPACIO VECTORIALES
APLICACIONES DE ESPACIO VECTORIALESAPLICACIONES DE ESPACIO VECTORIALES
APLICACIONES DE ESPACIO VECTORIALES
 

More from leolight2

Si el gobierno se hubiera apoderado de los activos de Global Trading.pdf
Si el gobierno se hubiera apoderado de los activos de Global Trading.pdfSi el gobierno se hubiera apoderado de los activos de Global Trading.pdf
Si el gobierno se hubiera apoderado de los activos de Global Trading.pdfleolight2
 
Si bien puede diferir en otros pa�ses, en los Estados Unidos la dist.pdf
Si bien puede diferir en otros pa�ses, en los Estados Unidos la dist.pdfSi bien puede diferir en otros pa�ses, en los Estados Unidos la dist.pdf
Si bien puede diferir en otros pa�ses, en los Estados Unidos la dist.pdfleolight2
 
SHOW STEPS IN EXCEL PLEASE.Data DayDateWeekdayDaily Deman.pdf
SHOW STEPS IN EXCEL PLEASE.Data DayDateWeekdayDaily Deman.pdfSHOW STEPS IN EXCEL PLEASE.Data DayDateWeekdayDaily Deman.pdf
SHOW STEPS IN EXCEL PLEASE.Data DayDateWeekdayDaily Deman.pdfleolight2
 
Si bien la mayor�a de los visitantes de Washington, DC, visitan los .pdf
Si bien la mayor�a de los visitantes de Washington, DC, visitan los .pdfSi bien la mayor�a de los visitantes de Washington, DC, visitan los .pdf
Si bien la mayor�a de los visitantes de Washington, DC, visitan los .pdfleolight2
 
Si bien es importante que los vendedores internacionales aprecien .pdf
Si bien es importante que los vendedores internacionales aprecien .pdfSi bien es importante que los vendedores internacionales aprecien .pdf
Si bien es importante que los vendedores internacionales aprecien .pdfleolight2
 
Show the Relational Algebra formula for each. This one may be a phot.pdf
Show the Relational Algebra formula for each. This one may be a phot.pdfShow the Relational Algebra formula for each. This one may be a phot.pdf
Show the Relational Algebra formula for each. This one may be a phot.pdfleolight2
 
should be at least two paragraphs long, or more, depending upon the .pdf
should be at least two paragraphs long, or more, depending upon the .pdfshould be at least two paragraphs long, or more, depending upon the .pdf
should be at least two paragraphs long, or more, depending upon the .pdfleolight2
 
Should Governments Report Like BusinessesHistorically, states a.pdf
Should Governments Report Like BusinessesHistorically, states a.pdfShould Governments Report Like BusinessesHistorically, states a.pdf
Should Governments Report Like BusinessesHistorically, states a.pdfleolight2
 
Seventy-three percent of adults in a certain country believe that li.pdf
Seventy-three percent of adults in a certain country believe that li.pdfSeventy-three percent of adults in a certain country believe that li.pdf
Seventy-three percent of adults in a certain country believe that li.pdfleolight2
 
Sheffield Corporation, a private corporation, was organized on Febru.pdf
Sheffield Corporation, a private corporation, was organized on Febru.pdfSheffield Corporation, a private corporation, was organized on Febru.pdf
Sheffield Corporation, a private corporation, was organized on Febru.pdfleolight2
 
SHOW ANSWER ON GRAPH Many demographers predict that the United State.pdf
SHOW ANSWER ON GRAPH Many demographers predict that the United State.pdfSHOW ANSWER ON GRAPH Many demographers predict that the United State.pdf
SHOW ANSWER ON GRAPH Many demographers predict that the United State.pdfleolight2
 
Ser capaz de amplificar fragmentos de ADN espec�ficos es fundamental.pdf
Ser capaz de amplificar fragmentos de ADN espec�ficos es fundamental.pdfSer capaz de amplificar fragmentos de ADN espec�ficos es fundamental.pdf
Ser capaz de amplificar fragmentos de ADN espec�ficos es fundamental.pdfleolight2
 
Solve all of them If the marginal propensity to save is 0.25 , then.pdf
Solve all of them  If the marginal propensity to save is 0.25 , then.pdfSolve all of them  If the marginal propensity to save is 0.25 , then.pdf
Solve all of them If the marginal propensity to save is 0.25 , then.pdfleolight2
 
Solution Register a service endpoint in the Dataverse instance that.pdf
Solution Register a service endpoint in the Dataverse instance that.pdfSolution Register a service endpoint in the Dataverse instance that.pdf
Solution Register a service endpoint in the Dataverse instance that.pdfleolight2
 
Solutions for The Toliza Museum of Art, did not cover all the answer.pdf
Solutions for The Toliza Museum of Art, did not cover all the answer.pdfSolutions for The Toliza Museum of Art, did not cover all the answer.pdf
Solutions for The Toliza Museum of Art, did not cover all the answer.pdfleolight2
 
Soles es una empresa de calzado que ha abierto recientemente su tien.pdf
Soles es una empresa de calzado que ha abierto recientemente su tien.pdfSoles es una empresa de calzado que ha abierto recientemente su tien.pdf
Soles es una empresa de calzado que ha abierto recientemente su tien.pdfleolight2
 
So I have 3 enums named land_type, entity, tile as shown enum lan.pdf
So I have 3 enums named land_type, entity, tile as shown enum lan.pdfSo I have 3 enums named land_type, entity, tile as shown enum lan.pdf
So I have 3 enums named land_type, entity, tile as shown enum lan.pdfleolight2
 
So for C-ferns the CP is the commonwild type (green) and the cp is .pdf
So for C-ferns the CP is the commonwild type (green) and the cp is .pdfSo for C-ferns the CP is the commonwild type (green) and the cp is .pdf
So for C-ferns the CP is the commonwild type (green) and the cp is .pdfleolight2
 
So I need to create a compound word game, and I dont quite understa.pdf
So I need to create a compound word game, and I dont quite understa.pdfSo I need to create a compound word game, and I dont quite understa.pdf
So I need to create a compound word game, and I dont quite understa.pdfleolight2
 
SLL Corporation�s balance sheet is shown below. The current rate on .pdf
SLL Corporation�s balance sheet is shown below. The current rate on .pdfSLL Corporation�s balance sheet is shown below. The current rate on .pdf
SLL Corporation�s balance sheet is shown below. The current rate on .pdfleolight2
 

More from leolight2 (20)

Si el gobierno se hubiera apoderado de los activos de Global Trading.pdf
Si el gobierno se hubiera apoderado de los activos de Global Trading.pdfSi el gobierno se hubiera apoderado de los activos de Global Trading.pdf
Si el gobierno se hubiera apoderado de los activos de Global Trading.pdf
 
Si bien puede diferir en otros pa�ses, en los Estados Unidos la dist.pdf
Si bien puede diferir en otros pa�ses, en los Estados Unidos la dist.pdfSi bien puede diferir en otros pa�ses, en los Estados Unidos la dist.pdf
Si bien puede diferir en otros pa�ses, en los Estados Unidos la dist.pdf
 
SHOW STEPS IN EXCEL PLEASE.Data DayDateWeekdayDaily Deman.pdf
SHOW STEPS IN EXCEL PLEASE.Data DayDateWeekdayDaily Deman.pdfSHOW STEPS IN EXCEL PLEASE.Data DayDateWeekdayDaily Deman.pdf
SHOW STEPS IN EXCEL PLEASE.Data DayDateWeekdayDaily Deman.pdf
 
Si bien la mayor�a de los visitantes de Washington, DC, visitan los .pdf
Si bien la mayor�a de los visitantes de Washington, DC, visitan los .pdfSi bien la mayor�a de los visitantes de Washington, DC, visitan los .pdf
Si bien la mayor�a de los visitantes de Washington, DC, visitan los .pdf
 
Si bien es importante que los vendedores internacionales aprecien .pdf
Si bien es importante que los vendedores internacionales aprecien .pdfSi bien es importante que los vendedores internacionales aprecien .pdf
Si bien es importante que los vendedores internacionales aprecien .pdf
 
Show the Relational Algebra formula for each. This one may be a phot.pdf
Show the Relational Algebra formula for each. This one may be a phot.pdfShow the Relational Algebra formula for each. This one may be a phot.pdf
Show the Relational Algebra formula for each. This one may be a phot.pdf
 
should be at least two paragraphs long, or more, depending upon the .pdf
should be at least two paragraphs long, or more, depending upon the .pdfshould be at least two paragraphs long, or more, depending upon the .pdf
should be at least two paragraphs long, or more, depending upon the .pdf
 
Should Governments Report Like BusinessesHistorically, states a.pdf
Should Governments Report Like BusinessesHistorically, states a.pdfShould Governments Report Like BusinessesHistorically, states a.pdf
Should Governments Report Like BusinessesHistorically, states a.pdf
 
Seventy-three percent of adults in a certain country believe that li.pdf
Seventy-three percent of adults in a certain country believe that li.pdfSeventy-three percent of adults in a certain country believe that li.pdf
Seventy-three percent of adults in a certain country believe that li.pdf
 
Sheffield Corporation, a private corporation, was organized on Febru.pdf
Sheffield Corporation, a private corporation, was organized on Febru.pdfSheffield Corporation, a private corporation, was organized on Febru.pdf
Sheffield Corporation, a private corporation, was organized on Febru.pdf
 
SHOW ANSWER ON GRAPH Many demographers predict that the United State.pdf
SHOW ANSWER ON GRAPH Many demographers predict that the United State.pdfSHOW ANSWER ON GRAPH Many demographers predict that the United State.pdf
SHOW ANSWER ON GRAPH Many demographers predict that the United State.pdf
 
Ser capaz de amplificar fragmentos de ADN espec�ficos es fundamental.pdf
Ser capaz de amplificar fragmentos de ADN espec�ficos es fundamental.pdfSer capaz de amplificar fragmentos de ADN espec�ficos es fundamental.pdf
Ser capaz de amplificar fragmentos de ADN espec�ficos es fundamental.pdf
 
Solve all of them If the marginal propensity to save is 0.25 , then.pdf
Solve all of them  If the marginal propensity to save is 0.25 , then.pdfSolve all of them  If the marginal propensity to save is 0.25 , then.pdf
Solve all of them If the marginal propensity to save is 0.25 , then.pdf
 
Solution Register a service endpoint in the Dataverse instance that.pdf
Solution Register a service endpoint in the Dataverse instance that.pdfSolution Register a service endpoint in the Dataverse instance that.pdf
Solution Register a service endpoint in the Dataverse instance that.pdf
 
Solutions for The Toliza Museum of Art, did not cover all the answer.pdf
Solutions for The Toliza Museum of Art, did not cover all the answer.pdfSolutions for The Toliza Museum of Art, did not cover all the answer.pdf
Solutions for The Toliza Museum of Art, did not cover all the answer.pdf
 
Soles es una empresa de calzado que ha abierto recientemente su tien.pdf
Soles es una empresa de calzado que ha abierto recientemente su tien.pdfSoles es una empresa de calzado que ha abierto recientemente su tien.pdf
Soles es una empresa de calzado que ha abierto recientemente su tien.pdf
 
So I have 3 enums named land_type, entity, tile as shown enum lan.pdf
So I have 3 enums named land_type, entity, tile as shown enum lan.pdfSo I have 3 enums named land_type, entity, tile as shown enum lan.pdf
So I have 3 enums named land_type, entity, tile as shown enum lan.pdf
 
So for C-ferns the CP is the commonwild type (green) and the cp is .pdf
So for C-ferns the CP is the commonwild type (green) and the cp is .pdfSo for C-ferns the CP is the commonwild type (green) and the cp is .pdf
So for C-ferns the CP is the commonwild type (green) and the cp is .pdf
 
So I need to create a compound word game, and I dont quite understa.pdf
So I need to create a compound word game, and I dont quite understa.pdfSo I need to create a compound word game, and I dont quite understa.pdf
So I need to create a compound word game, and I dont quite understa.pdf
 
SLL Corporation�s balance sheet is shown below. The current rate on .pdf
SLL Corporation�s balance sheet is shown below. The current rate on .pdfSLL Corporation�s balance sheet is shown below. The current rate on .pdf
SLL Corporation�s balance sheet is shown below. The current rate on .pdf
 

Recently uploaded

Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 

Recently uploaded (20)

Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 

Simulation of traffic queues in a junction with lightsIt has been .pdf

  • 1. Simulation of traffic queues in a junction with lights It has been determined that the traffic flow in the junction below is not satisfactory, there are often long queues. The junction is controlled by the four light signals s1, s2, s3 and s4. A significant part of the traffic that comes from E, to the right in the figure, is to turn left towards S in the junction but they are often blocked by vehicles that comes from W. To solve this problem, an additional lane for vehicles that comes from E respective W that are to turn left in the junction, i.e. we would like to have a junction like this: This junction does have additional lanes controlled by the light signals s2 and s5. To determine the length of these lanes, we would like to have a program that simulates the traffic flow in the crossing at different lengths of these turning" lanes, different traffic intensity and different cycles of the light signals. To do this it is enough to study the flow in one direction, i.e. in a system like this: Since traffic from E aiming to both N and W are controlled by the same light signal (s1) we dont need to separate these. We treat this traffic as aiming to W. We dont need to track the vehicles when they have left the crossing. Computer model We represent a lane with an array where each element is either empty (null) or a vehicle (all vehicles are assumed to have the same size). The system consists of the lanes (r0, r1 and r2) and two light signals (s1 and s2): In a time step one or more of the following events may occur: _ a signal changes color. _ a vehicle passes a signal (if it shows green). _ a vehicle advances one step in a lane (if the place before it is free). _ the vehicle immediately before X (i.e. in link list r0[0]) is moved to r1 or r2 depending on its destination (W or S), _ a vehicle arrives to the system at the point E. A simulation consists of a time stepping where the events above occur. The function of the light signals A signal is green or red (no yellow light is needed). A signal is characterized by two parameters: _ a period i.e. the number of time steps from the start of one green cycle to the start of the next. _ a greenperiod i.e. the number of timesteps the signal is green. These parameters are assigned when the light signal is built (ie as parameters to the constructor). A signal needs an internal clock that is ticked by a step-method. It is a good idea (but not necessary) to let the clock be circular, ie when it reaches the end of the period, it is reset to zero.
  • 2. You also need a method that decides whether the signal is green or not. Both signals should have the same period and start as green. Example: If the period is 7 and the green period for s1 is 3 and fore s2 is 2, the table below shows how the internal clock should tick and what color they show Simulation The program is controlled by the following parameters: _ The length of the lanes. The lanes r1 and r2 always have the same length. _ Probability of an arrival, i.e. the probability that a vehicle arrives at E at a time step. _ The probability that a created vehicle has S as its destination. _ The parameters of the light signals (period and green period). For the purpose of this assignment it is sufficient that these parameters are set in the code in a way so it is easy to change them. The result of a run _ Average time (number of time steps) and maximal time for a vehicle to pass the light signal s1 resp. s2 _ Number of time steps when the queue at either light signal is longer than r1 and r2, i.e. the time that the junction at X has been blocked by a queue. _ A simple illustration of the system. Example: Design and sequence of work You must follow the design (classes, methods- and name of attributes) that is found in the code skeleton attached. Solve the problem stepwise: 1. Create a folder for the files and copy the code skeleton into it. 2. Implement the Vehicle- and the Lane-classes. NOTE: Dont forget the toString() methods! 3. Implement the Light-class. 4. Implement the class TrafficSystem that defines a traffic system as described above. Leave the collection of statistics until the complete system is running. 5. Add the collection of the statistics. public class Lane { private Vehicle[] theLane; public Lane(int n) {
  • 3. } public void step() { } public Vehicle removeFirst() { return null; } public Vehicle getFirst() { return null; } public boolean lastFree() { return true; } public void putLast(Vehicle v) { } public String toString() { return null; } } public class Simulation { public static void main(String [] args) { TrafficSystem tf = new TrafficSystem(); while (true) { try { // If the printouts are done each timestep, a pause is needed Thread.sleep(100); } catch (InterruptedException e) { } tf.step(); tf.print(); } } }
  • 4. public class Light { private int period; private int green; private int time; public Light(int p, int g) { } public void step() { } public boolean isGreen() { return true; } public String toString() { return null; } } public class Vehicle { private int bornTime; private char destination; public Vehicle(int b, char d) { } public String toString() { return null; } } /** TrafficSystem * * Defines the lanes and signals that is to be studied. Collects statistics * * Model for traffic simulation * ============================ *
  • 5. * The following classes are used: * * Vehicle Represents a vehicle * Time of arrival and destination are set when create. * * Light Represents the light signals * See below * * Lane Represents a piece of a road * A lane is represented by an array where each element * either is empty or contain a reference to a * vehicle-object. * * TrafficSystem * Defines the components, ie the lanes and signals that * build the system. See below * * Simulation * main-method the controls the simulation * * * The situation that is to be simulated looks schematically like * * C X E * W s1<----r1-----<---------r0--------------------- * S s2<----r2-----< * * A lane (a piece of a road) r0 split into two files r1 and r2 at X. * The signal s1 controls the lane r1 and the signal s2 the lane r2. * * Vehicles are create at E. The probability that a vehicle arrives to E * at a certain time is called "the intensity of arrival". * * At a time step the vehicles move one step forward (if possible). * At C, the vehicles are removed from the system if the resp signal is green. * At X, vehicles are move from r0 to either r1 or r2 depending of its
  • 6. * destination (if there are space for them). * * */ public class TrafficSystem { // Attributes that describe the elements of the system private Lane r0; private Lane r1; private Lane r2; private Light s1; private Light s2; private int time = 0; public TrafficSystem() { } public void step() { } public void printStatistics() { } public void print() { } } " (1) | s (C) begin{tabular}{|l|c|c|c|c|c|c|c|c|c|c|c|c|} hline Timestep: & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & hline Internal clock: & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 0 & 1 & 2 & 3 & hline Color s1: & G & G & G & R & R & R & R & G & G & G & R & hline Color s2: & G & G & R & R & R & R & R & G & G & R & R & hline end{tabular} R:[WWW[WW[SWWSWWSSSWS]R:[SSSSSSSS]R:[WWWW][SWWSSWSSSWSW]R:[Ssss SSSS]