A company has several automatic vertical warehouses (called *elevators*). Each elevator have several *trays* and each *tray* has several *slots*. A slot contains a given quantity of a given article. Elevators, trays and slots are identified by unique IDs and slot also have access to the ID of their own article. In the same tray there can be multiple slots with the same article.

I have to design an algorithm which, given an order list (we can model it as a dictionary with articles’ IDs as key and quantity needed as values), returns the **minimum list of trays needed to satisfy the order**.

This is quite different from a standard warehouse optimization problem because we are not considering the physical distances between each tray, since the elevators are automatic and they give us the tray, while in the classical problem is the human who moves toward the tray to pick the item from it.

A distance function is given: **d(a, b)** which returns 1 if tray a and b are on different elevators and returns 2 if they’re on the same one. That could be counter-intuitive, but remember that these are *vertical* elevators, so the time needed to change tray on the same elevator is greater than the time to move to a different elevator with the tray already in bay. Furthermore, if we use more elevators at the same time, we can “parallelize” the picking process (man A pick from elevator 1 while man B picks from elevator 2…) Anyway, this function is given and I cannot change it.

After reading through articles about warehouse optimization, I’ve decided to take an heuristic approach.

I’ve modeled a sort of euclidean space, with an axes for each article contained in the order. Then we can consider a tray as a point on that space, with coordinates for each axes equal to the quantity that tray has of the article corresponding to that axes. In the same way we can imagine our order as a point.

Then I’ve create a heuristic function, **f(order o, tray t)**, which returns the “euclidean distance” from *point-tray t* to the *point-order o*. The idea is that the more a tray is “near” the order, the more article we can pick out of it.

So, to satisfy the order, I simply compute **f(order o, tray t)** for each tray in every elevator. Then I order it by descending value and finally I **greedily** take a tray with the minimum distance from the order. This will be repeated until we collect enough articles to satisfy the order.

Now I `d like to find a better solution, taking into account also the physical distances from tray returned by function **d**.

I`ve tried to build a graph in which each node is a tray and is connected to each of the others by a directed edge. The weights of the edge from node i to node j will be equal to the physical distance from tray i to tray j, plus the heuristic function computed on tray j

```
--> w(i, j) = d(i, j) + f(order, j)
```

This results in a fully-connected, bidirectional graph (each node linked with each other node by both an incoming and an outgoing edge).

I want to apply some algorithm of shortest path (or any other useful algorithm) taken from graph theory on this graph but I couldn`t find anything really helpful. I`

ve tried to apply the A* search algorithm (using function **d** as *gScore* and my function **f** as *heuristic*) but it gives me no result. I think A* can`t be applied in such a graph (bidirectional and fully connected).

Is there any algorithm I can apply on such a graph? Or maybe the graph is not the right structure to represent my problem. I`m open to new solutions.