  We study the quadratic resource allocation problem and its variant with lower
and upper constraints on nested sums of variables. This problem occurs in many
applications, in particular battery scheduling within decentralized energy
management (DEM) for smart grids. We present an algorithm for this problem that
runs in $O(n \log n)$ time and, in contrast to existing algorithms for this
problem, achieves this time complexity using relatively simple and
easy-to-implement subroutines and data structures. This makes our algorithm
very attractive for real-life adaptation and implementation. Numerical
comparisons of our algorithm with a subroutine for battery scheduling within an
existing tool for DEM research indicates that our algorithm significantly
reduces the overall execution time of the DEM system, especially when the
battery is expected to be completely full or empty multiple times in the
optimal schedule. Moreover, computational experiments with synthetic data show
that our algorithm outperforms the currently most efficient algorithm by more
than one order of magnitude. In particular, our algorithm is able to solves all
considered instances with up to one million variables in less than 17 seconds
on a personal computer.
