Download presentation
Published byGladys Payne Modified over 9 years ago
1
Elevator Algorithm B 楊定 B 王育軒 B 陳昶亦
2
At first…. At first , our goal is to find a efficient way for an
elevator model like 二活 , which has four elevators and twelve floors.
3
Let’s do it So we start our work like this… Student A is at 4F , he wants to go to 6F so elevator α come to A now additional student B is at 8F , he wants to go to 2F so elevator β come to B now another student C is at 3F , he wants to go to 10F so elevator γ come to C another student D is at 7F , he wants to go to 4F So elevator δ come to D
4
However However , we sadly found that with more and more student , the situation is beyond our control. Student D student E student F ….Student Z…StudentAA Student AB….StudentZZ…… 8F 4F 9F 11F
5
Q_____Q That is goddamn hard……
6
We need change!! In order to keep us alive , we have to try another way Our model now is a twenty floors building with one elevator, we use the model to test the three elevator algorithm , to compare them , hoping the result is the same to our initial model
7
Algorithm we used 1.FCFS Which means “First Come First Serve.” It is the most simple and traditional way to control elevators. The first one who sends the request can take the elevator first. 2.SSTF Which means “Shortest Seek Time First” It works depending on the shortest distance. It will find out which floor is the closest to the elevator. The elevator goes to that floor, and search the next requested floor according to their distance.
8
Algorithm we used 3. SCAN&LOOK
LOOK is similiar to the SCAN. SCAN makes elevators moving from top to the bottom. Elevators turn back when they reach the top or the bottom. LOOK is an optimization of SCAN. The different is that the elevator turns back when there is no request in the elevator’s direction (up or down) in the time.
9
Our Code (1) struct Request{ int Where;
int When; // Have the same concept about order // From 1~200 bool visited; }request[100]; struct Elevator{ int now; int sum; int T; }elevator;
10
Our Code (2) Concept of real time (causality) Other Useful Function
Use in SSTF and LOOK(SCAN) Output at any time depends on input at the same time and in the past. Elevators can only respond the request which is sent before now Ex. if(request[i].When<=elevator.T)….. Ex2. elevator.T+=step….. Other Useful Function bool AllRun() bool AllRun2(int deraction, int Time)
11
Our Code (3) Three main functions Void FCFS() Void SSTF()
NOT real time algorithm The most simple one According to their orders Void SSTF() Real time algorithm Search requests by their time and just finding which is the closest Void LOOK(int z) Search requests not only by their time but the elevator’s direction z=0 means going up, z=1 means going down Steadier than SSTF
12
Result
13
Conclusion Obviously, according to our model , SCAN&LOOK is the best way among the three algorithm to manipulate an elevator. So , we think SCAN&LOOK should be chosen when decide which algorithm to be chosen to manipulate an elevator.
14
Thank you~~~
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.