0

now i am making a simulation for something and i need to define time slots for it as i can not use the real time . For example , i want to know how many persons entered the bank in the 1st 5 minutes and then in the second 5 mins and so on , i want to simulate only so i do not wait 5 miin every time to be able to take the results.

can anyone help??

fank
  • 131
  • 2
  • 4

3 Answers3

1

You keep a priority queue of future events sorted by arrival time. Then just take the first and handle it until there is no more event remaining.

AProgrammer
  • 51,233
  • 8
  • 91
  • 143
  • Thanks alot for reply in advance :-) but all what i want to is to calcualte for example the number of persons came in the first slot. in the code i don not know when these persons arrive . also i want to insert to it a definition for the timeslot to be able to calculate the delay for one person. do you understand what i am trying to do or you need more explanation :-) ?? – fank Apr 15 '11 at 13:55
1

Don't know if this is what you are looking for, but it sounds like Discrete Event Simulation could help.

decimus phostle
  • 1,040
  • 2
  • 13
  • 28
0

It seems like you need two things.

  1. To maintain a record of how many arrivals occurred by timeslot. This is called a histogram. The timeslot ( usually called a bin when discussing histograms in general ) of each arrival is calculated ( integer division is often useful here ) and the correct bin count ( array or vector ) is incremented.

  2. To estimate the delay experienced by each arrival. This requires discrete event simulation - a big subject. The Wikipedia article is probably a good start.

ravenspoint
  • 19,093
  • 6
  • 57
  • 103
  • thanks for reply i worked before with the discrete time event simulation but sorry i can not understand well how i can implement the 1st thing concerning the histograms. can you explain more or give me a website or anything to understand more?? :-) the question is : can i use these histograms and timeslots without using real time? thanks alot – fank Apr 18 '11 at 08:35
  • Histograms: Construction, Analysis and Understanding http://quarknet.fnal.gov/toolkits/ati/histograms.html – ravenspoint Apr 18 '11 at 14:53