Skip to content

2. The min-norm max-flow problem

Recall that the NPoS problem consists on selecting a committee of validators of size $m$, and then assigning stake from the nominators to the validators. In this note, we assume we already picked a committee $S$ of $m$ validators, and explore the best way to assign stake.

After establishing some notation, we introduce the min-norm max-flow problem (MNMF) and explain why this is exactly the problem we need to solve. We then establish two algorithmic ways to solve MNMF, namely 1) using parametric flow algorithms, and 2) using a heuristic called star balancing, and we compare them.

1. Notation

We consider an instance of NPoS consisting of a bipartite graph $(N\cup S, E)$, where $m:=|S|\ll |N|$ and an edge $nv\in E$ represents the approval of nominator $n\in N$ to the elected validator $v\in S$. We are also given a vector $b\in\mathbb{R}^N_{\geq 0}$ of nominator budgets. An edge weight vector $w\in \mathbb{R}^E_{\geq 0}$ is affordable if it is component-wise non-negative and observes the budget constraints: $\sum_{v\in V: \ nv\in E} w_{nv} \leq b_n$ for each nominator $n\in N$. It is called maximally affordable if $\sum_{v\in S: \ nv\in E} w_{nv} = b_n$ for any $n\in N$ having at least one neighbor in $S$.

Let $B\in {0,1}^{S\times E}$ be the node-edge incidence matrix for the set $S$. For any $w\in \mathbb{R}_{\geq 0}^E$, the total support that $w$ assigns to each validator in $S$ is given by the vector $supp_w :=Bw\in \mathbb{R}^S$, so that for any validator $v\in S$, its support is the total amount of stake that $w$ assigns to $v$ from the nominators.

2. The min-norm max-flow problem (MNMF)

Given an instance $(N\cup S, b)$ of NPoS, the min-norm max-flow problem consists of finding a maximally affordable vector $w$ that minimizes the squared $\ell_2$ norm of the support vector, i.e. minimize

Now let's see how MNMF is relevant to NPoS. For an instance $(N\cup S, E, b)$, we need to choose an affordable weight vector $w$ according to some sensible objective, which intuitively maximizes the validators' supports. The two objective functions that first come to mind are maximizing

  • the support of any validator:
  • the total support of any group of $\lfloor m/3 \rfloor$ validators:

We show now that an optimal solution $w^*$ to MNMF is simultaneously maximal with respect to both of these objective functions. In fact, it is simultaneously maximal with respect to the family of objective functions

parameterized by $k=1,\cdots,m$.

Furthermore, if we want to maximize objective $F_k$, but subordinate to that we also want to minimize the total amount of stake used, we show that we achieve this by a simple truncation of vector $w^*$ into a vector $w^k$, defined as follows.

Algorithm 2.1: Definition of $w^k$ for a fixed parameter $k\in{1,\cdots,m}$.

  1. Find an optimal (maximally affordable) vector $w^{*}$ for MNMF.
  2. Order the validators by support, so that
  3. Define $w^k$ from $w^*$ by setting, for each $n\in N$ and $i\in{1,\cdots m}$,
  4. Output $w^k$.

Theorem 2.2: For a given instance $(N\cup S, b)$ and a given parameter $k$, consider the weight vectors $w^{*}$ and $w^k$ defined above. Then:

  1. for any affordable weight vector $w$ (i.e. $w^{*}$ is optimal for $F_k),$
  2. $F_k(w^k)=F_k(w^{*})$ (i.e. $w^k$ is still optimal for $F_k$), and
  3. $|supp_{w^k}|_1 \leq |supp_w|_1$ for any affordable weight vector $w$ with $F_k(w^k)=F_k(w)$ (i.e. $w^k$ is budget-minimal).

Proof: We start with the second claim. We use the same ordering of the validators as defined in the algorithm above. Notice that whenever $i\leq k$, and otherwise. Clearly, function $F_k(w)$ is the sum of the supports of the $k$ validators with smallest support. For both $w^{*}$ and $w^k$, this set of $k$ validators is the same, namely ${v_1, \cdots, v_k}$, and their supports are the same. Hence,

This proves the second claim.

We continue with the first claim, which we prove by contradiction. We assume that there is an affordable vector $w$ with . We also assume without loss of generality that

a. $w$ is maximally affordable like $w^{*}$, i.e. , and b. the ordering of the validator set is such that whenever there is a tie with $i<j$ then .

We have the inequalities


Now define the vector and consider it as a flow over the network . All nodes in $N$ preserve flow (by assumption a.), and the previous two inequalities show that $f$ has a net demand in set and a net excess in set . Thus, if we decompose $f$ into paths, there must be a simple path carrying some $\delta>0$ units of flow from $v_j$ to $v_i$ for some . Moreover, by assumption b., it must be the case that , because in case of a tie we would have that $f$ has net excess on $v_i$ and net demand on $v_j$, and the previously mentioned $v_j$-$v_i$ path would not exist in the flow decomposition.

Now, let $f'$ be a subflow of $f$ that carries $\varepsilon$ units of flow from $v_j$ to $v_i$ along this path, where . The fact that $f'$ is a feasible subflow of $f$ implies that is a maximally affordable solution with

which contradicts the fact that minimizes the support norm. This completes the proof of claim 1.

We continue with claim 3, which we also prove by contradiction. We assume that there is an afordable vector $w$ with and . Let be an ordering of the validators so that . Clearly, the value of objective is . Without loss of generality, we can assume that vector $w$ is "truncated", meaning that .

For the case $k=1$, from this assumption we immediately obtain the equality

which contradicts our hypothesis. Now let $2\leq k\leq m$. We have the inequality

where the terms $F_k(w^k)$ and $F_k(w)$ cancelled out, which implies that $supp_w(u_k)<supp_{w^k}(v_k)$. On the other hand, we have the equality

which together with the previous inequality implies that

which contradicts claim 1. This completes the proof of claim 3 and of the theorem. $\square$

3. Overview of algorithms for MNMF

In the previous section we established that solving NPoS on a fixed committee reduces to solving MNMF. There are three possible ways to solve MNMF:

  1. Via convex programming: MNMF can be solved with numerical methods for convex quadratic programs, but this is too computationally expensive to consider any further.
  2. Via parametric flow algorithms: We show in Section 4 how MNMF can potentially be solved in time $O(|E|m + m^3)$ using some advanced techniques for parametric flow problems.
  3. Via a simple combinatorial heuristic: In Section 5 we consider a heuristic for MNMF called star balancing that starts with any maximally affordable vector and converges to an optimal vector $w^*$ by following a local weight-balancing rule. It executes in time $\tilde{O}(|E|m^2)$, ignoring logarithmic factors.

At first look, the worst-case complexity bound is much better for technique 2 than for technique 3. However, we point out that Babenko et al. (2007) studied a parametric max flow problem closely related to MNMF and performed experimental evaluations of both of these techniques, over real data for an application in revenue optimization as well as over synthetic data. They concluded that the performance of star balancing is actually comparable to that of parametric flow algorithms, except for instances with degenerate graph topologies. In fact, they conjecture that these two techniques have similar complexities whenever the underlying graph has moderately good expansion properties.

In view of this and of the fact that star balancing is vastly easier to implement than the algorithm proposed in Section 4, we suggest that star balancing be used for NPoS. Still, it is good to know our options, so we give details about both of these techniques in the next two sections.

4. Technique using parametric flow algorithms

Hochbaum and Hong (1995, Section 6) consider a network resource allocation problem which generalizes MNMF: given a network with a single source, single sink and edge capacities, maximize the sum of squared flows over the edges reaching the sink, over all maximum flows. They show that this problem is equivalent to a parametric flow problem called lexicographically optimal flow problem, studied by Gallo, Gregoriadis and Tarjan (1989). In turn, in this last paper the authors show that, even though a parametric flow problem usually requires solving several consecutive max-flow instances, this particular problem can be solved running a single execution of the FIFO preflow-push algorithm proposed by Goldberg and Tarjan (1988).

Therefore, the complexity of MNMF is bounded by that of Goldberg and Tarjan's algorithm, which is $O(n^3)$ for a general $n$-node network. However, Ahuja et al. (1994) showed how to optimize several popular network flow algorithms for the case of bipartite networks, where one of the partitions is considerably smaller than the other. If the partition sizes are $n_1$ and $n_2$ with $n_1\ll n_2$, they implement a two-edge push rule that allows one to "charge" most of the computation weight to the nodes on the small partition, and hence obtain algorithms whose running times depend on $n_1$ rather than $n$. In particular, they show how to adapt Goldberg and Tarjan's algorithm to run in time $O(n_1 e +n_1^3)$, where $e$ is the number of edges. For our particular instance of MNMF where $n_1=m$, we obtain thus an algorithm that runs in time $O(|E|m+m^3)$.

5. The star balancing heuristic

We now describe the star balancing heuristic for MNMF, which is a combinatorial randomized algorithm that outputs a solution arbitrarily close to optimal with high probability (this is what is known as a polynomial-time approximation scheme, or PRAS). We remark that a different analysis to this algorithm can be found in Tarjan et al. (2006). We show the following.

Theorem 5.1: For any fixed parameters $\varepsilon, \delta>0$, the star balancing algorithm returns a feasible solution to MNMF whose value has probability at least $(1 - \delta)$ of being within a multiplicative factor at most $(1+\varepsilon)$ from optimal, and runs in time

Algorithm 5.2: Star balancing.

Consider an instance $(N\cup S, E, b)$. For each nominator $n\in N$ let $V_n\subseteq V$ be its set of neighbors.

Fix constants $\varepsilon, \delta>0$. The algorithm starts with an arbitrary maximally affordable vector $w$, and improves it iteratively by performing $r$ rounds, where $r = O(|N|m^2\log(n/\varepsilon \delta))$ and its precise value will be established later.

  1. Find any maximally affordable vector $w$.
  2. Repeat $r$ times: a. Select a nominator $n\in N$ uniformly at random. b. Modify the weights of the edges incident to $n$, observing the corresponding budget equality and non-negativity constraints, so that the supports of the neighboring validators are as close to each other as possible, i.e. so that
  3. Return $w$.

Running time: Consider a round of the algorithm. If nominator $n$ is selected, the running time of the round is $O(|V_n|)$ (explain why), assuming that floating-point arithmetic operations take constant time. Hence, the average running time per round is $\frac{1}{|N|}\sum_{n\in N} |V_n|=\frac{|E|}{|N|}$. Together with the bound on $r$, we obtain a global running time of

Analysis: For each $i\leq r$, let $w^i$ be the state of weight vector $w$ at the end of the $i$-th round, and let $w^0$ be the initial vector. Let $w^*$ be an optimal solution. Let's start with an easy observation.

Lemma 5.3: $val(w^0)\leq m\cdot val(w^*)$.

Proof: Recall that the objective value to minimize is $val(w)=|Bw|^2_2=|supp_w|_2^2$. As both $w^0$ and $w^*$ are maximally affordable, the $\ell_1$ norm of their support vectors are equal. Hence $\square$

Next we show that, in expectation, the progress in objective value perceived in each round is proportional to the difference between the current and optimal values.

Lemma 5.4: For each round $i\in{1,\cdots,r}$ that starts with vector $w^{i-1}$ and ends with vector $w^i$, the expected objective value of $w^i$ is such that

Proof: We fix a round $i$, and for notational convenience we drop the superscripts $i$ and $i-1$ within the scope of this proof. In particular, we let $w$ be the initial vector, and let $w'^n$ be the final vector in the case that nominator $n$ is picked in the round. Clearly, the expected progress in objective value equals the average progress $\frac{1}{|N|}\sum_{n\in N} [val(w) - val(w'^n)]$. To lower bound the latter, it is sufficient to exhibit a different family of weight vectors ${w^n}_{n\in N}$ such that $val(w'^n)\leq val(w^n)$ for each $n$, and then bound the average progress when moving from $w$ to a member of that family.

Define the vector $f:=w-w^*\in\mathbb{R}^E$. The following is a necessary technical observation whose proof we delay temporarily.

Lemma 5.5: $|f|^2 \leq m^2 |Bf|^2.$

Consider the decomposition of vector $f$ as $f=\sum_{n\in N} f^n$, where $f^n$ is the restriction of $f$ over the edges incident to nominator $n$, and define the family of weight vectors ${w^n:= w-\frac{1}{m^2} f^n}_{n\in N}$. We have $val(w'^n) \leq val(w^n)$ for all $n\in N$ as desired, because by construction (step 2.b. of the algorithm), $w'^n$ is precisely the vector of minimum objective value among all maximally affordable vectors that differ from $w$ only at the edges incident to $n$ (explain further?). Hence, it only remains to bound the average progress in objective value with respect to the new family.

For a fixed $n\in N$, we have Thus, the average progress over all $n\in N$ is where the inequality comes from Lemma 5.5. This completes the proof of Lemma 5.4. $\square$

Proof of Lemma 5.5: We interpret $f$ as a flow over the network $(N\cup S, E)$. As both and observe budgets constraints with equality, there is flow preservation over all nominators. Let be respectively the sets of sources and sinks, i.e. the sets of validators with net excess and net demand. By the flow decomposition theorem, there exists a decomposition into single-source subflows, where has as its single source. We can assume that this decomposition generates no cycles by adjusting the choice of the optimal solution .

Consider one of these subflows $f^v$. Its edge support looks like a directed acyclic graph (DAG) with single root $v$. We arrange the edges on this DAG by levels, where the level of an edge is the length of the longest path from $v$ containing this edge. These levels start at 1 for the edges incident to $v$, up to at most $2m$ because any simple path alternates between a nominator and a validator and there are only $m$ validators. We now split $f^v$ by levels, $f^v=\sum_{i\leq 2m} f^{v,i}$, where $f^{v,i}$ is the restriction of $f^v$ over the edges at level $i$. Since the excess in node $v$ is $supp_w(v)-supp_{w^*}(v)=(Bf)_v$ and no other node in the DAG has any excess, the sum of edge weights along each level $i$ is $|f^{v,i}|_1 \leq (Bf)_v$. Therefore,

Putting things together, we get where the first inequality is an application of Cauchy-Schwarz.

In a similar manner, working with sinks instead of sources, we can obtain the bound $|f|^2 \leq 2m|S_t| \cdot |Bf|^2$. Summing up these two bounds and dividing by two, we get which proves the claim. $\square$

For each round $i\leq r$, consider the random variable $\Delta^i:= val(w^i) - val(w^*)$, which represents how far from optimal the current solution is in terms of objective value. We now use Lemma 5.4 to show that $\Delta^i$ decays exponentially fast in expectation.

Lemma 5.6: For any $0<i\leq r$, the expected value of $\Delta^i$ observes

Proof: A reformulation of Lemma 5.4 gives . By induction and linearity of expectation, this implies that . Finally, by Lemma 5.3. $\square$

Recall now that we want the value of the output solution $val(w^r)$ to be within a factor of $(1+\varepsilon)$ from $val(w^*)$ with probability at least $(1-\delta)$. The next lemma completes the analysis of the algorithm and the proof of Theorem 5.1.

Lemma 5.7: If $r=\lceil |N|m^2\ln(m/\epsilon \delta) \rceil$, then $\mathbb{P}[val(w^r) > (1+\varepsilon)val(w^*)]\leq \delta$.

Proof: By Lemma 5.6 and the choice of value $r$, it follows that

As the variable $\Delta^r$ is non-negative, we can use Markov's inequality: which is the claim. $\square$