Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Modern Software Engineering pair programming (II) Elevator dispatching

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Modern Software Engineering pair programming (II) Elevator dispatching

Pair Project II: Elevator Scheduler

Pair programming assignment, author: Zou Xin

How to design API? How to consider the demand from different angles? How to evaluate different designs?

How to design a test framework to test many solutions? How to drive such a testing framework?

How to work with partners to meet these challenges quickly and effectively?

This is what we are going to practice in this little project.

Design and implement an Elevator Scheduler to aim for both correctness and performance, in managed code.

Skills to practice:

A) Requirement Analysis

Demand analysis

B) High level design (interface, information hiding, loose coupling)

Program API design, information hiding, coupling

C) Test Framework Design

Design test framework and simulate test data

D) Implementation skills

Realization of the design

E) Algorithm design

Algorithm design

1. Background

Imagine we're building a tall office building, We need to have design an efficient elevator system to carry people to their destinations. The following is an example of the configuration about elevators:

The Building has 21 floors, 4 elevators, many passengers use these elevators everyday (passenger weight: average 70kg. Max 120kg, min 40g).

Other constant data: Elevator speed, door open/close time, passenger time for going in/out of the elevator. We can make reasonable assumptions about these.

The building has 21 floors, from floor 0, 1,... To 20. Floor 0 is the underground parking level, floor 1 is the lobby level. Most people come in/out the building via these 2 floors.

Elevator name

Service floor list

Passenger limit

Weight limit

one

All floors

ten

800 kg

two

Floor 1..10

ten

800 kg

three

Floor 0,1,2..10

twenty

1600 kg

four

Floor 0pr 1, 11-20

twenty

2000 kg

* note: in our test program, the configuration of elevators can be changed, the scheduler need to read the configuraiton at the initialization time via the API.

2. Requirement to Student pairs

2.1 Each pair of students will design a set of interface and class definition so that an algorithm provider can provide his/her implementation to the "elevator scheduler" class.

2.2 We will discuss the student's submission in the class, pick the best design.

2.3 after the API is decided, we will focus on the design of test framework

2.41-2 volunteers will implment a "test framework" app, and the rest student pairs will each pair will focus on the implementation of the "elevator scheduler" program.

Consideration for the API:

A) how to keep it simple.

B) how to provide enough info for the scheduler to finish the scheduling work, without knowing too much info?

C) which component is actually driving the elevator?

D) how to regulate proper passenger behavor? (e.g. If a passenger needs to go to floor 3 from floor 20, but the current elevator can't go there directly, what should the passenger do?)

Consideration for the test framework:

A) how to make sure it generates the same result for the same test cases on a given scheduler?

B) how to check the correctness of the scheduler?

C) how to prevent "cheating" by the scheduler?

D) how to emulate the "real world" efficiently? (e.g. if 2 passengers are 30 minutes away, does the test framework need to wait for 30 minutes?)

TA will come up with a consistent testing model to test your program according to the "rush hour" scenario (see below), and record the total travel time of all passengers.

You (student pair) have:

2.5 Explanation of BUS program:

We can have a worst case algorithm called "bus". This algorithm treats an elevator as a bus, it goes from bottom to top, stops at every floor, open the door, to let people in and out, then close the door and move on. After it reaches the top floor, it will go down. This algorithm can serve all requests, but it's apparently not the fastest algorithm.

Your code is required to be managed code (managed Clearing, etc).

It has to generate 0 (zero) Code Analysis warnings and errors. (link for Code Analysis in Visual Studio)

It has to be correct, all passengers can reach their destinations

It should be as fast as possible.

It should not have randomness in scheduling (this is to avoid randomness in testing).

Score guideline: TA will evaluate the "average total travel time" for all passengers in the same test case, the lower, the better. If your performance is lower than "bus" solution, you get 0 points; if your program can't deliver any passenger to the correct destination, you get 0 points.

One hint about elevator scheduling: When total weight is within 40 kg of the max limit, or the number of passengers is already at maximum, the elevator doesn't need to stop for more external requests.

The elevator scheduler program doesn't know how many passengers are waiting on each floor, it doesn't know how many passengers will show up either. This is the same with the real world situation.

3. Testing

TA will simulate a "rush hour" test. The "rush hour" test is to simulate the come-to-work and leave-work scenario in a business building, which has the following 2 parts (they can be run next to each other).

20 people going thru random floors within 5 minutes.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report