Model analysis and program design of elevator dispatching problem (i.)

Source: Internet
Author: User

Model analysis and program design of elevator dispatching problem (i.)

    • Pair member: Nan Lei mouth flat tone
    • Coding System Address: Https://coding.net/user?key=2e63bb37-ddda-401d-8763-5c9ce6b1e8e7;
    • Nan Lei cnblogs Home address: http://www.cnblogs.com/ruanlei/;

I. Analysis of elevator dispatching problem

    • Problem description

existing new office building, a total of 21 floors, a total of four elevators, all elevators basic parameters are shown in the following table:

Elevator number

Service Floors available

Maximum number of passengers

Maximum Load weight

1

All floors

10

Approx.

2

Single layer

10

Approx.

3

Double

20

Approx.

4

All floors

20

Kg

The terms of use are as follows:

    1. The floor number is 0~20, of which No. 0 is the basement level;
    2. Elevators with floor restrictions do not stop at the response floor, such as a single double layer;
    3. All elevators are controlled by a unified button.
    • Demand analysis
    1. need to design four elevators , and you need to pay attention to the functions required by the four elevators;
    2. Considering elevator single-deck scheduling, elevators with floor restrictions do not stop at the response floor (i.e. single-storey elevators can only be dispatched between odd floors, and double-decker elevators are only dispatched between even floors);
    3. external elevator button response events, all floors with a unified button, and 0-storey only " Up button with "down" button on layer 20, two buttons for the remaining floors,
    4. Each elevator has different properties, such as the number of passengers and lift load, for the weight of the passengers of the property we have a random number to generate each passenger weight, and finally the total weight calculated by the number;
    5. Elevator scheduling should be in accordance with a certain priority to operate; For example, we specify odd-level passengers to odd floors, where we give priority to single-storey elevators;
    6. when no one was riding in the elevator, we stopped the elevator to the floor where the elevator was last run.

Two. Elevator scheduling function Realization

    • Elevator function Design
    1. When the elevator external passengers click on the Elevator button event, we judge the passenger's current floor and click operation;
    2. When the passenger enters the interior of the elevator, the passenger chooses the floor to which he wants to arrive, and we need to determine if the number of passengers in the lift is exceeded and the elevator is overloaded? If the elevator is overloaded we will call another suitable elevator to send the remaining passengers to the corresponding floor;
    3. And we judge whether the elevators that operate in the same direction have overlapping areas between the floors to which the passengers need to reach, so that we can send the passengers to the required arrival level in turn;
    4. For passengers of different directions, we have a priority to determine whether there is an empty elevator, if there is no empty elevator, then wait;
    5. For the elevator setup we use the structure array method to store four elevators, and set the corresponding elevator properties in the structure body.
    • Elevator function Flow Simulation
    1. External function implementation
    • The elevator outside should have the key function, determine whether there are passengers to take the elevator, and should have the passenger quantity attribute; Here we show you the implementation of external features in the form of flowcharts:

/* Show lift current status function */void printstatus (struct Lift lift[]) {for    (int i=0;i<4;i++)    {        cout<<i+1<< " Current floor of elevator: ";        cout<<lift[i].status<<endl;    }    Cout<<endl;} /* Initialize elevator operating direction */void startdir (struct Lift lift[]) {for    (int i=0;i<4;i++)    {        lift[i].dir=1;    }} /* Determine the floor of the elevator, confirm the key setting */void Keyset (int i) {    if (i==0)    {        cout<< "select operation (1.Up  0. No one):";    }    else if (i==20)    {        cout<< "selection action (2.Down  0. No one):";    }    else if (i>0&&i<20)    {        cout<< "selection operation (1.Up  2.Down  0. Unmanned):";    }}
2. Internal function Implementation
    • Inside the elevator we use the definition of a two-dimensional array in a struct array lift[i].floor[r][2] to store whether a passenger on a certain floor has a lift and record the number of passengers. And to determine the order of passenger call elevator operation, for different directions of passengers we use the strategy of calling the empty elevator to achieve, if there is no empty elevator waiting.

by this way we simulate the operation of the elevator, which is the core of the whole elevator scheduling problem. And this and we usually take the elevator when the dispatch mode when there is a big gap, according to the author understand the need to achieve an elevator actual scheduling, we need to introduce the concept of Java threads. However, the above-mentioned adjustment method can also achieve four elevator operation.

Three. Elevator dispatching test

    • This time we use the C + + language to achieve the function of the entire program, we have a simple test of the elevator scheduling situation, the first is the passenger to select the elevator and passengers need to reach the floor of the test, we assume that the same floor of everyone to the same floor, in this part of the test we only enter a set of passenger information, And we will dispatch the current number of floors of the elevator to display on the screen:
    • The second part of the elevator single-layer scheduling, We assume three cases: 1. Single-layer users arrive at the number floor, when we need to call the single-storey elevator (elevator 2nd); 2. Double-decker users reach even floors, when we need to call the double-decker elevator (elevator 3rd); 3. Single-layer users reach double-decker, or double-decker users reach the single layer, we need , Elevator No. 4th):
    • The third part is the elevator mixed dispatching, for example, on the 5 floor of the passengers to 15 floor, and at the same time there is a building of passengers to the 17 floor, we probably achieve such a mixed scheduling, the individual feel in the whole scheduling process should also be considered not comprehensive place, but the basic realization function, here need to consider the situation is actually more complex We make it simple:

Four. Summary

In this part, we mainly describe our team's basic idea of the elevator scheduling problem, and make a basic display for the problem model's establishment process and the realization of the final function. In general, our team completed the cooperation task, although only two people a small cooperation, But through this form, we learn the different ideas of the other side in solving the problem and the different ideas we put forward when we solve the problem, which helps us to solve the problem better. If we think for ourselves, it is possible that our own consideration of the problem is deficient in some aspect, and by way of cooperation, we can reduce the problem to a minimum, so as to have a great reference to the way we think about the problem in the future. In this part of the main for everyone to introduce the idea of design. In the next chapter, we will introduce everyone's responsibilities and roles in this development process.

Model analysis and program design of elevator dispatching problem (i.)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.