Ilia Shilov
email: ilia.shilov@inria.fr

Hélène Le Cadre
email: helene.le-cadre@inria.fr

Ana Bušić
email: ana.busic@inria.fr

¸alo Gonc

Almeida De

Terc

A Stackelberg Game Analysis of Risk-Hedging Strategies in Decentralized Electricity Markets

Keywords: Game theory, Generalized Nash Equilibrium, Stackelberg Game, Risk-Hedging, Electricity Market

We investigate equilibrium problems arising in a decentralized electricity market involving risk-averse prosumers. The prosumers have the possibility to hedge their risks through financial contracts that they can purchase from an insurance company or trade directly with their peers. We formulate the problem as a Stackelberg game where the insurance company acts as the leader while the prosumers behave as followers. We consider two designs of the problem, in the first model only the insurance company acts as a source of risk-hedging contracts, in the second model we supplement the former design by allowing inter-agent risk-hedging. We derive risk-hedging pricing scheme in each design and show that the Stackelberg game pessimistic formulation might have no solution. We propose an equivalent reformulation as a parametrized generalized Nash equilibrium problem, and characterize the set of equilibria. We prove that the insurance company can design price incentives that guarantee the existence of a solution of the pessimistic formulation, which is ε close to the optimistic one. We then derive economic properties of the Stackelberg equilibria such as fairness, equity, and economic efficiency. We also quantify the impact of the insurance company incomplete information on the prosumers' risk-aversion levels on its individual cost and social cost. Finally, we evaluate numerically the proposed risk-hedging market models, using residential data provided by Pecan Street.

Introduction

Motivated by the urgent need for electricity market restructuring, this paper quantitatively analyzes decentralized market designs formulated as equilibrium problems. In the last years, decentralization has been broadly seen as an upcoming trend in network economics [START_REF] Courcoubetis | Incentives for large peer-to-peer systems[END_REF]Weber, 2006, Fang et al., 2017), and more specifically in the electrcity market literature where it is perceived as an emerging topic [START_REF] Anderson | Using supply functions for offering generation into an electricity market[END_REF][START_REF] Cadre | Peer-to-peer electricity markets: from variational to generalized nash equilibrium[END_REF][START_REF] Moret | Energy collectives: A community and fairness based approach to future electricity markets[END_REF], largely due to the liberalization of the energy sector, that has to account for the massive penetration of renewable energy sources (RES), and the more proactive role of prosumers.

Equilibrium problems used to analyze market designs rely heavily on the structure and the rules of the market, as well as on the way network constraints are handled [START_REF] Hu | Using epecs to model bilevel games in restructured electricity markets with locational prices[END_REF]. As a first step, in order to account for the strategic behavior of consumers and the network constraints, we model the electricity market as a generalized Nash equilibrium problem (GNEP), i.e., a noncooperative game endogenizing shared coupling constraints within the agents' parametrized optimization problems. We employ generalized Nash equilibrium (GNE) as a solution concept [START_REF] Harker | Generalized nash games and quasi-variational inequalities[END_REF][START_REF] Kulkarni | On the variational equilibrium as a refinement of the generalized nash equilibrium[END_REF][START_REF] Yin | Nash equilibrium problems with scaled congestion costs and shared constraints[END_REF], and a refinement of it, called variational equilibria (VE), assuming that the shadow variables of the shared coupling constraints are aligned among the agents [START_REF] Kulkarni | On the variational equilibrium as a refinement of the generalized nash equilibrium[END_REF]Shanbhag, 2012, Rosen, 1965). We focus on the design of decentralized electricity markets which rely on a network defining each agent's trading relationships, e.g., their neighbors. We focus on a financial level of a distribution network, but coupling between the market and the physical layer of a distribution network (seen e.g. as two inter-dependent layers [START_REF] Shilov | Generalized nash equilibrium analysis of the interaction between a peer-to-peer financial market and the distribution grid[END_REF]) constitutes an interesting direction for future work.

When dealing with future uncertain losses, agents can have individual perception of uncertainties or risk perception, that should be accounted for in the prosumers' optimization problems. Whenever agents have different perceptions of risk (heterogeneous risk aversion framework), it might lead to market inefficiencies [START_REF] Philpott | Equilibrium, uncertainty and risk in hydro-thermal electricity systems[END_REF][START_REF] Gerard | On risk averse competitive equilibrium[END_REF][START_REF] Ehrenmann | Generation capacity expansion in a risky environment: A stochastic equilibrium analysis[END_REF][START_REF] Ralph | The invisible hand for risk averse investment in electricity generation[END_REF]. Additionally, the heterogeneous description of uncertainties makes the market incomplete for risk [START_REF] Moret | Heterogeneous risk preferences in community-based electricity markets[END_REF]. We allow financial contracts trading between agents to complete the market [START_REF] Ralph | Risk trading and endogenous probabilities in investment equilibria[END_REF]. These contracts act as instruments to reduce the effect of heterogeneous risk attitudes on the outcome of the risk adjusted market. The questions that naturally arise from this inclusion are: i) how to define a mechanism with desirable market properties (e.g., economic efficiency, fairness) for risk hedging financial contracts? ii) How to incentivize the prosumers to participate in this market? And, iii) how to characterize the resulting equilibria?

To answer these questions, we model financial contracts in the form of Arrow-Debreu securities. Several works have considered Arrow-Debreu securities for risk trading among prosumers in peer-to-peer electricity markets [START_REF] Moret | Heterogeneous risk preferences in community-based electricity markets[END_REF][START_REF] Vespermann | Risk trading in energy communities[END_REF][START_REF] Gerard | On risk averse competitive equilibrium[END_REF]) in a decentralized one-level setting. Dealing with these securities, a first market design option requires the involvement in the market of an additional strategic agent, that can be interpreted as an insurance company. The insurance company acts as a seller of financial contracts with the goal to maximize its profit. In a second market design option, we allow the agents to trade Arrow-Debreu securities both with the insurance company and with the other agents, to hedge their risks. For both options, the presence of an insurance company that has to provide contract options to the prosumers calls for a Stackelberg formulation of the model, in which the insurance company acts as a leader and prosumers as followers.

Stackelberg games [START_REF] Stackelberg | Marktform und Gleichgewicht[END_REF] have been extensively applied in various fields such as market design, financial hedging, security applications, etc. [START_REF] Caldentey | Supply contracts with financial hedging[END_REF][START_REF] Liu | International journal of computational intelligence systems[END_REF][START_REF] Wolf | A stochastic version of a stackelberg-nash-cournot equilibrium model[END_REF][START_REF] Sherali | Stackelberg-nash-cournot equilibria: Characterizations and computations[END_REF][START_REF] Yao | Modeling and computing two-settlement oligopolistic equilibrium in a congested electricity network[END_REF]. Stackelberg games can be casted as bilevel optimization problems where one problem (followers' or lower-level) is nested within another (leader's or upper-level). The structure of our problem naturally gives rise to a one-leader, multi-follower generalized Stackelberg game involving a GNEP at the lower level which might have multiple solutions [START_REF] Cadre | Peer-to-peer electricity markets: from variational to generalized nash equilibrium[END_REF], [START_REF] Vespermann | Risk trading in energy communities[END_REF]. In that setting agents might either try to cooperate with the leader, or behave in an adversarial way, thus, either they choose the best solution with respect to the leader's objective (optimistic bilevel problem) or the worst one (pessimistic bilevel problem). We consider both optimistic (OBP) and pessimistic (PBP) formulations. PBP is usually considered to be more complicated to solve than OBP, due to the difficulties arising in the computation of its solution or even in the proofs of existence of solutions [START_REF] Liu | International journal of computational intelligence systems[END_REF][START_REF] Robinson | Generalized equations and their solutions, part ii: Applications to nonlinear programming. Optimality and Stability in Mathematical Programming[END_REF][START_REF] Lucchetti | Existence theorems of equilibrium points in stackelberg[END_REF][START_REF] Ben-Ayed | Computational difficulties of bilevel linear programming[END_REF]. To guarantee the exis-tence of a solution of PBP, we include contract price based incentives for the prosumers, which allow us to characterize Stackelberg-Nash equilibrium of PBP, and to compare it to the solution of OBP.

In addition, the literature dedicated to the computation of PBP solutions often focuses on the computation of approximate equilibria [START_REF] Lampariello | The standard pessimistic bilevel problem[END_REF][START_REF] Liu | International journal of computational intelligence systems[END_REF] or specific cases [START_REF] Coniglio | Computing a pessimistic stackelberg equilibrium with multiple followers: The mixed-pure case[END_REF][START_REF] Basilico | Methods for finding leader-follower equilibria with multiple follower[END_REF][START_REF] Wang | Coordinating followers to reach better equilibria: End-to-end gradient descent for stackelberg games[END_REF]. Using the structure of our model, we parametrize the response of the prosumers by introducing a choice function, which allows us to reformulate the initial bilevel problem as a set of parametrized GNEPs. This allows us to use results from the GNEP literature [START_REF] Tushar | Transforming energy networks via peer-to-peer energy trading: Potential of game theoretic approaches[END_REF][START_REF] Tatarenko | Learning generalized nash equilibria in a class of convex games[END_REF][START_REF] Yin | Nash equilibrium problems with scaled congestion costs and shared constraints[END_REF] to analyze the market equilibria. Finally, we compare the properties of our market models on data from Pecan Street, by computing the prosumers' individual costs, the social cost, analyzing fairness, and the impact of incomplete information on the insurance company's cost.

Related Work

Game-theoretic models have been widely employed to investigate agents' strategic behaviors in electricity markets [START_REF] Hu | Using epecs to model bilevel games in restructured electricity markets with locational prices[END_REF][START_REF] Ehrenmann | A comparison of electricity market designs in networks[END_REF][START_REF] Tushar | Transforming energy networks via peer-to-peer energy trading: Potential of game theoretic approaches[END_REF][START_REF] Wang | Coordinating followers to reach better equilibria: End-to-end gradient descent for stackelberg games[END_REF]. In [START_REF] Cadre | Peer-to-peer electricity markets: from variational to generalized nash equilibrium[END_REF], authors quantify the efficiency loss relying on the price of anarchy and capture the impact of incomplete information on the market equilibrium relying on GNE and VE. In the same vein, the economic dispatch in electricity trading with different structures of communication is analysed using consensus based approaches in [START_REF] Moret | Heterogeneous risk preferences in community-based electricity markets[END_REF][START_REF] Moret | Energy collectives: A community and fairness based approach to future electricity markets[END_REF].

A large part of the literature focuses on the impact of risk on the agents' decisions in competitive settings (de Maere d' Aertrycke et al., 2017[START_REF] Höschle | Using admm for risk-averse equilibrium computation[END_REF][START_REF] Ralph | Risk trading and endogenous probabilities in investment equilibria[END_REF][START_REF] Gaur | Hedging inventory risk through market instruments[END_REF] and in electricity markets in particular [START_REF] Ralph | The invisible hand for risk averse investment in electricity generation[END_REF][START_REF] Moret | Heterogeneous risk preferences in community-based electricity markets[END_REF][START_REF] Abada | On the multiplicity of solutions in generation capacity investment models with incomplete markets: a risk-averse stochastic equilibrium approach[END_REF][START_REF] Vespermann | Risk trading in energy communities[END_REF][START_REF] Gerard | On risk averse competitive equilibrium[END_REF][START_REF] Philpott | Equilibrium, uncertainty and risk in hydro-thermal electricity systems[END_REF][START_REF] Ehrenmann | Generation capacity expansion in a risky environment: A stochastic equilibrium analysis[END_REF]. Among them, many papers explore equilibrium properties assuming that the market is not complete for risk [START_REF] Ralph | The invisible hand for risk averse investment in electricity generation[END_REF][START_REF] Abada | On the multiplicity of solutions in generation capacity investment models with incomplete markets: a risk-averse stochastic equilibrium approach[END_REF][START_REF] Ehrenmann | Generation capacity expansion in a risky environment: A stochastic equilibrium analysis[END_REF][START_REF] Philpott | Equilibrium, uncertainty and risk in hydro-thermal electricity systems[END_REF][START_REF] De Maere D'aertrycke | Investment with incomplete markets for risk: The need for long-term contracts[END_REF][START_REF] Ralph | Risk trading and endogenous probabilities in investment equilibria[END_REF]. In [START_REF] Kazempour | Effects of risk aversion on market outcomes: A stochastic two-stage equilibrium model[END_REF], authors analyze the impact of heterogeneous risk preferences on the electricity market equilibrium. In (de Maere d' Aertrycke et al., 2017), authors discuss incomplete risk trading and its impact on the long-term strategic investment decisions, and compare cases of complete and fully incomplete markets for risk. Risk trading alongside with the properties of complete market is explored in [START_REF] Ralph | Risk trading and endogenous probabilities in investment equilibria[END_REF]. Financial hedging in a supply chain, modeled as a Stackelberg game, is considered in [START_REF] Caldentey | Supply contracts with financial hedging[END_REF] and hedging inventory risk in [START_REF] Gaur | Hedging inventory risk through market instruments[END_REF], where authors show that risk hedging leads to a lower risk and a higher return on inventory investment.

Heterogeneous risk-adjusted decentralized electricity markets are considered in [START_REF] Moret | Heterogeneous risk preferences in community-based electricity markets[END_REF], [START_REF] Vespermann | Risk trading in energy communities[END_REF]. In [START_REF] Moret | Heterogeneous risk preferences in community-based electricity markets[END_REF], a model for risk hedging via financial contracts is considered. It addresses the definition of fairness and the impact of risk in a one settlement two-stage market. In [START_REF] Vespermann | Risk trading in energy communities[END_REF], a Nash equilibrium problem formulation is considered under different degrees of market completeness for risk. In [START_REF] Gerard | On risk averse competitive equilibrium[END_REF], coherent risk measures are employed. In this paper, the authors analyse risk-adjusted markets and evaluate the impact of risk-hedging contracts on the market efficiency. The question of uniqueness and existence of risk-averse equilibria is addressed in [START_REF] Abada | On the multiplicity of solutions in generation capacity investment models with incomplete markets: a risk-averse stochastic equilibrium approach[END_REF][START_REF] Gerard | On risk averse competitive equilibrium[END_REF][START_REF] Ralph | Risk trading and endogenous probabilities in investment equilibria[END_REF], where one can find insights on some equivalences between social planner problems and equilibrium problems. The problem we address in our paper relies on a similar risk-averse setting. In [START_REF] Moret | Heterogeneous risk preferences in community-based electricity markets[END_REF][START_REF] Gerard | On risk averse competitive equilibrium[END_REF][START_REF] Vespermann | Risk trading in energy communities[END_REF], risk trading takes the form of Arrow-Debreu financial contracts, that prosumers can trade among themselves. We go further and supplement this one stage model with an additional layer operated by an insurance company. We thoroughly analyze the resulting Stackelberg game, considering both optimistic and pessimistic formulations and provide results on equilibria characterization, solution existence and market properties.

A wide range of problems, from security games [START_REF] Sinha | A review on bilevel optimization: From classical to evolutionary approaches and applications[END_REF] to general market design, are modeled as Stackelberg games. We provide only a few relevant examples and refer the reader to the literature for further information [START_REF] Sinha | A review on bilevel optimization: From classical to evolutionary approaches and applications[END_REF][START_REF] Liu | International journal of computational intelligence systems[END_REF][START_REF] Dempe | Bilevel Programming Problems: Theory, Algorithms and Applications to Energy Networks[END_REF]. In [START_REF] Sherali | Stackelberg-nash-cournot equilibria: Characterizations and computations[END_REF], authors study Stackelberg-Nash-Cournot equilibria in a game with one leader and N followers and analyze its properties under mild economic assumptions. De Wolf and Smeers extend this result in [START_REF] Wolf | A stochastic version of a stackelberg-nash-cournot equilibrium model[END_REF] to a stochastic version, in which the decision of the leader is taken while the market demand is uncertain, and provide a practical implementation of their model in the European gas market. Equilibrium problems with equilibrium constraints (EPECs) arising from the applications of Stackelberg game to the electricity markets are thoroughly analyzed in [START_REF] Yao | Modeling and computing two-settlement oligopolistic equilibrium in a congested electricity network[END_REF][START_REF] Ralph | Epecs as models for electricity markets[END_REF][START_REF] Hu | Using epecs to model bilevel games in restructured electricity markets with locational prices[END_REF].

In the bilevel optimization literature, most papers focus on the solution characterization and the development of computational approaches [START_REF] Sinha | A review on bilevel optimization: From classical to evolutionary approaches and applications[END_REF][START_REF] Liu | International journal of computational intelligence systems[END_REF][START_REF] Coniglio | Computing a pessimistic stackelberg equilibrium with multiple followers: The mixed-pure case[END_REF][START_REF] Basilico | Methods for finding leader-follower equilibria with multiple follower[END_REF][START_REF] Lampariello | The standard pessimistic bilevel problem[END_REF][START_REF] Lucchetti | Existence theorems of equilibrium points in stackelberg[END_REF][START_REF] Wang | Coordinating followers to reach better equilibria: End-to-end gradient descent for stackelberg games[END_REF][START_REF] Ben-Ayed | Computational difficulties of bilevel linear programming[END_REF] . In [START_REF] Lampariello | The standard pessimistic bilevel problem[END_REF], authors focus on PBP, reformulating it in a standard form and then as a bilevel problem with a two player GNEP at the lower level, that later can be solved as a mathematical program with complementarity constraints (MPCC). They consider ε solution of the lower-level problem in order to overcome issues arising from PBP solution existence. We use the machinery from [START_REF] Lampariello | The standard pessimistic bilevel problem[END_REF] to analyze PBP and its properties, but we focus on ε solution of the upper-level problem and introduce a parametrization of the reaction of the prosumers that allows us to use computational approaches suited for GNEPs.

Contributions and Paper Organization

We provide a thorough analysis of equilibrium models for risk-averse market design taking into account uncertainties, the agents' strategic behaviors and network constraints. By comparison with the previous works that account for players with heterogeneous risk-aversion levels, in the context of local energy communities [START_REF] Moret | Heterogeneous risk preferences in community-based electricity markets[END_REF][START_REF] Vespermann | Risk trading in energy communities[END_REF], we focus on an imperfect competition setting in which the electricity market price is not enforced by an exogenous price setter, but is obtained as the result of the interactions between the prosumers. To that purpose, we first consider a noncooperative game model with coupled constraints capturing the energy trading reciprocity constraints between couples of agents, therefore leading to a GNEP framework. This allows us to include the connection graph structure, capturing the prosumers' trading preferences, in the prosumers' energy exchange model.

We first build a risk-averse model to capture risk-attitude heterogeneity among the agents and supplement it with an additional layer, operated by an insurance company. The insurance company can supply risk-hedging financial contracts for the agents as a sole supplier and as a competitor for an inter-agent financial contracts trading. We analyze the resulting Stackelberg game considering both optimistic and pessimistic formulations, and provide results on equilibria characterization, solution existence and market properties. We first prove the equivalence of the reformulation of the bilevel problem with a parameterized GNEP, by using a so-called choice function. Relying on this parametrization, we prove that the PBP formulation might not have a solution without including additional price incentives from the insurance company. Then, we prove that a slight decrease in the financial contracts' price leads to a solution of PBP that is ε close to the optimistic solution of OBP. We next discuss the situation where the insurance company has incomplete information about the prosumers' risk-aversion levels, and analyze the resulting two-stage market equilibrium, proving that it is economically efficient and fair.

The organization of the rest of this paper is as follows: after introducing the problem statement in Section 2 and the agents in Section 2.1, we analyse risk-averse market equilibria in an incomplete market setting, in Section 2.2. We discuss completeness of the market in Section 3, in which we build a two-stage market design involving an insurance company in Section 3.1. In Section 4, we provide a comprehensive analysis of the resulting Stackelberg game, considering both OBP and PBP. Numerical illustrations are provided in Section 5.

Problem Description

We consider a single-settlement market for decentralized electricity trading modeled as a noncooperative game P G involving a set N of N agents (prosumers). Each agent is located in a node of the network, which is modeled as an undirected connected graph G := (N, E) where E ⊆ N × N is the set of links between the agents. Agent n can trade energy only with her neighbors in G, denoted by Γ n . The graph G does not necessarily reflect the distribution power network constraints. We do not consider the physical layer of the distribution network, but coupling it with the market (seen as two inter-dependent layers) constitutes an interesting direction for future work [START_REF] Shilov | Generalized nash equilibrium analysis of the interaction between a peer-to-peer financial market and the distribution grid[END_REF].

Agents

We assume that each agent n ∈ N is equipped with RES-based self-generation which is denoted by ∆g n . To model randomness, we employ scenario based approach, which is widely used in the literature dedicated to the electricity markets [START_REF] Ehrenmann | Generation capacity expansion in a risky environment: A stochastic equilibrium analysis[END_REF][START_REF] Vespermann | Risk trading in energy communities[END_REF][START_REF] Moret | Heterogeneous risk preferences in community-based electricity markets[END_REF][START_REF] Gerard | On risk averse competitive equilibrium[END_REF]. This approach allows to account for the stochasticity of the electricity market involving RES-based generation and risk hedging contracts. There are T possible scenarios: T := (1, . . . , T ). Each agent's probability of being in a scenario t is given by p t s.t. t∈T p t = 1. Probabilities p t for all t ∈ T are known by all the agents. Another approach to model individual and collective uncertainty is described in Appendix 7.3.1.

Each prosumer n chooses independently her bilateral trades q t n , flexible energy generation g t n and flexible demand d t n , to minimize her cost function Π t n . The quantity exchanged between n and m, is denoted as q t nm for all m ∈ Γ n \ {n}. If q t nm ≥ 0, then n buys q t nm from m, otherwise (q t nm < 0) n sells -q t nm to m. We use subscript t to reflect the dependence of the decision variables on the scenario.

Feasibility Set

In each node, we introduce

D n := {d t n ∈ R + |D n ≤ d t n ≤ D n } as agent n's demand set and G n := {g t n ∈ R + |G n ≤ g t n ≤
G n } as agent n's generation set. Given a scenario t, we impose an equality on the trading reciprocity:

q t nm + q t mn = 0, ∀m ∈ Γ n (1)
which couples agents' bilateral trading decisions. It means that, in the case where q t mn > 0, the quantity that n buys from m should be equal to the quantity q t nm that m is willing to offer to n. Let κ nm ∈ [0, +∞) be the equivalent trading capacity between node n and node m, such that κ nm = κ mn . Then

q t nm ≤ κ nm , ∀m ∈ Γ n (2)
Local supply and demand balance leads to the following equality in each node n in N :

d t n = g t n + ∆g t n + m∈Γn q t nm (3)
We denote the dual variable ξ t nm associated with the constraint (2), ζ t n as the dual variable for (1) and λ t n for (3). Denote x t n := (d t n , g t n , q t n ) to be the vector which contains the decision variables of prosumer n. We denote feasibility sets as

K n (x t -n ) := {x t n |d t n ∈ D n , g t n ∈ G n , (1), (2), (3) hold ∀t ∈ T }, where x t -n
is a vector which contains the decisions of all agents excluding agent n. Joint admissible set is written then as a K := n K n (x t -n ).

Prosumer n's Cost Function

We consider a quadratic production cost with a n , b n , c n > 0:

C n g t n = 1 2 a n g t n 2 + b n g t n +
c n for all t ∈ T . We assume that the self-generation occurs at zero marginal cost with a quadratic form of the cost, that is seen as realistic for a large class of conventional generators [START_REF] Cadre | Peer-to-peer electricity markets: from variational to generalized nash equilibrium[END_REF]. The usage benefit perceived by agent n is modeled as a strictly concave function of agent n's demand:

U n d t n = -ã n (d t n -dt n ) 2
+ bn for all t ∈ T , where dt n is a target demand defined exogenously for agent n. We introduce price differentiation that characterizes both the locational aspects and the preferences of the prosumers. The preferences are modeled with (product) differentiation prices: each agent n has a price c nm to trade with an agent m in her neighborhood Γ n . The total trading cost of agent n is modeled by a linear function Cn (q t n ) = m∈Γn,m =n c nm q t nm , ∀t ∈ T , where parameters c mn > 0 can be interpreted as taxes for energy trading or agents' preferences regarding the trade characteristics. If q t nm > 0 then n has to pay the cost c nm q t nm > 0. Thus, the higher c nm is, the less interesting it is for n to buy electricity from m but the more interesting it is for n to sell electricity to m. We write prosumer n's cost function ∀t ∈ T as follows:

Π t n = C n g t n + Cn q t n -U n d t n ∀t ∈ T (4) 2.1.3. Local Market Operator (MO)
In the electricity market literature, the electricity trading problem is often considered to be solved in a centralized way, requiring the presence of a market operator (MO) to which all the private information is reported [START_REF] Vespermann | Risk trading in energy communities[END_REF], [START_REF] Moret | Heterogeneous risk preferences in community-based electricity markets[END_REF]. In our work, the centralized electricity market design will be considered as the benchmark. The MO minimizes the social cost, SC := n∈N t∈T Π t n , under constraints expressed by the joint feasible set K.

Risk-Averse Electricity Market Design

In this paper, we focus on a risk-averse design in which we consider a market with collective uncertainties that are common knowledge, but agents have different risk-aversion levels. On the contrary, in the risk-neutral formulation, prosumers optimize their costs with respect to the probabilities p t , without taking into account the heterogeneity of the risk perception of the agents. A detailed description of the risk-neutral electricity market design can be found in the Appendix.

Under risk-averse market design, the prosumers act upon the set of risk attitudes χ n , n ∈ N . Different risk attitudes imply different risk perception of the cost function (4). To account for the risk-averse behavior of the agents, we employ CVaR as a coherent risk measures in agents' objective functions. CVaR is known to have a lot of appealing properties, e.g., it is coherent, easy to integrate in an optimization problem, etc. [START_REF] Rockafellar | Optimization of conditional value-at-risk[END_REF].

By definition, CVaR is the average of all realizations larger than the VaR, where the latter is given by

η n = min ηn {η n | P[Π t n ≤ η n ] = χ n }.
Then, we write CVaR as follows: R[Π

t n ] = η n + 1 (1-χn) t∈T p t [Π t n - η n ] + . Note that R[Π t n ] is convex in (d t n , g t n , q t n , η n ) if Π t n is convex in (d t n , g t n , q t n ),
) := {x n = (d t n , g t n , q t n , u t n , η n ) t |(d t n , g t n , q t n ) ∈ K n (x t -n ), u t n ≥ 0, Π t n -η n ≤ u t n } and denote K := Kn (x t -n
) as a joint admissible set. We formulate agent n's optimization problem as:

min d t n ,g t n ,q t n ,u t n ,ηn η n + 1 (1 -χ n ) t∈T p t u t n , (5a)
s.t. (d t n , g t n , q t n , u t n , η n ) ∈ Kn (x t -n ). (5b)
To analyse the efficiency loss of decentralized electricity market designs, we apply solutions concepts of Generalized Nash Equilibria and Variational Equilibria, both of them exist under mild conditions [START_REF] Kulkarni | On the variational equilibrium as a refinement of the generalized nash equilibrium[END_REF], [START_REF] Yin | Nash equilibrium problems with scaled congestion costs and shared constraints[END_REF].

Definition 1. A Generalized Nash Equilibrium (GNE) of the noncooperative game P G with coupling constraints is a vector x := (x n ) n that solves the maximization problems of the agents or, equivalently, a vector x such that x solve the KKT system for each n.

Definition 2. A Variational Equilibrium (VE) is a GNE such that the Lagrangian multipliers of the coupling constraints (1), are equal, i.e.:

ζ t nm = ζ t mn , ∀n ∈ N , ∀m ∈ Γ n (6)
By duality theory, ζ t nm for n ∈ N , ∀m ∈ Γ n can be interpreted as bilateral energy trading prices [START_REF] Cadre | Peer-to-peer electricity markets: from variational to generalized nash equilibrium[END_REF]. In general, ζ t nm might not be aligned with ζ t mn , thus leading to non-symmetric energy trading prices between couple of agents. Relying on VE as solution concepts enforces a natural symmetry in the bilateral energy price valuations [START_REF] Cadre | Peer-to-peer electricity markets: from variational to generalized nash equilibrium[END_REF]. However, this might require strong coordination between the agents.

Completeness of the Market

A market is said to be complete, whenever there exists an equilibrium price for every asset in every possible state of the world; the market is incomplete otherwise [START_REF] Baron | On the relationship between complete and incomplete financial market models[END_REF], [START_REF] Moret | Heterogeneous risk preferences in community-based electricity markets[END_REF]. To complete the market in the sense of this definition, we include financial contracts that are intended to hedge the risk of market participants. We discuss below two possible designs of the risk hedging market.

Two Stage Design of the Risk-Hedging Market with an Insurance Company

We introduce an insurance company I, whose sole purpose is to sell the state contingent claims to the agents. We want to consider the situation in which financial contracts trading inside the community is not sufficient to satisfy all the demand, and agents still have the possibility to buy missing contracts from I. Below, we build a model of a risk hedging market, including first the insurance company and finally both the insurance company and inter-agent financial contracts trading. We model the insurance company as a distinct agent whose behavior is restricted purely to contract trading. I decides on the price α t n and the maximum contract value J t for the contract J t n , which is paid if the outcome t is realized. In this framework, the cost function of the insurance company is defined as follows:

Π I = n∈N - t∈T α t n J t n Received revenue + t∈T p t J t n Insurance payments (7)
With the presence of the sole insurance company at the upper-level and without inter-agent trading on the lower-level, the timeline of the risk-hedging market can be described as follows:

(1) The insurance company I optimizes (anticipating the reaction of the prosumers) the contract price α t n for prosumer n and the maximum amount J t (the same for all agents) for scenario t.

(2) Each prosumer n ∈ N determines the contracts J t n she wants to buy such that 0 ≤ J t n ≤ J t and buys the contracts by paying the total price t∈T α t n J t n to receive J t n in scenario t. Note that the price α t n for the insurances is settled per scenario, per agent instead of per scenario in the inter-agent trading case. The motivation for this setting comes from the ability of the insurance company to evaluate the risks related to each agent as it is usually done in practice: the insurance company has means to assess these risks more accurately than the prosumers. Moreover, the insurance might propose contract prices that are discriminatory.

The sequence of decisions introduced in the timeline above made by insurance company I and prosumers have a hierarchical structure. It can be modelled as a Stackelberg one leader multi-follower game in which I acts as a leader and prosumers as a followers. The leader anticipates the reaction of the followers when optimizing his strategy, while the followers react rationally to the actions of the leader by computing their best-response functions. Formally, the one leader multi-follower game can be written as follows:

min (α t n ,J t ) n∈N n∈N - t∈T α t n J t n + t∈T p t J t n (8a) s.t. 0 ≤ α t n ∀n ∈ N (8b) ∀n ∈ N J t n ∈ arg min J t n ,x t n Πn t∈T α t n J t n + η n + 1 (1 -χ n ) t∈T p t u t n (8c) s.t. x t n ∈ Kn (x t -n ) ∀n ∈ N (8d) 0 ≤ J t n ≤ J t ∀n ∈ N (8e)
where (8a) -( 8b) constitute the upper level and (8c) -( 8e), the lower level problems. Note that the riskadjusted costs of the agents are changing due to contract inclusion:

R[Π t n ] = t∈T α t n J t n + η n + 1 (1 -χ n ) t∈T p t [Π t n -J t n -η n ≤u t n ] + . (9)
for which we can employ the epigraph form accordingly.

Two-level Design of the Risk-Hedging Market with Insurance Company and Inter-Agent Trading

Finally, we incorporate risk-hedging that includes both the insurance company and inter-agent financial contracts trading. We assume that the agents can not only acquire insurances J t n but also they can trade risk with each other using financial contracts, i.e., they pay a certain amount contingent on a given scenario occurring. We assume that agent n can trade risk with the whole community N . The price for the contract corresponding to the scenario t ∈ T is denoted γ t . It is supposed to be homogeneous, e.g., the same price is proposed to all the agents in order to have non-discriminatory pricing on the prosumers' level. Note, that we impose no bound on the sign of W t n . More precisely, we consider a modified formulation of (8) with prosumers' risk-adjusted costs at the lower level written as

R[Π t n ] = t∈T [α t n J t n + γ t W t n ] + η n + 1 (1 -χ n ) t∈T p t [Π t n -W t n -J t n -η n ≤u t n ] + . ( 10
)
for which we can employ the epigraph form accordingly. It means that now in stage (2) of the timeline of the two-level game, each prosumer n ∈ N decides on the contracts W t n , J t n she wants to buy after receiving price α t n , s.t. 0 ≤ J t n ≤ J t and buys the contracts by paying the total price t∈T α t n J t n + t∈T γ t W t n in order to obtain contingent payments J t n + W t n in scenario t.

Stackelberg Game Analysis

Section 4.2 starts with an introduction of the differences between OBP and PBP formulations for the two-level problem with I as the only seller of financial contracts. In Section 4.2.1, we first discuss the prices of the financial contracts and existence of solution in PBP. We propose price incentives for the prosumers in Section 4.2.2 and compare the resulting equilibria with the solution of OBP, investigated in 4.2.3. Further, in 4.2.4, we discuss an extension of the Stackelberg game, including imperfect information about risk attitudes of the prosumers. In Section 4.3 we analyze the two-level formulation with both I and inter-agent trading of financial contracts. The also discuss the market properties of the resulting model.

Two-Stage Problem Preliminaries

First, we will need some standard bilevel optimization notations. We denote the insurance company's (at the upper level) variables as x I = (α t n , J t , u t n,I ) n and prosumer n's (at the lower level) variables as x L n = (J t n , x t n ). Let φ(x I ) denote the value function of the lower level problem in (8): φ(x

I ) := min xn {Π n (x I , x L n )|x n ∈ K * n (x L -n , x I )} where K * n (x L -n , x I )
is the feasible set of the lower level problem for prosumer n and x I , is the decision variables of I. Then, the dependent optimal point set of this problem can be written as

S n (x I , x -n ) := {x n ∈ K * n (x L -n , x I )|Π n (x I , x L n ) ≤ φ(x I )}.
X I denotes the feasible set of the upper-level optimization problem. Combining these definitions, we can write the bilevel optimization problem as " min

x I ,x L n " Π I (x I , x L n ) s.t. x I ∈ X I x L n ∈ S n (x I , x L -n ) ∀n ∈ N (11)
and separately the individual problem for agent n on a lower-level problem in a compact form ∀n ∈ N :

min x L n Π n (x I , x L n ) s.t. x L n ∈ K * n (x L -n , x I ) (12)
For the KKT conditions, we use the following notation:

g L n,i (•) ≤ 0 (h L n,j (•) = 0)
represents the generic inequality (equality) constraints of the lower-level problem for prosumer n, while ξ L n is the vector of dual variables for prosumer n's problem. In the same manner, we use notations g I i (•), h I j (•), ξ U for the upperlevel problem. Let I L (J L ) denote the index set of the market level inequality (equality) constraints and I U (J U ) denote the index set for the upper level constraints. The optimal dual variable set of prosumer n for the lower-level problem is denoted as

Ξ n (x I , x L -n , x L n ) := ξ L n ≥ 0 : ξ L n,i g L n,i (x I , x L -n , x L n ) = 0, ∇ x L n L(x I , x L -n , x L n , ξ L n ) = 0 (13)
Definition 3 (Slater's condition). We say that Slater's condition holds for prosumer n's lower level problem (12) for a given x I , if there exists

x L n such that h L i (x i , x L -n , x L n ) = 0 and g L i (x i , x L -n , x L n ) < 0.
Proposition 4.

1. Slater's condition holds for the lower level problem for each n ∈ N and for each

x I ∈ X I . 2. The lower-level problem (12) is convex ∀n ∈ N for each x I ∈ X I . 3. Ξ n (x I , x L -n , x L n ) is upper-semicontinuous.
Proof.

1. The first part of the proposition statement simply follows from the structure of the constraints of the lower-level problem: taking d t n = g t n > 0, u t n > 0 and q nm = 0 ∀n, m if κ nm > 0 and rewriting constraint (2) as an equality if κ nm = 0 we can guarantee its qualification. 2. Convexity of the lower level problem (12) follows from the fact that the matrices of the constraints are positive semi-definite. 3. Slater's condition implies MFCQ, then we use Theorem 3.1 from [START_REF] Dempe | Bilevel Programming Problems: Theory, Algorithms and Applications to Energy Networks[END_REF], Theorem 2.3 from [START_REF] Robinson | Generalized equations and their solutions, part ii: Applications to nonlinear programming. Optimality and Stability in Mathematical Programming[END_REF] Lastly, we recall the notion of equilibria we use in our analysis.

Definition 5. A Stackelberg equilibrium of the game defined in (8) is a tuple

(x * I , x * ,L ) such that x * ,L n ∈ S n (x * I , x * ,L -n ) and Π I (x * ,L I , x * ) ≤ max x L n ∈Sn(x I ,x L -n )∀n Π I (x I , x L ).

Efficiency of the Lower Level Equilibria

First market property that we prove is the economic efficiency of the Variational Equilibrium of the lower level problem (12), by considering its centralized formulation. A centralized problem is formulated by means of a local Market Operator (MO) who collects all the information of prosumers ∈ N and then solves the problem (12) as a single optimization problem, reacting to the actions x I of the leader (insurance company I). It constitutes a single leader single follower game (SLSF), with the lower level problem written as

min x L n∈N Π n (x I , x L n ) s.t. x L n ∈ K * n (x L -n , x I ) ∀n ∈ N (14)
Writing the KKT conditions for the problems ( 12) and ( 14), and using the property of the VE, we can establish the following result: Proposition 6. The set of Variational Equilibria of the GNEP given by (12) for all n ∈ N coincides with the set of social welfare optima solutions of (14).

Besides the important property of efficiency, Proposition 6 allows us also to build theoretical analysis of both pessimistic and optimistic formulations of bilevel problem.

Optimistic Versus Pessimistic Formulations of the Game

In our analysis of the two-level insurance market, we focus on two formulations of the bilevel optimization problem that are classical in the literature: optimistic and pessimistic. These two formulations are needed to analyse the Stackelebrg game, because the lower level problem in (8) does not have unique equilibrium. Thus, in order to optimize its problem, I has to choose an equilibrium among the set of the possible equilibria of the lower-level GNEP. Intuitively, we might see it as a situation in which there are some prosumers at the lower level who are indifferent between several outcomes of the game that result in the same cost, but the values of some decision variables of these prosumers have an impact on the cost of the leader. We illustrate this intuition on a simple example below.

Example 7. Assume that there are only two prosumers at the lower level of the Stackelberg game. Let us consider prosumer n = 1, 2. If at the equilibrium of the game the price for the contracts J t n established by insurance company equals p n 1-χn (which is a reasonable assumption as we show later) and u t n = Π t n -η n -J t n > 0, then prosumer n is indifferent in her choice of insurance:

J t n ∈ [0, min{J t n , Π t n -η n }].
But this choice is crucial for the profits of I, as J t n = min{J t n , Π t n -η n } is the best possible outcome for it and the worst one is J t n = 0, constituting two different outcomes of the game for I, while leading to the same result for prosumer n.

Note that we consider only one of two prosumers in the example above. Indeed, prosumers might have different behavior on the risk trading market, depending on the values of their decision variables in the electricity peer-to-peer market equilibrium. We further partition the set N into groups and emphasize on the ones that are indifferent in the context of risk trading with I, i.e. the group of the agents for whom the objective function remains of the same value for all J t n ∈ [0, min{J

t n , Π t n -η n }].
We first formally define different formulations of the two-level interaction, depending on the response of the prosumers.

When I and prosumers n ∈ N act in cooperative manner, that is prosumers seek not only to minimize their own costs, but also take into account the maximization of the profits of the insurance company, then I can choose to solve its own problem with respect to the best possible solution of the GNEP at the lower level (from its point of view). This leads us to the OBP formulation of (8):

min x I ,x L n Π I (x I , x L n ) s.t. x I ∈ X I x L n ∈ S n (x I , x L -n ) ∀n ∈ N (15)
Optimistic problems are widely studied in the literature [START_REF] Dempe | Bilevel Programming Problems: Theory, Algorithms and Applications to Energy Networks[END_REF], [START_REF] Sinha | A review on bilevel optimization: From classical to evolutionary approaches and applications[END_REF] and are considered to be more tractable as compared to the pessimistic position. The optimistic formulation is guaranteed to have an optimal solutions under reasonable assumptions of regularity and compactness [START_REF] Sinha | A review on bilevel optimization: From classical to evolutionary approaches and applications[END_REF]. Indeed, it is easy to establish existence of solutions of problem (15) using Proposition 4 and [START_REF] Dempe | Bilevel Programming Problems: Theory, Algorithms and Applications to Energy Networks[END_REF]. On the other hand, the optimistic solution might not exactly correspond to the design of the risk hedging market, as there are no intrinsic incentives for the prosumers at the lower level to act in favor of the insurance company's profit maximization.

Under PBP setting, we assume that the insurance company and the prosumers do not act in the cooperative manner. It might be natural to assume that the insurance company I considers "worst case" with respect to the equilibrium of the lower-level GNEP. Indeed, if we refer to the Example 7 and consider indifferent prosumers, then it is natural to assume that given the choice of buying the insurance and not buying it with the same outcome, prosumers would choose the latter option. Then, we can rewrite bilevel problem (8) as

min x I max x L n Π I (x I , x L n ) s.t. x I ∈ X I x L n ∈ S n (x I , x L -n ) ∀n ∈ N (16)
The scope of literature that investigates pessimistic formulations of bilevel problems is much smaller than that for the optimistic one, due to the fact that the pessimistic formulation is often more complicated than the optimistic one [START_REF] Dempe | Bilevel Programming Problems: Theory, Algorithms and Applications to Energy Networks[END_REF]. It is not always guaranteed that the solution of ( 16) exists even for very simple formulations [START_REF] Lampariello | The standard pessimistic bilevel problem[END_REF], [START_REF] Lucchetti | Existence theorems of equilibrium points in stackelberg[END_REF], and a lot of work is dedicated to the computation of approximate equilibria [START_REF] Lampariello | The standard pessimistic bilevel problem[END_REF][START_REF] Liu | International journal of computational intelligence systems[END_REF] or focus on specific cases [START_REF] Coniglio | Computing a pessimistic stackelberg equilibrium with multiple followers: The mixed-pure case[END_REF][START_REF] Liu | International journal of computational intelligence systems[END_REF][START_REF] Basilico | Methods for finding leader-follower equilibria with multiple follower[END_REF].

Insurance Company's Information About the Prosumers' Parameters

Alongside with the different formualtions of the bilevel optimization problem, we focus on the information structure of the Stackelberg game. For the insurance company I, it is crucial to have full information about the set of prosumers' electricity trading problem parameters: RES-based generation ∆g t n , target demand dt n , flexibility activation cost function C n (•) (more specifically parameters a n , b n , d t n ), u t n (•) the usage benefit function (more specifically parameters ãn , bn ), and bilateral trade cost function Cn (•) (more specifically parameters (c nm ) m∈Γn ). Also it is crucial that I has full information about the risk-attitudes (χ n ) n of the prosumers to properly settle the prices (α t n ) n . We first discuss theoretical properties of the Stackelberg game assuming full information of I on the parameters listed above. We prove that the noncooperative game ( 16) has no solution, and propose a method to compute an approximate equilibrium that we compare to the equilibrium obtained as output of the optimistic formulation. Then, we discuss the game outcome in case of incomplete information, i.e. when the insurance company does not have an access to the true values of the listed parameters in Section 4.2.4. We start with a lemma about the insurance prices α t in case when there is only insurance company on the risk-hedging market and there is no inter-agent financial contracts trading.

Lemma 8. The price α t n of the insurances J t n for agent n and scenario t does not exceed p t 1-χn .

Proof. The objective function of the prosumer at the lower level takes the closed form

Π n = t∈T η n + α t n J t n + p t 1 -χ n u t n
Note that prosumer n can belong to one of the following two groups, at the equilibrium, defined by the two cases below:

case (i) u t n = 0 if Π t n -η n -J t n ≤ 0 case (ii) u t n = Π t n -η n -J t n > 0 (17)
In case (i), we write the cost of prosumer n as Π n = t∈T η n + α t n J t n and in case (ii) as

Π n = t∈T η n (1 -p t 1-χn ) + J t n (α t n -p t 1-χn ) + p t 1-χn Π t n .
We aim to compute insurance company I's strategy, e.g., the insurance prices

(α t n ) n . First, consider case (ii): from the term J t n (α t n -p t n 1-χn ), it is clear that to have J t n ≥ 0, I needs to set α t n ≤ p t n 1-χn . In case of strict inequality, J t n = min{J t , Π t n -η n }, in case of equality agent n is indifferent, so J t n ∈ [0, min{J t , Π t n -η n }]
, and 0 otherwise.

For case (i), it is clear that J t n = 0 if Π t n -η n ≤ 0, and J t n = Π t n -η n otherwise. It means that the total price paid for the contract α t n J t n should be smaller than the loss incurred without one:

α t n J t n ≤ p t 1 -χ n (Π t n -η n ) ⇒ α t n ≤ p t 1 -χ n
Thus, considering the response of the prosumers to the price settled by the insurance company, we obtain that in both cases α t n ≤ p t 1-χn .

J t n α t n 0 min{J t n , Π t n -η n } • Indifference set A of agent n • p t 1-χn optimistic pessimistic BR n (x I )

Choice function.

In the text below we use the partition of the agents in groups. We denote agents with the value u t n = Π t n -η n -J t n > 0 at the GNE as N ⊆ N . This group is later referred to as indifferent prosumers (see Example 7). Agents with the value Π t n -η n -J t n ≤ 0 and Π t n -η n ≤ 0 are denoted as N ⊆ N and with Π t n -η n > 0 as N ⊆ N . Consider the group N . For this group of agents, we can describe best-response mapping of agent n to the insurance company w.r.t the decision x I = (α t n , J t ):

J t n = BR n (x I ) =                  0 if α t n > p t n q -χ n min{J t n , Π t n -η n } if α t n < p t n q -χ n Ch t n (A, ω) if α t n = p t n q -χ n where A := [0, min{J t n , Π t n -η n }] and Ch t n (A, ω) is a choice function Ch t n (A, ω) : {A} × Ω → A.
We refer to Figure 1 as an illustration of BR n (x I ). More precisely, for each agent n ∈ N , for each scenario t this function takes as input the interval A and parameter ω ∈ Ω and returns a single value J t n , corresponding to the insurance bought by agent n: Ch t n (A, ω) := ω Π t n -η n . Parameter ω ∈ Ω := [0, 1] controls the optimality of the choice of the prosumer for the insurance company I. Using this function, we write Ch t n (A, ω) instead of J t n in upper-level optimization problem (8a). We denote this formulation of ( 8) as G ch (ω).

Pessimistic Formulation Analysis

Connection between pessimistic formulation and G ch (ω). In the next lemmas, we show the link between pessimistic formulation ( 16) and G ch (ω). First, we follow the path established in [START_REF] Lampariello | The standard pessimistic bilevel problem[END_REF] and reformulate problem (16) as a one leader, multi-follower game, where the lower level is modeled as a GNEP with 2N players. Intuitively, at the lower level, each prosumer cares not only about minimization of her own cost function, but also about maximization of the cost of insurance company I. To formalize the setting, we introduce an auxiliary agent who takes care of this maximization task:

min x I ,(x L n ,z L n )n Π I (x I , x L n ) s.t. x I ∈ X I (x L n , z L n ) ∈ E(x I ) ∀n ∈ N (18)
where E(x I ) is the equilibrium set of the following GNEP: 16) exists and is a local optimal point of this problem, then for any

min x L n -Π I (x I , x L n ) s.t. x L n ∈ K * n (x L -n , x I ) Π n (x I , x L n ) ≤ Π n (x I , z L n ) min z L n Π n (x I , x L n ) s.t. z L n ∈ K * n (x L -n , x I ) (19) Lemma 9. If solution (x I , xL n ) of (
ẑL n ∈ S n (x I , xL -n ), the tuple (x I , xL n , ẑL n ) is a local optimal point of (18).
Proof. Denote the optimal value function ψ(x

I ) := max x L n ∈Sn(x I ,x L -n )∀n∈N Π I (x I , x L n ).
Suppose by contradiction that (x I , xL n , ẑL n ) is not a local optimal point for (18), i.e., there exists a sequence (

x k I , x L k n , z L k n ) with x k I ∈ X I and (x L k n , z L k n ) ∈ E(x k I ) for all n ∈ N such that (x k I , x L k n , z L k n ) → (x I , xL n , ẑL n ) and ψ(x k I ) = Π I (x k I , x L k n ) < Π I (x I , xL n ) = ψ(x I ).
This contradicts the optimality of (x I , xL n ).

Lemma 10. Stackelberg equilibria of (18) with VE at the lower level belong to the set of equilibria E G ch of G ch (0).

Proof. First, note that from Proposition 6, VE at the right part of ( 19) is efficient. From which it follows that at the left part of (19), instead of the last inequality we have an equality. Fix some α t n as a solution of the upper-level problem. Then, we can rewrite (19) as

min x L n n∈N t∈T α t n -p t J t n s.t. x L n ∈ V E (20)
where α t n -p t > 0. Thus, each agent chooses minimal possible J t n while satisfying the KKT conditions of (19). For prosumers n ∈ N N , the choice of best response J t n is fixed, so it follows that we should consider prosumers n ∈ N . The response of this group is fixed unless α t n = p t 1-χn , for which, in order to minimize the profits of the insurance company, each agent in N chooses J t n = 0.

No solution. Finally, we return to our initial statement that might be seen as the situation where the absence of the additional price incentives from the insurance company I for the group of indifferent agents n ∈ N leads to a non-existence of solution of (16).

Proposition 11. In a pessimistic framework, the problem (16) admits no solution.

Proof. Suppose by contradiction that the solution of problem ( 16) exists. We first state that at optimum of G ch (0), problem α t n can not be strictly less than p t 1-χn . Suppose, by contradiction, that at the optimum, α t n < p t 1-χn . Then, the insurance company I can always increase its profit by adding sufficiently small ε: α t n + ε < p t 1-χn , and taking the limit ε → 0, we obtain a contradiction wrt the optimality of α t n . Then, from Lemma 8, it follows that α t n = p t 1-χn . In addition, from the definition of problem G ch (0), it follows that the values of contracts J t n acquired by agents n ∈ N are equal to 0. Thus, decreasing α t n by small ε > 0 (see Figure 2), insurance company can increase its profits. Thus, we obtain a contradiction which concludes the proof.

Price incentives. Although the non-existence of a solution of the pessimistic bilevel problem is not a rare case [START_REF] Lucchetti | Existence theorems of equilibrium points in stackelberg[END_REF], it is not desirable from the market point of view. Several works deal with the question of overcoming this issue by computing ε-optimal solution [START_REF] Lampariello | The standard pessimistic bilevel problem[END_REF][START_REF] Liu | International journal of computational intelligence systems[END_REF] of the lower level problem. From Proposition 11, it is natural to consider an approximate solution of the upper level as a way to incentivize the indifferent prosumers n ∈ N to act in favor of buying insurances thus, increasing the profit of the insurance company. Indeed, consider again Example 7 and assume that the insurance company chooses to set α t n = p t 1-χn -ε for some now fixed parameter ε > 0. Then, the amount bought by the prosumer becomes min{J t n , Π t n -η n } as now it is profitable for her to acquire the insurance. In that case the profit of insurance company I will become

p t 1-χn -ε -p t min{J t n , Π t n -η n } > 0.
We formalize this in the following proposition: Proposition 12. For any given ε, if insurance company sets the prices α t n = p t 1-χn -ε for prosumers n ∈ N , then the problem (16) has a solution.

Proof. The proof follows directly from the reformulation of PBP as a Stackelberg game with 2N agents at the lower level and the proof of Lemma 8.

Moreover, these considerations allow us to evaluate how much the insurance company fails to receive when the agents are reluctant to cooperate by comparison with the optimistic solution. More precisely, we show that the value of the objective function Π P I in this formulation is at most ε n∈N min{J t n , Π t n -η n } less than the value of Π O I at the equilibrium of the optimistic problem (15).

Optimistic Formulation Analysis

Optimistic formulation can be described by means of the choice function if we set parameter ω = 1. That means that those agents who are indifferent in their choice of J t n choose the best possible option for I : Ch t n (A, 1) = Π t n -η n . First, note that if the type of the two-level game is optimistic, then we can set the price α t n = p t n 1-χn for all agents n ∈ N . Indeed, we follow the proof of Lemma 8 and extend it by considering slightly lower prices. But in the optimistic framework there is no need to provide incentives to the indifferent prosumers, so the insurance company can always increase price for them up to α t n = p t 1-χn . In the next proposition we show the connection between (15) and G ch (ω):

Proposition 13. Stackelberg equilibria of (15) with VE at the lower level coincides with the set of equilibria

E G ch of G ch (1). Proof. (i) Assume by contradiction that a solution (x G I , x L G ) of G ch (1)
is not a solution of (15). It means that there exists a solution (x I , xL ) of ( 15) such that Π

I (x I , xL ) ≤ Π I (x G I , x L G ). Equivalently: n∈N t∈T Ĵt n p t -αt n ≤ n∈N t∈T Π t n -η n + p t -α t n
We showed that αt n = α t n = p t 1-χn . Then, dividing by the term p tp t 1-χn , we obtain

n∈N t∈T Ĵt n ≥ n∈N t∈T Π t n -η n +
The set N can be split into three groups: N , N , N , that are defined as follows: (1)

Ĵ = Πt n -ηn > 0, (2) Ĵ = 0 and (3) Ĵ ∈ [0, Πt n -ηn ], Πt n -ηn > 0, thus n∈N t∈T Πt n -ηn + ≥ n∈N t∈T Π t n -η n +
which contradicts Proposition 6.

(ii) We use the fact that α t n = p t 1-χn and write the closed form of the objective function in (15):

min x I ,x L n n∈N t∈T J t n p t - p t 1 -χ n
from which it follows that each agent n maximizes J t n , while satisfying the KKT conditions. From Proposition 6, it follows that J t n = Ch t n (1) for all agents n ∈ N which gives us exactly a solution of G ch (1).

In view of the above results, we can directly establish the following proposition:

Proposition 14. The value of the objective function Π P I in PBP is at most ε n∈N min{J t n , Π t n -η n } less than the value of Π O I at the equilibrium of OBP (15):

Π O I -Π P i = ε n∈N min{J t n , Π t n -η n } (21)
4.2.4. Incomplete Information About the Risk Attitudes Up to this section, we assumed that the insurance company I can correctly assess the risk attitudes (χ n ) n of the prosumers and compute the prices accordingly, alongside with the parameters (a n , b n , d t n , ãn , bn , ∆g t n , Dn , c nm ) of the electricity trading problem. Nevertheless, in practice the insurance company does not have an access to the agents' perception of the risk, thus, the only information insurance company I has access to is some a priori belief about (χ n ) n , expressed by means of some distribution (X n ) n . We also assume that the insurance company has an access to good estimations of the electricity trading problem parameters in the sense that the difference in the resulting assessments and the true values bring negligible difference to our model. We leave the discussion about the ways to achieve this out of the scope of the paper. It follows that the insurance company solves the problem (8) by taking the expectation of (8c), where the expectation is taken with respect to some distribution χ n ∼ X n , ∀n. Following the same path as in the proof of Lemma 8, we establish the following result: Proposition 15. When the only information the insurance company has access to is a distribution χ n ∼ X n , then the price for the contract for agent n is given by α t n = E p t 1-χn . It is straightforward to determine which agent acquires the contracts, depending on the relation between α t n = E p t 1-χn and α t n = p t 1-χn and the partition into groups N , N , N . The only interesting situation appears when α t n = E p t 1-χn = p t 1-χn for some agent n ∈ N (e.g., when X n is discrete). Then, we again have to consider optimistic and pessimistic formulations and use the machinery established in Section 4.2.2. price incentives described in Section 4.2.2, and similarly to Proposition 12. We show that the prices of the insurances with price incentives are equal to α t n = p t 1-min χn -ε, ∀n ∈ N .

Remark 18. In the two-level model the insurance prices do not depend on their own risk aversion, but solely on the risk aversion of the least risk averse agent. Therefore, it is more appropriate to speak about equity than about any other kind of fairness, as the prices are now aligned across the agents.

Fairness

Investigating the impact of risk preferences on cost allocation in decentralized electricity markets becomes fundamental in order to design mechanisms that grant fairness among prosumers. We provide a definition for fairness of cost allocation in risk-adjusted market with financial contracts. Intuitively, in our framework involving the presence of an insurance company, fairness should relate the insurances' price (α t n ) n to the prosumers' risk aversion levels. More precisely:

Definition 19. We say that the risk-hedging market with an insurance company is fair if the insurances' price α t n is lower for less risk-averse agents, that is

α t n ≤ α t n if χ n ≤ χ n .
From the Propositions 12 and 13, it is straightforward that the risk-hedging market is fair:

Proposition 20. The risk-hedging market described by the two-level game (11) is fair in the sense of Definition 19.

Numerical Results

We compare the performance of the various electricity and financial contracts trading market designs proposed in this article, and analyze the impact of heterogeneous risk aversion on the prosumers' and I's costs as well as social cost, by solving the noncooperative games from Section 3.

Data. We use residential data provided by Pecan Street ([dataset], 2021) for Austin, Texas. The data consists of 15-minutes intervals specifying renewable generation, load and facilities energy consumption for 25 individual homes. We sample the distribution of scenarios for RES-based generation and demand from the generation data and aggregated consumption respectively. Histograms representing 100 scenarios of the RES-based generation and demand of three agents are given in Figures 4 and5. To run the experiments, we use the same probabilities to generate the scenarios for all the agents. Extensions of the model that account for different distributions across the agents is described in the Appendix. We solve the problem using a radial connection graph depicted in Figure 6. Here, edges represent the neighborhood of each prosumer. Edges were generated randomly, such that the radial structure of the graph is preserved. Comparison of different market designs. In order to compare the market design outcomes, we run a set of experiments (trials) with different values of the parameters (ã n , bn , a n , b n , dt n , χ n ) n sampled from a uniform distribution U [0, 1]. Then, for each set of parameters and 100 sampled scenarios for RES-based generation and target demand we solve the corresponding model and compute the prosumers' costs, the social cost and the insurance company I's profit where applicable. Prosumers' costs and social costs for 5 trials in the different market designs are shown in Figure 7; where a different mark is used for each trial. The costs are the lowest in the risk-neutral framework (RN). They increase in the risk-averse framework (RA), as one could expect, due to increased risk-aversion of the agents, which motivates them to make more conservative decisions such that the volatility of their overall costs reduces [START_REF] Vespermann | Risk trading in energy communities[END_REF].

The participation of an insurance company in the two-level (optimistic) framework (Only I) allows the agents to hedge their risk towards uncertainties, but numerical tests show that the prosumers adjust their electricity generations, demands and tradings to belong to the set of indifferent prosumers. This means that by buying insurances they do not decrease their costs, but due to the optimistic formulation, the purchases of the insurance company enable it to increase its profits. Pessimistic formulation in the Only I setting slightly decreases both the profits of I and the costs of the prosumers, but the difference is minor. The introduction of financial contracts in the one-level setting (No I) [START_REF] Moret | Heterogeneous risk preferences in community-based electricity markets[END_REF] sets more profitable financial contracts conditions for the prosumers, because now the contract prices are uniform and are set to be p t 1-min χn .

It allows agents to decrease their costs significantly by comparison with the risk-averse (RA) and twolevel with the sole I (Only I) settings. The possibility for I to propose insurances in the optimistic (OBP) formulation, allows prosumers to reduce their costs by comparison with the risk-averse setting -in the same manner as the one-level formulation -while bringing more profits to I. The pessimistic formulation entails slightly lower costs. That is an important consequence of the price incentives that I uses in PBP market: the relative reluctance of the agents to buy insurances from I motivates the company to slightly decrease its contract prices, making them cheaper to the agents. On the other hand, it leads to a decrease in I's profits.

From the experiments below, one can conclude that the most profitable framework for insurance company I is the Only I, in which it is the only provider of risk-hedging contracts. On the other hand, allowing competition between inter-agent contracts and I's acting as a contract provider allows prosumers to decrease their costs significantly, at the expense of the insurance company.

Impact of incomplete information. In Sections 4.2.1 and 4.2.4, we discussed the effects of incomplete information of I about the prosumers' parameters. We focus here more specifically on I's incomplete information about (χ n ) n in PBP, as introduced in Section 4.2.4. We test several distributions X n available to I as the beliefs about χ n and compare I's resulting profits induced by these distributions, in Table 2. The True value is a vector of risk attitudes for the 25 prosumers sampled from the beta distribution β(1, 1). Distributions of X n are taken from the same family of beta distributions with different parameter values for the distribution. The best outcome is obtained when the parameters of the distribution are guessed correctly by I.

True value

β(1, 1) β(0.5, 1) β(1, 0.5) β(2, 2) I's cost [$]
-0.0316 -0.0082 -0.0015 -0.0062 -0.0036 However, Table 2 shows that the insurance company's profit even in the best outcome is still 3.85 times lower than with complete information. The same holds for other two-level formulations. Clearly, this highlights the fact that the insurance company has incentives to learn the distribution of the risk-aversion levels of the prosumers. Further research should be done in order to understand how to choose suitable distribution to model the prosumers' risk aversion, and design learning mechanism for I that also enables it to maximize its profit. A more detailed analysis of the agents' parameters impact on the results of the model, is presented in the Appendix.

Concluding Remarks

In this work, we investigated two-level risk-hedging market designs of a decentralized electricity market, and provided a comprehensive analysis of the underlying equilibrium problems. An insurance company is included in the two-level market first as the only insurance supplier and then as a competitor with the interagent financial contract trading. We showed that the structure of the two-level design might lead to the nonexistence of a solution, but that problem can be overcome by designing price-based incentives which aim to incentivize the prosumers to buy insurances instead of trading contract with their peers. To that purpose, we reformulated the resulting Stackelberg game as a parametrized GNEP. The price incentives only slightly decrease the profits of the insurance company, but also allow prosumers to decrease their costs, as we illustrate in the numerical experiments.

The discussion around incomplete information on the prosumers' risk-aversion levels poses several questions for future research, e.g., how can the insurance company optimize the electricity trading parameters while learning the risk-aversion levels of the agents? One way to achieve that could be to build a dynamic incentive-compatible mechanism such that the agents report their private information to the insurance company. Another important extension of the proposed market design would be to allow competition among several insurance companies at the upper level of the Stackelberg game, leading to a multi-leader, multi-follower framework. Finally, another interesting branch of future research would be developing more efficient distributed algorithms to compute market equilibria. dispatch model, in which prosumers account for the uncertainty of their generation and inflexible demand when optimizing their strategy, with a common view on the collective uncertainty.

Centralized case

The first formulation that is considered in this paper, and will be used as a benchmark, is formulated in a centralized manner, where a global Market Operator minimizes the social cost for the risk-neutral community. We can write the formulation as follows: min D t ,G t ,q t E SC s.t.

x := (D t , G t , q t ) ∈ K.

The Social Cost function SC(.) is convex as the sum of convex functions defined on a convex feasibility set. Indeed, the feasibility set is obtained as Cartesian product of convex sets. Thus, the optimization problem can be solved using standard convex optimization algorithms.

Decentralized case

We propose different decentralized market designs, in which each prosumer n ∈ N selfishly optimizes her demand (d t n ), energy generation (g t n ) and bilateral trades (q t n ) with other prosumers in her neighborhood under constraints on demand, generation and trading capacity so as to minimize her expected costs. Formally, each prosumer in node n ∈ N solves the following optimization problem:

min d t n ,g t n ,q t n E[Π t n ], (22a)
s.t.

x n := (d t n , g t n , q t n ) ∈ K n (x -n ),

where expectation is given by

E[Π t n ] = t p t C n (g t n ) + Cn (q t n ) -U t n (d t n ) Π t n ( 23
)
This formulation can be viewed as a decomposition of the centralized problem which accounts for the strategic behavior of all the prosumers. We first show the efficiency of the equilibria of the game ( 22):

Proposition 21. The KKT conditions of the centralized market design coincide with the KKT conditions at any variational equilibrium (VE) of the decentralized market design. It follows that the set of VEs obtained as outcome of the decentralized market design contains economically efficient outcomes.

Proof. The proof follows from the KKT conditions and the definition of VE that impose that ζ t nm = ζ t mn , ∀m ∈ N , ∀m ∈ Γ n .

Lemma 22. At equilibrium, Π t n is uniquely defined, ∀n ∈ N . Moreover, if the values p t (c nm -c mn ) nm are not equal for any couple (n, m) ∈ N × Γ n and corresponding scenarios, then prosumer n's strategy x n at VE is unique.

Proof. We start the proof by decomposing the problem into quadratic and linear parts. First, let Q n = m∈Γn q nm be prosumer n's net import, and note that Q t n ∈ Q n where due to (2) Q n is closed and bounded set. We consider the following problem ∀(Q (24)

Problem ( 24) has unique solution (D t , G t ) for each Q t n ∈ Q n because it is strictly convex in D t , G t . To prove the statement of the lemma, we have to consider the linear subproblem, which is formulated as follows: min q t n∈N t∈T p t Cn (q t n ) s.t. q t nm ≤ κ nm , ∀m ∈ Γ n , ∀n ∈ N q t nm + q t mn = 0 ∀m ∈ Γ n , ∀m ∈ N Q t n = m∈Γn q t nm .

(25)

Using (1) we can rewrite the objective function of ( 25) as

(n,m)∈N ×Γn t∈T p t • q t nm (c nm -c mn )

For convenience, we index all possible combinations (n, m, t) ∈ N × Γ n × T of trades between agents and denote them as k 1 , . . . , k M , where M = |E| • |T |. Coefficients for q k i appearing in (26) are denoted as c k i Then, the linear subproblem can be written as follows:

min q t k i ,i=1,...,M c k i q k i s.t. -κ k i ≤ q k i ≤ κ k i Q j = k i ∈Jn q k i , (27)
where J n is a subset of indices k 1 , . . . , k M representing the trades of agent n. By Theorem 1 from (Mangasarian, 1979), a solution x of the linear problem {min x c t x|Ax = b, Cx ≥ d} is unique if and only if it remains a solution to all linear programs obtained by arbitrary but sufficiently small perturbation of its cost vector c, or equivalently, for each b in R n , there exists a real positive number ε such that x remains a solution of the perturbed linear program {min x (c + εb) T x|Ax = b, Cx ≥ d}. Thus, to finish the proof, we order the coefficients c k i such that c k 1 ≤ c k 2 ≤ • • • ≤ c k M , and consider two cases: (i) i, j : c k i = c k j or, equivalently, c k i < c k i+1 ≤ . . . c k M . Then, it is clear that solution qt of the original LP is a solution of the perturbed LP for any vector b, because the order of coefficients c k i can be preserved by choosing sufficiently small ε. In case (ii) in which the ordering of the coefficients is not strict, i.e. ∃i, j : c k i = c k j , perturbing the cost by vector b = (. . . , b k i , . . . , b k j , . . . ) with b k i = b k j restricts us from preserving the order of coefficients thus leading to a non unique solution. It remains to conclude that equal coefficients c k i among agents lead to the same trading costs, thus leading to the unique values of Π t n .

Figure 1 :Figure 2 :

 12 Figure 1: BRn(xI ) for n ∈ N .

Figure 4 :

 4 Figure 4: Histograms of RES-generation.

Figure 5 :

 5 Figure 5: Histograms of demand.

Figure 7 :

 7 Figure 7: Spread of the prosumers' costs and social cost in each market design for 5 trials. (RN) -risk-neutral, (RA) -risk-averse, (Only I) -two level with only I, (No I) -one level with risk-hedging, (OBP) -two-level optimistic, (PBP) -two-level pessimistic.

Figure 6 :

 6 Figure 6: Connection graph.

Table 1 :

 1 Prosumers' social cost, I's cost, market properties for different market designs computed on a 15 min interval.

Table 2 :

 2 I's cost differences under different distributions of the prosumers' risk attitudes in PBP.

Analysis of the Two-Level Formulation with Inter-Agent Trading

The most comprehensive formulation proposed in Section 3.2 poses a lot of questions regarding the market organization. First, we provide an illustration, why the prices α t n settled as in the previous sections may generate market imperfections in the framework with inter-agent trading.

Example 16. Consider decentralized electricity market with two agents at the lower level with risk attitudes χ 1 < χ 2 . Then α t 1 < α t 2 and if the price γ t is less than p t 1-χ 2 , then agent 1 can buy the insurances from I and resell them to agent 2. This behavior clearly reflects a market imperfection that must be addressed.

We again consider two formulations, optimistic (OBP) and pessimistic (PBP) and analyse the market prices and its properties at equilibrium. We use the results established in the previous section to address the problems encountered in the full formulation of the decentralized electricity market with risk hedging.

We consider OBP first. We first show that the price of the contracts at the lower level is settled as γ t = p t 1-χn . Proposition 17. For a inter-agent financial contracts trading, the risk-adjusted probabilities are aligned across market participants. Furthermore, the risk-adjusted probabilities coincide with those of the least risk averse agent and are equal to the prices of financial contracts, i.e., γ t = p t 1-minn χn

Proof.

From the KKT conditions, we get that p t 1-χn = τ t n + π t n . From the complementarity constraints, we see that the set of risk adjusted probabilities in the modified problem with risk-hedging contracts W t n implies zero probability on the scenarios with From the KKT conditions, we infer that the τ t n are aligned across agents: τ t n = τ t m = τ t ∀n, m ∈ N . To show that they coincide with those of the least risk averse agent, assume that the price γ t if fixed. Then, for those agent n ∈ N for whom γ t ≥ p t 1-χ n , it is profitable to sell the contracts (n ∈ S): W t n ≤ 0. The opposite holds for agent n with γ t ≤ p t 1-χ n , thus making her the buyer of the financial contracts (n ∈ B).

Consider n ∈ B ⊆ N . If u t n ≥ 0, then u t n = Π t n -η n -W t n , and the term representing financial contract trading becomes W t n (γ tp t 1-χ n ) ≤ 0, which implies that increasing W t n up to Π t n -η n leads to the decrease in the cost of the agent. In other words, taking the sub-derviative

1-min χn . It follows that the agent with the minimal risk aversion can supply risk-hedging demand for the agents at the lower level. In such setting, optimistic formulation again is expressed through the choice function Ch t n (A, 1) and by using choice function reformulation, we establish that the prices for the insurances provided by I are equal to α t n = p t 1-min χn , ∀n ∈ N . In PBP, the prosumers prefer to trade contracts directly with their peers than with I. More precisely, we follow the proofs of Lemmas 9 and 10 to derive Proposition 11. It leads to the question of how to design Remark 23. The implication of the above result is that even if the solution x n at VE is not unique, it still bears the same individual costs for all the prosumers. Moreover, the condition for having a unique VE in practice is pretty mild, e.g., it reduces to the agents having non-symmetric coefficients c nm . If the condition to have symmetric coefficients is crucial, e.g., when they represent taxes, it is possible to achieve uniqueness of VE by adding a regularization quadratic term φ q 2 nm that accounts for transaction costs [START_REF] Vespermann | Risk trading in energy communities[END_REF]. This track is discussed later in Section 7.2.

Regularized lower level problem

In this section, we modify the risk-adjusted costs of the agents in order to ensure the strict convexity of the lower-level problem:

with the costs Π t n redefined as

The regularization formulation is common in the literature; for example, in [START_REF] Vespermann | Risk trading in energy communities[END_REF], authors interpret the regularizer β 2 m∈Γn c nm q 2 nm as a transaction cost arising from trades. In [START_REF] Moret | Heterogeneous risk preferences in community-based electricity markets[END_REF] the regularizer β 1 J t 2 n is introduced as a transaction cost for financial contracts. These terms allow us to obtain a unique solution (J t n , x t n ) for all n ∈ N , for all values of x I . With this modification, we can write the KKT conditions of the lower-level problem (12) with modified Π t n , in which the only changes appear for the optimality condition w.r.t. q:

Proposition 24. For any ε > 0, there exists β 1 , β 2 > 0 s.t. Π R n ≤ Π n + ε, i.e., we can approximate any ε-GNE of the lower level using a regularized formulation. Moreover, there exists a sequence

Proof. We first observe that 1 2 β 2 m∈Γn c nm q 2 nm + β 1 J t 2 n is non-negative, and that |q nm | ≤ κ nm ∀n, m ∈ N , from which it follows that the difference between the objective functions for agent n can be bounded by β 2 m∈Γn c nm κ 2 nm . Fixing other decision variables at the equilibrium and taking

, we obtain the first statement.

Second, we note that from (7.2), boundeness of |q nm | and Proposition 4.3, that for each β k 2 there exists a set of dual variables s.t.

0, which approaches exactly the set of solutions described by KKT for original problem. We note that from the reformulation (19), the set of equilibria solutions of the lower-level problem in PBP is a subset of equilibra solutions of the lower level of OBP. Thus, the bound is proved for both formulations.

Numerical results supplement

RN

RA

No I OBP PBP CS 0.7 1.21 1.2 1.28 1.28 DS ∼1200 ∼1600 ∼1600 ∼1600 ∼1600 Computational approaches. In general, computing a GNE can be a challenging task. Many algorithms have been proposed, especially in recent years, but the conditions that guarantee their convergence, such as strong monotonicity of the pseudo-gradient of the game, aggregative structure, potential structure, etc. [START_REF] Facchinei | Decomposition algorithms for generalized potential games[END_REF], [START_REF] Paccagnan | Distributed computation of generalized nash equilibria in quadratic aggregative games with affine coupling constraint[END_REF], [START_REF] Tatarenko | Learning generalized nash equilibria in a class of convex games[END_REF], [START_REF] Yin | Nash equilibrium problems with scaled congestion costs and shared constraints[END_REF], might be to strong to justify in practice. Computing solutions of bilevel problems, especially in the pessimistic framework, can be even more challenging [START_REF] Sinha | A review on bilevel optimization: From classical to evolutionary approaches and applications[END_REF], [START_REF] Basilico | Methods for finding leader-follower equilibria with multiple follower[END_REF], [START_REF] Liu | International journal of computational intelligence systems[END_REF]. Reformulation as a centralized optimization problem might lead to the inefficiency of the solution [START_REF] Ralph | Risk trading and endogenous probabilities in investment equilibria[END_REF] and also, due to computational and communication limitations, it is not always possible to solve a large-scale optimization problem, and it is preferable to decompose the problem so that it can be solved by a distributed algorithmic approach. Using reformulation G ch with choice function, we can implement both centralized and distributed approaches to solve the two-level problem. To solve the problem in a distributed fashion, we use gradient-descent method discussed for e.g. in [START_REF] Yin | Nash equilibrium problems with scaled congestion costs and shared constraints[END_REF] implemented using PyTorch and for the centralized solution we use Gurobi Optimizer 9.5. The comparison of the computational time for centralized (CS) and decentralized (DS) solutions of different models with 100 scenarios are given in Table 3. Parameters' impact. We want to assess the agents' parameters' impact on their costs in different frameworks.

To that purpose, we use linear regression on a set of 2000 parameters sampled from the uniform distribution and extract the weights corresponding to the parameters, summing them over all agents. The result is depicted in Figure 8. The R 2 scored obtained are > 0.75. It might seem surprising that the main weights are put on bn and d t n , which are the constant terms in agent's demand and generation costs. This is due to the fact that these terms are not affected by the decisions of the prosumers, and, while prosumers minimize the terms in their costs that depend on d t n , g t n , these constants remain unchanged. Coefficients a n , b n of generation cost C n (g t n ) as well as risk aversion χ n affect a lot RA and Only I while not having a significant impact in OBP and PBP frameworks. This is due to the equity property of the latter, i.e., the price for the financial contracts being the same (and minimal possible) for all the prosumers.

Uncertainties

Scenario approach considered in the paper can be supplemented with a distinction between the correlated and independent random variables reflecting prosumers' generation, demand etc. It is possible to adapt the notion of the general types of individual risk and collective risk investigated in (Cass et al. , 1996), where authors accounted for both of them and investigated the effects of the combination of both Arrow-Debreu and Malinvaud's models of insurances on this type of uncertainty. In our work we can employ the former ones, while considering the same type of uncertainty division. Thus, each agent faces two sorts of uncertainty: individual uncertainty and collective uncertainty. It allows to speak about the independence of the random variables we focus on.

For each agent, there are possible S n individual states (1, . . . , S n ) and T possible collective states (1, . . . , T ). Each agent correctly believes that her probability of being in a joint state (s, t) is given by p n (s, t) > 0 s.t. (s,t) p n (s, t) = 1. We denote the corresponding random variables as S n and T . Agents view T as a possible state of nature (e.g. weather conditions) which are common knowledge for everyone. S n , on the other hand, reflects individual uncertainties conditioned on the state of nature (e.g. the demand of agent n). It is natural to assume that after the state of nature t is observed by the agents, their individual r.v. S n are independent i.e. S n are conditionally independent given T and the conditional probabilities are given by

All the results in the paper can be proven for this modified scenario approach. Additional constraints are introduced due to the trading in the electricity market. For pairs of agents n, m ∈ N, n = m, in order to align their trading decisions, we have to consider pairs of individual scenarios (s i , s j ) ∈ S n × S m , given collective state t. Under the assumption of conditional independence of individual scenarios, we can write the joint probabilities of individual scenarios conditionally to the state of nature, as p(s i , s j |t) = p

. Given a scenario (s i , s j , t), we impose an equality on the trading reciprocity: q (s i ,s j ,t) nm + q (s i ,s j ,t) mn = 0, ∀m ∈ Γ n ,

which couples the agents' bilateral trading decisions. It means that in the case where q (s i ,s j ,t) nm > 0, the quantity that n buys from m should be equal to the quantity q (s i ,s j ,t) mn that m is willing to offer to n. Individual uncertainties sets S n are unknown by other agents in the network, thus it follows that the trades of agent n decided for scenario s i should be equal for all the scenarios s j , s k of the agent m ∈ Γ n : q (s i ,s j ,t) nm = q (s i ,s k ,t) nm , ∀s j , s k ∈ S m .

(31)

D. Cass, G. Chichilnisky, H.-M. Wu, "Individual Risk and Mutual Insurance", Econometrica, 64(2), [333][334][335][336][337][338][339][340][341]1996