  Batched network coding is a variation of random linear network coding which
has low computational and storage costs. In order to adapt to random
fluctuations in the number of erasures in individual batches, it is not optimal
to recode and transmit the same number of packets for all batches. Different
distributed optimization models, which are called adaptive recoding schemes,
were formulated for this purpose. The key component of these optimization
problems is the expected value of the rank distribution of a batch at the next
network node, which is also known as the expected rank. In this paper, we put
forth a unified adaptive recoding framework with an arbitrary recoding field
size. We show that the expected rank functions are concave when the packet loss
pattern is a stationary stochastic process, which covers but not limited to
independent packet loss and Gilbert-Elliott packet loss model. Under this
concavity assumption, we show that there always exists a solution which not
only can minimize the randomness on the number of recoded packets but also can
tolerate rank distribution errors due to inaccurate measurements or limited
precision of the machine. We provide an algorithm to obtain such an optimal
optimal solution, and propose tuning schemes that can turn any feasible
solution into a desired optimal solution.
