1. A method for allocating energy to a plurality of devices, wherein each device is configured to consume, store and/or supply energy, the method comprising: assigning each device to a group of devices; assigning an aggregation node device to each group of devices; for a selection of devices, transmitting local power cost functions of the devices and/or power usage profiles of the devices with respect to a predetermined time slot to the assigned aggregation node device; at the aggregation node device, generating aggregated data as a function of the received local power cost functions and/or power usage profiles; transmitting the aggregated data to a central processing device; and at the central processing device, optimizing a global cost function for allocating power to the devices as a function of the aggregated data.