Name: XXXXXXXXXXXX ID: XXXXXXXXXXXX Date: Dec 1, 2017 To compile my program, type "make". To run my program, type "./sim". This was coded at home and at the U of C computer labs. NOTE:Read this file down to at least the charts before you change any init values. You can change the variables of my program at the top of the program, you will have to recompile. Most reasonable values are roughly tested (i.e. Dont put in negative elevators), though putting in too many extremes will enter into untested territory. My program should be able to run any number of elevators, any elevator size, any number of floors or any speed. The implementation I did used SSTF and Linear Scan, and the two idle modes I did were bottom and middle. The simulation technique I used was time step - I used this because I thought an event-list would be too much of a hastle to get each elevator on the correct floor after each loop iteration. Ex: Elevator 1 wants to get to the bottom, then up 3 while elevator 2 wants to go up 2 then idle and then with an update person working event. Basically, event lists make it more difficult to update every event, especially with things happening in between, for this particular simulation. I didnt use trace driven for a similar reason, it would be annoyingly difficult to match the elevator times to evey other elevator and working time. There is one bug that I can find in my program: Linear Scan seems to only work up to about 20,000 trials. Then it either starts to infinitely loop or just takes to long to finish - I suspect an infinite loop. I am considering 20,000 trials to get an average wait time to be high enough to represent the actually value. I misinterpretted the Linear Scan algorithm. My interpretation: Move in one direction until you start to idle (then pick the quickest direction after that). This means that if the elevator is on floor 1, it will pick up someone on floor 2, who wants to go to floor 1, then go all the way to the max floor, picking up anyone on the way, and then back down to the first floor, dropping people off on the way. I dont think I have enough time to rewrite this portion of the code, so sorry about that. Any reference of linear scan in this file, and others, will assume that my implementation was used. For all charts bellow, the units are in seconds. 0 on the top is bottom, 1 on the top is middle 0 on the left is SSTF, 1 on the left is Linear Scan Here is a chart of my average wait times using 1 elevator: Idle->| 0 | 1 | Mode| \\ | \\\\\\\ | \\\\\\\ | 0| \\ | 137.383 | 137.858 | 1| \\ | 191.567 | 182.865 | Here is a chart of my average wait times using 2 elevators: Idle->| 0 | 1 | Mode| \\ | \\\\\\\ | \\\\\\\ | 0| \\ | 104.924 | 105.075 | 1| \\ | 151.613 | 135.006 | Here is a chart of my average wait times using 3 elevators: Idle->| 0 | 1 | Mode| \\ | \\\\\\\ | \\\\\\\ | 0| \\ | 101.812 | 101.823 | 1| \\ | 144.950 | 125.115 | Elevator Mode: As you can see above, on average the SSTF algorithm is much quicker than the linear scan algorithm. This makes sense, because, the linear scan algorithm will pick people up going in one direction and then take a very long round a bout way to drop them off. You could argue that SSTF will also do this, and it will, but given the amount of time it takes for people to work and show up, it is a less significant variable for the SSTF than for the LS algorithm. It is possible for long "waiting to get to floor X" chains to occur for SSTF, but it will, on average, be less than that of LS. Idle Modes: Between the idle modes, bottom and middle, I am surprised that the difference is so small for SSTF. I would expect that the difference between them would be at least 10 less for middle mode. I think my initial expectation is wrong because since this elevator can go in both directions on a dime, it averages out each idle mode. For example, if someone appears at floor 1 then idle mode bottom will move them up in less time than the middle one. But then once that person wants to go back down, the middle mode will get them down faster than the bottom one, thus averaging out each mode. I conclude that this similar time for each mode makes sense. Linear Scan follows a trend that makes the middle mode better than the bottom mode. This makes sense do to my implementation of LS. If the elevator is in the middle and wants to move someone from floor 2 to 1, then they just go down whilst an elevator waiting at the bottom will have to go all the way to the top and back down which will drastically increase the average wait time. Number of Elevators: The gap between 1 and 2 elevators is larger than the gap between 2 and 3 elevators, and this makes sense do to the law of diminishing returns. If more and more elevators are added, the time between successive elevators will decrease more and more until the time between is negligible. This trend occurs for both SSTF and LS, which I think supports what I say. Of course, adding more elevators will make the average waiting time go down makes sense for obvious reasons - one may be free to pick you up whilst the other is busy.