## The 2-Cycle Theorem and You… Part 2!

This is Part 2 of a 2-part series on the 2-cycle theorem and how to apply it to Healers. In Part 1, I described how and why the 2-cycle theorem works and why it isn’t quite appropriate for Healers. In this (somewhat harder to follow) part, I discuss a solution to the problems I posed last time. In the process, I Solve Healing Once And For All (TM).

##### Disclaimer: Solving Healing Once And For All (TM) is a trademark of UNconstant and is not indicative of the product’s efficacy or completeness. Apply mounds of salt when reading this phrase.

At the end of the last post, I said that I think the problem lies in the scope over which we define the objective function – let me expand on that. In my day job, I read a lot about objective functions and optimizations which are used to make images look prettier. One of the standout comments in the literature is that the traditional methods are problematic because they are “insufficiently local in nature” – that means that they don’t react strongly to variations and details in the image. They are known as “global” functions – something which fundamentally assumes that we’re interested in only the result as a whole. Why is this important to healers and the 2-cycle theorem?

… or in our case – don’t.

Well, healers don’t care about the overall healing – we care about the minute to minute healing. If we don’t heal enough in a certain section of the encounter, we do the job incorrectly. This is what’s meant by “local” – you can’t just take into account the “whole fight”. We need a more local description of how healing works! I intend to develop such an approach in this post. I’m going to just straight into some examples now, because that is much easier for me that discussing the general principle.

### A New Approach

Imagine that I have a fight which has two distinct phases; constant low damage and constant high damage. For simplicity, let’s assume that the fight is split up into just two sections, i.e. you do some part of the fight with very low healing and then for the rest of the fight you have to jump up to very high healing. It’s an absurdly simple model, but it serves to show the single biggest flaw in the 2-cycle theorem; if you’re doing your high-healing rotation in Phase 1, you are wasting your mana. If you’re doing your low healing rotation in Phase 2, you’re causing people to die. So the time you split between rotations is determined more by the fight than your mana bar.

If the ratio of time spent in each rotation is already defined (as in the example above), there is no point in working out how many rotations to use; the job is to calculate what the optimal rotation is for each Phase in the fight, and stick to that one. This would seem to indicate that when the fight constrains you, you have no choice but to just use the optimal rotation for each Phase. In this case, you can break the fight down however you like and you still won’t find an application for the 2-cycle theorem.

Now let’s relax the idea that it’s only the fight that determines your response. In reality, the fight dictates a lot of your response, but your mana bar also dictates what you can respond with. Now imagine that we were to split the total mana budget for the fight into two uneven halves; the ratio of the mana budget split by the healing required in each phase. The high healing part gets assigned more mana than the low healing part. In Phase 1, we can now apply the 2-cycle theorem in a different way; minimize the mana spent while adhering to a particular total healing requirement.

That is completely possible. Now instead of DPS or HPS as an objective function, we’ve decided to minimize the mana spent as the objective function. To minimize, all we have to do is define the objective function to be negative of the mana spent and just apply the regular old linear programming ideas that we did before. The reason that this works is that when you take something that gets more positive over time and stick a minus sign in front of it… it gets more negative (i.e. smaller) over time. That means that the solution to our problem is at the minimum mana spent that is possible while at the same time meeting the healing requirements of each phase of the fight.

That’s actually not far off what healers actually do! Admittedly, it’s not perfect; what we’d really like is to use up exactly all of our mana over the fight… but then we come back to the problems we’ve already discussed. Further, this proposed “mana minimization” 2-cycle theorem only applies to phases in a fight where the damage is a well-defined constant over time. Fights, in general, aren’t like that. However let’s go with it for the moment.

Given what we discussed above, the 2-cycle theorem applies very well to the problem. For each phase, there are at most two rotations which it’s correct to use.

That’s an interesting application, but what does it tell us? Substantially, what it tells us is that in order to minimize your mana use for any constant damage taken, you must use at most two rotations. The question of which rotations to use and when is then a question that “can be solved” but is entirely fight dependent (in contrast to the DPS 2-cycle theorem).

This theory is an interesting application of the 2-cycle theorem but it doesn’t actually use up all of the mana we can spend in the fight. That does kind of defeat the original question which the 2-cycle theorem was invented to solve. In addition, there is an important caveat in Linear Programming; these results are only valid if an optimum exists within the constraints. In plainer language; this theory doesn’t guarantee that we will have enough mana to even keep everyone alive!

One strategy for addressing this concern is to add another thing which we want to optimize over, and modify our objective function a little. Instead of just considering time in each rotation, let’s add the amount of Spirit which we want to spec for as a variable. Now, if that’s a variable then we might reasonably also want to specify that the difference between the spent mana and the total mana budget is exactly zero. That is effectively saying this;

If I want to do exactly enough healing to finish the fight, and also minimize the mana I spend, what amount of Spirit should I take in order to Just afford to complete all objectives?

… which is exactly what healers want to know! It sounds on the surface that this gives us 3 constraints and therefore we have exactly 3 non-zero co-ordinates, of which Spirit is probably one. That leaves 2 rotations which have a nonzero time spent – the 2-cycle theorem! But it’s not that simple (sadly).

You see, the Spirit required in order to complete the fight would be different if we measured it Phase by Phase than if we measured it over the whole fight! There would be nothing worse than getting it right in Phase 1 but not having sufficient mana for Phase 2, so we have to consider the total mana budget. This introduces a problem; the success we had with the 2-cycle theorem above only works for cases where Phase 1 and Phase 2 are completely separate. Here’s the “locality” problem cropping up again. Woe! A more sophisticated approach is required to solving the problem.

### Algorithms

Earlier, I mentioned that something was “a problem which can be solved“, in the infuriating way that mathematicians tend to do. The reason is that I am not solving it right now; there are solutions, and that is sufficient to ensure that we can progress further. However, we have just hit at something which can’t be solved by a process which I know of already. Time to break out the computer code and design an algorithm!

What I’m going to assume is that we can just apply, at any given time, an algorithm which solves the (already solvable) problem which we talked about above. Namely; given a mana budget for a Phase, calculate the optimal rotation which does exactly X healing but minimizes the mana spend.

The problem is; given that we can calculate the optimal rotation for any particular mana budget, calculate the optimal amount of Spirit (i.e. the optimal mana budget) which allows that requirement. First, let’s discuss a smaller part of a larger solution; how do we go from modelling an individual phase to modelling a whole fight? Why, start at the beginning. Naturally!

Let’s assume that we have a good model for a fight; it has two or three well-defined Phases where the damage is roughly constant and we know to a good approximation when the Phases happen. Pick a value for the Spirit, and take the fight Phase by Phase; minimize the mana spend along the way. At each new Phase, update the mana budget so that the next Phase is affected by the amount of mana you have left. At the end of the fight, at least one of the following things is true;

• You were unable to beat Phase X because you could not do enough healing.
• You were able to beat all Phases, because you did exactly enough healing.
• You had too much mana at the end of the fight.
• You did not have enough mana at the end of the fight.
• You had roughly zero mana at the end of the fight, but did not overspend significantly either.

Now, depending on which combination of results you get, you can say whether you need more or less Spirit.

So, you can run a “simulation” of a fight and determine whether you had enough Spirit so… why not try another run with a different amount of Spirit? Easy. Repeat until you settle into a place where you can finish the fight and have roughly zero mana spent. At the same time, you calculate the optimal way of finishing the fight. This is a flow chart showing how the algorithm proceeds;

What I like about this is that the algorithm is very simple to implement in code, should be very quick to finish for any given fight, and should work! That’s the best thing about it, really. The main problem is that you have to already have a good model for what a fight looks like and what a “realistic” damage situation constitutes, neither of which I think we have a good picture of at the moment. In addition, while the technical detail of the code may be relatively simple, there will be some significant work required to build a database of sensible rotations and their healing/mana values. In all, it’s not a trivial problem to solve, but it can be solved.

### Wrapping Up.

So that’s it. That’s how to “solve” healing! All you have to do is have a good idea of what a fight looks like in terms of Phases, damage dealt, and mana spends per rotation. You also have to make an exhaustive list of rotations in order to actually be able to say with certainty that your solution is correct. Still, that’s work for another day! 🙂

What you should really take away from this is that it is entirely plausible that we can predict what levels of Spirit (approximately) will be optimal for which boss setups. It’s possible (arguably, even easy) to take into account active mana regeneration like the newly announced change to Elemental Blast for Restoration Shaman. Bringing everything together to follow up on this idea will be quite difficult, but it is certainly not impossible.

So there you go. Healing is solved, you can all go to bed happy now.   ;]