Tweeted twitter.com/StackProgrammer/status/780894996593537024
2 Improved readability.
source | link

what What algorithm is used by elevators to find the shortest path to travel floor orders?

I'm trying to simulate an elevator, as always I started very simple by taking only a single order at a time., then added memory to the elevator in the form of queues so that floors are traveled in the order in which they were pressed, which obviously isn't the best approach  . so

So at the moment I'm using a very simple and "short sighted" logic which is, for the current floor find the floor closest to me and set it as my next destination and loop till no more floors are in the list. but

But this doesn't always work  , for example the elevator was in the 3rd floor of a 5 floor building and got orders 4,5,2 the shortest path would be 2->4->5 which costs 4 floors but using this logic 4->5->2 which costs 5 has the same chance of being picked, depending on the code. how

How do I find the shortest path and make the elevator more efficient?

what algorithm is used by elevators to find the shortest path to travel floor orders

I'm trying to simulate an elevator, as always I started very simple by taking only a single order at a time. then added memory to the elevator in the form of queues so that floors are traveled in the order in which they were pressed, which obviously isn't the best approach  . so at the moment I'm using a very simple and "short sighted" logic which is, for the current floor find the floor closest to me and set it as my next destination and loop till no more floors are in the list. but this doesn't always work  , for example the elevator was in the 3rd floor of a 5 floor building and got orders 4,5,2 the shortest path would be 2->4->5 which costs 4 floors but using this logic 4->5->2 which costs 5 has the same chance of being picked, depending on the code. how do I find the shortest path and make the elevator more efficient?

What algorithm is used by elevators to find the shortest path to travel floor orders?

I'm trying to simulate an elevator, as always I started very simple by taking only a single order at a time, then added memory to the elevator in the form of queues so that floors are traveled in the order in which they were pressed, which obviously isn't the best approach.

So at the moment I'm using a very simple and "short sighted" logic which is, for the current floor find the floor closest to me and set it as my next destination and loop till no more floors are in the list.

But this doesn't always work, for example the elevator was in the 3rd floor of a 5 floor building and got orders 4,5,2 the shortest path would be 2->4->5 which costs 4 floors but using this logic 4->5->2 which costs 5 has the same chance of being picked, depending on the code.

How do I find the shortest path and make the elevator more efficient?

1
source | link

what algorithm is used by elevators to find the shortest path to travel floor orders

I'm trying to simulate an elevator, as always I started very simple by taking only a single order at a time. then added memory to the elevator in the form of queues so that floors are traveled in the order in which they were pressed, which obviously isn't the best approach . so at the moment I'm using a very simple and "short sighted" logic which is, for the current floor find the floor closest to me and set it as my next destination and loop till no more floors are in the list. but this doesn't always work , for example the elevator was in the 3rd floor of a 5 floor building and got orders 4,5,2 the shortest path would be 2->4->5 which costs 4 floors but using this logic 4->5->2 which costs 5 has the same chance of being picked, depending on the code. how do I find the shortest path and make the elevator more efficient?