Sachin
Sachin

Reputation:

Program to simulate vehicles at an intersection using queues

HI I got this coursework question to solve.

This is the question:

Design a program to simulate vehicles at an intersection.

Assume that there is one lane going in each of four directions, with stoplights facing each direction. Vary the arrival time of vehicles randomly in each direction and set up a regular frequency of the light changes. Run your direction and set up a regular frequency of the light changes. Run your simulation for a set period of time to view the "behaviour" of the intersection.

Coursework Requirement:

  1. Should be coded in java
  2. Use of proper data structures

If any one has any clue of how to do it, please help; I have no idea.

Upvotes: 3

Views: 3108

Answers (6)

Ali
Ali

Reputation: 617

If you have access to IEEE there is a journal about this topic here is the link

Upvotes: 0

Student for Life
Student for Life

Reputation: 1033

For managing the Stop/Wait/Go light sequences look into "Finite State Machines"

Upvotes: 1

Caerbanog
Caerbanog

Reputation: 1335

Just a small hint. It wont be a propper simulation if you don't setup some constant to simulate the time the car accelerates until it reaches the intersection. If you have 10 cars queued up and the light goes green they don't all immediatly get to cross the intersection.

Asides from that you really need to get to know queues, especially FIFO and Event queues will help you avoid going into the realm of multithreading world.

I hope you dont need to start with Java before you go into the queues.

Upvotes: 1

Vinko Vrsalovic
Vinko Vrsalovic

Reputation: 340486

Read about queues you have to use to simulate each traffic light.

Each randomly generated car going in each lane will get pushed into the corresponding queue and then popped out of it when the light is green, and keep popping cars as long as (hint: you need to simulate time as well (subhint: look into finite state machines)) the light is green, of course. You process each queue in order.

Upvotes: 1

gimel
gimel

Reputation: 86502

Read about discrete event simulation.

Upvotes: 1

John with waffle
John with waffle

Reputation: 4141

Some useful behaviors to monitor will include mean, max, and std. dev. of the number of cars waiting at each light.

Upvotes: 1

Related Questions