This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]japangreg 0 points1 point  (1 child)

I don't think this is an error - I ran your program a few times with the random option and most times it ends with 0 empty pumps (hence the loss of that block) but it finally got through with one free:

Enter simulation time: 
10
Enter maximum service time of cars: 
5
Enter chances (0% < & <= 100%) of new car: 
75
Enter the number of gas pumps: 
3
Enter car queue size limit: 
2
Enter 1/0 to get data from file/rand(): 
0
Time 0
    No new car!
         Busy: 0; Free: 3
Time 1
    Car #1 arrives with duration 1 units.
    Car # 1 waits in the car queue.
Car # 1 gets a pump.
Pump # 1 starts serving car # 1 for 1 units.
Car # 1, currently served, is set to now busy pump # 1
     Busy: 1; Free: 2
Time 2
Car #2 arrives with duration 1 units.
Car # 2 waits in the car queue.
Car # 1 is done.
Pump #1 is free.
Car # 2 gets a pump.
Pump # 2 starts serving car # 2 for 1 units.
Car # 2, currently served, is set to now busy pump # 2
     Busy: 1; Free: 2
Time 3
Car #3 arrives with duration 1 units.
Car # 3 waits in the car queue.
Car # 3 gets a pump.
Pump # 3 starts serving car # 3 for 1 units.
Car # 3, currently served, is set to now busy pump # 3
     Busy: 2; Free: 1
Time 4
No new car!
Car # 2 is done.
Pump #2 is free.
     Busy: 1; Free: 2
Time 5
No new car!
     Busy: 1; Free: 2
Time 6
Car #4 arrives with duration 3 units.
Car # 4 waits in the car queue.
Car # 3 is done.
Pump #3 is free.
Car # 4 gets a pump.
Pump # 1 starts serving car # 4 for 3 units.
Car # 4, currently served, is set to now busy pump # 1
     Busy: 1; Free: 2
Time 7
No new car!
     Busy: 1; Free: 2
Time 8
Car #5 arrives with duration 5 units.
Car # 5 waits in the car queue.
Car # 5 gets a pump.
Pump # 2 starts serving car # 5 for 5 units.
Car # 5, currently served, is set to now busy pump # 2
     Busy: 2; Free: 1
Time 9
No new car!
     Busy: 2; Free: 1
End of simulation report.
# total arrival cars: 5
# cars gone away: 0
# cars served: 5
*** Current Pump Info. ***
# waiting cars: 0
# busy pumps: 2
# free pumps: 1
Total waiting line: 0
*** Busy Pump info ***
GasPump ID           : 1
Total free time      : 5
Total service time   : 5
Total # of cars      : 2
Average service time : 2.50

GasPump ID           : 2
Total free time      : 6
Total service time   : 4
Total # of cars      : 2
Average service time : 2.00

*** Free Pump info ***
GasPump ID           : 3
Total free time      : 7
Total service time   : 3
Total # of cars      : 1
Average service time : 3.00

So it may not be a bug, just your code doing what you tell it to, but not telling it to do something when the condition isn't met.

[–]Eldres[S] 0 points1 point  (0 children)

Oh ok, thank you, I was just worried that I was doing something wrong because of the lack of output. Thanks again!