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, the aggregated data including inner state information for each of the selection of devices; 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, the optimizing comprising generating device optimization parameters for each of the devices, and transmitting the device optimization parameters to each of the devices via the aggregation node device.