The centralized energy supply in a network of distributed energy systems: A cost-based mathematical approach