snippetMinor
How to solve an arrangement problem at the Archive Nationale of France using graph theory?
Viewed 0 times
problemfrancethegraphnationaletheoryarrangementsolveusinghow
Problem
Good evening! I'm actually doing an internship at the Archives Nationales of France and I encountered a situation I wanted to solve using graphs...
I. The dusty situation
We want to optimize the arrangement of books of my library according to their height in order to minimize their archive cost. The height and thickness of the books are known. We already arranged the books in ascending order of height $H_1,H_2,\dots,H_n$ (I don't know if it was the best thing but... that's the way we did it). Knowing each book's thickness, we can determine for each $H_i$ class the necessary thickness for their arrangement, call it $L_i$ (for example, the books that are $H_i = 23\,\mathrm{cm}$ tall might have total thickness $L_i = 300\,\mathrm{cm}$).
The library can custom manufacture shelves, indicating the wished length and height (no problem with depth). A shelf of height $H_i$ and length $x_i$ costs $F_i+C_ix_i$, where $F_i$ is a fixed cost and and $C_i$ is the cost of the shelf per length unit.
Note that a shelf of height $H_i$ can be used to store books of height $H_j$
with $j\leq i$. We want to minimize the cost.
My tutor suggested I model this problem as a path-finding problem.
The model might involve $n+1$ vertices indexed form $0$ to $n$. My mentor suggested I work out the existing conditions, each edge signification and how to work out the valuation $v(i,j)$ associated to the edge $(i,j)$. I would also be OK with other solutions as well as insights.
For instance we have for the Convention (a dark period of the French History) such an array:
\begin{array}{|c|rr}
i & 1 & 2 & 3 & 4\\
\hline
H_i & 12\,\mathrm{cm} & 15\,\mathrm{cm} & 18\,\mathrm{cm} & 23\,\mathrm{cm}\\
L_i & 100\,\mathrm{cm} & 300\,\mathrm{cm} & 200\,\mathrm{cm} & 300\,\mathrm{cm} \\
\hline
F_i & 1000€ & 1200€ & 1100€ & 1600€ \\
C_i & 5€/\mathrm{cm} & 6€/\mathrm{cm} & 7€/\mathrm{cm} & 9€/\mathrm{cm}\\
\end{array}
II. The assumptions of a trainee bookworm
I think I have to compute an algorithm between D
I. The dusty situation
We want to optimize the arrangement of books of my library according to their height in order to minimize their archive cost. The height and thickness of the books are known. We already arranged the books in ascending order of height $H_1,H_2,\dots,H_n$ (I don't know if it was the best thing but... that's the way we did it). Knowing each book's thickness, we can determine for each $H_i$ class the necessary thickness for their arrangement, call it $L_i$ (for example, the books that are $H_i = 23\,\mathrm{cm}$ tall might have total thickness $L_i = 300\,\mathrm{cm}$).
The library can custom manufacture shelves, indicating the wished length and height (no problem with depth). A shelf of height $H_i$ and length $x_i$ costs $F_i+C_ix_i$, where $F_i$ is a fixed cost and and $C_i$ is the cost of the shelf per length unit.
Note that a shelf of height $H_i$ can be used to store books of height $H_j$
with $j\leq i$. We want to minimize the cost.
My tutor suggested I model this problem as a path-finding problem.
The model might involve $n+1$ vertices indexed form $0$ to $n$. My mentor suggested I work out the existing conditions, each edge signification and how to work out the valuation $v(i,j)$ associated to the edge $(i,j)$. I would also be OK with other solutions as well as insights.
For instance we have for the Convention (a dark period of the French History) such an array:
\begin{array}{|c|rr}
i & 1 & 2 & 3 & 4\\
\hline
H_i & 12\,\mathrm{cm} & 15\,\mathrm{cm} & 18\,\mathrm{cm} & 23\,\mathrm{cm}\\
L_i & 100\,\mathrm{cm} & 300\,\mathrm{cm} & 200\,\mathrm{cm} & 300\,\mathrm{cm} \\
\hline
F_i & 1000€ & 1200€ & 1100€ & 1600€ \\
C_i & 5€/\mathrm{cm} & 6€/\mathrm{cm} & 7€/\mathrm{cm} & 9€/\mathrm{cm}\\
\end{array}
II. The assumptions of a trainee bookworm
I think I have to compute an algorithm between D
Solution
I think I have a solution to your problem. Hopefully I haven't misunderstood something in the definition of your problem. Here it goes:
I'm going to describe a Dynamic Programming approach. It's an $O(n^{2})$ algorithm, which means that since the number of books is huge it's not going to help you a lot. (you need to modify it a bit!). With some work, you can turn said Dynamic Programming approach into an instance of finding the shortest path on a Directed Acyclic Graph. (Which itself is a dynamic programming algorithm :P)
Suppose there are $n$ books all of different height.
Suppose also that the optimal cost is achieved by assigning the books to $i$ shelfs of height $h_{1},h_{2},...,h_{i}$ where $h_{1}C_{a-1}$
Suppose the contrary. Let $B_{a-1}$ be the set of books assigned to shelf $a-1$
Then $cost = other,stuff + C_{a-1}*thickness(B_{a-1})$
Since, we assumed, $C_{a}C_{a-1}$ for all shelfs created
B. Let $j$ be a book that is assigned to shelf $a$. Let's prove that $height(j)>h_{a-1}$
This is fairly easy. If $height(j)$ was smaller than $h_{a-1}$ we could put the book into shelf $a-1$ for a better cost (due to A).
Of the two things we've proven, B is the significant one.
Let $dp[a]$= the optimal cost for shelving books $1...a$ so that there is a shelf of $height(a)$.
You have to find a way to define $dp[a]$ by the values $dp[1],dp[2],....dp[a-1]$
I'm going to stop here. If you are familiar with Dynamic Programming, using fact B, you will easily come up with the recurrence. Otherwise, ask :). As I said, this can be turned into a DAG problem. Knowing the relation above, it's easy to realize what the edge $(a,b)$ stands for and define its cost.
Last but not least, like I said above,as books are large, you cannot use the algorithm for each and every book. I think that representing its height by the sum of its thickness should do the trick. (I think it's already like that from your statement)
(I'm guessing number of different heights is much much less than number of books)
I'm going to describe a Dynamic Programming approach. It's an $O(n^{2})$ algorithm, which means that since the number of books is huge it's not going to help you a lot. (you need to modify it a bit!). With some work, you can turn said Dynamic Programming approach into an instance of finding the shortest path on a Directed Acyclic Graph. (Which itself is a dynamic programming algorithm :P)
Suppose there are $n$ books all of different height.
Suppose also that the optimal cost is achieved by assigning the books to $i$ shelfs of height $h_{1},h_{2},...,h_{i}$ where $h_{1}C_{a-1}$
Suppose the contrary. Let $B_{a-1}$ be the set of books assigned to shelf $a-1$
Then $cost = other,stuff + C_{a-1}*thickness(B_{a-1})$
Since, we assumed, $C_{a}C_{a-1}$ for all shelfs created
B. Let $j$ be a book that is assigned to shelf $a$. Let's prove that $height(j)>h_{a-1}$
This is fairly easy. If $height(j)$ was smaller than $h_{a-1}$ we could put the book into shelf $a-1$ for a better cost (due to A).
Of the two things we've proven, B is the significant one.
Let $dp[a]$= the optimal cost for shelving books $1...a$ so that there is a shelf of $height(a)$.
You have to find a way to define $dp[a]$ by the values $dp[1],dp[2],....dp[a-1]$
I'm going to stop here. If you are familiar with Dynamic Programming, using fact B, you will easily come up with the recurrence. Otherwise, ask :). As I said, this can be turned into a DAG problem. Knowing the relation above, it's easy to realize what the edge $(a,b)$ stands for and define its cost.
Last but not least, like I said above,as books are large, you cannot use the algorithm for each and every book. I think that representing its height by the sum of its thickness should do the trick. (I think it's already like that from your statement)
(I'm guessing number of different heights is much much less than number of books)
Context
StackExchange Computer Science Q#48511, answer score: 7
Revisions (0)
No revisions yet.