I really enjoy solving math problems. So it's a real bummer when I spend a good amount of time solving one only to find that neither an answer nor a worked out solution is available for me to check my work against. Here is one that I felt like would be fun to share in the hopes that either someone can enjoy the solution to this problem as well or perhaps point out if I have made a mistake.
This problem comes from the text Mining of Massive Datasets by Ullman and Rajaraman (edited slightly for text jargon that is confusing out of context):
Suppose a job consists in $n$ tasks and each task has a probability $p$ of failure. Suppose also that the execution time (summed over all tasks) of taking a checkpoint (backing everything up so that not all of the work has to be redone in case of failure) is $c$ times the time it takes to execute a task. To minimize the expected execution time of the job, how many tasks should elapse between checkpoints?
Definitely go ahead and solve this before reading on!
We can tackle this problem as follows, first derive an expression for the expected execution time of a job in terms of the number of checkpoints taken during the job. With such an expression we can solve for the number of checkpoints using standard optimization techniques i.e. differentiate with respect to the number of checkpoints, set the derivative to $0$ and solve.
Let $T$ be the time required to complete the job. In the best case, $T$ will be equal to the sum of the time it takes to complete all tasks and the time that it takes to make all the checkpoints, that is $T=nt + n_{c}ct$ where $n$ is the number of tasks, $t$ is the average time to complete each tasks and $n_{c}$ is the number of checkpoints being taken. If we let $t=1$ then the expression simplifies to: $T=n + n_{c}c$. Of course, this is the best case, where there are no failures, so to account for failures we introduce the term work lost, $w_{l}=\Sigma_{i=1}^{f} l_{i}$ where $f$ is the number of failures and $l_{i}$ is the number of jobs lost on the $i^{th}$ failure. This makes our expression $T=n + n_{c}c + w_{l}$, now we may take the expectation $E\lbrack T\rbrack = E[n + n_{c}c + w_{l}] = n + n_{c}c + E[w_{l}]$. We must now disentangle $E[w_{l}]=E[\Sigma_{i=1}^{f} l_{i}] = E[f]E[l_{i}] = np\frac{n}{2n_{c}}$ Plugging this back in we have $E[T] = n + n_{c}c + np\frac{n}{2n_{c}}$. And so we have derived a differentiable expression for $E[T]$ which completes the first step in our solution!
In the second step we differentiate $E[T]$ with respect to $n_{c}$ as follows and set the derivative equal to 0, this gives: $\frac{\partial}{\partial n_{c}}E[T]=c-\frac{n^2 p}{2n_{c}^2} = 0$. Solving this equality for $n_{c}$ we obtain $n_{c}=n\sqrt{\frac{p}{2c}}$ and finally we divide $n$ by $n_{c}$ for the number of tasks that should elapse between checkpoints for a final answer of $\frac{n}{n_{c}} = \sqrt{\frac{2c}{p}}$.
I have a feeling that there may be a simpler solution to this problem which skirts the introduction of so many variables. If anyone thinks of one please share!
No comments:
Post a Comment