Friday, October 19, 2012

Optimising stats

Megalodon has done a series of posts detailing the combination of % gear and stat gear on the official DoH blog.  While his derivations are good, they work in a way that doesn't generalise well, and that obscures some of the nice properties of the model.

Note that this is not criticizing Megas work at all, he used the right tools that he had available to him, and I know and use some other techniques - the same numbers will fall out of my method and his.

The model

I'm going to write the basic model as $$ \begin{align} V &= (a_1 + n_1 s_1 ) (a_2 + n_2 s_2) \\ &= \prod_{i=1}^2 (a_i + n_i s_i) \end{align} $$ The parameters are:
  • $V$ is the final resulting stat
  • $a_1$ is the base amount of the stat
  • $n_1$ number of flat enchants
  • $s_1$ amount of stat per flat enchant
  • $a_2$ base amount of multi
  • $n_2$ number of slots assigned to multi enchants
  • $s_2$ amount of multi per multi enchant.
There is also a constrain on the total number of slots you are using $$\Phi = n_a + n_b = n$$

The ugly maths (skip this if you dont like math)

When $V$ is maximised $\ln V$ is also maximised, and it is the maximum of this that we will look for as it simplifies our calculus slightly. $$ \ln V = \sum_{i=1}^2 \ln ( a_i + n_i s_i ) $$ We can use the Lagrange multiplier method from calculus for constrained optimization to find the optima of this. $$ \begin{align} \nabla V &= \lambda \nabla \Phi \\ \begin{bmatrix} s_1 / ( a_1 + n_1 s_1 ) \\ s_2 / ( a_2 + n_2 s_2 ) \\ \end{bmatrix} &= \lambda \begin{bmatrix} 1 \\ 1 \end{bmatrix} \end{align} $$ Some rearanging of this gives: $$ n_i = \left( \frac{1}{\lambda} - \frac{a_i}{s_i} \right ) $$ Summing these and solving for $1/\lambda$ gives $$ \frac{1}{\lambda} = \frac{1}{2}\left( N + \sum \frac{a_i}{s_i} \right) $$ Which finally gives us $$ n_i = N/2 + \frac{1}{2}\sum\frac{a_j}{s_j} - \frac{a_i}{s_i} $$

Isn't this uglier than Megas math?

Now you may ask why we bothered with the complicated formulae above ... and the reason is that I expect that the general form above will cary through to determining the optimal balance mult, pow multi and flat pow for damage, but thats a topic for another post...

A simpler interpretation of the results

The formulae in the previous section seems very tricky to interpret, but there's actually a very simple interpretation:

The neat interpretation relies on this result: If $a + b$ is a constant then $a\times b$ is maximized when $a = b$. Interestingly this still holds when you are trying to maximize $(s_a a ) \times (s_b b)$ as the $s_a$ and $s_b$ coefficients factor out.

So here's how the nice interpretation of the formulae works.

Assume I want to maximize Luck using T3+ and T3% enchants on my halfling pirate at level 80/80. With unsocketed myth equipment and a full inventory of notable runes I have $16*6 + 2*60 = 212$ slots to fill. Since I'm a halfling pirate I get +88% to my luck multi from skills giving me a base of 1.88, also I get about 900 stat points from gaining levels.

My base multi of 1.88 is equivalent to $1.88/0.056 \approx 34$ T3% enchants. My stats are equivalent to $900/37.5 \approx 24$ T3+ enchants. So we have a total of $34 + 24 + 212 = 270$ slots equivalent. For best performance we need them equally split, so 135 each in t3% and t3+. But we already have equivalent to 34 T3% enchants so we need 101 more. We have already have the equivalent of 24 T3+ enchants so we need 111 more.

For a character that does not get the +0.88 to the base luck multiplier, they only have $1.0/0.056 \approx 17$ T3% enchants. Running through the maths in the same way we find that they hit their maximum with 109 T3% and 103 T3+ enchants.

2 comments:

  1. Are you certainly sure having 50-50% ratio always gives the Max output ??

    ReplyDelete
  2. Hi JP,
    Yes, a 50-50 split always results in the highest output, so long as the split is calculated to include all of the base stats. However you start with 100% multiplier (roughly 20 slots), and a much lower base value, (1-2 slots) which is why at low levels you get best results get +stats items.

    Another way to think about this is that when I'm at the optimal configuration it shouldn't matter if I switch one of my + runes for a % rune (or vice-versa). If it did mater, I would switch them and get a better result - contradicting my claim that I was at the optimum.

    ReplyDelete