Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

The following optimization problem came to my attention as an idealization of the silly browser game Cookie Clicker, but is representative of a range of strategy games:

You have an initial production capacity $p_0$ and a number of improvements $A, B, C, \ldots$ to build in some sequence you can choose. Each improvement $X$ has a cost $c_X$ and will take time to build proportional to its cost and inversely proportional to your capacity. When finished it will increase your production capacity by a given amount $p_X$. You can only build one improvement at a time. Which sequence should you build in in order to get all improvements as quickly as possible?

To get a handle on this I started looking at the case where there are only two improvements $A$ and $B$. The time it will take us to build $A$ first and then $B$ is $\frac{c_A}{p_0} + \frac{c_B}{p_0+p_A}$, and mutatis mutandis for $B$ first. So you should choose to build $A$ first iff $$ \frac{c_A}{p_0} + \frac{c_B}{p_0+p_A} < \frac{c_B}{p_0} + \frac{c_A}{p_0+p_B} $$ After a bit of algebra (assuming the various parameters are positive, etc.) this turns out to be equivalent to $$ \tag{*} \frac{c_A}{p_0} + \frac{c_A}{p_A} < \frac{c_B}{p_0} + \frac{c_B}{p_B} $$ This condition has the nice property that all $A$s are on one side of the inequality and all $B$s are on the other. This hints of a solution for the case with more than two improvements, at least heuristically: Compute $c_X/p_0 + c_X/p_X$ for each improvement and start by building the $X$ with the lowest value. Afterwards, repeat the computation with a new $p_0$.

This question is about is the expression $$\frac{c_X}{p_0} + \frac{c_X}{p_X} = c_X\Bigl(\frac1{p_0}+\frac1{p_X}\Bigr)$$ It is suspiciously simple in light of the maze of algebra that me to it. My question is: Is there an intuitive way to understand that this expression is the right thing to compare?

The $c_X/p_X$ term is easy enough to understand: it is the cost per unit of added productivity we pay for building $X$. But what about $c_X/p_0$?

The effect of $c_X/p_0$ makes qualitative sense: In the limit of $p_0$ small this term dominates over the $c_X/p_X$ terms, and (*) reduces to comparing $c_A<c_B$. In other words when we have very little initial production capacity the important thing is to get something built as quickly as possible, and then the other will take comparatively little time. On the other hand, in the limit of large $p_0$s, the $c_X/p_0$ terms vanishe and we're left comparing $c_A/p_A$ with $c_B/p_B$. Then we should just buy the improvement that gives us most bang for the buck first. That makes intuitive sense too.

But between those two limits, why is $c_X/p_0$ the right adjustment term? What does it represent intuitively?

share|improve this question

2 Answers 2

I'm not sure whether looking for physical meaning makes much sense here because swapping of A and C in the ABC sequence is governed by a completely different law, which does also depend on the B parameters. An interesting problem, by the way! I have no idea how to do the general case...

An example:

Put $c_1=4/3, p_1=1, p_0=p_2=p_3=c_2=c_3=2$. This gives $c_1(\frac 1{p_0}+\frac 1{p_1})=c_2(\frac 1{p_0}+\frac 1{p_2})=c_3(\frac 1{p_0}+\frac 1{p_3})=2$, which means that no particular choice of the first step has any advantage according to the "heuristic strategy", and if we decrease $c_1$ just a tiny bit, it becomes the choice to make.

However, every order starting with $c_1$ currently gives $\frac 46+\frac 23+\frac 25=\frac{26}{15}=\frac 53+\frac 1{15}$ and every order ending with $c_1$ gives $\frac 22+\frac 24+\frac 4{18}=\frac{31}{18}=\frac 53+\frac 1{18}$, which is strictly shorter time, so it remains shorter under small perturbations.

share|improve this answer
    
Perhaps better as a comment? :) –  Sharkos Aug 28 '13 at 23:47
1  
Perhaps... How do you convert? –  fedja Aug 29 '13 at 0:36
    
If you have a concrete counterexample with three improvements where the heuristic I sketch would make a non-optimal decision, I'd be most interested in seeing it. –  Henning Makholm Aug 29 '13 at 9:48
    
@Henning Makholm Sure. I just posted it. Sorry for the delay :). –  fedja Aug 31 '13 at 13:59
    
Amazing. (+1) I probably ought to have tried something like that before becoming so enamored with the heuristic. –  Henning Makholm Aug 31 '13 at 15:29
up vote 5 down vote accepted

(Sigh. Of course simply writing down the question made me think enough about it to see the solution, but not before I'd already posted the question. Move along, nothing to see here).

Somehow it had escaped me that the $\frac{c_A}{p_0}$ term is there in both inequalities. It is simply the time it will take for improvement $A$ to be finished. In the same language $\frac{c_A}{p_A}$ is the time it will take for improvement $A$ to produce enough to pay for its own production cost after it is finished.

That makes perfect intuitive sense.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.