Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program to fulfil this assignment INTRODUCTION TO PROGRAMMING (202223) Task 3 The subject of this paper is the optimization of the operation

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Write a C program to fulfil this assignment

INTRODUCTION TO PROGRAMMING (202223) Task 3 The subject of this paper is the optimization of the operation of an elevator. The problem you are asked to solve is formulated below. The problem An elevator operates in a building with infinite floors (terms 1,2,3, ). On the ground floor (term 0) there are nrid people, each of whom wants to go to term destsi (1inrid). For some (technical and other reasons) the elevator will start from the ground floor and make at most nst stops. Each destination and take the stairs to his destination. Each time a passenger goes up or down the stairs from a condition to a condition adjacent to it (either going up or going down) has a cost of 1. What is the optimal solution (overall minimum cost), i.e., which stops should the elevator make so that its passengers make the fewest possible trips on foot? Among solutions with the same cost, those where the lift stops at lower floors are preferred (the reasons may be energy-related or for passengers to exercise and go up floors instead of down). It should be noted that it is not necessary for all passengers to enter the lift. Some may walk from the ground floor to their destination (because this will be closer to the ground floor than to the first lift stop). Also, there is a potential solution to the problem with less than nst stops, because the elevator will stop at all of its passengers' destinations and the cost will equal 0 . lift makes its two stops at the floors stops =[512], then the cost of this solution can be calculated as follows. The first passenger with a destination at floor 11 will exit at floor 12 (the nearest stop to his destination) and descend the stairs 1 floor (cost equal to 1). The second passenger, with a destination at floor 2, will not enter the lift and will take the stairs two floors up (cost 2). For the third passenger, we have a cost equal to 2 (destination floor 7 and stop at floor 5). Similarly, we find that the cost for the fourth passenger is 1 and for the fifth is 2 . The total cost for all passengers is 1+2+2+1+2= 8 , which is the cost of this solution. However, the solution stops =[711] has a cost equal to 4 (why? ) and can be shown to be the optimal solution. Thoughts on solving the problem As originally mentioned, we assume that the building has infinite floors. However, we easily observe that there is no case where the optimal solution contains a stop at a floor higher than the highest passenger destination. In the previous example, it does not make sense to have a stop above term 13 (if there were such a stop, we could move it to term 13 and the new solution would certainly have a lower cost than the previous one). For the sequel, let us denote the highest passenger destination as nfl Managing the contingency that fewer than nst stops are sufficient, so that we have a least-cost solution equal to 0 , can be handled in a simple way. Consider the case of nrid=5,nst=3 and We could represent this solution as stops =[006]. That is, we assume that there are additional, practically non-existent, stops on the ground floor. If a and b are two consecutive stops of the elevator, let fw(a,b) denote the total number of floors that all passengers who have a destination term d higher than term a will have to walk (a

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

=+(f2-tf1) du 0, since the integrand is nonnegative.

Answered: 1 week ago

Question

1. How might volunteering help the employer and the employee?

Answered: 1 week ago