{'fraction_non_alphanumeric': 0.025691291787040858, 'fraction_numerical': 0.005107304993809327, 'mean_word_length': 4.61721240220226, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A Bilevel Approach to Optimal Price-Setting of Time-and-Level-of-Use Tariffs

Time-and-Level-of-Use (TLOU) is a recently proposed pricing policy for energy, extending Time-of-Use with the addition of a capacity that users can book for a given time frame, reducing their expected energy cost if they respect this self-determined capacity limit. We introduce a variant of the TLOU defined in the literature, aligned with the supplier interest to prevent unplanned over-consumption. The optimal price-setting problem of TLOU is defined as a bilevel, bi-objective problem anticipating user choices in the supplier decision. An efficient resolution scheme is developed, based on the specific discrete structure of the lower-level user problem. Computational experiments using consumption distributions estimated from historical data illustrate the effectiveness of the proposed framework.


Introduction
The increasing penetration of wind and solar energy has marked the last decades, bringing a decentralization and higher stochasticity of power generation, yielding new challenges for the operation of electrical grids. Advances in communication technologies have enabled both scheduling of smart appliances and seamless data collection and exchange between different entities operating on power networks, from generators to end-consumers.
Using such capabilities, agents can make decisions based on probability distributions of different variables, possibly conditioned on known external factors, such as the weather.
As a promising lead to tackle these challenges, Demand This extended abstract was presented at, and included in the program of, the 13th EUROGEN conference on Evolutionary and Deterministic Computing for Industrial Applications.
Response (DR) has attracted an increasing interest in the past decades. Instead of compensating ever-increasing fluctuations of renewable production with conventional power generation, this approach consists in leveraging the flexibility of some consuming units by reducing or shifting their load. 1 The Time-and-Level-of-Use system presented in this paper is primarily a price-based Demand Response program based on the classification found in the literature, 1 although the self-determined consumption limit creates an incentive for respecting the commitment on the part of the user. Its design makes opting out of the program a natural extension and thus requires less coupling and interaction between users and suppliers to work. In a 2012 report, the US Federal Energy Regulatory Commission identified the lack of short-term estimation methods as one of the critical barriers to the effective implementation of Demand Response. 2 In a related approach, 3 an incentive-based Demand Response program is developed with users signaling both a predicted consumption and a reduction capacity, with the supplier selecting reductions randomly. Both the program developed by the authors 3 and the TLOU policy require a signal sent from the user to the supplier.
Bilevel optimization has been used to model and tackle optimization problems in energy networks. 4 Applications on power systems and markets are also mentioned in several reviews on bilevel optimization. 5,6 It allows decision-makers to encapsulate utility-generators, user-utility interactions, 7,8 or define robust formulations of unit commitment and optimal power flow. 9 Some recent work focuses on bilevel optimization for demand-response in the real-time market. 10 Multiple supplier settings are also considered, for instance in the determination of Time-of-Use pricing policies, 11 where competing retailers target residential users.
The Time-and-Level-of-Use (TLOU) pricing scheme 12 was built as an extension of Time-of-Use (TOU), targeting specifically the issue with current large-scale Demand-Response programs identified in the FERC report. 2 The optimal planning and operation of a smart building under this scheme was developed, taking the TLOU settings as input of the decision. In this work, we consider the perspective of the supplier determining the optimal parameters of TLOU.
We integrate the optimal user reaction in the supplier decision problem, thus modelling the interaction as a Stackelberg game solved as a bilevel optimization problem. The specific structure of the lower-level decision is leveraged to reduce the set of possibly optimal solutions to a finite enumerable set. Through this reduction, the lower-level optimality conditions are translated into a set of linear constraints. The set of optimal pricing configurations is derived for different distributions corresponding to different time frames. These options can be computed in advance and then one is chosen by the supplier ahead of the consumption time to create an incentive to book and consume a given capacity. We show the effectiveness of the method with discrete probability distributions computed from historical consumption data.

Time-and-Level-of-Use pricing
The TLOU policy was initially developed from the perspective of smart consumption units 12 which can be a building, an apartment or a micro-grid monitoring its consumption and equipped with programmable consuming devices. It is a pricing model for energy built upon the Time-of-Use (TOU) implemented by several jurisdictions and for which the energy price is fixed by intervals throughout the day. TLOU extends TOU by allowing users to self-determine and book an energy capacity at each time frame depending on their planned requirements; and by doing so, they provide the supplier with information on the intended consumption. We will refer to the capacity as the amount of energy booked by the user for a given time frame, following the same terminology as the reference implementation. 12 Energy prices still depend on the time frame within the day, but also on the capacity booked by the user. This pricing scheme is applied in a three-phase process: 1. The supplier sends the pricing information to the user.
2. The user books a capacity from the supplier for the time frame before a given deadline. If no capacity has been booked, the Time-of-Use pricing is used.
3. After the time frame, the energy cost is computed depending on the energy consumed x and booked capacity c: • If x ≤ c, then the applied price of energy is π L (c) and the energy cost is π L (c) · x.
• If x > c, then the applied price of energy is π H (c) and the energy cost is π H (c) · x.
In the model considered in this paper, only the first two steps involve decisions from the agents, making the decision process a Stackelberg game given the sequentiality of these decisions. The price structure is composed of three elements: a booking fee K, a step-wise decreasing function π L (c) representing the lower energy price and a step-wise increasing function π H (c) representing the higher energy price. The steps of the lower and higher price functions are given at different breakpoints: π L (c) will refer to the function of the capacity and π L j to the value of the lower price at step j. In the initial version of the pricing, 12 the energy consumed above the capacity is paid at the higher tariff while the rest is paid at the lower tariff.
Considering that most power systems try to prevent over-consumption and unplanned excess consumption, we introduce a variant where the whole energy consumed is paid at the lower tariff if it is less or equal to the capacity, and at the higher tariff otherwise, see Equation (1). In other words, if the consumption over the time frame remains below the booked capacity, the effective energy price is given by the lower tariff curve; if the consumption exceeds the booked capacity, the energy price is given by the higher tariff. The total cost for the user associated with a booked capacity c and a consumption X t for a time frame t is: The load distribution X t is a random variable; both user and supplier make decisions on the expected cost over the set of possible consumption levels Ω, given as: where E Ω is the expected value over the support Ω of the probability distribution.
Furthermore, π L (c = 0) = π H (c = 0) = π 0 (t), with π 0 (t) the Time-of-Use price at the time frame of interest t. This property allows users to opt-out of the program for some time frames by simply not booking any capacity. TLOU is designed for the day-ahead market, where both the pricing components and the capacity are chosen ahead of the consumption time. 12 It can however be adjusted to other markets 13 or intra-day settings. The entity defining the TLOU pricing can also extend the possible settings by decoupling the time spans for one price setting choice from the time frames for capacity booking. For instance, a price setting can be chosen by the utility for the week, while the booking of capacity occurs the day before the consumption.
TLOU offers the user the possibility to reduce their cost of energy by load planning, and offers the supplier the prospect of improved load forecasting, because under-consumption is paid by the excess booking cost while over-consumption is paid by the difference between higher and lower tariffs.
We illustrate this phenomenon with a supplier decision (K, π L , π H ) on Figures 1 and 2 using the relative cost: for different values of c. For c > 0, the fixed cost K · c makes low consumption levels expensive per consumed unit, while the transition from lower to higher price makes over-consumption more expensive than the baseline. In the example, c = 1.5 cannot be an optimal booked capacity since it is always more expensive than the baseline for all possible consumption levels. The cases c = 3.0 and c = 3.5 both have ranges of consumption for which this choice is optimal for the user; these ranges always have the capacity as upper bound. The difference in cost occurring at the transition from lower to higher price increases with the booked capacity, illustrating the guarantee against over-consumption the supplier gains from the capacity booked by the user. Regardless of the ability to shift consumption or irrational decision-making, the commitment to a capacity creates a cost difference if the user is not making an optimal decision, which compensates the supplier for these unexpected deviations. This financial incentive against a consumption above the booked capacity creates a guarantee of interest to the supplier and is cast as a second objective expressed in Section 3.  The supplier first builds their set of options based on prior consumption data. In the proposed method, the prior discrete distribution used can be conditioned on some independent variables if they are known and influence the consumption (e.g. forecast external temperature or day of the week). They can then pick a pricing setting for a given day based on generation-side considerations and constraints, including the option to stay at a flat Time-of-Use tariff for some or all time frames.

Bilevel model of the supplier problem
The supplier wishes to determine an optimal set of pricing options at any capacity level. In the model developed in this section, we consider a discrete probability distribution with a finite support, derive some properties of the cost structure which we then leverage to formulate the optimization problem in a tractable form.
At any capacity level, the decision process of the supplier involves two objectives, the expected revenue from the tariff and the guarantee of an upper bound on the consumption. The expected revenue is given by: x ω p ω π H (c) (4) with any capacity booked defining a partition of the set of scenarios: The function C (c) is minimized by the user with respect to their decision c. It is non-linear, non-smooth and discontinuous because of the partition of the scenarios by c and the transition between steps of the pricing curves π L (c), π H (c). Both the user and supplier problems are thus intractable with this initial formulation. Proposition 3.1 shows that only a discrete finite subset of capacity values are candidates to optimality for the user.
Proposition 3.1. The optimal booked capacity for a user at a time frame t belongs to a discrete and finite set of capacities S t , defined as: with Ω the set of consumption scenarios.
Proof. The user objective function is the sum of the booking cost and the expected electricity cost. The booking cost is linear in the booked capacity, with a positive slope equal to the booking fee. The expected electricity cost is piecewise constant in the booked capacity, with discontinuities at steps of both of the price curves because of the π L and π H prices and at possible load levels because of the transfer of a load from Ω + to the Ω − set. This can be highlighted using the indicator functions associated with each of the two sets: The expression of the user expected cost becomes: The sum of the two terms is therefore piecewise linear with a positive slope. On any interval between the discontinuity points, the optimal value lies on the lower bound, which can be any point of C L , C H , Ω or 0.
Furthermore, let C (c) be the user cost for a booked capacity andc such thatc ∈ C H andc / ∈ {0} ∪C L ∪ Ω. The higher tariff levels are monotonically increasing. Let ε > 0 be sufficiently small such that: The last condition guarantees there is no load value in the [c − ε,c + ε] interval and can also be expressed in terms of the two load sets split by the capacity: Then if such ε exists, we find that: The discontinuity on any x ∈ C H is therefore always positive and cannot be a candidate for optimality. It follows that optimality candidates are restricted to the set S = {0} ∪ C L ∪ Ω.
Proposition 3.1 means we can replace the continuous decision set of capacities with a discrete set that can be enumerated.
The guarantee of an upper bound on the consumption G corresponds to the incentive given to the user against consuming above the considered capacity. It is the second objective, given by the difference in cost at the capacity, which is the immediate difference in total cost at the transition from lower to higher tariff: The supplier needs to include the user behavior and optimal reaction in their decision-making process, which can be done by a bilevel constraint: The user thus books the least-cost option at each time frame, given the corresponding probability distribution. Given the finite set of optimal candidates S t defined in 3.1, this constraint can be re-written as: If multiple choices of c yield the minimum cost, the choice of the user is not well-defined. The supplier would want to ensure the uniqueness of the preferred solution by making it lower than the expected cost of any other capacity candidate by a fixed quantity δ > 0. This quantity can be interpreted as the conservativeness of the user (unwillingness to move to an optimal solution up to a difference of δ ). It is a parameter of the decision-making process, estimated by the supplier. The lower-level optimality constraint is then for a preferred candidate k:

Additional contractual constraints
In order to obtain regular price steps, the contract between supplier and consumer can include further constraints on the space of pricing parameters. We include three types of constraints: lower and upper bounds on the booking fee K, minimum and maximum increase at each step of the higher price and minimum and maximum decrease at each step of the higher price. All these can be expressed as linear constraints, and we gather them under the constraint set:

Complete optimization model
The model is defined for each of the capacity candidates and is thus noted P tk for candidate k and time frame t: max K,π L ,π H C (c tk , K, π L , π H ), G (c tk , π L , π H ) (16) C (c tk , K, π L , π H ) ≤ C (c lt , K, π L , π H ) − δ ∀l ∈ S t \k, where C (c tk , K, π L , π H ) =

Solution method and computational experiments
The proposed model was implemented and tested using historical consumption data 14 measured on a pilot house. The instantaneous consumption was measured every two minutes during 47 months on a residential building by the energy supplier and grid operator EDF. 15 Since the focus is the energy consumed within a given time frame, the instantaneous power can be averaged for each hour, yielding the energy in kW · h and avoiding issues of missing measurements in the dataset. Data preprocessing, density estimation and discretization, and visualization were performed using Julia, 16 matplotlib 17 and KernelDensity.jl. 18 The construction and optimization of the model were carried out using CLP from the COIN-OR project 19 as a linear solver and JuMP. 20 For all experiments where it is not specified, an inertia of δ = 0.05 has been applied. For every time frame and for all capacity candidates, the bi-objective supplier problem with objectives (C , G ) is solved with the ε-constraint method implemented in MultiJuMP.jl. 21 In all cases, the objectives are found to be non-conflicting, in the sense that the utopia point of the multi-objective problem is feasible and reached. This implies that a lexicographic multi-objective optimization solves the problem and reaches the utopia point, but does not guarantee that this holds for all problem configurations. The expected cost for the user of booking any capacity, given the price setting provided in Figure 5 is shown Figure  7. The most notable result is that in all cases tested, the utopia point, defined as the optimal value of the two objectives optimized separately, is reachable. This result is conceivable given that the supplier decision is taken in a high-level space, allowing multiple solutions to be optimal with respect to the revenue. In order to ensure the guarantee-maximizing optimal solution, a two-step process lexicographic multi-optimization procedure is used: 1. Solve the revenue-maximizing problem to obtain the maximal reachable revenue v.
Figures 8 and 9 present a TLOU configuration optimized for costs only and for cost and guarantee.
All the models solved are linear optimization problems with a fixed number of variables and a number of constraints growing linearly with the number of scenarios considered. However, all these constraints are of type: This is equivalent to: Therefore, at most one of the l will be active with a non-zero dual cost. The method can thus be scaled to a greater number of scenarios by adding these constraints on the fly.
With the current discretized distributions containing between 5 and 10 scenarios, the mean and median times  A study of the influence of the δ parameter is summarized Figure 10. For any hour, there always exists a maximum value δ max above which it becomes impossible to make a solution better for the lower-level than the baseline with a difference greater than δ max .

Conclusion
TLOU is designed to price energy across time and to reflect varying costs and requirements from the generation side. Defining two objectives for the supplier, we built the set of cost-optimal price settings maximizing the guarantee in a lexicographic fashion. Computations on distributions built from real data show the effectiveness of the method, requiring a low runtime to compute Future research will consider continuous probability distributions of the consumption and the price-setting problem with multiple users.

Acknowledgment
This work was supported by the NSERC Energy Storage Technology (NEST) Network.