Managing time shiftable devices Published on August 12, 2024 30 minute read Back to homepage Heat pumps, induction cooking, electric vehicles (EVs) - our energy consumption is rapidly becoming more and more electric. And with good reason: electrification (switching to devices that use electrical energy) is an effective way of reducing carbon emissions when the used energy is produced in a renewable way, so it is one of many ways by which we can try to limit global warming and climate change. This shift doesn't come without technical difficulties however - let's dive in! The average household uses around 10-25 kWh per day (depending on usage of air conditioning, electric heating, et cetera), with a peak power draw of up to 5 kW. Usually net energy production peaks due to solar panels occur around noon, and consumption peaks due to household and entertainment activities occur around 18:00-19:00. Fully charging an electric vehicle requires around 70 kWh, and usually draws power in the range of 3-11 kW - if this aligns with the usual peak power draw, this means a single household with a charging electric vehicle can match the peak power draw of about three households without electric vehicles! Here are some examples of what the daily energy profile of a household with solar panels without electric vehicle look like (data from the European CoSSMic project, graph generated using Mermaid): --- config: themeVariables: xyChart: plotColorPalette: "#000000, #00AAAA, #AA00AA, #AAAA00" --- xychart-beta x-axis "Time (hours)" ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24"] y-axis "Net power (kW)" -0.6 --> 1.75 line [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] line [0.550999999999476, 0.53899999999976, 0.524000000000342, 0.456000000000131, 1.17900000000009, 1.2510000000002, 0.565999999999804, 0.59900000000016, 0.0169999999993706, -0.361000000000331, -0.524999999999636, -0.295999999999822, -0.203999999999724, -0.335000000000036, 0.0799999999994725, -0.294000000000324, 0.0280000000007021, 0.734999999999673, 0.5, 1.0600000000004, 0.599999999999454, 0.955000000000837, 1.76599999999962, 0.802999999999884, 0.216000000000349] line [0.989999999999782,0.590000000000146,0.434000000000196,0.425000000000182,0.429999999999382,0.485000000000582,0.194999999999709,-0.0640000000003056,0.324000000000524,-0.179999999999836,-0.0399999999999636,-0.43100000000004,0.00599999999985812,-0.0850000000000364,-0.00999999999976353,-0.440000000000509,-0.320999999999913,0.792000000000371,1.26900000000023,0.920000000000073,1.2549999999992,1.45600000000013,0.739000000000488,0.59099999999944,0.690000000000509] line [0.690000000000509,0.804999999999382,0.454000000000633,0.453999999999724,0.46100000000024,0.25,0.255000000000109,0.244999999999891,0.800000000000182,1.08099999999968,0.518000000000029,0.460999999999785,-0.259999999999764,1.4399999999996,0.405000000000655,0.714999999999236,0.761000000000422,0.944000000000415,1.21599999999944,1.3739999999998,1.30100000000039,1.13400000000001,0.979999999999563,0.976000000000568,0.528999999999542] Lots of devices within a neighborhood starting more or less simultaneously, as well as synchronised feeding back of energy from solar panels, can quickly become a problem; the demand for transmission of electricity can exceed the safe operating capacity of the grid, potentially causing components to overheat, ultimately causing grid failure. This phenomenon, called grid congestion, is becoming more prevalent the more our energy usage is electrified. Simply increasing capacity of the grid to support this electrification is often infeasible: a smart solution is required. Smart grids Energy providers normally adjust energy production to expected consumption, but what if we could get consumers to adjust their consumption behaviour according to production instead? Ideally their consumption would be spread more evenly across the day, and consumers would use their own generated energy as much as possible - stabilizing the net energy flow in the grid. Incentivizing this is known as demand-side management. Demand-side management ideally happens automatically through devices that can be controlled to activate at a desirable time. For example, you could fill your dish washer or washing machine, and delegate activation to a controller that is aware of when your solar panels are giving you free energy. They could even be made aware of schedulable devices across households within the low-voltage network so devices can be scheduled when there is still excess power within the neighbourhood, or such that the total peak load on the transformer is minimized. This requires the grid to be enhanced with communication and control capabilities, since coordination is required to prevent accidentally causing high peak loads by activating many devices at the same time. A grid equipped with such capabilities is commonly referred to as a smart grid, the controllable devices are commonly called distributed energy resources. But how would a controller for such a network actually work? Different classifications of distributed energy resources exist. One such classification is provided by the Energy Flexibility Platform & Interface, which categorizes devices into one of four types according to the way their energy consumption and production can be controlled: uncontrollable, time shiftable, buffer, and unconstrained. Energy usage as optimization problem Consider a finite time domain, and divide it into discrete steps (typically 15 minute or 1 hour intervals depending on the required level of granularity), and let p t denote the total energy profile at time t . Let's say that positive values indicate energy consumption, and negative values energy production. What exactly a desirable energy profile is depends on which stakeholder you ask. As mentioned before, the grid operator is interested in lowering the peak power draw (so called 'peak shaving'). Less peak power draw means less wear on equipment, and potentially less maximum required capacity. This means both highly positive and highly negative values of p t are considered bad. One way to model this would be to say that we seek to utilize devices such that the sum of squares of the resulting energy profile is minimized: ∑ t = 1 T p t 2 . Under normal pricing schemes, consumers are probably not interested in peak shaving at all, and only seek to minimize the cost of operating their devices within certain time bounds. If c t is the cost of energy at time t , and s t the feed-in tariff at time t (the kWh price you are paid for delivering energy to the grid), then a consumer would seek to minimize: ∑ t = 1 T ( c t p t + + s t p t - ) , where p t + equals p t when it is positive and otherwise equals 0, and similarly p t + equals p t when it is negative and otherwise equals 0. (Typically the feed-in tariff is much lower than the energy price, to incentivize consumers to utilize their own generated energy.) Read leading psychologist Daniel Kahneman's excellent book Thinking, Fast and Slow about the flaws in assuming that humans are strictly rational actors (so called "econs"). Which is the implicit assumption we make when modelling consumers as 'cost minimization machines' like above. Nevertheless, this behaviour is something we must account for, as a controller could be programmed to execute this cost-minimization behaviour automatically for a consumer. In this article, we will focus on the simplest class of distributed energy resources for which we can optimize either of these functions - the so called time shiftable devices. These are devices that have a fixed energy profile once activated, but their activation time can be varied to some degree. Washing machines and dish washers belong to this category. Finding the optimal activation time for a single time shiftable devices is very straightforward and efficient: simply check for each possible activation time t what the objective value would be if the device would start at that time, and pick the activation time for which it is minimized. In code, this could look something like this: class TimeShiftable { constructor ( timeshiftable_profile ) { this . timeshiftable_profile = timeshiftable_profile this . activation_time = 0 } optimize ( remaining_profile , objective ) { let best_objective = Infinity for ( let activation_time = 0 ; activation_time < remaining_profile . length - this . timeshiftable_profile . length + 1 ; activation_time ++ ) { const leading_zeroes = Array ( activation_time ) . fill ( 0 ) const trailing_zeroes = Array ( remaining_profile . length - this . timeshiftable_profile . length - activation_time ) . fill ( 0 ) const shiftable_profile = leading_zeroes . concat ( this . timeshiftable_profile ) . concat ( trailing_zeroes ) const total_profile = remaining_profile . map (( v , i ) => v + shiftable_profile [ i ] ) const current_objective = objective ( total_profile ) if ( current_objective < best_objective ) { best_objective = current_objective this . activation_time = activation_time } } } } Where timeshiftable_profile is the energy profile of the time shiftable device from when it starts to operate until it finishes, remaining_profile is the summed energy profile of all other devices, and objective is function of interest that we want to minimize. Optimizing multiple time shiftable devices But what about optimizing multiple time shiftable devices? We can again start by naively finding the optimal solution, which now involves enumerating all possible combinations of starting times. This means that when optimizing two devices for T time slots, we need to consider the first device on the first time slot together with all T time slots for the second device, and the first on the second time slot together with all T time slots for the second, et cetera. In total we'd need to check all T 2 possible starting times. More generally, for n devices we need to enumerate T n possible start times. The number of starting time combinations grows exponentially in the number of devices! If we're just optimizing 10 washing machines and/or dish washer across a single day, where the devices may start at any 15 minute interval, finding the optimal solution requires us to enumerate ( 4 * 24 ) 10 = 66.483.263.599.150.104.576 starting times, and keep the best one. A very rough estimate (based on using a CPU with a very high instruction per second count, and assuming just a single instruction is required to evaluate a starting time combination) tells us this will take a long time to finish; the naive approach is not going to cut it for multiple devices. So can we solve the problem efficiently? That's a difficult question to answer, so let's start with a simpler one. Let's say we're trying to assign a set of six devices each to one of two starting times, where each device takes exactly one time interval to run, and we seek to minimize the sum of squares ∑ t = 1 T p t 2 . The required energy during the interval of their activation is as follows respectively for each device: 3 kWh, 1 kWh, 1 kWh, 2 kWh, 2 kWh, and 1 kWh. Which device should start when? I encourage you to play around a bit with the device assignments below before reading further. What should the solution look like intuitively? First device (3 kWh): 1 2 Second device (1 kWh): 1 2 Third device (1 kWh): 1 2 Fourth device (2 kWh): 1 2 Fifth device (2 kWh): 1 2 Sixth device (1 kWh): 1 2 Sum of squares: --- config: themeVariables: xyChart: plotColorPalette: "#000000, #00AAAA" --- xychart-beta x-axis "Time (hours)" ["1", "2"] y-axis "Net power (kW)" -0.1 --> 10.1 line [0, 0] line [10, 0] Let's denote the required energy for the devices as x 1 , ... , x n , and we denote their sum as x 1 + ... + x n = 2 S , then if we can divide the devices into two groups that each sum to S , the assignment according to these groups is the optimal one. To see why this is true, first consider that all other assignments can be characterized as follows: for some ε > 0 one group sums to S + ε and the other to S - ε . And note that these assignments all have a higher, and thus worse, objective value than the one that equally divides the devices: ( S + ε ) 2 + ( S - ε ) 2 = ( S 2 + 2 ε S + ε 2 ) + ( S 2 - 2 ε S + ε 2 ) = 2 S 2 + 2 ε 2 > 2 S 2 . So in general, if we did have an efficient algorithm to optimize multiple device time shiftable devices simultaneously, we would also be able to efficiently divide a set of numbers into two groups with equal sums (if possible for the given set of numbers). This is also known as the partition problem, which is a very hard problem that mathematicians have yet to crack. Barring some mathematical breakthrough, finding the optimal solution seems out of reach for the foreseeable future. This does not mean that an efficient algorithm does not exist, just that we haven't found one yet, and currently don't know if it exists. If P = NP , then an efficient algorithm exists, otherwise it doesn't. The next best thing In practice, we probably don't care about finding the optimal solution. Many starting time combinations are non-optimal, but good enough. One approach to get "good enough" results, is called profile steering. The basic idea is that we pick a random time shiftable device to optimize, while keeping the others fixed, and repeat this procedure until we are stuck in a local optimum, and thus find no more improvements. The following tool allows you to play around with one or more time shiftable devices across one or more households, and implements the single time shiftable optimization procedure from before. Pressing the 🧠 button optimizes according to sum of squares objective, and pressing the 💰 button according to the cost objective. The energy profiles of the devices as well as the energy and feed-in tariff can be edited. --- config: themeVariables: xyChart: plotColorPalette: "#000000, #00AAAA, #AA00AA, #AAAA00" --- xychart-beta x-axis "Time (hours)" ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24"] y-axis "Net power (kW)" -0.1 --> 0.1 line [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] Controls Add household Add washing machine Add dish washer Energy prices: Feed-in tariff: Profiles Objective values Cost: Sum of squares: Wrapping up We now have the beginnings for a scheduler that could be used in a controller embedded in a smart grid. In theory, this allows us to automatically schedule devices to desirable time slots, but there are still some issues with our approach. Foremost of these is that we might end up actually incentivizing devices to consume energy simultaneously, rather than disincentivize it! Consider what happens when there is no static household profile, and two machines are scheduled according to cost minimization - there is no solar energy to utilize, so they both end up choosing the time slot with lowest energy price. The decisions on which device to utilize when are more or less independent in this case, but they should be dependent. The same thing happens even in the presence of a static household profile, when there are many devices that can be scheduled - there is an incentive to first utilize own generated solar energy, but afterward energy consumption gets clustered at the lowest energy price. Of course, energy prices are not actually fixed and known beforehand, but depend on how much power is drawn in the previous time interval, in that sense the decisions should influence each other. But exactly how prices will change throughout the day is impossible to predict, as in a smart grid it requires us to know beforehand which devices are used when, but that's exactly what we're trying to determine in the first place! The consumer and grid operator are at odds with each other under the normal pricing model. So besides the technical issues of scheduling and communication, we require a different incentive structure to not let consumers cluster their energy consumption around the lowest energy price, for example by rewarding cooperation. Check out Decentralized Energy Management with Profile Steering (PDF) for more information about profile steering. In the next article, we will take a closer look at charging of electric vehicles, stay tuned!