Simulation Problem

This is a discussion on Simulation Problem within the C Programming forums, part of the General Programming Boards category; Hi all, I have a simulation problem. A phone line connecting 2 cities only operates from 8AM to 12AM (16 ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    8

    Simulation Problem

    Hi all, I have a simulation problem.

    A phone line connecting 2 cities only operates from 8AM to 12AM (16 hours) everyday. Customers in these 2 cities randomly make phone calls through it. The distribution for the time interval between 2 calls is approximately an exponential function with lamda = 1/6 minutes^(-1). The distribution for the time each phone call lasts is approximately N(6,4) in minutes. When the line is busy, the next customer just gives up making his/her phone call. Write a program to simulate the phone line problem when there are n phone lines. (n is an arbitrary integer).

    I know the algorithm to simulate 1 phone line, but am lost when it comes to a variable number of phone lines. All I can think of is to keep track of the time when a call ends that is the earliest of all the phone lines, and the next call is made to that phone line.
    However, after updating that line, if another call comes in, I won't
    be able to find the phone line for that call to connect to without
    going through all the phone lines and comparing the times. This is
    going to be a big problem is there are thousands of phone lines.

    Can someone please help me?

    A small question -
    When creating a random variate for a normal distribution, you get 2 normally distributed random variates from 2 random numbers, i.e. z1 = sqrt(-2ln(R_1))cos(2piR_2) and z2 = sqrt(-2ln(R_1))sin(2piR_2). To obtain normal variates X_i with means 6 and variance 4, we take X_i = 6 + 2*z_i. Since there are 2 z_i values, how do I know which value to take, if I need, say, 10 normal variates X_i?

    Thank you.

    Regards,
    Rayne

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Why don't you just use a queue and push free phone lines on it when they're empty? Then whenever a call comes in, pop an empty line off of the free line pile and move it over to the in use pile. When a line is no longer in use, pull it from the list of used lines.

    I'm assuming they're giving you some way of saying "this phone call is done". Well, when a phone call starts, since you know it's going to be done in 4-6 minutes, drop it into a scheduler that many minutes out. Then you just poll through the current minute to see if any have ended. Drop those ended calls into the free list.

    Basicly, use a queue to store empty lines. Use a basic task scheduler to schedule the calls as they come in, then check the current minutes calls for ones that are ending, and drop them onto the queue of unused lines.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 10:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  5. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 05:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21