Develop a simulation of an elevator - devise and implement


Elevator project

Develop a simulation of an elevator that travels between floors 1 and N where N is an input. Time is sequenced in discrete steps starting at 1; at each time step, the elevator may ascend one floor, descend one floor, or remain at its current floor, as determined by its strategy. The first line of the input file indicates the number N of floors. This is followed by one line per person using the elevator: her id, call time (when she calls for the elevator), origin floor (where she boards the elevator), and destination floor (where she debarks the elevator). For example:

5
100 2 1 4
101 3 4 5
102 3 3 2
103 5 5 1
104 5 1 4

Here, individual 100 boards at time 2 from floor 1 with a destination of floor 4. Assume sensible inputs (e.g., times are positive integers, floors are integers in the range 1 through N).

Whenever the elevator stops at a floor from which people have called it (i.e., their origin floor but not before their call time), they all board the elevator. And whenever the elevator stops at any passengers' destination floor, they all get off the elevator. (Everyone behaves so as to minimize their travel time.) The simulation stops when every individual has been brought to their destination floor (subject of course to their call time and origin floor constraints).

A strategy determines the floor the elevator begins on at time 1, and a policy for moving to the next floor (up one floor, down one floor, or remaining at the current floor) from one time step to the next. Here is a simple strategy:

Strategy 1: Start at floor 1. In each time step, successively go up one floor until reaching the top floor N, then successively go down one floor until reaching the bottom floor 1, and continue this ‘up to the top floor then down to the bottom floor' policy.

1. A scenario diagram for the case where a customer calls the elevator, the elevator arrives, she boards, the elevator moves (over time) to her destination floor, and she debarks. You may devise other diagrams but this one is essential. You are welcome to discuss and work on your design on our discussion board and during class time (but you should implement the project on your own).

2. Implement Strategy 1 as part of your project. In addition, devise and implement a second strategy that is generally more efficient than Strategy 1. Where sim is a Simulation object, we run a simulation like this:

sim.run(filename_string, strategy_symbol)

The symbol :strategy2 should identify your (more efficient) strategy.

3. Write a method

sim.multirun(nbr_runs, filename_prefix, strategy)

that runs your program nbr_runs many times on the input files named by filename_prefix with suffixes 000.in, 001.in, ..., and returns the average efficiency. For example:

sim.multirun(15, 'myelev', :strategy2)

runs your Strategy 2 on the files myelev000.in, ..., myelev014.in and returns the average of the 15 efficiency values. I will give you a set of input files to test your program on, and you should report the average efficiency you obtain on these files for both strategies. You can also use these input files to compare your strategy to other strategies, with respect to efficiency. I'll also give you a short Ruby program to generate your own test files.

4. Submit your Ruby code for this project, in addition to your scenario diagram, in a zip archive by the due date.

Solution Preview :

Prepared by a verified Expert
Computer Graphics: Develop a simulation of an elevator - devise and implement
Reference No:- TGS0808518

Now Priced at $70 (50% Discount)

Recommended (96%)

Rated (4.8/5)