Robertson–Webb envy-free cake-cutting algorithm

The Robertson–Webb protocol is a protocol for envy-free cake-cutting which is also near-exact. It has the following properties:
 * It works for any number (n) of partners.
 * It works for any set of weights representing different entitlements of the partners.
 * The pieces are not necessarily connected, i.e. each partner might receive a collection of small "crumbs".
 * The number of queries is finite but unbounded – it is not known in advance how many queries will be needed.

The protocol was developed by Jack M. Robertson and William A. Webb. It was first published in 1997 and later in 1998.

Problem definition
A cake C has to be divided among n agents. Each agent i has:


 * A value-measure Vi on subsets of C;
 * A weight wi representing the fraction of C to which the agent is entitled.

The sum of all wi is 1. If all agents have the same rights, then wi = 1/n for all i, but in general the weights may be different.

It is required to partition C into n subsets, not necessarily connected, such that, for every two agents i and h:"$V_i(X_i) / w_i \geq V_i(X_h) / w_h$"So i does not envy j when taking their different entitlements into account.

Details
The main difficulty in designing an envy-free procedure for n > 2 agents is that the problem is not "divisible". I.e., if we divide half of the cake among n/2 agents in an envy-free manner, we cannot just let the other n/2 agents divide the other half in the same manner, because this might cause the first group of n/2 agents to be envious (e.g., it is possible that A and B both believe they got 1/2 of their half which is 1/4 of the entire cake; C and D also believe the same way; but, A believes that C actually got the entire half while D got nothing, so A envies C).

The Robertson–Webb protocol addresses this difficulty by requiring that the division is not only envy-free but also near-exact. The recursive part of the protocol is the following subroutine.

Inputs

 * Any piece of cake X;
 * Any ε > 0;
 * n players, A1, …, An;
 * m ≤ n players which are identified as "active players", A1, …, Am (the other n − m players are identified as "watching players");
 * Any set of m positive weights w1, …, wm;

Output
A partition of X to pieces X1, …, Xm, assigned to the m active players, such that:
 * For every active player i and every other player h (active or watching):"$V_i(X_i) / w_i \geq V_i(X_h) / w_h$"So agent i does not envy agent h when taking their different entitlements into account.
 * The division is ε-near-exact with the given weights among all n players – both active and watching.

Procedure
''Note: the presentation here is informal and simplified. A more accurate presentation is given in the book. ''

Use a near-exact division procedure on X and get a partition which all n players view as ε-near-exact with weights w1, …, wm.

Let one of the active players (e.g. A1) cut the pieces such that the division is exact for him, i.e. for every j: V1(Xj)/V1(X) = wj.

If all other active players agree with the cutter, then just give piece Xi to active player Ai. This division is envy-free among the active players, so we are done.

Otherwise, there is some piece P on which there is disagreement among the active players. By cutting P to smaller pieces if necessary, we may bound the disagreement such that all players agree that: V(P)/V(X) < ε.

Split the active players to two camps: the "optimists" who think that P is more valuable, and the "pessimists" who think that P is less valuable. Let δ be the difference between the values, such that for every optimist i and every pessimist j: Vi(P)/Vi(X) – Vj(P)/Vj(X) > δ.

Divide the remaining cake, X − P, into pieces Q and R, such that the division is near-exact among all n players.

Assign P ∪ Q to the optimists. Because they believe that P is valuable, they necessarily believe that P ∪ Q is sufficiently valuable to more than cover their due share.

Assign R to the pessimists. Because they believe that P is less valuable, they necessarily believe that the remainder, R, is sufficiently valuable to more than cover their due share.

At this point we have partitioned the active players to two camps, each collectively claiming complementary portions of the cake and each camp is more than satisfied with their collective portion.

It remains to divide each portion of the cake to the players in its camp. This is done by two recursive applications of the procedure:
 * Recursively partition P ∪ Q among the optimists (i.e. the optimists are active and all other players are only watching).
 * Recursively partition R among the pessimists.

In both applications, the near-exactness factor should be at most δ. Because the resulting partition is δ-near-exact among all n players, the partition among the optimists doesn't cause envy among the pessimists and vice versa. Thus the over-all division is both envy-free and near-exact.