Henry Ford

Harvey Firestone

Alexis Carrel

Charles Lindbergh

Je Souhaite

Je Tiens À Remercier Particulièrement

Didier Aussel

René Henrion D'

Roger Guesnerie

Michel De

Emmanuel Gobet

Justina Gianatti

Daphné Giorgi

Olivier Tissot

Philip Thompson

Wahid Faisal

Merci

Guillermo Jiménez Estévez

Fernando Lanas

Stéphane Gaubert

Robert Phillips

Harborne W Stuart

Stéphane

Anne-Lise Patrick

Sarah Noémie

Frédéric Bonnans

Pierre Martinon

Francisco Silva

Guillermo Jiménez-Estévez

mon travail de recherche

Keywords: Contributions mathématiques pour la régulation électricité, micro réseau, marchés en réseaux, optimisation, vieillissement, mécanismes d'incitation electricity, microgrid, network markets, optimization, aging, mechanism design, auctions

We are like tenant farmers chopping down the fence around our house for fuel when we should be using Nature's inexhaustible sources of energy-sun, wind and tide. I'd put my money on the sun and solar energy. What a source of power! I hope we don't have to wait until oil and coal run out before we tackle that.

Le travail résumé dans cette thèse est dédié à la mémoire de Théo Heymann. Que son souvenir soit une bénédiction.

Chapter 1

Introduction

This introduction, the only chapter of the thesis written in French, presents in broad terms the whole content of the manuscript.

Présentation générale

Ce manuscrit rassemble le travail des trois années de thèse que j'ai effectuées à l'Ecole polytechnique au sein de l'équipe Inria Commands, sous la direction de Frédéric Bonnans, co-encadré par Alejandro Jofré de l'Universidad de Chile. Au cours de cette thèse, j'ai effectué trois séjours de plusieurs mois à Santiago du Chili pour travailler avec Alejandro Jofré et une équipe du centro de Energía. Mon travail porte sur certaines questions d'optimisation liées à la production d'électricité. Chacune des deux parties de cette thèse en aborde un aspect différent. L'annexe quant à elle apporte quelques informations complémentaires sur BocopHJB, le solveur numérique de contrôle optimal au développement duquel j'ai pu participer.

La première partie de cette thèse porte sur l'optimisation de la production d'électricité par un micro-réseau. Dans les deux premiers chapitres de cette partie, nous formulons le problème d'optimisation du micro-réseau comme un problème de commande optimale.

Le micro-réseau (microgrid en anglais) est un paradigme de production et de distribution La première partie se termine par un algorithme permettant de prendre en compte le vieillissement de long terme (Chapitre 4) de systèmes commandés. J'applique ensuite ce résultat à un exemple simplifié de micro-réseau. Ce travail est motivé par une question pratique à l'énoncé très simple : comment prendre en compte l'usure de la batterie dans le problème d'optimisation ?

Les idées et résultats de cette première partie sont construits sur la théorie du contrôle optimal en temps continu (appelé aussi commande optimale), avec une petite incursion dans la théorie du contrôle optimal stochastique dans le chapitre 3. Nous détaillons un peu plus bas notre contribution scientifique sur le sujet des micro-réseaux.

La deuxième partie de ma thèse porte sur un thème plus macroscopique : le marché de l'électricité. J'étudie un modèle d'enchères d'approvisionnement où un opérateur central organise la production pour minimiser le prix que le consommateur devra payer.

Observons que la réalité est très complexe. Les règles d'allocations et de rétributions, les contraintes techniques et réglementaires et le type d'agents qui y prennent part dépendent du marché considéré. En plus de l'aspect géographique, il existe plusieurs types de marchés (puissance, capacité, etc.) et ces marchés sont interconnectés que ce soit par des connexions physiques ou des produits financiers.

L'étude que nous proposons porte sur un modèle statique en réseau avec une demande inélastique. La demande est considérée comme un objet déterministe pour simplifier, le cas stochastique se traitant de façon similaire. Nous proposons un mécanisme d'incitation permettant:

• D'inciter les producteurs à révéler leurs vrais coûts de production,

• De minimiser le coût payé par le consommateur.

Nous étudions également la structure de ce marché à la lumière de quelques éléments de théorie des jeux. Ce travail emprunte beaucoup à la théorie des enchères et à la théorie Enfin, l'industrie de l'électricité est en pleine mutation. Au cours de ma deuxième année de thèse, le marché mondial du panneau solaire a augmenté de 25%. Les énergies renouvelables sont en plein essor (cf. graphique 1.4 et 1.5). L'objectif de la France est un mix énergétique comprenant 20% de renouvelables d'ici 2020. L'ADEME (Agence de l'Environnement et de la Maîtrise de l'Energie) a même envisagé (plus comme expérience de pensée que comme plan politique) des scénarios avec des mix à plus de 80%. Dans ce contexte, les quelques phrases données en épigraphe, attribuées à Thomas Edison (à qui l'on attribue l'invention de la lampe à incandescence) prennent des accents de prophétie.

Dans certains pays, la part de renouvelables dépasse les 50% (Norvège 98%, Brésil 77%, Canada 63%, Costa Rica 88%). De grands projets sont en cours dans d'autres pays (au Chili par exemple). La catastrophe de Fukushima a durablement changé le rapport des sociétés au nucléaire.

Des changements importants s'annoncent pour les années à venir:

• augmentation des sources intermittentes dans le mix énergétique, A priori, il y a donc deux variables d'ajustement possible pour le problème, mais si on considère l'équation d'équilibre des puissances :

P diesel + P batterie + P solaire = P demande , (1.1)
on se rend compte que si on fixe la puissance diesel, la puissance de la batterie est fixée aussi. On en déduit qu'une formulation avec un contrôle (le diesel) et un état contrôlable Or, si l'on considère le problème d'optimisation du micro-réseau sur plusieurs années, il faut prendre en compte l'état de santé de la batterie comme une variable d'état, au même titre que la quantité d'énergie stockée dans la batterie. Sur un intervalle temporel grand, il existe donc un profil optimal d'âge.

L'algorithme de poids adaptatifs permet de choisir le coefficient de pénalisation (le poids) de telle sorte que le contrôle optimal résultant pour un horizon d'une journée provoque un niveau de vieillissement qui soit proche de l'optimum. Les résultats sont d'abord présentés de façon générale, en dehors du contexte du micro-réseau. J'expérimente ensuite l'algorithme sur un modèle analytique de micro-réseau.

Nous venons de voir les principaux axes abordés dans cette première partie. Les principales contributions sont les suivantes Chapitre 2: Continuous Optimal Control Approaches to Microgrid Energy

Management

• formulation du problème de l'EMS comme d'un problème de contrôle optimal non linéaire en temps continu,

• modélisation des états allumé et éteint du générateur diesel,

• introduction d'une simplification algorithmique pour le cas des coûts de production concaves,

RÉSUMÉ ET CONTRIBUTIONS DE LA SECONDE PARTIE

• comparaison de deux méthodes de résolution du problème en temps continu avec une approche mixte linéaire en nombres entiers (MILP). • extension au cas stochastique du modèle déterministe. Le modèle proposé pour la demande nécessite l'estimation d'un nombre limité de paramètres.

• comparaison avec une approche déterministe à horizon glissant sur un profil historique.

Chapter 4: Long Term Aging : An Adaptative Weights Dynamic Programming Algorithm

• introduction de l'algorithme de poids adaptatifs,

• estimation de l'erreur,

• discussion sur la complexité algorithmique,

• expérience numérique sur le vieillissement d'un micro-réseau.

Résumé et contributions de la seconde partie

Dans la second partie, nous proposons un mécanisme de régulation permettant de diminuer le pouvoir de marché des producteurs d'électricité, au profit du consommateur. On considère un modèle de marché en réseau. Le marché est modélisé par un graphe. En chaque point du graphe:

• il y a un producteur d'électricité,

• la demande est connue.

Un opérateur central alloue la production de façon à minimiser ses coûts. L'électricité peut transiter à travers le réseau, mais cela engendre des pertes en ligne (effet Joule). Ces pertes sont à la charge du consommateur.

Les producteurs voulant maximiser leur profit, ils sont tentés de surévaluer leurs coûts de production pour augmenter leurs marges. Escobar et Jofré ont montré dans [START_REF]Monopolistic competition in electricity networks with resistance losses[END_REF] que les pertes en ligne donnent aux producteurs un pouvoir de marché, et que la surévaluation est dans ce cadre là une attitude raisonnable des producteurs.

CHAPTER 1. INTRODUCTION

Ainsi dans le cas d'un réseau de deux noeuds avec des producteurs symétriques de coût marginal de production c, on peut montrer que ceux-ci annonceront à la place un coût de Pour cette deuxième partie, les contributions apportées sont:

c * = c 1 -2rd > c, (1.2
Chapter 5: Mechanism Design and Auctions for Electricity Network

• ce chapitre est principalement une introduction du contexte général pour ce qui va suivre,

• on propose en illustration un calcul de la solution du problème d'allocation de l'opérateur dans le cas de deux noeuds et des coûts de production linéaire par morceaux (deux morceaux).

Chapter 6: Cost-Minimizing regulations for a wholesale electricity market

• nous introduisons le mécanisme d'incitation dans le cas de coûts linéaires,

• nous calculons numériquement sur un exemple ce que gagne le consommateur si ce mécanisme d'incitation est implémenté,

• nous montrons que, contrairement à ce que pourraient nous faire croire les résultats numériques, ce que paie consommateur n'est pas une fonction affine du coefficient de perte en ligne r.

BOCOPHJB

Chapter 7: Mechanism design and allocation algorithms for network markets with piece-wise linear costs and quadratic externalities

• nous généralisons le résultat du chapitre précédent pour des fonctions linéaires par morceaux, des externalités et un réseau général,

• nous observons quelques propriétés de la solution du problème d'allocation de l'opérateur central,

• nous en déduisons en particulier que la quantité moyenne produite par un producteur est une fonction régulière de son coût de production,

• nous en déduisons aussi un algorithme de point fixe pour calculer la solution du problème d'allocation du principal,

• nous comparons les performances de cet algorithme avec les performances d'une résolution avec le solveur CVX,

• pour le cas binodal, nous introduisons un autre algorithme plus rapide.

Chapter 8: On a class of bidding games whose dynamics converges to the unique pure equilibrium

• nous identifions une classe de jeux Bayésien pour laquelle nous montrons l'existence d'un équilibre de Nash en stratégie pure,

• nous donnons des conditions suffisantes d'unicité,

• nous proposons un algorithme pour calculer les stratégies d'équilibre,

• nous appliquons ces résultats au cas du marché binodal avec coûts de production linéaires.

BocopHJB

BocopHJB est un solveur numérique codé en C++ que nous avons développé pendant la première année de thèse. BocopHJB permet la formulation et la résolution de problèmes de contrôle optimal en temps continu.

Il repose sur le principe de programmation dynamique énoncé par Richard Bellman dans les années 1950. On considère formellement le problème de contrôle optimal suivant:

V (x 0 , t 0 ) = inf u T t (u(t), x(t))dt + φ(x T ), (1.3)
où x est un état contrôlé par la commande u, est un coût intégral et φ un coût final. La quantité V correspond au coût total minimum que l'on puisse obtenir en partant de l'état CHAPTER 1. INTRODUCTION

x 0 au temps t 0 . On dit que V est la fonction valeur du problème. C'est une fonction de x 0 et de t 0 . Le principe de programmation dynamique de Bellman exprime la chose suivante:

Supposons qu'un contrôle u est optimal entre le temps t 0 et le temps T et nous amène à x au temps t. Alors si on part de x, ce contrôle est optimal entre le temps t et le temps T .

Le lecteur intéressé par ce principe pourra notamment lire le livre de Isaacs sur les jeux différentiels [START_REF] Isaacs | Differential games: a mathematical theory with applications to warfare and pursuit[END_REF].

BocopHJB est, comme Bocop, un logiciel de contrôle optimal développé au sein de l'équipe Commands. Celui-ci ne repose pas sur de la programmation dynamique, mais sur ce que l'on appelle la méthode directe, qui consiste à discrétiser directement le problème et résoudre ensuite le problème d'optimisation discrétisé. Le guide utilisateur et quelques exemples sont donnés en annexe de la thèse. BocopHJB se présente comme un code source en C++ (non compilé). Pour résoudre un problème de contrôle avec BocopHJB, il suffit d'indiquer les différentes données du problème (dynamique, objectif, contraintes) dans des fonctions C++ correspondantes. Les paramètres de discrétisation et de simulation sont à indiquer dans des fichiers textes. Une fois le problème écrit, l'utilisateur doit compiler le code, puis le lancer.

BocopHJB résout alors le problème par programmation dynamique. Plus techniquement, BocopHJB calcule la solution de l'équation de Hamilton-Jacobi-Bellman associée au problème de contrôle optimal en utilisant un schéma semi-Lagrangien. L'équation de Hamilton-Jacobi-Bellman (HJB, d'où BocopHJB tient son nom) est une équation aux dérivées partielles non linéaire qui s'obtient formellement en combinant un développement de Taylor de la fonction valeur (ou d'Itô dans un cadre stochastique avec un mouvement Brownien) avec le principe de programmation dynamique:

∂ t V (x, t) + inf u (x, u) + ∂ x V (x, t)b(x, u) = 0, (1.4)
où b est la dynamique du système commandé. Pour des références sur l'équation HJB, le lecteur pourra consulter [START_REF] Bonnans | Commande et optimisation de systemes dynamiques[END_REF], [START_REF] Bonnans | Quelques aspects numériques de la commande optimale stochastique[END_REF], [START_REF] Touzi | Stochastic control and application to finance[END_REF] et [START_REF] Pham | Continuous-time stochastic control and optimization with financial applications[END_REF].

Il est important de préciser ici que cette dérivation est formelle, et qu'en général, un travail théorique est nécessaire pour donner un sens à cette équation. En effet, rien n'assure a priori que la fonction valeur V soit dérivable. Dans ce cas, le sens de (1.4) n'est pas clair dans un cadre classique. La bonne notion de solution est celle de solution de viscosité. Le lecteur pourra se référer au User Guide [START_REF] Crandall | Users guide to viscosity solutions of second order partial differential equations[END_REF] pour une présentation détaillée de la théorie.

L'idée est la suivante : en chaque point, remplacer la fonction valeur par des fonctions test régulières qui l'approchent par en dessus ou par en dessous. Ensuite au lieu de vérifier directement que V satisfait l'identité (1.4), on utilise les fonctions test (et une relation très proche de (1.4))

1.6. PERSPECTIVES

27

Le schéma numérique par lequel nous résolvons l'équation HJB est un schéma semi-Lagrangien, qui revient à discrétiser directement le principe de programmation dynamique.

Le lecteur pourra consulter [START_REF] Debrabant | Semi-lagrangian schemes for linear and fully non-linear diffusion equations[END_REF] pour plus de détail sur ce schéma numérique.

La résolution de l'équation de Hamilton-Jacobi-Bellman par schéma semi-Lagrangien consiste donc à calculer, en partant du temps final, les fonctions valeurs. Les calculs peuvent prendre du temps si l'état est de dimension "grande" (typiquement supérieur à 3). C'est ce que l'on appelle la malédiction de la dimension: le nombre d'opérations à effectuer lors de la résolution numérique explose avec la dimension de l'état. C'est l'une des principales limites de l'approche par programmation dynamique. Une fois que le calcul des fonctions valeurs pour chaque pas de temps est terminé, il reste à calculer effectivement le contrôle optimal. Pour cela on exploite à nouveau le principe de programmation dynamique, en remarquant que si V est connue, u s'obtient "très facilement". On part donc de l'état initial et on construit la trajectoire optimale à l'aide des fonctions valeurs calculées par schéma semi-Lagrangien.

Perspectives

Nous identifions ici quelques pistes d'approfondissement:

• pour le modèle d'EMS des chapitres 2 et 3, étendre la méthode à des processus avec sauts, étudier d'autres approches de résolution,

• étendre l'algorithme de poids adaptatifs au cas stochastique avec des contraintes en espérance,

• identifier d'autres applications de cet algorithme (en économie ?), qui ne nécessite en fait que des hypothèses de monotonie par rapport à une variable d'état monotone dans le temps,

• faire une étude plus poussée du gain lorsque le mécanisme d'incitation est implémenté (dans le cas général),

• identifier d'autres domaines d'application de ce mécanisme,

• le dernier chapitre s'intéresse à une partie restreinte du sujet qu'il aborde, mais une étude plus approfondie pourrait possiblement ouvrir le champ à un contexte plus général.

Part I We propose a novel method for the microgrid energy management problem by introducing a nonlinear, continuous-time, rolling horizon formulation. The method is linearization-free and gives a global optimal solution with closed loop controls. It allows for the modelling of switches.

Microgrid optimization and dynamic programming

CHAPTER 2. OPTIMAL CONTROL OF MIGROGRID

We formulate the energy management problem as a deterministic optimal control problem (OCP). We solve (OCP) with two classical approaches: the direct method and Bellman's Dynamic Programming Principle (DPP). In both cases we use the optimal control toolbox Bocop for the numerical simulations. For the DP approach we implement a semi-Lagrangian scheme adapted to handle the optimization of switching times for the on/off modes of the diesel generator. The DP approach allows for accurate modelling and is computationally cheap. It finds the global optimum in less than a second, a CPU time similar to the time needed with a Mixed Integer Linear Programming (MILP) approach used in previous works. We achieve this result by introducing a trick based on the Pontryagin Maximum Principle (PMP). The trick increases the computation speed by several orders and improves the precision of the solution.

For validation purposes, we performed simulations on datasets from an actual isolated microgrid located in northern Chile. The result shows that the DP method is very well suited for this type of problem.

Introduction

Distributed Energy Resources (DER) play a key role as an energy supply alternative.

Moreover, DER are in most of the cases renewable energy sources and bring positive environmental impacts and contribute to sustainability. In order to integrate in a massive way DER into interconnected power systems or make use of DER as a power source for isolated locations, microgrids appear as a suitable technical solution.

A microgrid is a group of interconnected loads and DER that acts as a single controllable entity. It can operate connected to the main network or autonomously (isolated) [START_REF]The smart grid: An introduction[END_REF]. In either case, an Energy Management System (EMS) is required to coordinate the different units that compose it. The EMS solves an optimization problem and, as described in [START_REF] Olivares | Trends in microgrid control[END_REF],

this problem falls into the category of mixed integer nonlinear programming (MILP).

Depending on the philosophy established for the EMS and the different components (generation units, loads, storage devices) incorporated into the microgrid, the objective function may be nonlinear. Moreover, the operation of some of these components involves start up / shut down set points that are typically represented as binary functions of time in the problem formulation. Constraints represent in particular operational limitations of storage devices and generation units (i.e., batteries (dis)charging patterns).

There has been different formulations to handle this problem, the most common being through MILP, for which the complexity mostly stems from the modelling of nonlinearities: battery charging/discharging pattern and the diesel engine efficiency [START_REF] Olivares | Trends in microgrid control[END_REF] for instance.

Heuristic techniques have been also applied to the microgrid EMS problem, such as Genetic Algorithms (GA) [START_REF] Conti | Optimal dispatching of distributed generators in an MV autonomous micro-grid to minimize operating costs and emissions[END_REF], [START_REF] Hatziargyriou | Energy management and control of island power systems with increased penetration from renewable sources[END_REF], Particle Swarm Optimization (PSO) [START_REF] Conti | Optimal dispatching of distributed generators in an MV autonomous micro-grid to minimize operating costs and emissions[END_REF], and Ant Colony Optimization (ACO) [START_REF] Colson | Ant colony optimization for microgrid multi-objective power management[END_REF].

INTRODUCTION

33

Finally, recent works which focus on microgrid energy management systems have incorporated a more detailed modelling of the energy storage system. This energy management system considers the importance of the cost associated with its replacement, so that extending the life span of the battery is part of the objective. In this context, GA have been implemented to solve the problem [START_REF] Zhao | Operation optimization of standalone microgrids considering lifetime characteristics of battery energy storage system, Sustainable Energy[END_REF], and other predictive control approaches such as the ones described in [START_REF] Garcia | Optimal economic dispatch for renewable energy microgrids with hybrid storage using Model Predictive Control[END_REF], [START_REF] Pourmousavi | A framework for real-time power management of a grid-tied microgrid to extend battery lifetime and reduce cost of energy[END_REF], [START_REF] Hooshmand | A novel cost-aware multi-objective energy management method for microgrids[END_REF] and [START_REF] Khasawneh | Battery cycle life balancing in a microgrid through flexible distribution of energy and storage resources[END_REF].

Other authors have made use of Dynamic Programming (DP) to solve the EMS problem. Kanchev et. al. [START_REF] Kanchev | Unit commitment by dynamic programming for microgrid operational planning optimization and emission reduction[END_REF] use DP but look for GHG emissions reductions, [START_REF] Liu | The application of dynamic programming in the stand-alone micro-grid optimal operation[END_REF] focus its objective on the Energy Storage System (ESS) management. These cases do not consider the economic efficiency of the whole microgrid. In [START_REF] Zhang | Optimal operation for energy-efficient building micro-grid[END_REF] the EMS problem is focused on buildings decision incorporating uncertainty modeled with Markov chains under a discrete approach. Babazadeh [START_REF] Babazadeh | Optimal energy management of wind power generation system in islanded microgrid system[END_REF] makes use of DP to handle the wind power management in a microgrid environment. In [START_REF] Nguyen | Dynamic programming formulation of micro-grid operation with heat and electricity constraints[END_REF] DP has been developed to solve out the maximum profit an owner might achieve from energy trading in a day, either in isolated or connected mode, but do not consider in an explicit way effects and management of batteries. Finally, [START_REF] Huang | DC microgrid operation planning[END_REF] applies a multi path dynamic programming (MPDP) approach to solve a power scheduling considering load/generation changes and time of use (TOU) tariff for a low voltage DC microgrid incorporating energy storage battery, fuel cell and PV.

An important conceptual difference between previous works and the present study is that we start with the optimal control problem formulated in continuous time. This gives access to a broader set of theoretical and numerical tools (e.g. Pontryagin's Principle and the Direct Approach).

The microgrid model presented in this work handles some challenges involved with the microgrid EMS, such as units modelling, ESS management, CPU solving time for real applications and the switching of the generator mode (on or off) among others, with a continuous time optimal control formulation. This approach keeps the original non-linear model for the numerical optimization, which enhances the solutions accuracy. The proposal considers two solution methods:

The direct method starts with a time discretization to transform the continuous optimal control problem into a Nonlinear Programming (NLP) problem. The NLP is then solved with any usual technique (see for instance [START_REF] Betts | Practical methods for optimal control and estimation using nonlinear programming[END_REF]).

The DP method relies on Bellman' s Principle and uses a discretization of both time and space to compute the value function. This information then allows the reconstruction of the optimal trajectory using feedback controls (See for example [START_REF] Bellman | Dynamic Programming[END_REF]).

We perform numerical simulations for both methods using the optimal toolboxes Bocop and BocopHJB [START_REF] Bonnans | Bocop -a collection of examples[END_REF][START_REF] Bonnans | Bocophjb 1.0. 1-user guide[END_REF]. The proposed methods are validated with data from a real microgrid operating in Huatacondo, an isolated northern Chilean village that relies completely on the microgrid concept for its electricity supply, which is described in section II.

The present study uses a similar model to the one presented in [START_REF] Palma-Behnke | A microgrid energy management system based on the rolling horizon strategy[END_REF], so that the comparison CHAPTER 2. OPTIMAL CONTROL OF MIGROGRID is relevant. We show results for the three approaches: MILP, direct method and DP.

Note that this work focuses on the comparison of the three techniques, but does not intend to deal with their implementation as building block of upper level algorithms, such as Model Predictive Control (MPC). Likewise, the demand and load modelling is out of the scope of this article. In addition, in all this work the microgrid is considered in disconnected mode, but a similar approach in connected mode could be envisioned (using a market price for instance).

The main contributions of this work are:

• the introduction of a continuous time non-linear framework for the microgrid energy management problem,

• for the dynamic programming approach, the modelling of the generator switching,

• the combination of the Pontryagin Maximum Principle and the Dynamic Programing Principle to get a surprising improvement of the computing time

• a comparison of the continuous time non-linear framework (with two resolution techniques, DP and direct method) with a MILP formulation.

The paper is organized as follows. Section II describes the microgrid system and the optimal control formulation for its energy management. Section III explains the numerical methods we use to solve the optimal control problem. Section IV presents the numerical simulations with the direct and DP methods. Section V comments the results of the simulations. The conclusion sums up the main results and presents ongoing research in the continuation of this work.

Model Presentation

General Aspects

Description of the Microgrid

The following model is based on a real microgrid operating in Huatacondo, an isolated village in northern Chile that relies entirely on the microgrid concept for its electricity supply. The microgrid we are considering includes a photovoltaic power plant (PV), a diesel generator and a battery energy storage system (BESS). It uses a mix of fuel and renewable energy sources. The solar panel produces electricity without any additional cost, but the generation pattern cannot be controlled and depends on the daily weather.

The BESS can store energy for later use, but has limited capacity and power. The diesel generator has a minimal and a maximal output levels, and has a fixed start-up cost. All these are local generation units, i.e. situated physically near the electric consumption point, and electric losses due to distribution are not considered.

The aim is to find the optimal planning that meets the power demand and minimizes the operational costs, which, in this case, mainly relates to the diesel consumption. We follow the problem description from [START_REF] Palma-Behnke | A microgrid energy management system based on the rolling horizon strategy[END_REF].

Optimal Control Formulation

We consider a fixed horizon T = 48 hours. For t ∈ [0, T ], we denote by P S (t) the solar power from the photovoltaic panels, P D (t) the diesel generator power and P L (t) the electricity load. The state of charge SOC(t) of the BESS evolves according to the dynamics

ṠOC(t) = 1 Q B (P I (t)ρ I -P O (t)/ρ O ) , (2.1)
where Q B is the maximum capacity of the battery, P I , P O > 0 are the input and output power of the BESS, and ρ I , ρ o are the efficiency ratios for the charge and discharge processes, assumed constant. Observe that (2.1) writes equivalently

ṠOC(t) = 1 QB (P I (t)ρ -P O (t)) , (2.2)
where

QB = ρ O Q B and ρ = ρ I ρ O .
We introduce the slack variable P slack that represents the excess power (P slack < 0), which has to be shed, or the missing power in the microgrid (P slack > 0), which turns into unmet demand. The addition of this variable ensures the mathematical feasibility of the problem. Positive P slack will be penalized by C U S P + slack , where C U S is a positive constant (see Table 2.1).

The underlying power equilibrium equation is

P D + P O + P S + P slack -P L -P I = 0. (2.3)
Taking into account the demand and the various power production devices, we obtain that P O and P I can be written as nonlinear functions of (t, P D , P slack ): by the diesel generator manufacturer as in [START_REF] Palma-Behnke | A microgrid energy management system based on the rolling horizon strategy[END_REF].

P O (
For physical reasons, the system is subject to the following constraints at every time t ∈ [0, T ]: (2.9) are control constraints. The minimal and maximal power for the diesel generator are given by (2.7). The charging and discharging limits for the battery are stated in (2.8) and (2.9). The charging limit depends on the state of charge, and is therefore a mixed control-state constraint, as illustrated on Fig. 2.1.

SOC(t) ∈ [0.2, 1], (2.6)
P D (t) ∈ {0} ∪ [5, 120], (2.7
Since the operations time frame is larger than the optimization horizon, we impose a constraint on the final time to avoid the battery depletion. We impose this constraint either with a periodicity condition SOC(0) = SOC(T ) (direct method) or a penalization term g(SOC(T )) (DP method).

In summary the optimal control problem can be written under the following abstract formulation (see [START_REF] Bryson | Applied optimal control[END_REF]Chapter 2])

(OCP )                        min u T 0 (u(t))dt + g(x(T )) ẋ(t) = F (u(t), t) x(0) = x 0 u(t) ∈ U x(t)
x(t) ∈ C.

(2.10)

In the notation above, x, u, F , U x and C correspond respectively to the state variable (SOC), the control variable (P D and P slack ), the dynamics of the system (2.1) and (2.4), the control constraints on u(t) (see (2.7), (2.8) and (2.9)), and the state constraints (2.6). The time horizon T is 48 hours. The objective function is the sum of a final cost g (introduced in Section 2.2.3 to impose a periodicity condition) and the integral of defined in (2.5) (to which we add the penalization associated with the slack variable). Those functions take value from the state space and the control space respectively to R.

Switching Cost

Turning the diesel generator on consumes fuel. We model this by considering that the diesel generator has two modes: when off, the only admissible control is P D = 0, whereas when it is on, P D ∈ [P min , P max ]. At any time, one can switch from one mode to the other by paying the corresponding switching cost. This cost is zero to turn the generator off, and is equal to C D to turn the generator on. It should be stressed that while the modelling of the switching cost is made straightforward by the Dynamic Programming approach, it is challenging for the Direct Method approach.

Periodicity Condition

To avoid the battery depletion at the end of the time horizon, we add a periodicity constraint on the state

SOC(0) = SOC(T ). (2.11)
The implementation of the constraint is straightforward for the MILP model and the Direct Method. The actual initial value is then optimized by the algorithm.

For the dynamic programming approach we model the periodicity condition by taking a similar approach to the "big M method" in linear programming:

g(SOC(T )) = M ifSOC(T ) < SOC 0 , g(SOC(T )) = 0 if SOC(T ) ≥ SOC 0 .
For the simulations, we set SOC 0 = 0.7.

CHAPTER 2. OPTIMAL CONTROL OF MIGROGRID

Presentation of the numerical methods

We give here a brief presentation of the two resolution approaches we are considering and explain how to apply them in order to solve (2.10). The reader will find more on these approaches in [START_REF] Betts | Practical methods for optimal control and estimation using nonlinear programming[END_REF] and [START_REF] Falcone | Semi-Lagrangian approximation schemes for linear and Hamilton-Jacobi equations[END_REF].

The Direct Method Approach

Presentation

In the Direct Method we apply a time discretization to the dynamics equation. The optimal control problem is rewritten as a finite-dimensional optimization problem. The decision variables of this discretized problem are the values of the control variables at each time step. Since we solve the discretized problem by locally convergent algorithms, we cannot guarantee that the numerical solution (if any) is close to a global optimum. On the other hand, this approach often provides efficient solutions for large scale optimal control problems, with limited computing times.

Summary of the time discretization, using the Euler formula:

t ∈ [0, T ] → {t 0 = 0, . . . , t N = T } x(•), u(•) → Z = {x 0 , . . . , x N , u 0 , . . . , u N -1 } Criterion → min h N -1 i=0 (u i ) + G(x N ) Dynamics → x i+i = x i + hf (x i , u i ) i = 0, . . . , N Controls → u i ∈ U x i i = 0, . . . , N -1 States → x i ∈ C i = 0, . . . , N
We therefore obtain a nonlinear programming problem on the discretized state and control variables

(N LP ) min Z F (Z) LB ≤ C(Z) ≤ U B.
The optimal control toolbox Bocop solves the discretized nonlinear optimization problem with the Ipopt solver [START_REF] Waechter | On the implementation of an interior-point filter line-search algorithm for large-scale nonlinear programming[END_REF] that implements a primal-dual interior point algorithm.

Modelling Remarks

We come back to our setting. This method allows a periodicity constraint of the form

SOC(0) = SOC(T )
where the actual value is optimized by the algorithm. On the other hand, the constraint (2.7) is changed into P D ∈ [0, 120] because switching are hard to deal

PRESENTATION OF THE NUMERICAL METHODS

with within this framework. Another drawback is that switching costs are binary decisions which are not easily handled within this framework.

Dynamic Programming Approach

We propose a semi-Lagrangian scheme to solve the DP, in particular because it is adapted for problems with switching modes. We refer the reader to the monograph [START_REF] Falcone | Semi-Lagrangian approximation schemes for linear and Hamilton-Jacobi equations[END_REF] and the references therein for an introduction to semi-Lagrangian schemes applied to optimal control problems. In addition, the Pontryagin Maximum Principle (PMP), see [START_REF] Pontryagin | The Mathematical Theory of Optimal Processes[END_REF], provides additional information on the optimal solution. The combination of the Dynamic Programming Principle and the Pontryagin Maximum Principle reduces the computing time of the method significantly.

Brief Presentation of the Theory

Let V (t, x 0 ) denote the value of problem (2.10) with initial time t and initial condition x 0 .

In R. Bellman's words [START_REF] Bellman | Dynamic Programming[END_REF] "An optimal policy has the property that whatever the initial state and initial decision are, the remaining decisions must constitute an optimal policy with regard to the state resulting from the first decision." In mathematical terms, V satisfies for

h ∈ (0, T -t): V (t, x 0 ) = inf t+h t (u s )ds + V (t + h, x(t + h)) , (2.12)
the infimum being taken over the set of admissible controls. In our case, we will use an extended version of the DP approach that handles the switchings (See [START_REF] Falcone | Semi-Lagrangian approximation schemes for linear and Hamilton-Jacobi equations[END_REF] for more details).

Semi-Lagrangian Scheme

The Semi-Lagrangian scheme consists of solving a discretized version of (2.12) over the space backward in time (see [START_REF] Falcone | Semi-Lagrangian approximation schemes for linear and Hamilton-Jacobi equations[END_REF] for an overview). We have chosen this scheme to solve the problem because it has good stability properties, it allows large time steps and it is easy to implement. Let us motivate the scheme by first discretizing in time (2.12). Given a time step h and N such that N h = T , let us set t k = kh (k = 0, . . . , N ). Denoting by V k the "approximated" value function at t k we have

V k (x) = min u∈Ux h (u) + V k+1 (x + hF (u, t k )) . (2.13)
We derive the Semi-Lagrangian scheme from (2.13) by discretizing in space the state variable x and introducing interpolation operators in order to approximate

V k+1 (x+hF (u, t k ))
in terms of its values in the space grid. The scheme is solved backward in time and, under standard conditions, it converges to the solution V of (2.12). We use the implementation of BocopHJB (see [START_REF] Bonnans | Bocop -a collection of examples[END_REF][START_REF] Bonnans | Bocophjb 1.0. 1-user guide[END_REF]) for the numerical experiment.

CHAPTER 2. OPTIMAL CONTROL OF MIGROGRID

The PMP Trick

The formulation has a property that greatly reduces the computing time. For the sake of simplicity we do not detail the aspects related to the state constraints. If ū is the optimal control, denote by x the optimal state and by p the costate associated to the dynamics constraint ẋ(t) = F (t, u(t)). Defining the Hamiltonian H(u, p, t) := pF (u, t) + (u) the PMP says that for all t ∈ [0, T ] we have

H(ū(t), p(t), t) ≤ H(v, p(t), t) for all v ∈ U x(t) .
Since the dynamics is continuous and piecewise affine, the Hamiltonian is the sum of a continuous, piecewise affine and of a continuous strictly concave functions, and therefore is continuous, piecewise strictly concave. Therefore it can attain its minimum only at one of the extreme points of the pieces. Taking into account the constraints, we have at most five possible optimal controls, as illustrated in figure 2.2. Moreover, the values of these controls can be computed explicitly, since they do not depend on p. Therefore, when doing the minimization in (2.13), we test only these controls instead of discretizing the control space, gaining both in speed and precision. So:

• if the Diesel is off (mode 0), we simply take P D = 0.

• if the Diesel is on (mode 1), we test the five cases -P D = 5 (minimum power),

-P D = 120 (maximum power),

-P D such that ṠOC = 0 (battery unused),

-P D such that P i = P max i (SOC) (maximal charge),

-P D such that P 0 = 40 (maximal discharge).

The specific structure of the problem permits to reduce the computing time. More precisely, the candidates for the optimal control do not depend on the costate p and therefore can be evaluated and tested when computing the value function. In the general case, the control that minimizes the Hamiltonian is expressed from both the state and costate, the latter being unavailable in the DP approach (the costate actually corresponds to the gradient of the Value Function under suitable regularity assumptions).

Remark 1 (Slack variable). In the five cases above, we adjust the slack variable if needed to get an admissible Diesel output P D .

We now propose a pseudo-algorithm for the numerical resolution:

V k m (SOC) = min{ min P D ∈G(SOC,m,kh) h (P D ) + V k+1 (x + hF (P D , kh)), min P D ∈G(SOC, m,kh) h (P D ) + V k+1 (x + hF (P D , kh)) + C switch (m)} end end end
The parameter h corresponds to the time discretization size, and I SOC is the state discretization grid. The result is the value function V k for each time step k. The functions F and correspond to the dynamics and running cost as expressed in the abstract optimal control problem formulation (2.10) The mode m ∈ {ON,OFF} corresponds to the fact that the diesel can be already working or turned off. We have denoted by m the negation of m. In case of switch, a cost C switch (m) has to be added to the cost to go function. This cost is the startup cost if the generator is turned on (see Table 2.1), and 0 else. The set G(SOC, m, t) corresponds to the potential optimal controls we deduced from the PMP trick. Since the actual microgrid is situated in the Atacama desert, we assume the production from the photovoltaic panels to be reliably predictable. The demand, on the other hand, has a greater variability. While it is modeled as deterministic in this initial work, the extension of this model to a stochastic demand setting is the focus of another work.

Numerical simulations

Optimal Solutions for the Different Methods

In addition to the direct and DP methods, we present the results obtained with the MILP approach from [START_REF] Palma-Behnke | A microgrid energy management system based on the rolling horizon strategy[END_REF] as baseline for comparison. The six solutions are illustrated in Figures

General Observations

• The Solar Power fills the demand, with any excess power used to charge the battery.

• The Diesel is always off when solar power is available, and is switched on once a day during the evening peak in demand. The Diesel output is often greater than power demand: it is also used to charge the battery.

• The battery fills the gaps between production and demand especially at night.

• MILP and DP solutions are quite close, while direct solution shows some clear differences (different initial/final SOC, no minimal power, spurious switchings).

Diesel Range

A qualitative difference between MILP and DP/direct is the existence of time intervals with a constant SOC, while the diesel exactly matches the power load. In the MILP solutions the diesel is either off or saturating the charge limit.

First we note that there is a tradeoff between low average production cost and low storage cost per energy unit. On the one hand, since the diesel cost function is concave, the diesel generator should run at maximal capacity to minimize the average unit price of power produced. On the other hand one incurs some losses when storing energy because the battery is not perfectly efficient. One has to set the diesel output equal to the net demand (so that nothing gets in or leaves the battery) to minimize those losses. This tradeoff explains why on the DP and Direct solutions we observe two kinds of non zero diesel levels (low: just sufficient to satisfy the demand, and thus keep a constant SOC, or high: maximum physical production level). The question is then why we do not observe the low level on the MILP simulation. We do not have a straightforward answer, as different phenomena could contribute to this observation. First the MILP problem is a linearized version of the DP problem, so it may happen that this linearized version does not produce the same output. Second the MILP numerical solution is only locally optimal and so may differ from the MILP actual solution.

Comparison of the methods

We highlight below the differences between the three optimization methods.

Global optimum. Both the MILP and direct approaches are local methods and may converge to a local solution, depending on the provided starting point and the choice of the stopping criterion (gap). On the other hand, the DP approach performs a global optimization over all possible (discretized) trajectories, and therefore always finds the global optimum. This is an advantage for the user since one does not have to find a "suitable" starting point. Also, the DP solution provides a feedback optimal control, whereas MILP and direct solutions are open-loop.

Switching cost. Both MILP and DP approaches take into account the switching costs for the diesel generator. They typically find solutions with one switch per day, located during the peak of power demand in the evening. On the other hand, the direct approach has free switchings, which explains why it may find solutions with many on-off oscillations.

Nonlinear model. The MILP method requires a piecewise linear reformulation of the nonlinear functions in the model, here for example the charging power limit or the cost of diesel consumption. Both direct and DP methods use the original nonlinear model. This simplifies the actual implementation, and may imply more accurate solutions.

Periodicity constraint and minimal diesel power. Compared to MILP and DP, the direct method optimizes the value of the initial/final SOC. On the other hand, it does not take into account the minimal power output for the diesel generator.

Computing time. For this problem the computing time is a few seconds for MILP and direct method, and less than one second for the DP approach. Note that DP is outperforming the two other approaches because of the PMP trick and the fact that the state is one dimensionnal. An interesting question is how well each method would scale CHAPTER 2. OPTIMAL CONTROL OF MIGROGRID for higher dimensions. MILP and direct approach are iterative methods, so changing the problem size may lead to a different convergence, making it difficult to assess the evolution of the CPU time. For the DP approach, on the other hand, the number of operations is always known and the CPU time can be predicted reliably. The CPU time should increase linearly in the number of time steps. Due to the state discretization, however, adding new state variables to the problem would have a significant impact on performance (the so-called curse of dimensionality). In terms of high performance computing, parallelization is possible with MILP and DP methods, not so easily with the direct method.

Conclusion and perspectives

We have applied two methods from the continuous optimal control field to the optimal energy management of a microgrid, namely the direct and DP approaches. Numerical simulations indicate that the DP method is very well suited to this problem as it is a linearization-free method that provides global optimal solution with closed loop control. It allows for the modelling of the switches and it is as fast as the MILP approach. We were able to obtain the global optimum in less than one second of CPU time, while taking into account the switching cost for the diesel generator. Solutions are close to the ones obtained in [START_REF] Palma-Behnke | A microgrid energy management system based on the rolling horizon strategy[END_REF] with a MILP formulation, the main difference being the existence of time intervals where the battery stays at a constant SOC. In comparison with the two other approaches, the use of Pontryagin's Maximum Principle combined with Dynamic Programming reduces the computing time. The numerical experiments were performed with the optimal control toolbox Bocop.

From a theoretical standpoint, the continuous model offers a very large collection of mathematical results. The PMP trick introduced here is an example of insight one can get from a continuous time mathematical analysis. (Observe that a Maximum Principle exists for the discrete case, but only for convex Hamiltonian).

Ongoing works on this topic include the extension to a stochastic model for the power demand, and the study of the long-term aging of the battery. We propose a novel stochastic control formulation for the microgrid energy management problem and extend previous works on continuous time rolling horizon strategy to uncertain demand. We modelize the demand dynamics with a stochastic differential equation.

We decompose this dynamics into three terms: an average drift, a time-dependent meanreversion term and a Brownian noise. We use BocopHJB for the numerical simulations.

CHAPTER 3. STOCHASTIC MODEL FOR MICROGRID

This optimal control toolbox implements a semi-Lagrangian scheme and handles the optimization of switching times required for the discrete on/off modes of the diesel generator.

The scheme allows for an accurate modelling and is computationally cheap as long as the state dimension is small. As described in previous works, we use a trick to reduce the search of the optimal control values to six points. This increases the computation speed by several orders. We compare this new formulation with the deterministic control approach introduced in [START_REF] Heymann | Continuous optimal control approaches to microgrid energy management[END_REF] using data from an isolated microgrid located in northern Chile.

Introduction

A microgrid is a small network of loads and energy ressources controlled by an Energy

Management System (EMS). It can be either connected to the main network or isolated.

The coordination of the microgrid units requires the resolution of an optimization problem.

This problem is described in the literature as the microgrid management problem. Palma- [START_REF] Heymann | Continuous optimal control approaches to microgrid energy management[END_REF] that this MIP formulation could be replaced by a continuous Optimal Control (OC) formulation. We extend this last approach to the stochastic case by introducing a stochastic dynamics for the load.

In [START_REF] Ji | Optimal microgrid energy management integrating intermittent renewable energy and stochastic load[END_REF] the microgrid energy management problem is formulated as a two-stage stochastic programming model based on optimization principle. Then, the optimization model is decomposed into a mixed integer quadratic programming problem by using discrete stochastic scenarios to approximate the continuous random variables. A scenarios generation approach based on a time-homogeneous Markov chain model is proposed to simulate time-series of renewable energy generation and load demand. Similar approaches are considered in [START_REF] Li | Scenario-based stochastic programming strategy for microgrid energy scheduling considering uncertainties[END_REF] and [START_REF] Eajal | Two-stage stochastic power generation scheduling in microgrids[END_REF], especially in [START_REF] Li | Scenario-based stochastic programming strategy for microgrid energy scheduling considering uncertainties[END_REF] uncertainty is characterized by a scenarios generation approach based on autoregressive moving average (ARMA) model according to the probability density function of each random variable. In [START_REF] Olivares | Stochasticpredictive energy management system for isolated microgrids, Smart Grid[END_REF], uncertainty is addressed using a two-stage decision process combined with a receding horizon approach. The first stage decision variables (unit commitment) are determined using a stochastic mixed-integer linear programming formulation, whereas the second stage variables (optimal power flow) are refined using a nonlinear programming formulation. Other approaches appear, such as the one described in [START_REF] Zakariazadeh | Smart microgrid energy and reserve scheduling with demand response using stochastic optimization[END_REF] where uncertainties related to renewable distributed generation are modeled by proper probability distribution functions and are managed by reserve provided by both DGs and loads.

The reader may refer to [START_REF] Pham | Continuous-time stochastic control and optimization with financial applications[END_REF] to get an overview of stochastic control theory and the applications of the dynamic programming principle, and to [START_REF] Debrabant | Semi-lagrangian schemes for linear and fully non-linear diffusion equations[END_REF] and [START_REF] Camilli | An approximation scheme for the optimal control of diffusion processes[END_REF] for more details about the discretization scheme we use. As in [START_REF] Heymann | Continuous optimal control approaches to microgrid energy management[END_REF] we solve the microgrid management problem using Bellman's Dynamic Programming Principle (DPP). We compute an approx-

MODEL PRESENTATION

51

imation of the value function using a time and space discretization, and then we use this value function to reconstruct an optimal control. The DPP approach presents numerous advantages. First, no starting point is required to initiate the optimization algorithm.

Second, the algorithm computes a global optimum, as opposed to other methods relying for instance on first order optimality conditions that only compute local optima. Third, we can deal with integer variables such as the on/off status of a device (in our case the diesel generator). Fourth, we use directly the original non-linear model. This simplifies the implementation, and may also give more accurate solutions. Fifth, since we derive the optimal controls from the value function, those controls are in feedback form. Last but not least, if the state dimension is low (in our case, two), it is competitive from a computational perspective. In particular, the computational burden is linear in the number of time steps.

We perform numerical simulations with BocopHJB, a C++ open source numerical solver for stochastic optimal control problems (see [START_REF] Bonnans | Bocophjb 1.0. 1-user guide[END_REF]). We point out that this solver does not solve stochastic problems with scenario trees but instead solves an associated deterministic second order partial differential equation. The data for our problem come from the Huatacondo microgrid. Huatacondo is an isolated village in the Atacama desert (northern Chile). The village relies completely on the microgrid for its energy supply.

This paper is organized as follows: Section 3.2 describes the microgrid and the demand model, and then formulates the stochastic optimal control problem. Section 3.3 presents the numerical method as well as the simulation methodology. We explain the parameters estimation in Section 3.4, and in Section 3.5 we display and comment the simulations results. Finally, the conclusion sums up the main results and presents ongoing research in the continuation of this work.

Model Presentation

System Description

On the supply side, the microgrid includes a photovoltaic power plant, a diesel generator and a Battery Energy Storage System (BESS). The photovoltaic power plant is a non dispatchable unit. Since one can accurately predict the climate in the desert region of the microgrid, we assume that we know the future production of renewable energy. This is why it is deterministic in this work. The diesel generator and the battery play the role of the dispatchable units. The marginal cost of the energy the generator produces is decreasing, i.e. the fuel consumption cost is a strictly concave function of the energy produced by the diesel generator. We derived this production function in [START_REF] Heymann | Continuous optimal control approaches to microgrid energy management[END_REF] from the constructor data sheet. The diesel generator is either on or off. When on, the diesel generator cannot work below a given threshold (due to its physical properties). When switched on, the generator needs an additional amount of energy to warm up, which is modeled as a fixed switching cost. Since any ON switching is followed by an OFF switching and conversely, we account

CHAPTER 3. STOCHASTIC MODEL FOR MICROGRID

for half this switching cost for any switch, ON or OFF. We can store the energy surplus in the BESS when production is greater than demand and supply this energy to the system when demand is greater than production. This storage is not free as some energy is lost in the charge/discharge process. We will not take into account the battery aging in this work. On the demand side, the load comes from the villagers domestic needs. In our model proposal the randomness comes from the demand side. Since the village is small, the load is volatile. We modelize the load dynamics with a Stochastic Differential Equation (SDE).

The grid is isolated, so there cannot be any flows from or to the outer world. We neglect the transmission losses because the village is small. Our objective is to find a strategy that minimizes the operating cost (diesel and switching cost) and produce enough electricity for the village.

Load Model

The microgrid historical load might suggest a random model with several jumps. Nonetheless such type of models requires a large number of parameters: the sizes and probabilities of jumps need to be fitted. As a first step toward the integration of stochastic modeling within our framework we propose a simpler model based on a Brownian motion. Our proposal is similar to an Ornstein-Uhlenbeck process (which is the continuous time equivalent of the AR(1) model) because it is a Brownian dynamics with a mean reversion. The difference is that the mean and volatility parameters are time dependent. We model the load process L(t) with the Stochastic Differential Equation (SDE)

dL(t) = ( Λ(t) + b(Λ(t) -L(t))dt + σ(t, L)dW (t), (3.1)
where Λ(t) is a deterministic load process (in kW), b ≥ 0 is a unitless mean reversion coefficient, σ(t, L) is the volatility (in kW.t -0.5 ), W (t) is a Wiener process and L(0) = L 0 .

The volatility σ has a bounded support in [0, T ] × [0, L max ]. Since Λ is bounded and b ≥ 0, the load L remains bounded (and positive):

L(t) ≤ max(sup t {Λ(t)}, L max ). (3.2)
This allows us to refer to section 3 of [START_REF] Camilli | An approximation scheme for the optimal control of diffusion processes[END_REF] for the mathematical properties of the system.

Setting Y (t) = L(t)e bt and applying Itô's formula we get that L(t) is equal to

Λ(t) + e -bt (L 0 -Λ(0)) + t 0 e b(τ -t) σ(τ, L(τ ))dW (τ ).
So, L(t) has expectation Λ(t) + (L 0 -Λ(0))e -bt and, by Itô isometry, a variance of at most sup(σ 2 )(1e -2bt )/(2b). In Section 3.4 we will discuss the computation of σ and b and provide an empirical justification of the model.

Notations

We denote by t 0 the initial time and by T the time horizon. We denote by Q B the maximum capacity of the battery, while ρ I and ρ O are the efficiency ratios for the charge and discharge processes. We write the cost function associated to the diesel consumption. The final cost function g ensures a minimal value of the final state of charge:

g(C) = 0 if C ≥ C 0 g(C) = M otherwise. (3.5)
where M is a large penalty parameter. Setting C 0 = C(t 0 ) we ensure that the system finishes the day with as much energy in the BESS as what was stored at t 0 .

Stochastic Control Formulation

We now define the value of the microgrid management problem as

V m 0 (t 0 , C 0 , L 0 ) := CHAPTER 3.
m(t) = 1 + (-1) n(t) (2m t 0 -1) 2 (3.9) (C(t 0 ), L(t 0 ), m(t 0 )) = (C 0 , L 0 , m 0 ) (3.10) d(t) = 0 and s(t) ≤ 0 if m(t) = 0, d(t) ∈ I d otherwise (3.11) C(t) ∈ I c (3.12
)

P O ∈ I P O (3.13)
P I ∈ I P I if C(t) < 0.9,

P I ≤ A(C(t) -1) 2 otherwise (3.14)
where

F C (L, d, s, t) = 1 Q B (P I ρ I -P O /ρ O ).
We point out that by many ways this stochastic optimal control problem is similar to the deterministic model presented in [START_REF] Heymann | Continuous optimal control approaches to microgrid energy management[END_REF]. Here the decision variables are the diesel output at any instant d(t), the slack variable s(t) and the value of the counting function n(t). Note that optimizing over the counting functions is equivalent to optimizing over the switching times. Implicitly we impose those decisions to be non anticipative, i.e. progressively measurable with respect to the filtration generated by W (t). Constraints (3.7) and (3.8) are respectively the power balance for the battery and the load dynamics. Relation (3.9) expresses the current mode as a function of the initial mode and the number of switches that occurred since t 0 . If this number is even, m(t) = m 0 and if it is odd, m(t) = 1-m 0 . Constraint (3.10) is the initial condition. Constraint (3.11) corresponds to the modeling of the diesel generator mode (ON = 1 or OF F = 0). If OF F , the diesel generator cannot produce anything and d = 0, else, the physics of the generator imposes d to be in

I d = [d 1 , d 2 ], with d 1 > 0. Last, constraints (3.

Technical Remark

We already noticed that L is bounded over [0, T ]. Thus the number of switches n is bounded on any scenario and the slack variable s is uniformly bounded over the scenari (this is of course true for d since d ∈ {0} ∪ I d ). To our knowledge, there are no general well posedness results for stochastic control with state constraints. Nonetheless, since the controls are bounded and the diffusion is orthogonal to the outer normal of the state constraint we can argue that the viscosity approach developed in [START_REF] Katsoulakis | Viscosity solutions of second order fully nonlinear elliptic equations with state constraints[END_REF] for second order fully nonlinear elliptic equations with state constraints could be extended to our case with finite horizon and switching times.

Numerical Optimization Method

Dynamic Programming

The Dynamic Programming Principle (DPP) states that (see [START_REF] Pham | Continuous-time stochastic control and optimization with financial applications[END_REF])

V m 0 (t 0 , C 0 , L 0 ) = inf d∈Dm 0 ,τ ∈Tt,s E τ t 0 (d, s)dt + min{V m 0 (τ, C(τ ), L(τ )), K + V 1-m 0 (τ, C(τ ), L(τ ))} (3.15)
where the optimization is performed over (7)-( 14) and D 0 = {0}, D 1 = I d , and T t is the set of stopping times in [t 0 , T ]. The time dependency of d and s is implicite in the integrand.

Note that from (3.15) and applying Itô's formula we get that the value function formally satisfies the Hamilton-Jacobi-Bellman equation (see for instance [START_REF] Pham | Continuous-time stochastic control and optimization with financial applications[END_REF])

max -V i t -0.5V i LL σ 2 -V i L ( Λ + b(Λ -L)) + H i , V i -(K + V 1-i )) = 0, (3.16)
where

H 0 = sup s≤0 -{ (0, s) + V 1 C F C (L, 0, s, t)} (3.17) H 1 = sup d∈I d ,s -{ (d, s) + V 0 C F C (L, d, s, t)}. (3.18)
We now explain a weaker version of a trick introduced in [START_REF] Heymann | Continuous optimal control approaches to microgrid energy management[END_REF] for the deterministic case.

We assume s = 0, i.e. there is a good balance between production capacity and load. If the diesel generator is off then by definition d = 0. Otherwise, the dynamics of the system is locally (3.16) for i = 1, so that heuristically, the control should maximize the Hamiltonian H 1 defined at (3.18). Since we maximize a piecewise convexconvexe function, the optimal controls can take a limited number of values that can be explicitly computed.

CHAPTER 3. STOCHASTIC MODEL FOR MICROGRID

• if the diesel is off (m = -1), we simply take d = 0.

• if the diesel is on (m = 1), we test the five cases d is set to the minimum power, d is set to the maximum power, d such that F C = Ċ = 0 (battery unused), d such that P i is maximal (maximal charge),

d such that P 0 is maximal (maximal discharge).

From a computational perspective it is sufficient to test those values instead of discretizing the control space.

Algorithm

We solve the Hamilton-Jacobi-Bellman equation (3.15) with BocopHJB [START_REF] Bonnans | Bocophjb 1.0. 1-user guide[END_REF]. This opensource software solves second order finite horizon Hamilton-Jacobi-Bellman equations with a semi-Lagrangian scheme and allows for the use of switches. The semi-Lagrangian scheme is obtained by discretizing (3.15) first in time and then in space: it consists in the backward resolution of a discretized dynamic programming principle The reader may refer to [START_REF] Debrabant | Semi-lagrangian schemes for linear and fully non-linear diffusion equations[END_REF] and [START_REF] Camilli | An approximation scheme for the optimal control of diffusion processes[END_REF] for the discretization theory. We point out that the semi-Lagrangian scheme does not require to generate scenari (as opposed to other mainstream approaches in stochastic programming), since the Brownian motion is discretized for each time step with deterministic variables (see [START_REF] Bonnans | Bocophjb 1.0. 1-user guide[END_REF]). For this kind of scheme, the computation burden is exponential in the state dimension (curse of dimensionality), but here this dimension is only two. On the other hand, the complexity increases only linearly with the number of time steps.

Parameters Estimation

We display in Table 3.1 the numerical values we have for the model. Most of them are those used in [START_REF] Heymann | Continuous optimal control approaches to microgrid energy management[END_REF] and [START_REF] Palma-Behnke | A microgrid energy management system based on the rolling horizon strategy[END_REF]. The data consist in about ten months (N days = 300) of historic load and renewable production from Huatacondo. The renewable production data look both smooth and very similar days after days due to the climate in Huatacondo, so we use the average for the optimization and the simulation (see Figure 3.5). We denote by h the time step (15 minutes), t k = kh, σ k the volatility and Lk the historical load at time t k .

The data being discrete, Equation (3.8) becomes, for each day i

Li k+1 -Li k = Λ k+1 -Λ k + b(Λ k -Li k )h + σ k i k √ h, (3.19
} d k,i = Li k -Λ k , b = hb and σ k = σ k √ h. Then (3.19) is equivalent to d k+1,i -d k,i (1-b ) = σ k k .
We then use a mean square estimator. If we consider σ k fixed for all k, then b should minimize k,i (d i k+1 -

d i k (1 -b )) 2 /σ 2 k , so that b = { k,i d 2 k,i /σ 2 k -d k,i d k+1,i /σ 2 k }/{ d 2 k,i /σ 2 k }.
On the other hand, if we know b , σ k is the standard deviation of d k+1,id k,i (1b) computed over the same epoch of the day i on the data. So we start with σ k = 1 and iterate the two formulas until numerical convergence to get our estimators. We get b = 0.174. We display σ in Figure 3.1. We display on Figure 3.2 some random samples of the data and some generated scenari. They qualitatively look alike.

Simulation

We compare the stochastic extension with the determinist rolling horizon algorithm proposed in [START_REF] Heymann | Continuous optimal control approaches to microgrid energy management[END_REF] on a three day simulation. The simulation procedure is summarized in Figures The rolling horizon for the deterministic algorithm is set to 24 hours and for each horizon we impose the final state of charge to be at least equal to the initial state of charge at the beginning of the horizon. For every time step, we perform an optimization using an updated load forecast for the next 24 hours. We use as a forecast for the k th step the expectation of the flow of the load process with initial condition L k , where L k is the corresponding historical Load.

For the stochastic simulation, we solve only once the Hamilton-Jacobi-Bellman equation, and then use the value function and the load historical realization to produce a trajectory. We impose the state of charge to be at least equal to what is obtained with the deterministic simulation at the end of the three day period.

We display on Figures 3.6, 3.8, 3.7 and 3.9 the results for the model with real data. On

Conclusion

We have extended the deterministic continuous time model for microgrid management to a stochastic setting and performed a numerical experiment on real data from the Huatacondo microgrid. The total cost of the solution proposed by the stochastic algorithm was lower than the one obtained with a deterministic rolling horizon formulation. Ongoing works on this topic include the study of the long-term aging of the battery as well as a jump model for the load process. We introduce a class of optimal control problems with periodic data. A state variable that we call the age of the system represents the negative impact of the operations on the system qualities over time: other things being equal, older systems have higher operating costs.

Many industrial problems relate to this class. If we envision to perform an optimization over a large number of periods, there is a tradeoff between minimizing repeatedly the one-period criterion in a short sighted way and taking into account the impact of the decision on the aging speed (which modifies the minimal one period criterion). In general, because the aging process is slow, short term optimization strategies-such as one period sliding horizon strategies-either neglect it or use rule-of-thumb penalization terms in the criterion, which leads to suboptimal solutions. On the other hand, for most applications it is unrealistic to envision a brute-force numerical resolution by dynamic programming of the long term problem because of the computation burden. We introduce a two-scale method to reduce this computation burden. The method relies on Lagrangian duality and some monotony properties. We expose the theoretical foundations of the method and discuss some practical aspects: approximation errors, asymptotic estimation, computation burden, possible extensions, etc. Since our initial motivation was the difficulty to take long term battery aging in Energy Management Systems into account, we implement the method on a toy long term microgrid energy management problem.

Introduction

The aging of physical systems is almost never taken into account in decision making. This can be a cause of sub-optimality. For instance, for many controlled industrial systems, a decision is taken every day. The decision should minimize a tangible criterion, such as the operating cost and is subject to some operating and physical constraints. As time goes on, the system gets older and its physical qualities decrease. On the one hand, this slow aging process depends on how the system is operated. On the other hand the aging of the system is responsible for a loss in efficiency that increases the daily operating cost. Therefore, in an ideal world, the operator should take into account the impact of the daily decision on the long term aging of the system. Nonetheless, this is often technically challenging:

4.1. INTRODUCTION 65
because of the time scales involved, the long term optimization problem requires a lot of time and memory to be solved (curse of dimensionality with respect to the state variables).

In this work the system aging process is modeled with a one dimensional age variable a with values in a segment. The physical qualities of the system decrease as a increases. We point out that the choice of an increasing variable to measure the aging process is arbitrary, and we could have defined instead a decreasing health variable. Of course in this case the physical qualities of the system would have been increasing in the health process.

We introduce a class of optimal control problems with periodic data. If we envision to perform an optimization over a large number of periods, there is a trade-off between minimizing repeatedly the one-period criterion in a short sighted way and taking into account the impact of the decision on the aging speed (which will later on in turn have an impact on the minimal one-period criterion). Microgrid energy management relates to the framework proposed in this paper when considering the aging of the battery. We discuss some existing approaches from this literature in §4.6.2. As far as we know, it appears that when taken into account, aging is constrained or penalized but not directly subject to a long term optimization. An important characteristic of our problem is the existence of two time scales. Some other works on multi time scales problem consider averaging techniques (see [START_REF] Chaplais | Averaging and deterministic optimal control[END_REF]).

A first essential observation is that if we knew an optimal aging profile over the whole time horizon, then the long term problem could be decomposed into a sum of micro problems with smaller time horizon, say one period. We could then use myopic approaches to solve the resulting one period (or micro) problems. The reverse is also true: the long term (or macro) problem can be reformulated by means of the micro problems. So we could precompute the solutions of the micro problems off-line to solve the long term aging problem afterward with a macro dynamic programming optimization. This is a first step to reduce the problem numerical complexity. It will be detailed in §4.3.

Another essential observation is that aging is a slow process, so we could neglect the age variations within a period to solve simplified micro problems without truly impacting the performances. Indeed, this would decrease by one the number of state variables. Yet it is still necessary to know the age at the end of the period to solve the long term problem.

Moreover, since we want to take the age into account in the decision, we should be able to control the total aging over the period. So we look for a method to control the total aging over a period without requiring the age to be a state variable in the micro problem numerical resolution. Our approach consists in penalizing the aging over the period in the criterion of the micro problems. Then we map the penalization coefficients with the resulting agings. By doing so, we do not need to keep track of the aging within the micro problems (see §4.4).

We then optimize for each period the penalization coefficient in the reformulation of the long term problem. Observe that even if the penalization parameter could be interpreted as

CHAPTER 4. ADAPTIVE WEIGHTS ALGORITHM

a Lagrangian multiplier, we will be performing a minimization over this coefficient, which can be confusing. An alternative understanding is to see this penalization parameters as a change of variable: instead of optimizing over the one-period age increments, we optimize over the corresponding penalization coefficients. Figure 4.1 illustrates this idea, with α being the optimization parameter.

To sum up, we propose a decomposition/parametrization method to solve a long term optimal control problem incorporating an age variable. We use the fact that the age (as a state variable) is slow to neglect its variations within a single period to limit the computation burden. We solve a collection of one period, penalized, optimal control problems and associate the resulting total agings with the corresponding coefficients, which allow us to perform a dynamic optimization over the coefficients to solve the long term problem.

Observe that we do not fix only one coefficient for the whole problem as in penalization approaches: we control the penalization coefficients of every single period. Then the aging-conscious on-line one-period decision can be computed for an optimized time varying penalization parameter that incorporates the long term aging.

The long term and short term optimal control problems are presented in the next subsection, followed by the technical assumptions we use in this work. We present the bilevel dynamic programming in §4.3 and the adaptive weights approach in §4.4. We discuss the theoretical results and some possible refinements and variations in §4.5. The last section is dedicated to an application of this approach to the microgrid energy management problem. Readers only interested in applications might want to start with this last section.

In the proofs we will use LHS and RHS as shorthands for left-hand side and right-hand side.

Setting

Problem Formulation

We consider a system with two state variables: the age a and the fast state c. The fast state should be interpreted as a form of wealth (available cash, energy, inventory). This is why we will refer to the fast state as the charge, in reference to this idea and to the toy microgrid model example proposed in the last section. The age a and the charge c follow a T -periodic dynamics controlled by a time dependent parameter u:

ȧ(t) = F a (a(t), c(t), u(t), t) ċ(t) = F c (a(t), c(t), u(t), t), (4.1)
or equivalently if we set x = (a, c) and F = (F a , F c ):

ẋ(t) = F (x(t), u(t), t). (4.2) 4.2. SETTING 67
Think of T > 0 as the length of a day for instance. The whole horizon T tot is a multiple of T , i.e. T tot = N T with N being a large integer (think of T tot as the length of five years for example). The control u is restricted to be in

U = {u s.t. ∀t ∈ [0, T tot ], u(t) ∈ Ū },
and the charge c and the age a should belong to respectively C and A, where Ū and C are compact subsets of R n and R, and there exists (a -, a + ) such that A = [a -, a + ] and

a -≤ a(0) ≤ a + .
The age a of the system is non-decreasing in time, i.e. F a ≥ 0, and for all (u, t, c) ∈ Ū × [0, T ] × C, F a (a + , c, u, t) = 0, which ensures that for all time t, a(t) ∈ [a -, a + ]. One can interpret a = a + as the aging component of the system being definitely dead. Then F a (a + , c, u, t) = 0 means that once this component dead, it cannot get older anymore.

The behaviors of the system change as it get older. In fact, the older the system, the more effort should be needed to complete a given task. The aging process should decrease the efficiency of the system. In addition, as c is a form of wealth, the cost-to-go functions of our minimization problems should be decreasing in c. Those notions are expressed in the monotonicity assumption (see. §4.2.2).

While the relevant time scale for the charge c is the period T , the dynamics of the age a is so slow that one need to wait many periods to observe a non-microscopic change in a. Our objective is to minimize the sum of an integral criterion and a non-decreasing final cost φ(a Ttot ) while verifying some constraints. Like the dynamics, the (bounded) running cost (u, t) is T -periodic. We end up with the following optimal control formulation:

P 1 (a 0 , c 0 , t 0 )                        V 1 (a 0 , c 0 , t 0 ) = inf u∈U Ttot t 0 (u(t), t)dt + φ(a Ttot ) (a(t 0 ), c(t 0 )) = (a 0 , c 0 ) a(T tot ) ≤ a max ∀t ∈ [t 0 , T tot ], ϕ(c(t), u(t), t) ∈ A ( ȧ(t), ċ(t)) = (F a (a(t), c(t), u(t), t), F c (a(t), c(t), u(t), t)), (4.3)
where A is a closed set, ϕ a continuous T periodic-function, and a max a final constraint.

Problem P 1 is parametrized by the initial point (a 0 , c 0 , t 0 ). The value function V 1 associates any set of initial time and state variables with the corresponding minimal cost-to-go function. Under Lipschitz conditions on F a and F c , the ordinary differential equation has a unique solution.The integrand satisfies the following properties:

• is bounded

• for all t ∈ [0, T ], u → (u, t) is continuous • for all u ∈ Ū , t → (u, t) is measurable.
We use the standard flow notation i.e. for τ > 0, X u,t+τ x,t

is the value of the solution of the first order ordinary differential equation of the dynamics at time t + τ when the initial point is x = (a, c) at time t and the control is u. We will use the notation a u,t+τ x,t (resp. c u,t+τ x,t ) to refer to the flow of the age (resp. the charge). When the context will be clear, we will sometimes simply write X(t).

The dynamic programming principle applies and we can write the value function of problem P 1 as the solution of:

V 1 (a 0 , c 0 , t 0 ) = inf u∈U t 0 +T t 0 (u(t), t)dt + V 1 (X u,t 0 +T x 0 ,t 0 , t 0 + T ), (4.4)
where the infimum is taken over controls such that ϕ(c u,t x 0 ,0 , u(t), t) ∈ A for any t ∈ [t 0 , t 0 + T ]. Observe that problem P 1 is not always feasible, the optimization is by construction performed over the feasible V 1 (X u,t 0 +T x 0 ,t 0 , t 0 + T ). Now set t = t k = kT for k ∈ N, by T -periodicity of the data, we get the formulation we will use throughout this article

V 1 (a 0 , c 0 , t k ) = inf u∈Ua 0 ,c 0 T 0 (u(t), t)dt + V 1 (X u,T x 0 ,0 , t k ), (4.5)
where

U a 0 ,c 0 is the set of controls u ∈ U T = {u ∈ L ∞ (0, T ) s.t. ∀t ∈ [0, T ], u(t) ∈ Ū } such that ϕ(c u,t x 0 ,0 , u(t), t) ∈ A for any t ∈ [0, T ].
We propose a bi-level approach to solve problem P 1 . First we introduce a collection of micro problems

P µ 1 (a 0 , δa, c 0 , c F )                              V µ 1 (a 0 , δa, c 0 , c F ) = inf u∈U T T 0 (u(t), t)dt (a(0), c(0)) = (a 0 , c 0 ) a(T ) ≤ a 0 + δa c(T ) ≥ c F ∀t ∈ [0, T ], ϕ(c(t), u(t), t) ∈ A. ( ȧ(t), ċ(t)) = (F a (a(t), c(t), u(t), t), F c (a(t), c(t), u(t), t)). (4.6)
The superscript µ stands for micro. The micro problem P µ 1 is in many ways similar to P 1 : the dynamics, the mixed constraints and the integrand of the criterion are the same. The difference is that the time horizon is only one period. Moreover, the final state condition on the age a and the final cost φ(a Ttot ) are replaced by two final state conditions on the age a and the state c. The problem is parametrized by δa, which represents the maximal amount of aging for the period. If φ = 0 then for both P 1 and P µ 1 the goal is to minimize the integral of the running cost over a time horizon without increasing the age of the system a by more than a given quantity.

BILEVEL DYNAMIC PROGRAMMING

Assumptions

We make the following assumptions.

Assumption 1 (Slow aging).

There exists a constant L > 0 such that

• F c is L-Lipschitz and uniformly bounded by L,
• F a is L/N -Lipschitz and uniformly bounded by L/N . Assumption 1 expresses that the aging process is slow. The dependence of the F a Lipschitz constant and bound in N (which is the number of periods in the macro problem P 1 ) is needed to perform an asymptotic estimation. (see §4.5.1). Assumption 1 is used in the proof of Lemma 4.15.

Assumption 2 (Monotonicity). The value functions V µ 1 and V 1 are non decreasing in a 0 and non increasing in c 0 .

Assumption 2 corresponds to the fact that youth and wealth are always preferable for the systems envisionned.

Assumption 3 (Regularity of the aging process). For any > 0, ∆ > 0, there exists

1 > 0 such that if x 0 = (a 0 , c 0 ) ∈ A × C, u ∈ U x 0 and ∆ ≤ T 0 F a (X(t), u(t), t)dt ≤ ∆ + 1 , then there exists u ∈ U x 0 such that T 0 F a (X(t), u (t), t)dt = ∆ and | T 0 [ (u(t), t) -(u (t), t)]dt| ≤ . (4.7)
We can interpret ∆ as a maximum aging level. Assumption 3 ensures that if we set a maximum aging level and a precision level, then we can modify any "almost admissible" control for the maximum aging level into an admissible one, and the change in integral cost will not be more than the precision level. This Assumption is used in the proof of Lemma 4.1.

Bilevel Dynamic Programming

Mathematical Justification

We start with the following (intuitive) result.

Lemma 4.1. For all (k, a 0 , c 0 ) ∈ N × A × C, V 1 (a 0 , c 0 , t k ) = inf δa∈R + ,c F ∈C V µ 1 (a 0 , δa, c 0 , c F ) + V 1 (a 0 + δa, c F , t k+1 ). (4.8)
Proof. LHS ≥ RHS: Set x 0 = (c 0 , a 0 ). First we establish that LHS ≥ RHS. Take a control u ∈ U x 0 and set δa = a u,T x 0 ,0a 0 and c F = c u,T x 0 ,0 . By construction of δa and c F , u is admissible for P µ 1 (a 0 , δa, c 0 , c F ) so by definition of

V µ 1 , T 0 (u(t), t)dt ≥ V µ 1 (c 0 , c F , a 0 , δa). Moreover, trivially V 1 (X u,T x 0 ,0 , t k+1 ) = V 1 (a 0 + δa, c F , t k+1 ) therefore T 0 (u(t), t)dt + V 1 (X u,T x 0 ,0 , t k+1 ) ≥ V µ 1 (c 0 , c F , a 0 , δa) + V 1 (a 0 + δa, c F , t k+1 ) ≥ RHS.(4.9)
Since this is true for any u ∈ U x 0 , we can apply the dynamic programing principle (4.5) to get LHS ≥ RHS. We point out that here we did not use the existence of minimizers.

LHS ≤ RHS Take δa and c F an -optimal decision for the RHS and u ∈ U x 0 anoptimal control for P µ 1 (a 0 , δa, c 0 , c F ). By definition of P µ 1 (a 0 , δa, c 0 , c F ) and admissibility of u, c u,T

x 0 ,0 ≥ c F and a u,T x 0 ,0 ≤ a 0 + δa. By -optimality,

RHS + 2 ≥ T 0 (u(t), t)dt + V 1 (a 0 + δa, c F , t k+1 ) (4.10) By monotonicity of V 1 , V 1 (a + δa, c F , t k+1 ) ≥ V 1 (a + δa, c u,T x 0 ,0 , t k+1 ) ≥ V 1 (a u,T x 0 ,0 , c u,T x 0 ,0 , t k+1 , ). (4.11)
Therefore,

RHS + 2 ≥ T 0 (u(t), t)dt + V 1 (X u,T x 0 ,0 , t k+1 ) ≥ LHS, (4.12)
where we used the dynamic programming principle (4.5) and the fact that u ∈ U x 0 for the last inequality. We can conclude that RHS = LHS.

Complexity Analysis

We proceed with a complexity analysis of the previous results. Assume we characterize the discretization of the space and time grid with the integer parameters N a , N c , N u and N t , which are the discretization levels of a, c, u and one unit of time. On the one hand, if we solve problem P 1 directly by dynamic programming (for a fixed initial state), the computation burden is proportional to N a N c N u N t T N . On the other hand if we use Lemma 4.1, we first solve P µ 1 offline for each possible parameters. Problem P µ 1 computation burden for one numerical resolution is proportional to N a N c N u N t T , but we need to solve it for each final parameters (c F , a F = a 0 + δa), i.e. N a N c times (indeed, observe that one resolution solves the problem for all possible initial states). Then we have to do the macro resolution ( O(N a N c N )). So the total cost with the micro/macro formulation is

O(N 2 a N 2 c N u N t T ) + O(N a N c N ), which can be competitive against a brute-force dynamic programming if N is large compared to N a N c .
Consider a specific case where the charge c has to be the same at the beginning of each 4.3. BILEVEL DYNAMIC PROGRAMMING 71 period. In this case we get:

• Direct dynamic programming resolution: O(N a N c N u N t T N ) • One micro problem resolution: O(N a N c N u N t T ) • Number of parameters for the micro problem: O(N a ) • Resolution of the macro problem: O(N 2 a N )
• Total computation burden for the bilevel approach:

O(N 2 a N ) + O(N 2 a N c N u N t T )
Then this approach becomes competitive compared to the direct DP approach if N is larger than N a . Note that when solving the micro problem, the complexity is proportional to N a , but the grid does not need to contain the whole A segment for a given set of final ages.

The pseudo code of such an algorithm is straightforward.

• Compute the value function of P µ 1 for all δa.

• Compute the value function of the macro problem using the previous results.

Now assume we do an online implementation (with periodic c F = ĉF ): at the beginning of each period, we compute an optimal control for the period, with a final constraint With a bilevel approach, we can keep in memory either the whole value function of the macro problem (c), the value functions of the micro problems at t = 0 for different maximal aging (d), or the mapping of the optimal δa for each (a, t) (e). The first solution is similar to (a) and is not realistic. The second solution requires a memory space of O(N 2 a ), which is not proportional to N . Then we need to get the optimal aging by dynamic programming on the macro problem O(N 2 a N ) and compute an optimal control O(N a N c N u N t T ). The last possibility requires a N a × N table. The online computation of the control will then require two states, which represents a computation burden proportional to N a N c N u N t T .

Note that this last possibility is equivalent to (b) for the online phase.

The complexity analysis is summarized in Tables 4.1 and 4.2.

We point out that we have not used much of the problem specificity, as only Assumptions 2 is needed in the proof of Lemma 4.1. Moreover, such online computation burden may be too big for some applications. This is what motivates the next section.

CHAPTER 4. ADAPTIVE WEIGHTS ALGORITHM

Adaptative Weights

Preliminary Results

Note that we could replace the final constraint and the final cost in P 1 by a penalization on the age variation. We would get the criterion

Ttot t 0 (u(t), t)dt + α[a(T tot ) -a max ] + φ(a Ttot ). (4.13)
where α ∈ R + is a penalization coefficient. Since a max and â0 are constants over which we are not optimizing, we get an equivalent optimization problem by using instead the

criterion Ttot t 0 (u(t), t)dt + α Ttot t 0 F a (X(t), u(t), t)dt + φ(a Ttot ). (4.14)
We then get the penalized problem (with free final age)

P 2 (a 0 , c 0 , α, t 0 )                  V 2 (a 0 , c 0 , α, t 0 ) = inf u∈U Ttot t 0 [ (u(t), t) + αF a (X(t), u(t), t)]dt + φ(a Ttot ) Ẋ(t) = F (X(t), u(t), t) (a(t 0 ), c(t 0 )) = (a 0 , c 0 ) ϕ(c(t), u(t), t) ∈ A (4.15)
Let us introduce the corresponding micro-problem:

P µ 2 (a 0 , c 0 , c F , α)                        V µ 2 (a 0 , c 0 , c F , α) = inf u∈U T 0 [ (u(t), t) + αF a (X(t), u(t), t)]dt Ẋ(t) = F (X(t), u(t), t) (a(0), c(0)) = (a 0 , c 0 ) ϕ(c(t), u(t), t) ∈ A c(T ) ≥ c F . (4.16)
As the notations implies, P µ 2 is to P 2 what P µ 1 is to P 1 : a one day version. Just note that the final constraint in P 1 is considered as fixed and is a parameter in P µ 1 whereas the penalization coefficient is a parameter for both P µ 2 and P 2 . In addition, note that we cannot write a dynamic programming principle directly with P µ 2 and P 2 as we did for P µ 1 and P 1 in Lemma 4.1.

If problem P 1 is strictly feasible, then for α big enough the final constraint is satisfied by the solutions of P 2 (a 0 , c 0 , α, t 0 ) (see the proof of Lemma 4.6). A standard way to deal with aging is to replace P 1 (a 0 , c 0 , t 0 ) by an approximation of P 2 (a 0 , c 0 , c F , α) where the

ADAPTATIVE WEIGHTS

73

age a is fixed:

P2 (a 0 , c 0 , α, t 0 )                  V 2 (a 0 , c 0 , α, t 0 ) = inf u∈U Ttot t 0 [ (u(t), t) + αF a (a 0 , c(t), u(t), t)]dt + φ(a Ttot ) ċ(t) = F c (a 0 , c(t), u(t), t) (a(t 0 ), c(t 0 )) = (a 0 , c 0 ) ϕ(c(t), u(t), t) ∈ A (4.17)
To set α, practitioners would often compute a collection of solutions of P2 for different values of α, and then take the best admissible solution in the sense of P 1 . Nonetheless such an approach neglects the impact of the aging on the efficiency and more generally the fact that the dynamics are coupled.

In addition, there may be a duality gap. In this case any (theoretical) solution of P 2 admissible for P 1 is suboptimal for P 1 . Ekeland and Aubin propose an estimate of this sub-optimality in a finite dimensional setting [START_REF] Aubin | Estimates of the duality gap in nonconvex optimization[END_REF].

The following lemma is a relation between the value functions of the two micro problems

P µ 2 and P µ 1 . Lemma 4.2. For any (a 0 , c 0 , c F , α) ∈ A × C 2 × R + , V µ 2 (a 0 , c 0 , c F , α) = inf δa∈R + V µ 1 (a 0 , δa, c 0 , c F ) + αδa (4.18)
Proof. LHS ≥ RHS: Take > 0, u ∈ U x 0 an -optimal solution of the LHS. Set δa = a u,T x 0 ,0a 0 . By -optimality of u

LHS + ≥ T 0 (u(t), t)dt + αδa. (4.19)
In addition note that u is admissible for

P µ 1 (a 0 , δa, c 0 , c F ) therefore by definition of V µ 1 , T 0 (u(t), t)dt ≥ V µ 1 (a 0 , δa, c 0 , c F ). Then LHS + ≥ V µ 1 (a 0 , δa, c 0 , c F ) + αδa ≥ inf δa∈R + V µ 1 (a 0 , δa, c 0 , c F ) + αδa = RHS. (4.20)
Therefore LHS ≥ RHS.

LHS ≤ RHS: Take > 0, δa ∈ R + an -optimal solution of the RHS and u ∈ U x 0 an -optimal solution of problem P µ 1 (a 0 , δa, c 0 , c F ). By -optimality

RHS + ≥ V µ 1 (a 0 , δa, c 0 , c F ) + αδa and V µ 1 (a 0 , δa, c 0 , c F ) + ≥ T 0 (u(t), t)dt, (4.21) CHAPTER 4. ADAPTIVE WEIGHTS ALGORITHM so RHS ≥ T 0 (u(t), t)dt + αδa -2 . (4.22) Moreover, since u is P µ 1 (a 0 , δa, c 0 , c F )-admissible, δa ≥ T 0 F a (X(t), u(t), t)dt, so RHS ≥ T 0 [ (u(t), t) + αF a (X(t), u(t), t)]dt -2 ≥ LHS -2 . (4.23)
Therefore LHS ≤ RHS and the proof is done.

We point out that this result does not depend on φ and a max which are macro problem specific parameters.

Corollary 4.3. For any (a 0 , c 0 , c F , δa, α) ∈ A × C 2 × R 2 + , V µ 1 (a 0 , δa, c 0 , c F ) ≥ V µ 2 (a 0 , c 0 , c F , α) -αδa. (4.24)

Nice Case: No Duality Jumps

To proceed we need some additional notations. First for any x 0 ∈ A × C, and any control

u ∈ U x 0 , we define ∆a(u) = T 0 F a (X(t), u(t), t))dt and L(u) = T 0 (u(t), t)dt. (4.25)
Note that for readability the initial conditions are kept implicit. For any (a 0 , c 0 , c F , α)

∈ A × C 2 × R + , let Γ(a 0 , c 0 , c F , α) =    δa = lim n ∆a(u n ); u n minimizing sequence of P µ 2 (a 0 , c 0 , c F , α)    (4.26)
Roughly speaking, given some (a 0 , c 0 , c F ) ∈ A × C 2 , α → Γ(a 0 , c 0 , c F , α) associates the penalization coefficients with the set of optimal aging levels for P µ 2 . Lemma 4.4 is a key result for what follows.

Lemma 4.4. Let (a 0 , c 0 , c F , α, ∆a) ∈ A × C 2 × R 2 + such that ∆a ∈ Γ(a 0 , c 0 , c F , α). Then V µ 1 (a 0 , ∆a, c 0 , c F ) = V µ 2 (a 0 , c 0 , c F , α) -α∆a. (4.27)
Proof. We deduce LHS ≥ RHS from Corollary 4.3, so we only need to show that LHS ≤ RHS. Let > 0. By Assumption 3, there exists 1 ≥ 0 such that if u 2 ∈ U x 0 and ∆a ≤ ∆a(u 2 ) ≤ ∆a + 1 , then there exists u ∈ U x 0 such that

∆a(u ) = ∆a and |L(u 2 ) -L(u )| ≤ . (4.28)
By hypothesis, ∆a ∈ Γ(a 0 , c 0 , c F , α) so by definition of Γ there exists u 2 -optimal for

P µ 2 (a 0 , c 0 , c F , α) that satisfies |∆a(u 2 ) -∆a| ≤ min( 1 , α ). If ∆a(u 2 ) ≤ ∆a, then V µ 2 (a 0 , c 0 , c F , α) -α∆a ≥ V µ 2 (a 0 , c 0 , c F , α) -α∆a(u 2 ) -≥ (4.29) -2 + L(u 2 ) ≥ -2 + V µ 1 (c 0 , c F , a 0 , ∆a). (4.30)
We used α|∆a(u 2 ) -∆a| ≤ for the first inequality, the -optimality of u 2 for the second inequality, and the admissibility of u 2 for P µ 1 (c 0 , c F , a 0 , ∆a) in the third. Else we have the existence of a control u satisfying (4.28). Then by -optimality of u 2 for P µ 2 , (4.28) and ∆a(u 2 ) > ∆a, and the fact that u is admissible for P µ 1 and ∆a(u ) = ∆a:

V µ 2 (a 0 , c 0 , c F , α) ≥ -+ L(u 2 ) + α∆a(u 2 ) ≥ (4.31) -2 + L(u ) + α∆(u ) ≥ (4.32) -2 + V µ 1 (c 0 , c F , a 0 , ∆a) + α∆a. (4.33)
Then we can conclude.

From Lemma 4.4 it is trivial that Corollary 4.5. Let (a 0 , c 0 , c F , α, δa, u) ∈ A × C 2 × R 2 + × U T and > 0 such that u is an -optimal solution of P µ 1 (a 0 , δa, c 0 , c F ) and ∆a(u) ∈ Γ(a 0 , c 0 , c F , α) then

V µ 1 (a 0 , ∆a(u), c 0 , c F ) = V µ 2 (a 0 , c 0 , c F , α) -α∆a(u) (4.34)
Now we have the tools to prove one of our main results.

Theorem 4.6. Let (a 0 , c 0 , α n , u) ∈ A × C × R n + × U and > 0 such that u is an - optimal solution for P 1 (a 0 , c 0 , 0) and (a k+1 -a k ) ∈ Γ(a k , c k , c k+1 , α n ), where a k = a u,t k x 0 ,0 and c k = c u,t k x 0 ,0 . Then for all k = 0 . . . N -1 |V 1 (a k , c k , t k ) -inf (α,c F ,δa) {V µ 2 (a 0 , c 0 , c F , α) -αδa + V 1 (a k + δa, c F , t k+1 )}| ≤ , (4.35)
where the optimization is performed over the (α, δa, c

F ) such that α ∈ R + , c F ∈ C and δa ∈ Γ(a k , c k , c F , α).
Proof. Without loss of generality, we deal with the case k = 0. First note that the restriction u T of u to [0, T ] is an -optimal solution for P µ 1 (a 0 , a 1a 0 , c 0 , c 1 ). By -optimality, admissibility of u T for P µ 1 (a 0 , a 1a 0 , c 0 , c 1 ), Corollary 4.5 and the 76

CHAPTER 4. ADAPTIVE WEIGHTS ALGORITHM fact that a 1 -a 0 ∈ Γ(a 0 , c 0 , c 1 , α 0 ), V 1 (a 0 , c 0 , 0) + ≥ L(u T ) + V 1 (a 1 , c 1 , T ) ≥ V µ 1 (a 0 , a 1 -a 0 , c 0 , c 1 ) + V 1 (a 1 , c 1 , T ) (4.36) ≥ V µ 2 (a 0 , c 0 , c 1 , α 0 ) -α 0 (a 1 -a 0 ) + V 1 (a 0 + a 1 -a 0 , c 1 , T ) (4.37) ≥ inf α,δa,c F V µ 2 (a 0 , c 0 , c F , α) -αδa + V 1 (a 0 + δa, c F , T ) (4.38)
Therefore RHS ≤ LHS + .

For any (α, δa, c

F ) ∈ R + × R + × C such that δa ∈ Γ(a 0 , c 0 , c F , α),
V µ 2 (a 0 , c 0 , c F , α) -αδa + V 1 (a 0 + δa, c F , T ) = (4.39) V µ 1 (a 0 , δa, c 0 , c F ) + V 1 (a 0 + δa, c F , T ) ≥ V 1 (a 0 , c 0 , 0). (4.40)
Therefore RHS ≥ LHS and the conclusion follows.

We point out that the result is still true if we want to fix the c k as operational constraints. Under the hypothesis of the previous theorem, assume that Γ is a singleton, then V 1 can be computed by dynamic programming over α. We will get a similar result in the next section as a consequence of Theorem 4.13. Note that since in P µ 2 there is no final constraint on the age a we could approximate this problem by fixing the age in the dynamics. With Assumption 1 we should be able to get an error estimate. Last but not least, beware that the optimal α in Theorem 4.6 is not the α that would relate by duality two macro problems P 1 and P 2 .

Some comments on Γ

We say that P µ 1 (a 0 , δa, c 0 , c F ) is strictly feasible if there exists u ∈ U x 0 such that ∆a(u) < δa. We start with the following classical result: Lemma 4.7. If problem P µ 1 (a 0 , δa, c 0 , c F ) is strictly feasible, then there is an α 0 such that for α bigger than α 0 , ∀∆a ∈ Γ(a 0 , c 0 , c F , α), ∆a ≤ δa.

(4.41)

Proof. Since P µ 1 (a 0 , δa, c 0 , c F ) is strictly feasible, there exists u ∈ U x 0 such that ∆a(u) < δa. Assume that there exists α n an increasing sequence such that α n → +∞ and ∀n ∈ N, ∃∆a n ∈ Γ(a 0 , c 0 , c F , α n ), ∆a n > δa.

(4.42)

Then

n(∆a n -∆a(u)) ≥ n(δa -δa(u)) (4.43)
Then for n big enough, since is bounded, we would have L(u)+n∆a(u) < V µ 2 (a 0 , c 0 , c F , n), which is absurd.

The result of the next lemma is clear to the intuition: Γ should be decreasing in α.

Lemma 4.8. Let (a 0 , c 0 , c F ) ∈ A × C 2 , then for any 0 ≤ α 1 < α 2 , (δ 1 , δ 2 ) ∈ Γ(a 0 , c 0 , c F , α 1 ) × Γ(a 0 , c 0 , c F , α 2 ) ⇒ δ 1 ≥ δ 2 (4.44)
Proof. To simplify, we omit (a 0 , c 0 , c F ) because they do not intervene in the proof. Assume that for some non-negative α 1 < α 2 , there exist some (δ 1 , δ 2 ) such that δ 1 < δ 2 . Then by corollary 4.3

V µ 2 (α 2 ) ≤ V µ 1 (δ 1 ) + α 2 δ 1 . (4.45)
This implies with Lemma 4.4 that

α 2 (δ 2 -δ 1 ) ≤ V µ 1 (δ 1 ) -V µ 1 (δ 2 ) (4.46) Then since α 1 < α 2 and δ 2 -δ 1 > 0 α 1 (δ 2 -δ 1 ) < V µ 1 (δ 1 ) -V µ 1 (δ 2 ) (4.47)
which in turn implies that

V µ 1 (δ 2 ) + α 1 δ 2 < V µ 1 (δ 1 ) + α 1 δ 1 = V µ 2 (α 1 ), (4.48)
which is not coherent with the optimality of V µ 2 (α 1 ). We conclude that δ 1 ≥ δ 2 .

Since the data are bounded, Γ is included in a compact set. Since P µ 2 has a value, and u → ∆(u) is valued in a compact set, Γ is not empty. We display in Figure 4.1 a sketch of Γ as a function of α (the other variables being fixed). By Lemma 4.8 Γ is non-increasing. There is no reason a priori why it could not be locally constant. Indeed, even the solution of

P µ
2 could be locally constant with respect to α. Observe that Γ not necessarily a singleton: we can have some jumps. In addition it is not necessarily convex valued.

Lemma 4.9. Let (a 0 , c 0 , c F , α, ∆a 1 , ∆a 2 ) ∈ A × C 2 × R 2 + such that ∆a i ∈ Γ(a 0 , c 0 , c F , α) for i = 1, 2 then V µ 1 (a 0 , ∆a 1 , c 0 , c F ) -V µ 1 (a 0 , ∆a 2 , c 0 , c F ) = α(∆a 2 -∆a 1 ) (4.49)
Proof. This is a direct consequence of Lemma 4.4. It can be either continuous and strictly decreasing or constant, or it may "jump" for a given value of α. If there is a jump at α = α 0 then we cannot a priori say that Γ(α 0 ) is a singleton. In addition, it may happen that Γ 'misses' some values at α 0 .

Generic Case

In general we do not have any guarantee of the existence of the α's as in Theorem 4.4. In relation with problem P µ 2 , we introduce for any

(x 0 , c F , α) ∈ (A × C) × C × R + ∆ -(x 0 , c F , α) = inf u∈S(x 0 ,c F ,α) lim inf n→+∞ ∆a(u n ), (4.50)
and

∆ + (x 0 , c F , α) = sup u∈S(x 0 ,c F ,α) lim sup n→+∞ ∆a(u n ), (4.51)
where

S(x 0 , c F , α) = {u ∈ (U T ) N ; (u n ) n∈N minimizing sequence of P µ 2 (x 0 , c F , α)}. (4.52)
In addition, we denote by Γ the set

Γ(x 0 , c F , α) = {∆ -(x 0 , c F , α), ∆ + (x 0 , c F , α)} (4.53)
which is either a 2-uplet if there is a jump, and a singleton otherwise. The set Γ corresponds to the minimal and maximal optimal age increments for a given α. Last, we denote by γ

γ = sup (x 0 ,c F ,α)∈(A×C)×C×R + { lim α -<α ∆ + (x 0 , c F , α -) -lim α + >α ∆ -(x 0 , c F , α + )}, (4.54)
which corresponds to the size of the biggest possible duality jump. By monotonicity of Γ with respect to α, γ is non negative, and by Assumption 1, γ is finite. We denote by

P 3 (x k , t k ) for k = 0 . . . N -1 the problem V 3 (x k , t k ) = inf (x i ,α i ) N -1 i=k {V µ 2 (x i , c i+1 , α i ) -α i (a i+1 -a i )} + φ(a N ), (4.55)
where the optimization is performed over the

(x i , α i ) i=k+1,...,N ∈ (A × C × R + ) N -k such that for any i = k . . . N -1, (a i+1 -a i ) ∈ Γ(x i , c i+1 , α i ) (4.56) and φ(a) = φ(a) if a < a max , +∞ else. Lemma 4.10. Let (a 0 , c 0 , c F , α, δa) ∈ A × C 2 × R 2 + , such that δa ∈ Γ(a 0 , c 0 , c F , α), then V µ 1 (a 0 , c 0 , c F , δa) = V µ 2 (a 0 , c 0 , c F , α) -αδa (4.57)
Proof. We just observe that Γ(x 0 , c F , α) ∈ Γ(x 0 , c F , α) and apply Lemma 4.4.

Lemma 4.11. Let (x, k) ∈ A × C × [0 . . . N -1], then V 3 (x, t k ) ≥ V 1 (x, t k ).
Proof. By Lemma 4.1, we have

V 1 (x, t k ) = inf x i N -1 i=k V µ 1 (x i , c i+1 , a i+1 -a i ) + φ(a N ). (4.58)
and by Lemma 4.10 and the definition of V 3 ,

V 3 (x, t k ) = inf x i N -1 i=k V µ 1 (x i , c i+1 , a i+1 -a i ) + φ(a N ), (4.59)
where the optimization is performed over the x i such that there exist (α i ) i=k+1,...,N to satisfy (4.56). QED.

Remember the definition of γ in (4.54).

Lemma 4.12. For any (x 0 , c F , u) ∈ (A×C)×C ×U T such that u is admissible for problem

P µ 1 (a 0 , ∆a(u), c 0 , c F ), there exists α such that dist(∆a(u), Γ(x 0 , c F , α)) ≤ γ. (4.60)
Proof. We know that for α ∈ R + big enough, δ ∈ Γ(x 0 , c F , α) implies δ ≤ ∆a(u). Take α 0 the infimum of those α. Then if there exists δ ∈ Γ(x 0 , c F , α 0 ) such that δ = ∆a(u) we just take α = α 0 and we are done. Else by definition of α 0 , for all α -< α, ∆ + (x 0 , c F , α -) > ∆a(u) and for all α + > α, ∆ -(x 0 , c F , α + ) ≤ ∆a(u). This rewrites, for all δ ∈ Γ(x 0 , c F , α)

∆ -(x 0 , c F , α + ) -δ ≤ ∆a(u) -δ ≤ ∆ + (x 0 , c F , α -) -δ (4.61)
Taking the limit in α -and α + , we get

|∆a(u) -δ| ≤ γ (4.62) i.e. dist(∆a(u), Γ(x 0 , c F , α)) ≤ γ. (4.63)
The next result contains one of the main ideas of the paper: the set of the x i satisfying (4.56) is rich enough to approximate a trajectory with a precision of γ.

Theorem 4.13. Let x 0 ∈ A × C and u ∈ U admissible for P 1 (x 0 , 0). Then there exist (α, δa) ∈ R 2N + such that for all k = 0, . . . , N :

δa k ∈ Γ(a 0 + k-1 j=0 δa j , c k , c k+1 , α k ) (4.64) k-1 i=0 δa i ≤ a(t k ) -a 0 (4.65) k-1 i=0 δa i ≥ a(t k ) -a 0 -γ, (4.66)
where a k = a(t k ) and c k = c(t k ).

Proof. First note that (4.65) and (4.66) are satisfied for k = 0. Now consider k = 0, . . . , N such that the three properties are satisfied until (k -1). If there exist α such that

a(t k+1 ) -a(t k ) ∈ Γ(a 0 + k-1 j=0 δa j , c k , c k+1 , α k ) (4.67)
then set δa k = a(t k+1 )a(t k ) and α k = α. and then the three properties are still trivially satisfied for k. Else, we apply Lemma 4.12 to justify the existence of an α k such that

dist(a(t k+1 ) -a(t k ), Γ(a 0 + k-1 j=0 δa j , c k , c k+1 , α k ) ≤ γ. (4.68) then if k-1 j=0 δa j + ∆ + (a 0 + k-1 j=0 δa j , c k , c k+1 , α k ) ≤ a(t k+1 ) -a 0 (4.69)
then we set δa k = ∆ + (a 0 + k-1 j=0 δa j , c k , c k+1 , α k ) Then constraints (4.64) and (4.65) are satisfied. We need to check that (4.66) is also satisfied. To see this, observe that k-1 j=0

δa j + ∆ + (a 0 + k-1 j=0 δa j , c k , c k+1 , α k ) (4.70) ≥ a(t k ) -a 0 -γ + ∆ + (a 0 + k-1 j=0 δa j , c k , c k+1 , α k ) (4.71) ≥ a(t k+1 ) -a 0 + ∆ + (a 0 + k-1 j=0 δa j , c k , c k+1 , α k ) -(a(t k+1 ) -a(t k )) -γ (4.72) ≥ a(t k+1 ) -γ, (4.73)
where we applied, the induction and the fact that

∆ + (a 0 + k-1 j=0 δa j , c k , c k+1 , α k ) ≥ a(t k+1 ) -a(t k ). Else we set δa k = ∆ -(a 0 + k-1 j=0 δa j , c k , c k+1 , α k ). We have k-1 j=0 δa j + ∆ -(a 0 + k-1 j=0 δa j , c k , c k+1 , α k ) (4.74) > a(t k+1 ) -a 0 -∆ + (a 0 + k-1 j=0 δa j , c k , c k+1 , α k ) -∆ -(a 0 + k-1 j=0 δa j , c k , c k+1 , α k ) (4.75) > a(t k+1 ) -a 0 -γ (4.76) and k-1 j=0 δa j + ∆ -(a 0 + k-1 j=0 δa j , c k , c k+1 , α k ) (4.77) ≤ a(t k ) -a 0 + ∆ -(a 0 + k-1 j=0 δa j , c k , c k+1 , α k ) (4.78) ≤ a(t k+1 ) -a 0 (4.79)
which concludes the induction.

We point out that the proof of this result is constructive. We propose in the next result an a posteriori error estimate based on this construction. Since a(t k ) is the age of the system piloted by the -optimal solution u and a 0 + k i=1 δa i is the age of the system piloted by the solution we are building with adaptative weights, relation (4.64) means that the system is always in better shape (i.e. younger) in the solution we are building, and at CHAPTER 4. ADAPTIVE WEIGHTS ALGORITHM the same time, it cannot be more than γ better (reminder: γ is the maximal diameter of Γ). Theorem 4.14 (Error Estimate). For any -optimal solution of P 1 (a 0 , c 0 , t 0 ), the construction of the previous theorem gives the estimate:

V 3 (a 0 , c 0 , t 0 ) -V 1 (a 0 , c 0 , t 0 ) ≤ N -1 k=0 α k (a(t k+1 ) -a(t k ) -δa k ) + (4.80)
Note that (a(t k+1 )a(t k )δa k ) = 0 when there is no jump at α k , which can be numerically checked. Thus the theorem give an a posteriori estimate of the error when optimizing with an adaptative weights approach. For instance, if the structure of the problem allows us to claim that there are no jumps, then we do not make any approximation error.

Proof. Take > 0 and u ∈ U an -optimal control for problem P 1 (c 0 , a 0 , t 0 ). We apply Theorem 4.13 to u.

We have

V 3 (c 0 , a 0 ) ≤ N k=1 {V µ 2 (a 0 + k-1 j=0 δa j , c k , c k+1 , α k ) -α k δa k } + φ(a + N -1 k=0 δa k ) (4.81)
We deal with the first term of the RHS. According to Lemma 4.10, for all k = 0 . . . N -1

V µ 2 (a 0 + k-1 j=0 δa j , c k , c k+1 , α k ) -α k δa k = V µ 1 (a 0 + k-1 j=0 δa j , δa k , c k , c k+1 ) (4.82) Therefore V µ 2 (a 0 + k-1 j=0 δa j , c k-1 , c k , α k ) -α k δa k -V µ 1 (a(t k ), a(t k+1 ) -a(t k ), c k , c k+1 ) (4.83) = V µ 1 (a 0 + k-1 j=0 δa j , δa k , c k , c k+1 ) -V µ 1 (a(t k ), a(t k+1 ) -a(t k ), c k , c k+1 ) (4.84) = V µ 1 (a 0 + k-1 j=0 δa j , δa k , c k , c k+1 ) -V µ 1 (a 0 + k-1 j=0 δa j , a(t k+1 ) -a(t k ), c k , c k+1 ) + (4.85) V µ 1 (a 0 + k-1 j=0 δa j , a(t k+1 ) -a(t k ), c k , c k+1 ) -V µ 1 (a(t k ), a(t k+1 ) -a(t k ), c k , c k+1 ) (4.86)
The second difference is negative because V µ 1 is decreasing in its first variable and a 0 + k-1 j=0 δa j ≤ a(t k ) by construction. We thus concentrate on the first difference. If there is no jump, this quantity is zero. Otherwise, we need to compare (simplifying the notations)

V µ 1 (δa k ) and V µ 1 (a(t k+1 ) -a(t k )
. By definition of P µ 2 , we have

V µ 1 (a(t k+1 ) -a(t k )) + α k (a(t k+1 ) -a(t k )) ≥ V µ 2 (α k ). (4.87)
Remember that by definition the pair (α k , δa k ) satisfies δa k ∈ Γ(a 0 + k-1 j=0 δa j , c k , c k+1 , α k ). We can apply Lemma 4.10 to get

V µ 2 (α k ) = V µ 1 (δa k ) + α k δa k . (4.88)
Therefore, combining relations (4.87) and (4.88) we get

V µ 1 (δa k ) -V µ 1 (a(t k+1 ) -a(t k )) ≤ α k (a(t k+1 ) -a(t k ) -δa k ) (4.89)
Therefore if we denote by K jumps the k ∈ [0..N -1] such there is a jump in the construction:

V 3 (a 0 , c 0 , t 0 ) -V 1 (a 0 , c 0 , t 0 ) ≤ (4.90) k∈K jumps α k (a(t k+1 ) -a(t k ) -δa k ) + φ(a 0 + N -1 k=0 δa k ) -φ(a(t N )) + (4.91) ≤ k∈K jumps α k (a(t k+1 ) -a(t k ) -δa k ) + . (4.92)
Since a(t N ) ≥ a 0 + N -1 k=0 δa k by construction, φ is monotone decreasing and u is admissible for P 1 (x 0 , t 0 ).

Complexity Analysis

We denote by N α the number of elements in the discretization of α. We get the following offline computation burden for the adaptative weights algorithm if we neglect the age variations in the micro problem.

• Micro problem: O(N c N u N t T ) • Parameters for micro: O(N α N a N c ) • Macro: O(N a N c N α N ) • Total bilevel: O(N a N α N ) + O(N α N a N 2 c N u N t T )
We proceed with a complexity analysis for the case where we have the constraint c t k = c 0 and we neglect the age variations in the micro problem:

• Micro problem: O(N c N u N t T ) • Parameters for micro: O(N α N a ) Offline Computation burden Approach offline BF N a N c N u N t T N Bilevel N 2 a N 2 c N + N 2 a N 2 c N u N t T AWA N α N a N 2 c N + N α N a N 2 c N u N t T
N a N c N u N t T N N a N c N u N t T N a N Bilevel (d) N 2 a N + N 2 a N c N u N t T N 2 a N + N a N c N u N t T N 2 a (e) " N a N c N u N t T N a N AWA N a N α N + N α N a N c N u N t T N a N α N + N c N u N t T N a N α Table 4.2 -
The computation burdens for the case where c has to be the same at the beginning of each period

• Macro: O(N a N α N ) • Total bilevel: O(N a N α N ) + O(N α N a N c N u N t T )
If N a and N α are of the same order, then the offline computation burdens for the adaptive weights and bilevel dynamic programming algorithms are of the same order. We then store an N a × N α matrix. The online optimization complexity is proportional to

N a N α N + N c N u N t T .
The complexity analysis is summarized in Tables 4.1 and 4.2.

Discussion

Asymptotic Analysis

We propose in this subsection an asymptotic error estimate. The derivation of the estimate relies mostly on Assumption 1, which by the way we did not use in the previous sections.

We now express formally the approximation of V µ 2 envisioned in the complexity analysis:

P µ 2 (a 0 , c 0 , c F , α)                        Ṽ µ 2 (a 0 , c 0 , c F , α) = inf u∈U T 0 [ (u(t), t) + αF a (a 0 , c(t), u(t), t)]dt ċ(t) = F c (a 0 , c(t), u(t), t) (a(0), c(0)) = (a 0 , c 0 ) ϕ(c(t), u(t), t) ∈ A c(T ) ≥ c F . (4.93)
This approximation consists in neglecting the evolution of a in the micro optimal control problem. We then set ∆a(u) = T 0 F a (a 0 , c(t), u(t), t)dt and define Γ for P µ 2 the same way we defined Γ for P µ 2 . Last we define Ṽ3 by replacing Γ and V µ 2 by Γ and Ṽ µ 2 in the definition of V 3 and Ũx as the set of controls u

∈ U T = {u ∈ L ∞ (0, T ) s.t. ∀t ∈ [0, T ], u(t) ∈ Ū } such that ϕ(c u,t
x 0 ,0 , u(t), t) ∈ A for any t ∈ [0, T ], where c is the flow corresponding to the dynamics (4.93).

First we estimate with Gronwall's lemma the error made on the trajectories. Lemma 4.15. There exists a constant K such that for any (a 0 , c 0 , u, t)

∈ A × C × U T × [0, T ], |a 0 -a u,t x 0 ,0 | ≤ K/N and |c u,t x 0 ,0 -cu,t x 0 ,0 | ≤ K/N, (4.94
)

and |∆a(u) -∆a(u)| ≤ K/N 2 . (4.95)
Proof. We get the first inequality using F a ≤ L/N , the second inequality by combining the L-Lipschitzianity of F c , the first inequality and Gronwall lemma. We get (4.95) combining the L/N -Lipschitziannity of F a with (4.94).

We continue with the error estimate.

Theorem 4.16. Let x 0 = (a 0 , c 0 ) ∈ A×C. Let (α i , a i , c i ) be some minimizers of V 3 (x 0 , 0).

Let u i ∈ U a i ,c i be a minimizer of P µ 2 (a i , c i , c i+1 , α i ) such that u i ∈ Ũa i ,c i . Let ψ ∈ R → R and C ≥ 0 be such that • a i+1 -a i ∈ Γ(x i , c i+1 , ψ(α i )) • | ψ(α i ) -α i |≤ C • α i ≤ N C Then Ṽ3 (x 0 , 0) -V 3 (x 0 , 0) N ≤ 3CK N (4.96) CHAPTER 4. ADAPTIVE WEIGHTS ALGORITHM Proof. Set δa i = a i+1 -a i . By definition of Ṽ3 , we have Ṽ3 (x 0 , 0) -V 3 (x 0 , 0) ≤ (4.97) N -1 i=0 Ṽ µ 2 (x i , c i+1 , ψ(α i )) -V µ 2 (x i , c i+1 , α i ) + (α i -ψ(α i ))δa i + φ(a n ) -φ(a n ) (4.98) ≤ N -1 i=0 inf u∈ Ũx i [L(u) + ψ(α i ) ∆a(u)] -inf u∈Ux i [L(u) + α i ∆a(u)] + (α i -ψ(α i ))δa i (4.99) ≤ N -1 i=0 inf u∈ Ũx i [L(u) + ψ(α i ) ∆a(u)] -inf u∈ Ũx i [L(u) + α i ∆a(u)] + CK/N (4.100) ≤ N -1 i=0 sup u∈ Ũx i [ψ(α i ) ∆a(u) -α i ∆a(u)] + CK/N (4.101) ≤ N -1 i=0 CK N + α i K N 2 + CK N ≤ 3CK (4.102)
The reverse result can be proved similarly.

To give an intuition of the estimate of α, observe that Γ(x 0 , c F , N α) is equal to a constant divided by N for any α.

Extensions

In this subsection we propose some possible extensions for the adaptative weights algorithm.

Obstacle

In many applications, it is possible to buy off the shelf spare parts to replace worn components. Hence we may want to introduce the possibility to buy a replacement in the optimization problem. This could be done with an impulse control: for a fixed price p, we should be able to reset the age a to zero. We would get the following dynamic programming principle:

V 3 (a, c, t k ) = min{ inf c f ,α,δa V µ 2 (a, c, c f , α) -αδa + V 3 (a + δa, c f , t k+1 ), V 3 (0 + δa, c f , t k+1 ) + p} (4.103)

Periodicity

We can include seasonality by having different kinds of periods. For instance, we could model winter and summer days. In this case, one need to perform an offline pre-processing for each kind of day.

Infinite Horizon

If we add a discount rate, the arguments should apply for infinite horizon. Then one needs to replace the macro dynamic programing algorithm by either a policy iteration algorithm or a value iteration algorithm.

Algorithm

We propose a bi-level approach that consists in an offline and an online part. For readability we assume that c should have the same value at the end of each period c. We already defined ∆a(u) and L(u). The inputs of the algorithm are the discretization grids of the age and the parameters, namely I a and I α . We denote by k 0 the current period number and by a 0 the current age. We use the notation φ(a) = φ(a) if a < a max , +∞ else. For a table T indexed by I a FT is an interpolation of T over the grid. The output of the offline algorithm is the pair of tables (∆ α,a 0 , L α,a 0 ). The output of the online algorithm is a control u * ∈ U T .

Algorithm 1 offline Algorithm Data:

I a , I α Result: ∆ α,a 0 L α,a 0 for α ∈ I α do for a 0 ∈ I a do Solve P µ 2 (a 0 , c, c, α) Compute an optimal control u for P µ 2 (a 0 , c, c, α) ∆ α,a 0 ← ∆a(u) and L α,a 0 ← L(u) end end Algorithm 2 online Algorithm Data: k 0 , a 0 , I a , I α , ∆ α,a 0 , L α,a 0 Result: u * Initialize Ṽ:,: ∈ I a × [k 0 + 1 . . . N ] Ṽ:,: ← +∞ Ṽ:,N ← φ(:) for k ← N -1 to k 0 + 1 do for a ∈ I a do for α ∈ I α do Ṽa,k ← min{L α,a + F Ṽ (a + ∆ α,a , k + 1); Ṽa,k } end end end α * ← argmin Iα {L α,a -α∆ α,a 0 + Ṽ (a 0 + ∆ α,a 0 , k 0 + 1)} Compute an optimal control u * for P µ 2 (a 0 , c, c, α * ) Return u *

Simulation and Implementation on a Microgrid Model

Problem Presentation

A microgrid is an electric system that includes electricity generation units (dispatchable and non dispatchable) and a battery to store energy for later use. Although the battery price is a non negligible part of the total infrastructure cost, the battery aging is rarely taken into account in the control of the grid: this is the source of sub-optimality we propose to deal with. The profusion and complexity of battery aging models is a reason why, to the extent of our knowledge, no generic optimization tools have been proposed yet. It is nonetheless natural to model the aging through a quantity representing the age of the battery that would increase as the battery is used. The scope of our framework is the models for which the battery age dynamics is a controlled first order ordinary differential equation. We use a severity factor model for the aging and solve the simplified optimal control formulation (introduced in [START_REF] Heymann | Continuous optimal control approaches to microgrid energy management[END_REF] and [START_REF] Heymann | A stochastic continuous time model for microgrid energy management[END_REF] by dynamic programming.

Here is a brief description of the microgrid we consider. The electricity is produced by some non dispatchable units (solar panels) and a dispatchable unit (a diesel generator or the network for instance). At each instant, there is an instantaneous demand (non controllable) for electricity. If there is a production surplus, one can store this surplus in the battery. If there is not enough electricity produced at this instant, and there is some energy left in the battery, one can use the battery to fill the gap or increase the production from the dispatchable unit. Note that the battery is not a perfect storage: if one unit of energy is stored in an empty battery, the total amount of energy we can get from the battery is strictly lower than 1. Of course, there is a cost associated with the production of electricity from the dispatchable unit.

SIMULATION AND IMPLEMENTATION ON A MICROGRID MODEL

89

A more detailed and technical description of the system, with the underlying equations, is proposed in §4.6.3. As already discussed, the battery state can be described by two variables: the state of charge c and the age a. The state of charge c is a normalized quantity that is the ratio of energy stored in the battery over the maximum quantity the battery can store. It is zero when the battery is empty, and 1 when the battery is full.

The age a is also a normalized quantity in [0, 1]. We set a = 0 for a brand new battery and a = 1 for a dead one. Obviously, we need to precise the dynamics of a and c so that the model makes sense from a physics perspective. Such dynamics can be found in the literature (see §4.6.2). Very often in the literature instead of the notion of age we find the concept of state of health h = 1a. We prefer the notion of age in this work, to stay coherent with the previous sections.

In order to make the document self contained and the results reproducible we use analytical inputs for the solar power production and for the power consumption (load)

Battery Aging Model

As noted by Koller et al. in [START_REF] Koller | Defining a degradation cost function for optimal control of a battery energy storage system[END_REF], battery based solutions for energy storage present the advantage of being deployable without any consideration of the geographic factors and within short schedule thanks to their modularity. In [START_REF] Sauer | Comparison of different approaches for lifetime prediction of electrochemical systems-using lead-acid batteries as example[END_REF] The aging is taken into account in the model using a working zones approach as proposed in [START_REF] Guasch | Dynamic battery model for photovoltaic applications[END_REF] and the penalty parameter is the investment cost of the battery.

As argued in the final comments of [START_REF] Haessig | Dimensionnement et gestion d'un stockage d'énergie pour l'atténuation des incertitudes de production éolienne[END_REF] instead of using a penalization approach, one could impose a maximal aging constraint. The supporting argument is that the appropriateness of an aging profile depends on the time horizon over which the battery is supposed to be in operation. Then in [START_REF] Haessig | Energy storage control with aging limitation[END_REF] Haessig et al. propose to implement an aging constraint by introducing the notion of exchangeable energy for exchanged energy counting aging model.

CHAPTER 4. ADAPTIVE WEIGHTS ALGORITHM

To our knowledge there are basically three approaches in the literature to take battery aging into account in an optimization model:

• Some constraints on the control and state variables (for instance to avoid extreme State of Charge values). This requires deciding which constraints to implement. The aging is not directly taken into account in the optimization process. The constraints can be too or not enough conservative.

• A penalization of the aging. This requires choosing an aging model and a penalization parameter.

• An aging constraint. This requires choosing an aging model and the aging level. In addition, one may need a heuristic to implement this constraint if a direct numerical optimization is too burdensome.

Observe that ideally, we should perform an optimization over the whole remaining existence of the microgrid and take into account the impact of the aging on the battery performance.

If the battery scheduled lifetime is shorter than the microgrid one, then the optimal aging profile should take into account the possibilities and the conditions (price, etc. ) to buy a new battery. Then it appears that in this very idealistic viewpoint, the optimal control of the microgrid would take into account the aging without requiring the implementation of any penalization or constraint. The aging penalization and the aging constraint are in fact rule of thumbs to incorporate those long term considerations.

Nonetheless, it is hard to conciliate long term optimization and the modeling of the aging related performances variations. Moreover, the numerical resolution of the optimal control formulation problem needs to be fast enough if one envisions a real online implementation.

Note that the adaptative weights approach presented in this paper allows for a long term offline optimization. The output of the offline optimization is a closed loop optimal penalization parameter which can be then used as input for the online (and short term) optimal control problem. Since the age variation within a single day has a negligible impact on the performance, we can neglect those variations for the numerical resolution of the online optimal control problem. By doing so, the online problem approximation is one dimensional an can be solved efficiently with dynamic programming.

Note that this approach should work as long as we have a continuous time model for the aging (i.e. an ordinary differential equation). In the following we will apply our framework to a severity factor model based on the state of charge of the battery. The whole quantitative formulation is presented in §4.6.3.

SIMULATION AND IMPLEMENTATION ON A MICROGRID MODEL

The Optimal Control Formulation

We implement the adaptative weights framework on a simplified version of the continuous time optimal control formulation we introduced in [START_REF] Heymann | Continuous optimal control approaches to microgrid energy management[END_REF] and extended to a stochastic setting in [START_REF] Heymann | A stochastic continuous time model for microgrid energy management[END_REF]. The unit of time is the hour and T = 24 corresponds to a day. The long term optimal control problem writes

P 1 (a 0 , c 0 , t 0 )                        V 1 (a 0 , c 0 , t 0 ) = inf u∈U Ttot t 0 (u(t))dt (a(t 0 ), c(t 0 )) = (a 0 , c 0 ) a(T tot ) ≤ a max c(t) ∈ [0.1, 1] ( ȧ(t), ċ(t)) = (F a (a(t), c(t), u(t), t), F c (a(t), c(t), u(t), t)), (4.104)
The control u corresponds to the power produced by the dispatchable unit (a diesel generator). If the battery is full and renewable production is greater than demand, we can disconnect the battery. To simplify the model, we implement this by allowing u to be negative. Let β > 0. The integral cost

(u) = β(u + ) 2 , (4.105)
is a quadratic (and so convex) function associated with the generator consumption of fuel.

The value of β as well as the other model parameters are detailed in Table 4.3. Observe that only the product of U bat and Ah bat matters, so to decrease the number of parameters, we only indicate their product. If we denote by P s (t) the power produced by the solar panels and by P L (t) the load then the state of charge dynamics is

F c (c, u, t) = ρ i (a)P i (a, c, u, t) -P o (a, c, u, t)/ρ o C (4.106)
with P i (a, c, u, t) = (-u -P s (t) + P l (t)) + being the power that gets into the battery and P o (a, c, u, t) = (-u -P s (t) + P l (t)) -being the power that gets out of the battery. We make the choice for simplicity purpose to model the aging impact on the performances by decreasing the efficiency ratio ρ i :

ρ i (a) = (1 -a)ρ (4.107)
Where ρ is the initial coefficient for a = 0. We denote by C the capacity of the battery. In order to make our numerical experiment reproducible, we take T periodic functions with analytic expression for the data input. The functions were chosen to be realistic enough.

For t ∈ [0, 24] P S (t) = max(0, 13 -0.3(4t -48) 2 ) (4.108)

P L (t) = 3 + 3e -0.1(4t-32) 2 + 12e -0.03(4t-74) 2 . (4.109)
The aging dynamics corresponds to a severity factor model

F a (a(t), c(t), u(t), t) = η(c) P o (a, c, u, t) U bat Ah bat (4.110)
where

η(c) = (-4c 2 + 5) 5 (4.111)
is the severity factor (see Figure 4.2 ) and U bat , Ah bat are parameters that depend on the battery (see4.3). We set a -= 0 and a + = 1000. For the numerical experiment, we will set a max = 500 and N = 600.

Parameter N a N c N u N t Value 100 100 100 4

Implementation

Periodicity

We impose that at the end of each day, the charge c should be equal to c, which is a parameter decided upfront. The origin of this additional constraint is operational. Indeed, in a real setting, the optimization is performed regularly on a 24-hours sliding horizon window. Without any final constraint, the optimization program will tend to deplete the battery at the end of its horizon (end of the world effect). What is often done to deal with the undesirable effect is to impose that the battery at the end of the time horizon should be as charged as at the beginning. This is more or less what we implement here.

In dynamic programming, we cannot in general impose hard equality constraints such as c T = c when doing numerics. So we implement the periodicity of the daily final state of charge using a penalty function (in the running cost for the long term bruteforce problem, in the final constraints for the micro problem):

Ψ(c) =    (c -c)M 1 if c ≥ c M 2 else . (4.112)
Where M 1 and M 2 are two penalty parameters.

Discretization and Numerical Resolution

We display in Figure 4.4 the discretization parameters. We take N = 600 and T = 24. We take α between 0 and 500 with a discretization of 10 points, to which we add a α = +∞ point. We use a discretization of 20 points for the adaptive weights algorithm.

We use the optimal control toolbox BocopHJB (see [START_REF] Bonnans | Bocophjb 1.0. 1-user guide[END_REF] and [START_REF] Bonnans | Bocop -a collection of examples[END_REF]) to solve the optimal control problems. The macro algorithm is coded in the R scripting language. We performed the computation on laptop running OSX 10 with 1.3 GHz and 4 logical cores.

The computing times are displayed in Table 4.5.

Results for the Micro Problem

Before commenting the results of the numerical experiment for the adaptive weights dynamic programming algorithm (that we will refer to as AWA), it is worth having a closer look at the micro problem (one day time horizon). We display in Figure 4.3 three simulations for (α, a) equal to (0, 0) (solid line), (0, 400) (dot and dash) and (250, 0) (dot). We see that the increase in age or α is associated with a decrease in the total aging within the day. This is done by diminishing the use of the battery: the maximal value of c is greater for the red curve. The explanations are different for the case a = 400 and α = 250.

For the first one, because the battery efficiency is poor, the quantity that gets effectively stored in the battery is low, so that there is not much to take from the battery during the peaks. The diesel needs to compensate the battery age. For the second one, the battery is efficient, but its use is penalized, so the diesel generator is used during the load peak to decrease the quantity of energy taken from the battery. Observe that, unlike what is seen in the two other cases, the control is flat for a new battery with no penalty. The aging occurs during the two load peaks for all profiles, when the battery is discharging.

We display ∆a(α) for α = 0 in Figure 4.4 (solid curve). Observe that this picture is qualitatively similar to the sketch in Figure 4.1. Yet it is likely that some jumps are the result of the discretization.

We display in Figure 4.4 and 4.5 ∆a(α) and L(α) with respect to α for two values of a and make the following observations:

• monotonicity of ∆a(α): we observe that ∆a(α) is monotone in a.

• regularity of ∆a(α): There seem to be smooth and non smooth ranges for α. It is probable that some of the jumps are due to the discretization choice.

• as expected L(α) and ∆a(α) are respectively non-decreasing and non-increasing with respect to α for a fixed.

Remark on the periodicity of c We chose to impose a periodicity condition on the charge c for simplicity (in particular, the results are easier to represent) and because it makes sense from an operational perspective (see for instance [START_REF] Palma-Behnke | A microgrid energy management system based on the rolling horizon strategy[END_REF]).

We compare in Figure 4.6 the optimal trajectories (computed by dynamic programming) with and without this periodicity condition.

We now proceed with the analysis of the macro part of the adaptative weights algorithm.

Results for the Macro Dynamic Programming Phase of AWA (Adaptative Weights Algorithm)

We display in Figure 4.7 two trajectories corresponding to two different initial ages. We observe that as long as the age is far from a max , the lines look smooth. We display in

Comparison with the Bruteforce Results

We display in Figures 4.10 and 4.11 the envelopes of c and u for a(0) = 0 obtained with the bruteforce dynamic programming algorithm. We see that the battery utilization rate decreases as time goes on, while the diesel generator's increases. We observe that the state of charge c is always slightly above its expected terminal value during the first month, which is possible since the constraint is implemented through a piecewise linear penalt, for Last but not least we display on the same plot in Figure 4.12, two pairs of trajectories computed with AWA and a bruteforce dynamic programming approach for two initial ages.

The corresponding values are displayed in

Conclusion

We have introduced the adaptive weight dynamic programming algorithm (AWA), which is a decomposition technique for problems with periodic data. We tested this algorithm on a toy micro grid problem to integrate the battery aging within the decision process. The trajectories and the value functions obtained with AWA are close to those obtained with a bruteforce approach, and the computing times are way smaller.

Part II

Electricity markets

Chapter 5

Mechanism Design and Auctions for Electricity Networks

This joint work with Alejandro Jofré was accepted for publication in the Contributed Volume Generalized Nash Equilibrium Problems, Bilevel Programming and MPEC (Springer).

MECHANISMS AND AUCTIONS FOR ELECTRICITY NETWORKS

In this chapter, we present some key aspects of wholesale electricity markets modeling and more specifically focus our attention on auctions and mechanism design. Some of the results stemming from these models are the computation of an optimal allocation for the Independent System Operator, the study of equilibria (existence and uniqueness in particular) and the design of mechanisms to increase the social surplus. More generally, this field of research provides clues to discuss how wholesale electricity market should be regulated. We begin with a general introduction and then present some results we obtained recently. We also briefly discuss some ongoing related research. As an illustrative example, a section is devoted to the computation of the Independent System Operator response function for a symmetric binodal setting with piece-wise linear production cost functions.

Introduction

Economists, engineers and mathematicians have given a lot of attention to electricity markets since the beginning of the liberalization era in the 1980s. We present recent results

and ongoing research about wholesale electricity markets and, in particular, the optimal design of such market. The field of market design studies the effects of market rules on economic functioning such as oligopoly behavior, vertical integration, market power, pricing, externalities and so on. The number of recent Nobel Prize laureates with contributions in this field demonstrates its impact on economic thinking. In this chapter we focus on recent works [START_REF]Equilibrium analysis of electricity auctions[END_REF], [START_REF]Monopolistic competition in electricity networks with resistance losses[END_REF], [START_REF] Escobar | Equilibrium analysis for a network market model[END_REF] and [START_REF] Figueroa | Cost-minimizing regulations for a wholesale electricity market[END_REF] as well as on some ongoing research by the authors. In the following sections, we assume that we are in a mandatory pool market, i.e. the agents will satisfy their engagements.

Diversity in electrical markets models can be explained by market specificity. This specificity stems from its economics, industrial and geographical setting, its dependency on the regulatory environment, time scales, and the complex physical properties of electrical networks (Kirchhoff laws, for instance) as well as the entities that compose it -producers, consumers, Independent System Operator (ISO) and networks.

Key modeling decisions concern the agents preferences, the uncertainties on the energy sources and demands, information representation, production capacities, and the physics of the system. In particular one has to specify the structure used to represent the bidding strategies of the producers. Since the physics of an electrical network are a difficult problem too, it is usually simplified.

There are (also) classic questions which accompany any modeling attempt, such as the mathematical well posedness of the problem, and the existence, uniqueness and tractability of the equilibria as wel as their properties. One might also ask about the existence of efficient algorithms for calculating those equilibria. We point out that models for wholesale 5.2. SETTING 105 electricity markets are often general enough to be relevant for other economic settings.

In our setting, the production allocation plan is the result of an auction. The producers communicate their selling prices to a central agent, and then the central agent minimizes the total cost while satisfying the demand. In our model we most of the time take into account the geography of the network (i.e. production and consumption are not co-localized at one point) as well as the losses due to the electricity transportation. Figure 5.1 presents a simple example of a network with four nodes.

We first present the general setting of the model in Section 2. Section 3 is a short review of some recent relevant work in the field. We give a quantitative formulation of the problem in Section 4. We will discuss the main results in Section 5. In Section 6 we develop the example of a two producers setting with piece-wise linear cost functions. We conclude in Section 7.

Setting

This section is a qualitative description of the market settings encountered in literature. We try to be as general as possible, whereas in Section 3 we focus on the frameworks Escobar, Figueroa, Heymann and Jofré study in [START_REF]Equilibrium analysis of electricity auctions[END_REF], [START_REF]Monopolistic competition in electricity networks with resistance losses[END_REF], [START_REF] Escobar | Equilibrium analysis for a network market model[END_REF] and [START_REF] Figueroa | Cost-minimizing regulations for a wholesale electricity market[END_REF]. The main market model components are the agents, the demand, the network, the regulation and the structure of information (since some uncertainty is usually part of the model). Different types of equilibria could be considered. An example of a network is proposed in Figure 5.1.

The agents are divided among those who produce electricity (producers) and those who consume it (usually aggregated into an ISO). In our setting, both producers and consumers are macroscopic, but for the sake of completeness, we note that some models use a continuum of microscopic producers. Such models correspond to situations where no producer can have any unilateral impact on the market.

Producers incur production costs when they supply electricity to the market. These costs depend on the quantity of electricity they each produce individually. The relation between the quantity a producer supplies and its production cost is encoded in his production cost function. To sell electricity, producers quote a price to the market. We consider two structures to model the way a producer specifies a selling price, which we discuss later in the chapter: the bid function and the supply function. A bid function maps any quantity of electricity to the price a producer asks to supply such a quantity. A supply function maps any price to the quantity a producer is ready to supply at such price. The objective of each producer is to maximize his individual profit (or his average profit if the model contains any form of randomness). We consider only non cooperative settings: producers are competing against each other.

We assume dispatch decisions to be centralized: a unique agent, the Independent System Operator (ISO), aggregates the demand side. We justify this aggregation by the 106CHAPTER 5. MECHANISMS AND AUCTIONS FOR ELECTRICITY NETWORKS Figure 5.1 -An example of a wholesale electricity market network. On the demand side, at each node a i there is a demand (load) d i that has to be fulfilled. On the supply side, electricity can be produced at some nodes by some independent agents. The production cost function associates the quantity produced by an agent and the corresponding economic cost (it is specific to the agent). For modeling but also technical and practical reasons, those production cost functions are often approximated with functions in simple functional sets (linear, quadratic, piecewise linear...). Electricity can be sent from one node to another through the edges of the network, but there is a price for that (for instance, a loss proportional to the square of the quantity sent, due to resistivity). The Independent System Operator (ISO) is as its name indicates a central operator that has to allocate the production so that supply meet demand while minimizing a criteria (usually the total price). To produce this allocation, the ISO needs to know the price he will have to pay for each allocation, so the producers specify their bid functions that are usually in the same simple aforementioned functional set. Since the ISO has no way to know the real production cost function of the producers, it is in their interest to game the system. We point out that stochasticity may occurs on the demand. Moreover, the network aspect of the market is of primary importance, as it is responsible for the market power of the agent.

a 1 a 2 a 3 a 4 r 1,2 r 2,3 r 1,4
r 2,4 r 3,4

SETTING

107 regulatory environment and the market organization. The ISO receives bids from producers and has to supply the local electricity demand where it is needed by buying the electricity at the quoted prices (pay as bid market). Generally, the demand is inelastic (in the literature we are considering), but it could be either deterministic or stochastic.

Usually electricity is seen as a divisible commodity. Nonetheless, in our model we can also see it as a geographically differentiated product. Unless production facilities and consumers are colocalized, productions and demands are dispatched on a network. The network contains nodes and edges. Each node is a place where electricity is produced or consumed (or both) and as such is characterized by its local demand and its local producers.

Each edge is a place through which electricity can be sent. The ISO has the possibility to send any nodal electricity surplus where it is needed through the network cables but those cables are subject to physical limitations such as capacity constraints and online losses (due to Joule effects). The geographical differentiation comes from the fact that it the ISO which incurs those losses.

In our model, we envision different kinds of optimization problems: the standard ISO problem, the agent's profit maximization problem and the mechanism design problem. The first one consists simply in finding the minimal cost production plan. For this problem, the ISO (or the principal, if we wish to use mechanism design terminology) receives bids from the different producers and knows the demand (deterministic or stochastic) at each node. He then has to supply this demand at each node for the cheapest total cost. This optimization is subject to the network's physical limitations and is parametrized by the demand at each node and the producers' bids. We call the function that maps these parameters with the solution of the corresponding problem principal response.

The second problem stems from the agents' perspectives. Knowing the principal response function, their own production cost functions and possessing some common knowledge on their fellow producers, they optimize their bids to maximize their individual profits.

This problem raises questions about best response strategies and Nash equilibria.

As alluded previously, in mechanism design, there is an agent and a principal. In our model, we assign the role of the principal to the ISO. The mechanism design problem reverts the role of the principal and the agents: the principal builds his response function knowing that the agents will then maximize their profits. By offering the right incentives, he leads the agents. The mechanism design problem can be formulated by considering that the principal gives a new response function that is not the optimal solution of the first problem. Indeed, instead of waiting for the bids to order the production, the ISO defines in a contract a response function that he will respect in the future. This contract depends on the (future) bids of each producer and the demand at each node. This occurs because otherwise there would not exist incentives to convince the agents to tell the truth about their production costs. They would optimize their own benefits based on the information they have. We have shown that in some very general setting, it is possible for the principal 108CHAPTER

MECHANISMS AND AUCTIONS FOR ELECTRICITY NETWORKS

to formulate the response function in the contract so that the producers are incentivized to reveal their true types (i.e. real production costs). Put differently, the principal can design a contract so that for each producer, it is optimal to reveal his true production costs function. To do so, the principal has to pay (virtually, through the payment function defined in the contract) an information rent to the producers, but his total cost is smaller than in the previous setting.

In general, the principal does not know the real production cost of the producers. This

iis the reason why producers can bid higher than their production cost. The information the principal has about producers' costs is modeled by a probability distribution. The less the producer knows about production costs, the higher the information rent.

Literature

Several approaches have been proposed to answer the questions raised in the previous section. In [START_REF] Klemperer | Supply function equilibria in oligopoly under uncertainty[END_REF], Klemperer and Meyer show that uncertainty reduces the quantity of supply function Nash equilibria. The firms bid their supply functions before demand is revealed.

The existence of a Nash equilibria is shown for a symmetric oligopoly. In [4], Anderson and Philpott show how to construct optimal time dependent supply functions in electricity market settings where demand and competing generators' behaviors are unknown by introducing a market distribution function. The gaming aspect of the situation is reduced by arguing that competitors do not react to the producer bids. The problem is formulated as an optimal control problem. In [3] the authors study asymmetric competition and propose a numerical solver based on GAMS to compute the optimal strategies. They compare the algorithm with the ODE method. In [1], Anderson gives a proof of existence of a pure Nash Equilibria under some technical assumptions when the network is reduced to a single point. He also gives sufficient conditions for uniqueness. Optimal auction design was introduced by Myerson in his 1981 seminal article [START_REF] Myerson | Optimal auction design[END_REF]. Laffont and Martimort wrote in [START_REF] Laffont | The theory of incentives: the principal-agent model[END_REF] an introduction to mechanism design in a general setting. These authors expose important concepts such as the revelation principle, adverse selection, participation constraints and information rent. The book does not consider interactions on a network -which is the specificity of the wholesale electricity market. Bi-level approaches with quadratic production cost functions are proposed in [START_REF] Aussel | Electricity spot market with transmission losses[END_REF] and [START_REF] Hu | Using epecs to model bilevel games in restructured electricity markets with locational prices[END_REF] to study the ISO response functions and the Nash equilibria. For a reference on complementarity modeling, the reader can consult

[?]. Escobar and Jofré show in [START_REF] Escobar | Equilibrium analysis for a network market model[END_REF] that in a random environment a Walrasian and a non-cooperative equilibria exist (for the non-cooperative equilibrium the distribution need to be atom-less) in this setting, the demand is elastic and the ISO maximizes the sum of the utility functions. Utility functions and cost functions are general.

QUANTITATIVE FORMULATIONS

109

Quantitative formulations

We briefly present in this section some questions of interest concerning models that fit into the general setting described in Section 2. Those questions were partially addressed in recent works by the authors.

Generality

We will generically use the notations i to refer to a node or its corresponding producer and q i to refer to the quantity this agent produces. The nodes are connected by edges and we denote by h i,i the quantity of electricity that is sent from node i to node i . The market network is not necessary complete. We call d i the demand at node i. Each producer quotes a bid denoted by b i to the principal. This bid is a function of the quantity q i .

Each producer also informs the principal of the maximum quantity qi he can produce.

In general, the allocation problem is subject to network constraints, i.e., the vector h of components h i,i has to be in a set H. For example the set H could be made of all vectors h such that h i,i ≤ h max i,i , which means that one cannot send an arbitrary big amount of electricity through the network.

The standard allocation problem

The principal receives bids from the agents and allocates the production so that:

• the allocation minimizes the total cost;

• the allocation respects the network and capacity constraints;

• supply is greater than demand at any node.

The last point corresponds to the nodal constraints. The supply at a given node i is the sum of the local production q i and the importations from neighboring nodes i h i ,i . To this we need to subtract the exportations to neighboring nodes i h i,i and the line losses.

If we send a quantity h through an edge {i, i }, we denote by L i,i (h) the corresponding loss. We will count half of this loss at node i and the other half at node i . We end up with the following nodal constraint:

q i + i [h i ,i -h i,i ] - i L i ,i (h i ,i ) + L i,i (h i,i ) 2 ≥ d i , (5.1)
110CHAPTER

MECHANISMS AND AUCTIONS FOR ELECTRICITY NETWORKS

where the summations are performed over the nodes adjacent to i. All this being said, the generic allocation problem writes minimize

q,h i b i (q i ) subject to q i + i [h i ,i -h i,i ] - i L i,i (h i ,i ) + L i,i (h i,i ) 2 ≥ d i q i ≤ qi q i ≥ 0 h ∈ H h i,j ≥ 0.
(5.2)

We point out that if the bidding and the loss functions are convex functions and H is a convex set, then the problem is convex. For instance, one can take the bid functions linear, the loss functions quadratic and H equal to R + . Observe that for a convex problem, if L is strictly convex then at optimality h i ,i h i,i = 0. Note that the bid functions b i and the demand vector d can be seen as parameters of the optimization problem. We could make the solution of this problem stochastic by adding a dependency of d to a random variable ω. This would not change the solution of the problem from the operator perspective, but it would change the market setting for the agents.

What is the solution of this deterministic allocation problem? What are the analytical properties of this solution? How can we compute it?

The agent problem

The objective of each producer is to maximize his profit. Note that by solving the principal allocation problem, we have the response function of the ISO to the agents bids. It is stochastic if the demand is stochastic. We can map each bidding profile of the agents with the expected profit of each agent. By competing against each other, the agents are playing a game. In addition, producer i does not know the production cost functions of his fellow agents. As a result, we are in an imperfect information setting. We assume that for each agent i there is a probability distribution f i over a set of potential production cost functions. The probability distribution f i represents the (common) information the other agents have about agent i. We assume those probability distributions to be independent.

The profit of an agent of type (i.e. production cost function) c i that bids b i (that associates any production level with the price he asks or such production level) is given by

π i (c i , b i ) = C -i [b i (q i (b i , b -i (c -i )) -c i (q i (b i , b -i (c -i )))]f -i (c -i )dc -i , (5.3)

QUANTITATIVE FORMULATIONS

111

where the integral is performed over the types of the other agents. In this expression, q i (b i , b -i ) corresponds to the production level of producer i in the ISO allocation plan when the bids are (b i , b -i ). The production cost function c i associates the production level q i and the corresponding true cost for producer i: c i (q i ). The function b -i (c -i ) is the vector of bidding functions of the other producers when their types is the vector c -i . Then the maximized profit is

π i (c) = max b i C -i [(b i (q i (b i , b -i (c -i )) -c(q i (b i , b -i (c -i ))]f -i (c -i )dc -i . (5.4)
So for each agent the best response strategy to the other agents is the solution of an optimization problem on the set of maps from the types (i.e. production cost functions) c

to the bids b. Usually, the production cost functions will be characterized by a vector of R n . In this case this is an optimization over the functions from R n to R n . Observe that this setting corresponds to a (Bayesian) Bertrand game. Of course, it is natural to ask about the Nash Equilibria of the game. We point out that when L = 0, and there are no network and capacity constraints (and of course, the network is connected), the problem corresponds to the classic setting of first best auction theory (see Figure 5.

3). What can

we say about this game? Is there an equilibrium ? Is it unique ? Can the agents 'game' the system ?

The optimal mechanism design problem

In this section we assume that every participant knows the demand. As in 5.4.3, only producer i knows his true type c i . The other agent and the ISO only know f i . In order to decrease the market power of the agents and increase social welfare, we reverse the role of the principal (the ISO) and the agents, i.e. the principal "bids" a contract to the agent.

The contract should associate each bid profile (b i ) i with two vectors q and x, where q i is the quantity of electricity agent i has to produce and x i is amount of money he will receive.

This contract is communicated to the producers before the bidding phase. Of course, this contract has to be incentive compatible, i.e. the payments described by the principal need to be high enough to make the agent willing to stay in the market. In this situation, the 112CHAPTER

MECHANISMS AND AUCTIONS FOR ELECTRICITY NETWORKS

problem we are solving is the design of the optimal contract: minimize q j ,h i,k ,x j j

Ex j (c)

subject to q j (c) + i h i,j -h j,i - i L i,j (h i,j ) + L j,i (h j,i ) 2 ≥ d j Ex j (c) -c j (q j (c)) ≥ Ex j (b) -c j (q j (b)) Ex j (c) -c j (q j (c)) ≥ 0 h i,j , x j ≥ 0, (5.5)
where E denotes the mean operator with respect to the f i 's, c denote the vector of production cost functions and the constraints should be verified for all c. We refer to [START_REF] Figueroa | Cost-minimizing regulations for a wholesale electricity market[END_REF] for a justification of the formulation. We point out that this is an optimization problem over a functional set (so infinite dimensional) with an infinite number of constraints. The solution of this problem is an optimal mechanism, i.e. based on the information to the ISO, it provides the allocation and payment rules (q, x) that minimize the expected payments to the producers. We display some results in Figures 5.3 and 5.4. How do we build such problem? How can we solve it? How much better is the social surplus with an optimal design?

A differential equation

As noted in 5.4.3, the agents are playing a Bayesian Bertrand-like game in the standard setting. In this section we propose a technique to compute a Nash equilibrium of this game. It is based on a fictitious play like dynamics. For instance, consider the simplified binodal, symmetric setting:

• 2 agents;

• L i,i (h i,i ) = rh i,i ; • H = R 2 + ;
• qi = +∞;

• the cost functions and the bid functions are linear;

• d 1 = d 2 : the demand is equal at each node.

•

f 1 = f 2 = f
We look for a symmetric equilibrium. If the agents iteratively change their bid functions proportionally to the corresponding increase in profit this will produce, the bid functions

IMPORTANT RESULTS

113

dynamics should be described by this formal differential equation.

∂ t b(c, t) = ∂ b π b (c, b(c, t))) (5.6) with π b (c, s) = C -i (s -c)(q i (s, b(c -i ))f (c -i )dc -i .
(5.7) Is this dynamical system well posed? What conclusions can we draw from its study? Can we build such dynamics for more general settings?

Important results

In this section we sum up some results concerning the setting introduced previously. Most of the results focus on quadratic externalities (i.e. L i ,i (h i ,i ) = rh 2 i ,i ) which is a realistic and simple assumption. Escobar and Jofré demonstrate in [START_REF]Equilibrium analysis of electricity auctions[END_REF] the existence of non-cooperative and Walrasian equilibrium when the ISO solves the standard ISO problem and demand is uncertain. The paper finishes with a welfare theorem for wholesale electricity auction. Escobar and Jofré give in [START_REF]Monopolistic competition in electricity networks with resistance losses[END_REF] a lower bound on the market power exercised by each producer.

The existence of a mixed strategy Nash equilibrium is given.The authors also give some regularity property on the ISO response function (condition to be a singleton, continuity and Lipschitzianity). The cost functions are general. Figueroa, Jofré and Heymann study in [START_REF] Figueroa | Cost-minimizing regulations for a wholesale electricity market[END_REF], a bi-nodal symmetric market with linear production cost functions and quadratic losses (i.e. L i,i (h i,i ) = rh 2 i,i , see Figure 5.3). The principal minimal cost production plan problem was already solved in [START_REF]Monopolistic competition in electricity networks with resistance losses[END_REF] and an explicit solution given. If we define

F (x, y) = d + 1 2r x -y x + y 2 - 1 r x -y x + y and q = 2 1 - √ 1 -2dr r , (5.8)
then the solution of the standard allocation problem is

q i (c i , c -i ) =      F (c i , c -i ) if F (c i , c -i ) ≥ 0 and F (c -i , c i ) ≥ 0 q if F (c -i , c i ) < 0 and F (c i , c -i ) ≥ 0 0 if F (c i , c -i ) < 0 and F (c -i , c i ) ≥ 0 (5.9)
This solution is used to compute an explicit solution of the mechanism design problem. The mechanism design solution is then compared to the standard setting for which numerical simulations are performed. The authors assume that the function

J i : c i -→ c i + F i (c i ) f i (c i )
is increasing in c i , where f i is the distribution of the marginal cost of producer i and F i is its integral. Then the main result is Proposition 5.1. Define 114CHAPTER

MECHANISMS AND AUCTIONS FOR ELECTRICITY NETWORKS

q = 2 1 - √ 1 -2dr r
Then an optimal mechanism is given by

qi (c) =            F (J i (c i ), J -i (c -i )) if F (J i (c i ), J -i (c -i )) ≥ 0 and F (J -i (c -i ), J i (c i )) ≥ 0 0 if F (J i (c i ), J -i (c -i )) ≤ 0 q if F (J -i (c -i ), J i (c i )) ≤ 0 ĥi (c) =        1 r J -i (c -i )-J i (c i ) J -i (c -i )+J i (c i ) if J i (c i ) ≤ J -i (c -i ) and F (J -i (c -i ), J i (c i )) ≥ 0 q -1 if J i (c i ) ≤ J -i (c -i ) and F (J -i (c -i ), J i (c i )) ≤ 0 0 if not xi (c) = c i qi (c) + c i c i q i (s, c -i )ds
We point out that the mechanism is built with the standard ISO response function, where we just replace c i by J i (c i ). The mechanism is incentive compatible, i.e. for any agent of any type, bidding the true type ensures a better profit for the agent than any other bidding strategy. Also the mechanism should satisfy a participation constraint, so that any agent can make a nonnegative profit. The optimal mechanism minimizes the total expected payment from the ISO to the agents while satisfying the incentive compatibility constraints, the participation constraints and the nodal constraints.

5.6

The ISO response for a binodal setting with piecewise linear cost

Introduction

In this section we derive an explicit expression for a specific example of ISO allocation problem as defined in 5.4.2 We study the bi-nodal market with quadratic externalities displayed in Figure 5.3. The production cost functions of both agents are made of two linear pieces, with a slope change when the production level is equal to q. We denote by c 1 (resp. c 2 ) producer 1 (resp. 2) marginal cost when his production level is below q, and by c1 (resp. c2 ) when it is above. The production cost functions are convex i.e. c i < ci and the demand d is the same at both nodes. We end-up with the following formulation

THE ISO RESPONSE FOR A BINODAL SETTING WITH PIECEWISE LINEAR COST 115

for the ISO allocation problem: minimize q i ,q i ,h c 1 q 1 + c1 q1 + c 2 q 2 + c2 q2

subject to q i + qi + (-1) i h ≥ r 2 (h 2 ) + d (λ i ) for i = 1, 2 q i , qi ≥ 0 (µ i ) for i = 1, 2 q i ≤ q (γ i ) for i = 1, 2.
(5.10)

In this formulation, q i is the quantity produced by agent i at marginal cost c i , and qi is the quantity produced by i at marginal cost ci . These quantities are subject to positivity constraints with multipliers µ i and μi . We also introduce λ i the multipliers of the nodal constraints, and γ i the multipliers of the constraints q i ≤ q. We denote

F (λ 1 , λ 2 ) = d + 1 r λ 2 -λ 1 λ 1 + λ 2 + 1 2r λ 2 -λ 1 λ 1 + λ 2 2 , (5.11)
P (h) = h + rh 2 2 + d, (5.12
)

k(λ 1 , λ 2 ) = P λ 2 -λ 1 r(λ 1 + λ 2 ) , (5.13)
and q tot i = q i + qi .

(5.14)

We assume without loss of generality that q < 2d and c 1 < c 2 . It is clear that if q 1 < q, then q1 = 0. To solve this problem, we check whether d < q or d ≥ q.

If d < q

By hypothesis c 1 < c 2 . This implies that q 1 ≥ q 2 . So q2 > 0 implies that q 1 = q 2 = q > d, which is not optimal. Therefore we can set q2 = 0. We can also relax the constraint q 2 < q because it won't be binding for the optimal solution. So we rewrite the problem minimize

q i ,q 1 ,h c 1 q 1 + c1 q1 + c 2 q 2 subject to q 1 + q1 -h ≥ r 2 (h 2 ) + d (λ 1 ) q 2 + h ≥ r 2 (h 2 ) + d (λ 2 ) q 1 , q 2 , q1 ≥ 0 (µ i ) q 1 ≤ q (γ 1 ) 116CHAPTER 5

. MECHANISMS AND AUCTIONS FOR ELECTRICITY NETWORKS

The first order conditions give

c 1 -λ 1 -µ 1 + γ 1 = 0 (5.15) c 2 -λ 2 -µ 2 = 0 (5.16) c1 -λ 1 -μ1 = 0 (5.17) h = λ 2 -λ 1 r(λ 1 + λ 2 )
(5.18)

There are four possible cases.

Case 1 :

P ( c 2 -c 1 r(c 1 +c 2 ) ) ≤ q
We consider a relaxation of the problem by removing the constraint q 1 ≤ q. In this relaxed problem, any optimal solution should verify q1 = 0 so the relaxed problem is equivalent to the linear cost functions allocation problem with costs c i , for which we have an explicit formula of the solution. We then notice that the optimal solution of the relaxed problem is admissible, so it is also the solution of (5.10).

Case 2 : P ( c 2 -c 1 r(c 1 +c 2 ) ) > q and P ( c 2 -c 1 r(c 1 +c 2 ) ) ≤ q

We show that q1 = 0 and q 1 = q. If q1 > 0, then by complementarity of the multiplier μ1 = 0, so with (5.17) λ 1 = c1 . So by (5.18) we have h = λ 2 -c 1 r(c 1 +λ 2 ) . Then by hypothesis and the fact that P is increasing and λ 2 ≤ c 2 we have that P (h) ≤ P ( c 2 -c 1 r(c 1 +c 2 ) ) ≤ q . So q 1 + q1 = q tot ≤ q. Then using the fact that q 1 < q ⇒ q1 = 0, we deduce that q1 is null, which is not the hypothesis. We conclude that q1 = 0.

By hypothesis, q < 2d and less than q is produced at node 1. Summing the two nodal constraints we see that q 2 > 0, so that λ 2 = c 2 . Now if q 1 < q, then by complementarity of the multiplier γ 1 = 0, then with (5.15) c 1 = λ 1 and with (5.18), h = c 2 -c 1 r(c 1 +c 2 ) . Therefore we get q 1 + q1 = q tot 1 ≥ P ( c 2 -c 1 r(c 1 +c 2 ) ) (by the first nodal constraint), so by hypothesis q tot 1 ≥ q and so q1 which we know as false. So q 1 = q.

Case 3 : P ( c 2 -c 1 r(c 1 +c 2 ) ) > q and P ( c 2 -c 1 r(c 1 +c 2 ) ) > q and P ( c1 -c 2 r(c 1 +c 2 ) ) > 0

We show that q 2 > 0, q 1 = q, q1 > 0, and, q 2 = P ( c1 -c 2 r(c 1 +c 2 ) ). First we show that q 2 > 0. If q 2 = 0, then by the second nodal constraint h ≥ rh 2 2 + d, which means that P (-h) ≤ 0. Moreover, q1 > 0 because 2d > q. So by (5.17) λ 1 = c1 . With (5.16) and (5.18) we have P ( c1 -c 2 r(c 1 +c 2 ) ) ≤ P ( c1 -λ 2 r(c 1 +λ 2 ) ) = P (-h) ≤ 0, which is false by hypothesis. So q 2 > 0. We deduce from this and (5.16) that λ 2 = c 2 .

If q 1 < q then by complementarity of the multiplier γ 1 = 0, so by (5.15), λ 1 = c 1 and by (5.18), h = c 2 -c 1 r(c 1 +c 2 ) . Then we get q tot 1 ≥ P ( c 2 -c 1 r(c 1 +c 2 ) ) (by the first nodal constraint), so by

THE ISO RESPONSE FOR A BINODAL SETTING WITH PIECEWISE LINEAR COST 117

hypothesis q tot 1 ≥ q, which implies q 1 = q, which is absurd since we assumed q 1 < q. So q 1 = q. If q1 = 0 then with (5.17), λ 1 ≤ c1 and so with (5.18), h ≥ c 2 -c 1 r(c 1 +c 2 ) . We then deduce by nodal constraint 1 and the hypothesis that q tot 1 ≥ P (h) ≥ q, which implies that q1 > 0, which is absurd. So q > 0.

We know that q2 = 0. Using the second nodal constraint, we get q 2 = P ( c1 -c 2 r(c 1 +c 2 ) ). With the first nodal constraint, we have q1 = P ( c 2 -c 1 r(c 1 +c 2 ) )q.

Case 4 : P ( c 2 -c 1 r(c 1 +c 2 ) ) > q and P ( c 2 -c 1 r(c 1 +c 2 ) ) > q and P ( c1 -c 2 r(c 1 +c 2 ) ) ≤ 0 We show that q 2 = 0. Indeed, if q 2 > 0, then λ 2 = c 2 . Using the same reasoning as the one used in the third case, we would show that q 1 = q and q1 > 0. So that h = -c1 -c 2 r(c 1 +c 2 ) . So using P ( c1 -c 2 r(c 1 +c 2 ) ) ≤ 0, we see that nodal constraint 2 is satisfied with q 2 = 0, so the solution is not optimal, which is absurd. So q 2 = 0.

We conclude Theorem 5.2. Assuming d < q < 2d, then:

q tot 1 = k(c 1 , c 2 ) and q tot 2 = k(c 2 , c 1 ) if k(c 1 , c 2 ) ≤ q q tot 1 = q and q tot 2 = q -2 -1 + 1 + 2r(q -d) r if k(c 1 , c 2 ) > q and k(c 1 , c 2 ) ≤ q q tot 1 = k(c 1 , c 2 ) and q tot 2 = k(c 2 , c1 ) if k(c 1 , c 2 ) > q, k(c 1 , c 2 ) > q and k(c 2 , c1 ) > 0 q tot 1 = 2 1 - √ 1 -2dr r and q tot 2 = 0 if k(c 1 , c 2 ) > q, k(c 1 , c 2 )
> q and k(c 2 , c1 ) ≤ 0

Case d ≥ q

Since we consider that c 1 is smaller than c 2 , there are two possibilities. Either the ci are all bigger than the c i , or c1 is smaller than c 2 .

If the ci are all bigger than the c i

In this case, we first show that q 1 = q 2 = q. The problem then writes minimize [START_REF] Figueroa | Cost-minimizing regulations for a wholesale electricity market[END_REF] and [START_REF]Monopolistic competition in electricity networks with resistance losses[END_REF], the authors consider a binodal market with quadratic line losses. The demand is the same at both nodes. The production cost functions are linear. There are no network and capacity constraints. A very intuitive justification of the market power induced by the line losses is given in [START_REF]Monopolistic competition in electricity networks with resistance losses[END_REF]. Indeed, in a symmetric perfect information setting with linear production cost function of slope c, the equilibrium strategy of both producers is to bid c 1-2dr > c.

q i ,q i ,h c1 q1 + c2 q2 subject to q1 + -h ≥ r 2 (h 2 ) + d -q (λ 1 ) q2 + h ≥ r 2 (h 2 ) + d -q (λ 2 ) qi ≥ 0 (µ i ) for i = 1, 2 118CHAPTER
which corresponds to the linear case problem with a demand of dq and costs of ci .

If c1 is smaller than c 2

We point out that replacing c 1 by c1 does not change the solution.

If F (c 2 , c1 ) ≤ q, we show that q2 = 0 the problem can be reduced to the linear production cost problem with demand d and marginal costs c1 and c 2 .

If F (c 2 , c1 ) > q, we show that we can reduce the linear production cost problem with demand dq and marginal costs c1 and c2 .

Theorem 5.3. If d ≥ q, then
• If c i ≤ cj for all i, j, then we get the result by solving the linear problem with demand dq and costs ci and adding q to the quantity we get.

• If 0 ≤ F (c 2 , c1 ) ≤ q we reduce to the linear allocation problem with demand d and marginal cost c1 and c 2 .

• If F (c 2 , c1 ) > q, we reduce the problem to the linear allocation problem with demand dq and marginal costs c1 and c2 and add q to the q i s we get.

Ongoing work

We are currently working on several questions raised in this chapter. In particular, we have shown that for a market with n-pieces piecewise linear production cost functions and any number of producers, there is a mechanism design with an explicit formulation.

Acknowledgments

The authors would like to thank Idalia Gonzalez for her English editing. .3 -The average total cost for the ISO (in the market described in Figure 5.3) as a function of the loss coefficient r for the standard mechanism and the optimal mechanism. We take

ACKNOWLEDGMENTS

f 1 (c) = f 2 (c) = 2c + (1 -2 4 )1 c≤ 1 2 + -2c + (1 + 3 2 )1 c≥ 1 2
. Note how r influences the social cost in the standard mechanism. The agents market power increase with r. When r goes to zero, the two mechanisms lead to the same social cost. When r = 0 we recover a classic result on first and second best auctions. We consider a wholesale electricity market model with general networks, transmission losses and strategic producers. Previous work by Escobar and Jofré [START_REF]Monopolistic competition in electricity networks with resistance losses[END_REF] shows how regulation mechanisms, for instance when prices correspond to the Lagrange multipliers of a centralized cost minimization program, allow the producers to charge significantly more than marginal price. In this paper we consider an incomplete information setting where the cost structure of a producer is unknown to both its competitor and the regulator. We derive an optimal regulation mechanism, and compare its performance to the "price equal to Lagrange multiplier" mechanism in an incomplete information setting (that we solve numerically). 122 CHAPTER 6. COST-MINIMIZING REGULATION

Introduction

A common design in many recently liberalized electricity markets (e.g. US, UK, Spain, etc) involves wholesale trading through an integrated market. Frequent market clearing processes take place, through rules managed by a central authority, commonly referenced as an independent system operator (ISO). In the context of this short-term operations, demand is inelastic and must be satisfied through a grid that imposes significant constraints on the allocations that can be selected. A particularly important feature of the problem is that generators are connected through a grid to the places where demand is concentrated, and there are important losses through the transmission lines. This makes electric power, which is a priori an homogeneous good, a differentiated product, giving generators some degree of market power. This has been remarked, among others, in the work by Borenstein et al. [START_REF] Borenstein | The competitive effects of transmission capacity in a deregulated electricity industry[END_REF], which emphasizes that "transmission costs will be at the heart of market power issues in a restructured electricity market". This situation originates a very important regulatory problem. Given a set of generators and a vector of demands in a network, with production costs that are private information, what pricing scheme should be used in order to minimize the total cost paid and such that the vector of demands is satisfied? An extensively used method is the following: ask each generator its cost function, solve the problem of minimizing cost subject to the fulfillment of the demand requirements, then pay, at each node, a price equal to the Lagrange multiplier associated to that constraint. In such a game, generators have incentives to "shade their bids", and bid costs above their true levels. This is true even if there is complete information among generators but transmission costs are not zero, as it was shown in Escobar and Jofré [START_REF]Monopolistic competition in electricity networks with resistance losses[END_REF] in a simple network with two nodes and a fixed symmetric cost structure.

With this in mind, we solve the problem of designing an optimal (cost minimizing) mechanism in the presence of incomplete information and transmission losses in a simple network.

By using mechanism design tools, we completely characterize the optimal mechanism, derive explicit formulas and compute the total cost for the regulator. Moreover, in order to compare the performance of the optimal mechanism with the standard one, we numerically solve the Bayesian equilibrium of the game induced by the standard mechanism. Some important features appear. In the absence of transmission costs, both the standard and the optimal mechanism yield the same expected costs. The intuition comes from standard auction theory. In the absence of transmission costs there is a single object being bought (the procurement of all nodes in the network), the standard mechanism is equivalent to a first-price procurement auction and the optimal one is a second-price auction. Since both assign to the lowest cost generator, the revenue equivalence principle implies that 6.2. THE PROBLEM 123 both yield the same expected costs. However, if transmission costs are non-zero, the standard and the optimal mechanism allocate production differently, and have therefore different expected costs. Basically, the distortions induced by (individually-optimal) bid-shading in the standard mechanism are different than those induced by the cost-minimizing mechanism. While both induce inefficient allocations, the ones in the mechanism we characterize are designed so that expected total cost is minimized. It is important to remark that the allocative first best, the assignment that would actually result if there was complete information, can be achieved through a VCG mechanism. However, such a mechanism would not minimize expected total cost. From a cost-minimizer perspective, it is optimal to induce inefficiencies in order to minimize the producer's informational rents.

We show that the implementation of the cost-minimizing mechanism is essentially of the same complexity as the implementation of the standard one. To compute the optimal allocation, it requires solving the same problem the ISO operator solves in the standard one, but with modified parameters. To compute the optimal transfers, which are an essential part of the rules of the game, a parameterized optimization problem must be solved.

The Problem

It is well known that price competition with differentiated products does not necessarily lead to zero profits for the firms. In the context of electricity markets, the presence of transmission losses makes the energy produced by different generators differentiated goods, thus creating power and allowing generators to charge prices above marginal cost. This effect was shown in Escobar and Jofré [START_REF]Monopolistic competition in electricity networks with resistance losses[END_REF], in the context of symmetric producers and complete information. There, the mechanism "price equal to Lagrange multiplier" induces insufficient competition, leading to a Nash Equilibrium where both firms charge prices above marginal cost.

To keep things simple, we consider an electric network with two nodes, each of them with a fixed demand d. At each node, there exists a generator, and it is possible to transmit any amount of electricity h between the nodes, but in that case an amount rh 2 is lost. So the network would look like the one in Figure 6.1. The fact that firms exercise their market power under the classical regulatory system gives rise to some important questions. We know that with the current system firms charge 124 CHAPTER 6. COST-MINIMIZING REGULATION prices above marginal cost but this does not seem completely avoidable. Is the current mechanism optimal? If not, how costlier than an optimal mechanism is it? Maybe more importantly, what is the best mechanism to regulate generators in the presence of transmission losses?

To study these natural regulatory questions, a degree of incomplete information, which is at the core of regulatory issues, is needed. First of all, it is realistic, since generators rarely know exactly the cost structure of competitors, and the ISO is not perfectly informed about generators either. Moreover, without private information the regulatory problem is trivial:

just ask each generator to produce at marginal cost, minimizing cost and guaranteeing participation.

We introduce incomplete information in the marginal cost of a generator, c i . We assume that c i is drawn from a distribution with density f i which has support C i = [c i , c i ] and is positive in the interval. The parameter c i is known by firm i, but the regulator and its competitor only know the distribution f i (of cumulated distribution function F i ). We will

use the notation C = C 1 × C 2 and f (c) = f 1 (c 1 )f 2 (c 2 ).
Given the rules designed by the regulator, the generators maximize their expected profits.

Knowing this behavior, the regulator aims to design a mechanism that satisfies demand at each node and minimizes expected cost. We address this problem in the next section, using the techniques of mechanism design.

A Mechanism Design Approach

We now study the problem of the optimal regulatory mechanism in the presence of transmission losses and private information. We assume that the regulator sets up some "rules of the game", which are then followed by the generators based on their private information.

Due to the presence of private information, these rules must allow the generators to reveal their preferences, which in this case are given by their cost structure. By the revelation principle we know that without loss of generality the regulator can restrict attention to incentive compatible direct revelation mechanisms, where the agents's message space is their type space C i , and to incentive compatible mechanisms, where generators have incentives to tell the truth. Definition 6.1. A direct revelation mechanism M = (q, h, x) consists of an assignment rule (q 1 , q 2 , h 1 , h 2 ) : C -→ R 4 and a payment rule x :

C -→ R 2 .
The assignment rule specifies the quantity that each generator must produce and the flows for each vector of reports. We denote by q i (c) the quantity that generator i must produce

A MECHANISM DESIGN APPROACH

125 when the vector of reports is c and by h i (c) the surplus transmitted from generator i to generator j. The payment rule x specifies, for each vector of reports c, a vector of payments, one for each generator.

The ex-ante expected utility of a buyer of type c i when he participates and declares c i is

U i (c i , c i ; (q, h, x)) = E c -i [x i (c i , c -i ) -c i q i (c i , c -i )]
Since we can consider only incentive compatible mechanisms, a natural notion of a feasible mechanism is the following: Definition 6.2. (Feasible Mechanisms) We say that a mechanism (q, h, x) is feasible iff

U i (c i , c i ; (q, h, x)) ≥ U i (c i , c i ; (q, h, x)) for all c i , c i ∈ C i and i = 1, 2 U i (c i , c i ; (q, h, x)) ≥ 0 for all c i ∈ C i and i = 1, 2 q i (c) -h i (c) + h -i (c) ≥ r 2 [h 2 1 (c) + h 2 2 (c)] + d for all c ∈ C and i = 1, 2 q i (c), h i (c) ≥ 0 for all c ∈ C and i = 1, 2
The first set of constraints are the incentive compatibility constraints IC, the second one are the voluntary participation constraints, PC, and the last two ones impose the requirements that the quantities generated and the flows satisfy the demand and are positive quantities, in other words these are the resource constraints, RES.

At an incentive compatible direct revelation mechanism M = (q, h, x), the regulator's expected cost is given by

C i=1,2 x i (c)f (c)dc
Therefore, the problem of the planner can be written as

min C I i=1 x i (c)f (c)dc (6.1)
subject to (q, h, x) being "feasible".

Some Basic Results

We now investigate properties of feasible mechanisms. This will in turn allow us to write the regulator's problem in a simpler way. We use V i (c i ) to denote i's maximized surplus, that is

V i (c i ) = max c i E c -i [x i (c i , c -i ) -c i q i (c i , c -i )] (6.2) 126 CHAPTER 6.

COST-MINIMIZING REGULATION

We will also define the expected quantity to be produced by a generator that declares a type c i (resp. expected payment) as

Q i (c i ) ≡ E c -i [q i (c i , c -i )] (resp. X i (c i ) ≡ E c -i [x i (c i , c -i )]) Lemma 6.3. A mechanism (q, h, x) is feasible iff Q i (c i ) ≤ Q i (c i ) for all c i > c i (6.3) V i (c i ) = V i (c i ) + c i c i Q i (s)ds for all c i ∈ C i , i = 1, 2 (6.4
)

q i (c) -h i (c) + h -i (c) ≥ r 2 [h 2 1 (c) + h 2 2 (c)] + d for all c ∈ C, i = 1, 2 (6.5)
q i (c), h i (c) ≥ 0 for all c ∈ C and i = 1, 2 (6.6)

Proof. See Appendix

With this, we can write the expected payment to a seller as a function of the assignment rule. This is expressed in the next lemma.

Lemma 6.4. The expected payment of buyer i can be written as

C x i (c)f (c)dc = C q i (c)[c i + F i (c i ) f i (c i ) ]f (c)dc (6.7)
Proof. See Appendix.

With these two lemmas, we can characterize the seller's problem in the next proposition: Proposition 6.5. If in a mechanism (q, ĥ, x) the assignment function (q, ĥ) solves

min q,h C i=1,2 q i (c)[c i + F i (c i ) f i (c i ) ]f (c)dc (6.8)
subject to the constraints (6.3), (6.5) and (6.6), and the payment function x satisfies

xi (c) = qi (c)c i + c i c i q i (s, c -i )ds (6.9)
then (q, ĥ, x) is an optimal mechanism.

Proof. Direct from lemma (6.3) and (6.4). Now, with a simple assumption on the distribution f , we can find an explicit solution of the problem.

THE STANDARD MECHANISM

127 Assumption 4. The function

J i : c i -→ c i + F i (c i ) f i (c i ) is increasing in c i .
This assumption will guarantee that pointwise minimization of (6.8), subject to the feasibility constraints (6.5) and (6.6), leads to an allocation rule q(c) that is incentive compatible.

With this, the solution to the seller's problem is simple: for each realization of costs c, solve a cost minimization problem, but where the agents' costs are J i (c i ) instead of c i .

Proposition 6.6. Suppose that assumption 4 is satisfied.

Define

F (x, y) = d + 1 2r x -y x + y 2 - 1 r x -y x + y and q = 2 1 - √ 1 -2dr r
Then an optimal mechanism is given by

qi (c) =                d + 1 2r J -i (c -i )-J i (c i ) J -i (c -i )+J i (c i ) 2 + 1 r J -i (c -i )-J i (c i ) J -i (c -i )+J i (c i ) if F (J i (c i ), J -i (c -i )) ≥ 0 and F (J -i (c -i ), J i (c i )) ≥ 0 0 if F (J i (c i ), J -i (c -i )) ≤ 0 q if F (J -i (c -i ), J i (c i )) ≤ 0 ĥi (c) =        1 r J -i (c -i )-J i (c i ) J -i (c -i )+J i (c i ) if J i (c i ) ≤ J -i (c -i ) and F (J -i (c -i ), J i (c i )) ≥ 0 q -1 if J i (c i ) ≤ J -i (c -i ) and F (J -i (c -i ), J i (c i )) ≤ 0 0 if not xi (c) = c i qi (c) + c i c i q i (s, c -i )ds
Proof. Notice that (q, ĥ) solve the problem of proposition 6.5 pointwise if the constraint (6.3) is relaxed (see appendix) so it is enough to show that (6.3) is satisfied. A sufficient condition is that the function qi :

(c i , c -i ) -→ qi (c i , c -i ) is non-increasing in c i for a fixed c -i . A straightforward calculation 1 shows that ∂ qi (c i ,c -i ) ∂c i = - 4J 2 -i (c -i )J i (c i ) [J i (c i )+J -i (c -i )]
2 ≤ 0 in the region where qi (c i , c -i ) is not constant, so the result follows.

The Standard Mechanism

A standard regulatory mechanism is the following: the regulator asks each generator his marginal cost of production and then, using these revelations as the true costs, solves the 128 CHAPTER 6. COST-MINIMIZING REGULATION Figure 6.2 -The function q problem of minimizing the total cost of production subject to the feasibility constraints.

In our case this corresponds to solve, considering c 1 and c 2 as given:

min q,h 2 i=1 c i q i s.t. q i -h i + h -i ≥ r 2 [h 2 1 + h 2 2 ] + d for i = 1, 2 q i , h i ≥ 0 for i = 1, 2
The regulator will then ask generator i to produce a quantity q i and will pay him a unit price λ i , where λ i is the Lagrange multiplier associated with the feasibility constraint at node i.

If we define

F (x, y) = d + 1 2r x -y x + y 2 - 1 r x -y x + y and q = 2 1 - √ 1 -2dr r
the solution to this problem can be written as (see appendix)

q i (c i , c -i ) =      F (c i , c -i ) if F (c i , c -i ) ≥ 0 and F (c -i , c i ) ≥ 0 q if F (c -i , c i ) < 0 and F (c i , c -i ) ≥ 0 0 if F (c i , c -i ) < 0 and F (c -i , c i ) ≥ 0 λ i (c i , c -i ) = c i if F (c i , c -i ) ≥ 0 2- √ 1-2dr √ 1-2dr c -i otherwise
We display q in Figure 6.2.

6.4. THE STANDARD MECHANISM 129

The Bayesian Game

Consider now the situation we analyzed in the previous section: each generator independently draws a marginal cost c i ∈ C i . They then play a Bayesian game where the quantity asked from a generator that bids a cost x and confronts a generator who bids a cost y is given by q i (x, y), and the unit price paid to him is p i (x, y) = λ i (x, y). Generators are profit maximizers.

The equilibrium of this game would be the benchmark against which we compare the optimal mechanism. A symmetric equilibrium corresponds to a strategy b : [0, 1] -→ R that is played by both generators, where b(c) is the bid of a generator of type c.

The profit of a generator of type c that bids x is given by

π(c, x) = C -i [p i (x, b(c -i )) -c]q i (x, b(c -i ))f -i (c -i )dc -i (6.10)
The maximized profit is

π(c) = max x C -i [p i (x, b(c -i )) -c]q i (x, b(c -i ))f -i (c -i )dc -i (6.11)
and an optimal strategy b(c) must satisfy:

b(c) ∈ argmax x C -i [p i (x, b(c -i )) -c]q i (x, b(c -i ))f -i (c -i
)dc -i (6.12)

Approximation

We now propose an approximation scheme to compute b(c). Without loss of generality, let's assume C i = [0, 1] (this is just a rescaling).

Doing a direct resolution by iterating on the strategies leads to numerical instability for small r. We introduce formally the equation

∂ t b t (c) = ∂ b π bt (c, b t (c))
. The economical interpretation is clear: each agent changes his strategy proportionally to the gain he would get from small local changes. While a mathematical analysis of this equation and of the Nash equilibrium will soon be presented in another paper, we will assume here that the derivative could be understood as small variations for a given discretization when the derivative does not exist. Starting with b(c) = c, we observe numerically that the limit when t goes to infinity of b is a symmetric Nash equilibrium strategy. Some results are displayed in Figures 5.4, 6.5 and 6.5. An interesting comment is that the ISO expected cost in the optimal mechanism seems to depend linearly on r. We show in Section 6.8 that this is not the case from a mathematical standpoint, but still, this approximation is very close to the true function.

Some Comparisons

In order to compare both mechanisms in the presence of transmission costs we consider the following class of distributions in [0, 1]:

g a (x) = ax + (1 -a 4 ) if x ≤ 1 2 -ax + (1 + 3a 4 ) if x ≥ 1 2
It is easy to verify that these distributions satisfy Assumption 4. The case of maximum variance corresponds to a = 0 (the uniform distribution) and a = 4 corresponds to the case of minimal variance. The results are display in Figures and .

As we can see, the optimal mechanism performs significantly better.

Practical Implementation

Now that we have seen that the optimal mechanism design performs significantly better, we turn to the problem of implementation. How difficult is it to implement it in practice?

Is it significantly more difficult to implement than the standard mechanism?

Let's start with the simple case analyzed in this paper, that is a network with only two nodes. As long as the distribution of types satisfies Assumption 4, all that is required from the regulator is to solve the optimization problem (6.8) pointwise, for all possible realizations of (c 1 , c 2 ). With this, he would state the rules of the game (q, x, ĥ). Once this is done, the agents will declare marginal costs c i , and the regulator will evaluate the mechanism at the revealed costs, instructing each generator to produce qi (c) and paying them xi (c). In comparison, in the standard case this optimization is solved once for each time the agents declare some costs. Therefore, if the mechanism is to be used repeatedly over time, the optimal mechanism has a computational cost similar to the standard mechanism which is frequently used.

If we apply this technique to a more complicated network, like the ones that appear in practice, a result analogous to the one in Proposition 6.5 can be proved. Moreover, under Assumption 6, the pointwise solution of the problem would continue to be incentive compatible, since the quantity bought from a generator is decreasing in its own cost (keeping the other generators' costs fixed), which is sufficient for incentive compatibility (for details about this result in a general setting, see Correa and Figueroa [START_REF] Correa | On the planners loss due to lack of information in bayesian mechanism design[END_REF]). Then, computing the optimal mechanism would require solving the ISO problem for modified costs (instead of actual ones), a problem of the same computational complexity as the one actually solved by the ISO.

Sensitivity Analysis

There is a natural concern. To compute the optimal mechanism, the regulator does not need to know the generators' costs, but he needs to have a prior about the distribution of these costs. This weaker requirement can still be difficult to satisfy in practice, and the regulator can make mistakes when assessing these prior distributions. This, coupled with the well documented fact that generators know each other very well, and much better than the regulator knows them, could give rise to unexpected and undesirable results. In what follows we consider a scenario where the regulator designs a mechanism with wrong information, and generators that know the true distributions of their competitors, plus the rules of the game.

We conduct the following sensitivity analysis. Let's suppose that the true distributions are f 1 , f 2 , but that the regulator mistakenly designs the optimal mechanism (q f , ĥ f ,

x f )
for distribution f1 , f2 . We compare the expected payment that the seller was hoping to pay (for distributions f 1 , f 2 ) with the expected payment that the seller actually pays (for distributions f1 , f2 ).

First, we note that the mechanism (q f , ĥ f , x f ) (designed with f1 , f2 in mind) is incentive compatible in dominant strategies since the payment defined in (6.9) satisfies (6.4) pointwise. Therefore the agent has incentives to tell the truth regardless of his beliefs about the other agent's distribution. This is particularly important since the "wrong" mechanism does not induce, as a second-order effect, players to lie about their costs, no matter how mistaken the regulator was in his assessment of the prior distribution f . The cost paid by a regulator who thinks the distributions are f1 , f2 but is really facing distributions f 1 , f 2 is given by

C f ,f = C i=1,2 q f i (c)[c i + F i (c i ) f i (c i ) ]f (c)dc

The social cost is not affine

We derive an explicite expression of the expected social cost for the optimal mechanism.

We consider the symmetric binodal setting with the common knowledge density f being the uniform distribution on [0, 1]. For r in [0, 1/2d], we denote by G(r) the social cost associated with the optimal mechanism. By definition of f , the virtual cost writes (by symmetry, the expression is the same for producer 1 and producer 2): J(c) = 2c. We will use the short-

hand F (c 1 , c 2 ) = F (J(c 1 ), J(c 2 )) = F (2c 1 , 2c 2 ). Observe that, F (c 1 , c 2 ) = F (c 1 , c 2 ).
G(r) = E(x 1 + x 2 ) = 1 c 1 =0 1 c 2 =0
{J(c 1 )q(c 1 , c 2 ) + J(c 2 )q(c 2 , c 1 )}dc 2 dc 1 (6.13) where q is the optimal mechanism allocation rule (which depends on r). Note that by symmetry, the participation of the part such that c 1 < c 2 is equal to the participation of the part such that c 2 ≤ c 1 and those two parts form a partition of (c

1 , c 2 ) ∈ [0, 1] 2 .
Therefore,

G(r) = 2 1 c 1 =0 c 1 c 2 =0 {J(c 1 )q(c 1 , c 2 ) + J(c 2 )q(c 2 , c 1 )}dc 2 dc 1 , (6.14)
then we decompose the integral in two terms: the integral over the locus such that F (c 1 , c 2 ) ≥ 0 and the integral over the locus such that

F (c 1 , c 2 ) < 0. Observe that since c 1 > c 2 , F (c 2 , c 1 ) ≥ 0. G(r) = 2 1 c 1 =0 c 1 c 2 =0 {J(c 1 ) F (c 1 , c 2 ) + J(c 2 ) F (c 2 , c 1 )}1 F (c 1 ,c 2 )≥0 dc 2 dc 1 (6.15) +2 1 c 1 =0 c 1 c 2 =0 qJ(c 2 )1 F (c 1 ,c 2 )<0 dc 2 dc 1 (6.16) = 4 1 c 1 =0 c 1 c 2 =0 {c 1 F (c 1 , c 2 ) + c 2 F (c 2 , c 1 )}1 F (c 1 ,c 2 )≥0 dc 2 dc 1 (6.17) +4 1 c 1 =0 c 1 c 2 =0 qc 2 1 F (c 1 ,c 2 )<0 dc 2 dc 1 . (6.18) Therefore G(r) = 4A(r) + 4qB(r) (6.19)
with

A(r) = 1 c 1 =0 c 1 c 2 =0 {c 1 F (c 1 , c 2 ) + c 2 F (c 2 , c 1 )}1 F (c 1 ,c 2 )≥0 dc 2 dc 1 (6.20)
and

B(r) = 1 c 1 =0 c 1 c 2 =0 c 2 1 F (c 1 ,c 2 )<0 dc 2 dc 1 . (6.21)
Note that the dependence in r is implicite in F and q. We denote by Y the function Now we observe that for any (c 1 , c 2 ) ∈ [0, 1] 2 such that c 1 ≥ c 2 :

Y (c 1 , c 2 ) = c 1 -c 2
F (c 1 , c 2 ) ≥ 0 ⇐⇒ P (Y (c 1 , c 2 )) ≥ 0 ⇐⇒ Y ≤ y 0 (r) (6.23)
and

F (c 1 , c 2 ) ≤ 0 ⇐⇒ Y (c 1 , c 2 ) ≥ y 0 (r). ( 6

.24)

Therefore A(r) rewrites

1 c 1 =0 c 1 c 2 =0 {c 1 F (c 1 , c 2 ) + c 2 F (c 2 , c 1 )}1 F (c 1 ,c 2 )≥0 dc 2 dc 1 (6.25) = 1 c 1 =0 c 1 c 2 =0 {c 1 P (Y (c 1 , c 2 )) + c 2 P (Y (c 2 , c 1 ))}1 Y (c 1 ,c 2 )≤y 0 (r) dc 2 dc 1 (6.26) = 1 c 1 =0 0 Y =1 {c 1 P (Y ) + c 1 1 -Y 1 + Y P (-Y )}1 Y ≤y 0 (r) -2c 1 (1 + Y ) 2 dY dc 1 (6.27) = 2 1 c 1 =0 c 2 1 dc 1 y 0 (r) Y =0 {P (Y ) + 1 -Y 1 + Y P (-Y )} 1 (1 + Y ) 2 dY (6.28) = 2 3r y 0 (r) Y =0 2dr -Y 2 (1 + Y ) 3 dY = 2 3r y 0 (r) Y =0 -1 1 + Y + 2 (1 + Y ) 2 + 2rd -1 (1 + Y ) 3 dY (6.29)
Here are some justifications:

1. Definitions of y 0 , Y and P ,

Change of variable

Y = (c 1 -c 2 )/(c 1 + c 2 ) ⇐⇒ c 2 = c 1 (1 -Y )/(1 + Y ),
3. Simplification and Fubini theorem, 4. Simplification

5. Check that -1 1+Y + 2 (1+Y ) 2 + 2rd-1 (1+Y ) 3 = 2dr-Y 2 (1+Y ) 3 Thus A(r) = 2 3r 2rd -1 2 y 0 (r) 2 + 2y 0 (r) (1 + y 0 (r)) 2 + 2y 0 (r) 1 + y 0 (r)
ln(1 + y 0 (r)) . (6.30)

APPENDIX 135

Then follows similarly the computation of B(r) :

B(r) = 1 c 1 =0 c 1 c 2 =0 c 2 1 F (c 1 ,c 2 ) (6.31) = 1 c 1 =0 c 1 c 2 =0 c 2 1 Y (c 1 ,c 2 )>y 0 (r) dc 2 dc 1 (6.32) = - 1 c 1 =0 0 Y =1 c 1 1 -Y 1 + Y 1 Y >y 0 (r) c 1 2 (1 + Y ) 2 dY dc 1 (6.33) = 2 1 c 1 =0 c 2 1 dc 1 1 Y =y 0 (r) 1 -Y (1 + Y ) 3 dY (6.34) = 2 3 1 Y =y 0 (r) 2 (1 + Y ) 3 - 1 (1 + Y ) 2 dY (6.35) = 2 3 1 (1 + y 0 (r)) 2 - 1 4 - 1 (1 + y 0 (r)) + 1 2 (6.36) = 1 6 1 -y 0 (r) 1 + y 0 (r) 2 (6.37)
Note that q = 2y 0 r We conclude:

G(r) = 8 3r 2rd -1 2 y 0 (r) 2 + 2y 0 (r) (1 + y 0 (r)) 2 + 2y 0 (r) 1 + y 0 (r) -ln(1 + y 0 (r)) + 4y 0 (r) 3r 1 -y 0 (r) 1 + y 0 (r) 2 (6.38)
Because of the logarithm, G is not linear in r. We set d = 1 for the plot displayed in Figure 6.5.

Appendix

Proof of lemma 6.3 If (q, h, x) is feasible, then

U i (c i , c i ) ≥ U i (c i , c i ) and U i (c i , c i ) ≥ U i (c i , c i ) (6.39)
implies

(Q i (c i ) -Q i (c i ))(c i -c i ) ≤ 0 (6.40)
which means that Q i is non-increasing. We get (6.4) with the envelop theorem.

Conversely if (q, h, x) satisfies (6.3) to (6.6), then 6.9. APPENDIX 137 which is non-negative since Q i is non-increasing. Then we get the voluntary participation constraint combining (6.4) with V i (c i ) ≥ 0.

U i (c i , c i ) -U i (c i , c i ) = X(c i ) -X(c i ) + c i (Q i (c i ) -Q i (c i )) (6.41) = V (c i ) + c i Q(c i ) -(V (c i ) + c i Q(c i )) + c i (Q i (c i ) -Q i (c i )) (6.42) = c i c i Q i (s)ds -(c i Q(c i ) -c i (Q i (c i ))) = c i c i Q i (s) -Q(c i )ds, ( 6
Proof of lemma 6.4 From (6.2) we get that

C x i (c)f (c)dc = C c i q i (c i , c -i )f (c)dc + C i V i (c i )dc i ,
The second term on the right-hand side can be written (by using (6.4) and changing the order of integration) as:

C i V i (c i )dc i = C i [V i (c i ) + c i c i Q i (s i )ds i ]f i (c i )dc i = V i (c i ) + C i Q i (s i )[ s i c i f i (c i )dc i ]ds i = V i (c i ) + C i Q i (c i )F i (c i )dc i = V i (c i ) + C i C -i q i (c i , c -i )F i (c i )dc i = V i (c i ) + C q i (c) F i (c i ) f i (c i ) f (c)dc
Replacing this last expression and noticing that in any optimal mechanism V i (c i ) = 0 the result follows.

The Solution to the pointwise optimization problem

For given c 1 and c 2 , we analyze the seller's cost minimization problem, where he faces modified costs L 1 (c 1 ) and L 2 (c 2 ). In the case of section 3,

L i (c i ) = J i (c i ), while in section 4, L i (c i ) = c i . min q,h 2 i=1 L i (c i )q i s.t. q i -h i + h -i ≥ r 2 [h 2 1 + h 2 2 ] + d for i = 1, 2 q i , h i ≥ 0 for i = 1, 2
Without loss of generality we consider c 1 ≤ c 2 (we can just change indices otherwise). In that case we get h 2 = 0, and the constraints q 1 ≥ 0, h 1 ≥ 0 never bind. The problem then 138

CHAPTER 6. COST-MINIMIZING REGULATION becomes min q,h 2 i=1 L i (c i )q i s.t. q 1 -h 1 ≥ r 2 [h 2 1 + h 2 2 ] + d q 2 + h 1 ≥ r 2 [h 2 1 + h 2 2 ] + d q i , h i ≥ 0 for i = 1, 2
Writing the Lagrangian and taking FOC we get:

-L 1 (c 1 ) + λ 1 = 0 (6.44) -L 2 (c 2 ) + λ 2 + µ = 0 (6.45) -λ 1 -λ 1 rh 1 + λ 2 -λ 2 rh 1 = 0 (6.46) -q 1 + h 1 + d + r 2 h 2 1 ≤ 0 (6.47) -q 2 -h 1 + d + r 2 h 2 1 ≤ 0 (6.48) -q 2 ≤ 0 (6.49) µ, λ 1 , λ 2 ≥ 0 (6.50)
The solution can be broadly divided into two cases, depending on whether the positivity constraint q 2 ≥ 0 binds or not.

Case 1: d -L 2 (c 2 )-L 1 (c 1 ) r(L 2 (c 2 )+L 1 (c 1 )) + (L 2 (c 2 )-L 1 (c 1 )) 2 2r(L 2 (c 2 )+L 1 (c 1 )
) 2 ≥ 0 This case corresponds to the non-binding case, and the solution is given by µ = 0

λ i = L i (c i ) q 1 = d + L 2 (c 2 ) -L 1 (c 1 ) r(L 2 (c 2 ) + L 1 (c 1 )) + (L 2 (c 2 ) -L 1 (c 1 )) 2 2r(L 2 (c 2 ) + L 1 (c 1 )) 2 q 2 = d - L 2 (c 2 ) -L 1 (c 1 ) r(L 2 (c 2 ) + L 1 (c 1 )) + (L 2 (c 2 ) -L 1 (c 1 )) 2 2r(L 2 (c 2 ) + L 1 (c 1 )) 2 h 1 = L 2 (c 2 ) -L 1 (c 1 ) r(L 2 (c 2 ) + L 1 (c 1 )) Case 2: d -L 2 (c 2 )-L 1 (c 1 ) r(L 2 (c 2 )+L 1 (c 1 )) + (L 2 (c 2 )-L 1 (c 1 )) 2 2r(L 2 (c 2 )+L 1 (c 1 )
) 2 < 0 This is the binding case (it can only happen if 2dr < 1), and the solution is: Motivated by market power in electricity market we introduce a mechanism design in [START_REF] Figueroa | Cost-minimizing regulations for a wholesale electricity market[END_REF] for simplified markets of two agents with linear production cost functions. In standard procurement auctions, the market power resulting from the quadratic transmission losses allow the producers to bid above their true value (i.e. production cost). The mechanism proposed in the previous paper reduces the producers margin to the society benefit. We extend those results to a more general market made of a finite number of agents with piecewise linear cost functions, which make the problem more difficult, but at the same time more realistic. We show that the methodology works for a large class of externalities.

µ = L 1 (c 1 ) + L 2 (c 2 ) - 2L 1 (c 1 ) √ 1 -2dr λ 1 = L 1 (c 1 ) 6.9. APPENDIX 139 λ 2 = 2 - √ 1 -2dr √ 1 -2dr L 1 (c 1 ) q 1 = 2 1 - √ 1 -2dr r q 2 = 0 h 1 = L 2 (c 2 ) -L 1 (c 1 ) r(L 2 (c 2 ) + L 1 (c 1 )) 142CHAPTER 7.

MECHANISM DESIGN AND ALLOCATIONS FOR NETWORK MARKETS

We also provide two algorithms to solve the principal allocation problem.

Introduction

Our purpose is to show how monopolistic behaviors in network markets can be opposed using mechanism design. We point out that the optimal mechanism we obtain has a surprisingly simple expression. We complete this work with algorithmic tools for the computation of this mechanism. Following a model proposal already discussed in [START_REF]Monopolistic competition in electricity networks with resistance losses[END_REF][START_REF]Equilibrium analysis of electricity auctions[END_REF][START_REF] Figueroa | Cost-minimizing regulations for a wholesale electricity market[END_REF],

we consider a geographically extended market where a divisible good is traded. Each market participant is located on a node of a graph, and the nodes are connected by edges. The good can travel from one node to another through those edges at the cost of a quadratic loss. We will use the word principal to designate what could also be called in the literature a central operator, or in the context of electricity markets, an ISO. This principal, who aggregates the (inelastic) demand side, has to match locally -i.e. at each node -production and demand at the lowest expense through a procurement auction. As argued in [START_REF] Figueroa | Cost-minimizing regulations for a wholesale electricity market[END_REF] this setting is relevant to describe some real electricity markets, but it could also be used in other markets where a good is transported. There is a clear antagonism between the market participants: the operator wants to minimize its expected cost while the producers want to maximize their expected profit. So there is a transaction and a commitment between each agent and the principal, and at the same time, there is a competition among the agents.

In a standard procurement auction, the market power resulting from the quadratic line losses allow the producers to bid above their true value (i.e. production cost) [START_REF]Monopolistic competition in electricity networks with resistance losses[END_REF]. The mechanism reduces the producers margin and decrease the social cost represented in this case by the optimal value of the principal. The optimal auction design was introduced by Myerson in 1981 [START_REF] Myerson | Optimal auction design[END_REF]. We build on an electricity market model introduced by the second 7.1. INTRODUCTION 143 author in two previous papers [START_REF]Equilibrium analysis of electricity auctions[END_REF] and [START_REF]Monopolistic competition in electricity networks with resistance losses[END_REF]. The authors wrote a brief presentation of this model in [START_REF] Heymann | Mechanism design and auctions for electricity network[END_REF]. Other models were proposed for example in [START_REF] Aussel | Electricity spot market with transmission losses[END_REF], [2], and [START_REF] Hu | Using epecs to model bilevel games in restructured electricity markets with locational prices[END_REF], with a focus on the existence of a market equilibrium. Concerning the techniques we use in this paper the reader can refer to [START_REF] Laffont | The theory of incentives: the principal-agent model[END_REF], [START_REF] Nisan | Introduction to mechanism design (for computer scientists)[END_REF], [START_REF] Aumann | Handbook of game theory with economic applications[END_REF] chapter 45 and [87] for general introductions on principal agent theory, mechanism design, game theory and lattices theory respectively.

We consider -similarly to [START_REF] Figueroa | Cost-minimizing regulations for a wholesale electricity market[END_REF]-that everybody knows the demand at each node before the interactions start and that the production cost of each agent is private information. In a standard setting the agents first bid their cost and then the principal, knowing the bids, a posteriori minimizes its cost. So in a standard setting the principal is a bid taker. The producers know they influence the allocation and compete with each other to maximize their individual profit. Since the demand is known by everyone, everyone can guess the principal reaction once the bids have been announced: we can virtually remove the principal from the interaction in the standard setting and consider that the agents are the players of a game with incomplete information (since the agents do not know their fellow agents preferences). This equivalence is true provided that the agents are not communicating with each others. The mechanism design consists in changing the payoff function of this game -subject to constraints we detail in this article-so as to minimize a priori (i.e. before the bids are announced) the principal cost. Allowing the principal to strike first by revealing a committing rule gives him a strategic advantage in the negotiation.

We restrict our discussion to determinist demand, but the reasoning extends naturally to random demand as long as any possible realization of the demand satisfies the model assumptions. Indeed since the optimal mechanism constructed in this article is incentive compatible, then a random version (where the demand is revealed after the producers bidding phase, as in [START_REF]Equilibrium analysis of electricity auctions[END_REF]) would be realization-wise incentive compatible, and so incentive compatible. Observe the mechanism we propose in the following could be adapted to elastic, piecewise linear demand.

Our first main result is the mechanism design characterization. Interestingly the allocation procedures for the optimal and the standard mechanism are the same (one just needs to modify the input of the allocation procedure of the standard mechanism to get the allocation of the optimal mechanism). Our second main result is a principal allocation algorithm based on a fixed point. The fixed point could be interpreted as cooperating agents trying to minimize a global criteria by sharing relevant information. Our implementation of the algorithm gives good results against standard methods. We point out that the numerical computation of Nash equilibrium for the procurement auction (important to compare the optimal mechanism and the standard auction setting) requires an efficient algorithm to compute the allocation. Some other additional facts are presented within the paper: the smoothness of the allocation functions (q and Q), a decreasing rate estimation for the fixed point iterations, some results of numerical experiments with the fixed point algorithm, and a specific algorithm for the two-agent case.

144CHAPTER 7. MECHANISM DESIGN AND ALLOCATIONS FOR NETWORK MARKETS

We describe the market in the next section. In §7.3 we introduce and solve the mechanism design problem. In §7.4, we study the standard allocation problem and propose an algorithm to solve it. In §7.5 we propose a different algorithm for the 2-agent standard allocation problem. In §7.6 we sum up and comment the main results and propose some continuations for this work. A reader only interested in mechanism design could read §7.2, §7.3 and §7.4 only, whereas readers interested only in allocation algorithms could concentrate on §7.4 and §7.5.

Market description

The production cost of each agent is assumed to be piecewise linear, non decreasing and convex in the quantity produced. This class of functions is sufficiently rich to represent real life problems and sufficiently simple for theoretical study. In this work we need to assume that the production levels at which there is a slope change are known in advance and exogenous (i.e. the agents cannot choose them). Then without loss of generality we assume that there is a quantity q such that the changes of slope only occur at the multiples of q. Thus, the authors find it practical to write the production cost functions in the form

C c (q) = N j=1 c j min((q -(j -1)q) + , q), (7.1)
where N ∈ N and the c j are some slopes coefficients specific to the agent, while q is the quantity produced. We will sometimes refer to the vector of the c j as the cost vector (of the agent). If we denote by q j i the quantity produced by agent i at marginal cost c j i , then q j i = min((q i -(j -1)q) + , q), where q i is the total quantity produced by this agent. Let c * < c * ∈ R * + and C a set of non-decreasing N -tuples of [c * , c * ]. To each element c of C we associate the piecewise linear cost function q → C c (q). Throughout the paper we set, for any c ∈ C, c N +1 = c * to simplify notations in some proofs. Note that in practice a capacity constraint of the type q ≤ j q for a given agent can be implemented by setting its (j + 1) th slope c j+1 equal to a big positive number. If an agent of cost vector c produces a quantity q and receives a transfer x, then its profit is

u i = x -C c (q). (7.2)
There are n agents numbered from 1 to n in the market. We denote I = [1 . . . n] and use generically the letter i to refer to a specific agent, and -i to refer to I\{i}. We denote J = [1 . . . N ] and we will use generically j for the cost coefficients of the jth segment (starting from 1). The agents are dispatched on the n nodes of a graph. At each node i we find the corresponding agent i and a local demand d i . The nodes are connected by undirected edges. We write V (i) the set of nodes different from i connected to i. Obviously

MARKET DESCRIPTION

145 if i 1 ∈ V (i 2 ) then i 2 ∈ V (i 1 ). We denote E = {(i 1 , i 2 ) : i 1 ∈ V (i 2 )} the set of undirected edges. For each (i 1 , i 2 ) ∈ E, we introduce a quadratic loss coefficient r i 1 ,i 2 such that r i 1 ,i 2 = r i 2 ,i 1 .
In the context of electricity market, this quadratic coefficient corresponds to the Joule effect within the lines. We make the non restricting assumption that N is big enough so that in what follows production at each node is smaller than qN .

We assume that both the agents and the principal are risk neutral: they maximize their expected profit. If the principal proposes to pay a price x i to agent i to make her produce a quantity q i -this agent being free to accept or decline the offer-and if the agent i has a production cost defined by c i , then she accepts the offer if

x i -C c i (q i ) ≥ 0. (7.3)
So for agent i, either x i ≥ C c i (q i ) or q i = 0. Thus, if the principal knew the cost vectors c i , he would solve an allocation problem with those c i , and then bid to the agents the quantity and the payments corresponding to the solution of the allocation problem. But the principal does not know the cost vectors, so instead what happens is that the agents tell her some values for the c i (not necessary their real cost vectors), and then the principal decides based on those values. In this case, previous works [START_REF]Monopolistic competition in electricity networks with resistance losses[END_REF] showed that the agents can get non-zero profits and bid above their production costs. The question we adress is how to reduce their margins.

To do so, we need to consider an intermediate scenario between the one in which the agent knows nothing (and is a price taker), and the one in which he knows everything (and optimizes directly the whole system as a global optimizer). Each agent is characterized by an element f i , which is a probability density of support included in C and an element c i of C drawn according to f i . Only agent i knows c i , which is private information. The other agents and the principal only know the probability f i with which it was drawn. The density f i corresponds to the public knowledge on agent i production costs so the principal won't accept any bid c i that is not in the support of f i . We assume that the cost slopes are not correlated for a given agent and between agents, i.e. their laws f j i are independent. In particular

f i (c i ) = j∈J f j i (c j i ).
In such situation, it makes sense to define

f -i (c -i ) = i ∈I\i f i (c i ) and f (c 1 , .., c n ) = i∈I f i (c i ), (7.4)
and E (respectively E c -i ) the mean operator with respect to f (respectively f -i ). The density f (resp. f -i ) represents the uncertainty from the principal (resp. agent i) perspective.

To simplify notations we will use the symbole C n to denote the product of the supports of the f i . We denote by Q the set of allocation functions -which are the applications from C n to R n + , by X the set of payments functions -which are the applications from C n to R n , and by H the set of flow functions -which are the applications from C n to R E . A direct 146CHAPTER 7. MECHANISM DESIGN AND ALLOCATIONS FOR NETWORK MARKETS mechanism is a triple (q, x, h) ∈ (Q, X, H). Let (q, x) ∈ (Q, X). For this payment function and this allocation function, the expected profit of agent i of type c i and bid c i is

U i (c i , c i ) = E -i u i = X i (c i ) - j∈J c j i Q j i (c i ). (7.5)
where the capitalized quantities

Q j i (c i ) = E -i min((q i (c i , c -i ) -(j -1)q) + , q) and X i (c i ) = E -i x i (c i , c -i ) (7.6)
correspond to the average of their non capitalized counterpart. We also denote by

V i (c i ) = U i (c i , c i ). (7.7)
the expected profit of agent i if she is of type c i and bids her true production cost.

In this work we make five assumptions.

• First, the non overlapping working zones assumption is that if we denote by C i the support of f i , then C i should be of the form:

C i = [c 1- i , c 1+ i ] × . . . × [c N - i , c N + i ] (7.8)
with c 1- i < c 1+ i < . . . < c N - i < c N + i .
We could interprete each segments over which the agent has a constant marginal cost as a working zone with identified productive assets. The expertise of the market participants should allow them to, based on the working zone, assess the marginal cost of the agent. This makes senses for instance if the setting is repeated over time. This estimation need to be precise enough so that there is no chance that it corresponds to another working zone. We use this item in particular in the proof of lemma 7.6.

• For i ∈ I, j ∈ J and c i ∈ C i let

K j i (c i ) = c j i c j- i f i (c -j i , s)ds f i (c i ) . (7.9)
We point out that by independence of the laws of the c j i ,

K j i (c i ) = c j i c j- i f j i (s)ds/ f j i (c j i ) = K j i (c j i ).
So K j i is simply the ratio of the cumulative distribution and the probability density for c j i . The second assumption is the discernability assumption. For all i ∈ I and c i ∈ C i , the virtual cost J i,j (c j i ) = c j i + K j i (c j i ) is increasing in j. As demonstrated in the next section, the virtual cost could be interpreted as the real marginal cost augmented by a marginal information rent. The item imposes the marginal information rent to be such that for any bid, the virtual marginal prices are 7.3. MECHANISM DESIGN 147 increasing, i.e. the virtual production cost function is convex. The item is necessary to show the independence property of the reformulation in Lemmas 7.8 and 7.9.

• Third, in the following we assume that, for all j ∈ J, i ∈ I and c i ∈ C i ,

c j i → c j i + K i j (c j i ) (7.10)
is increasing in c j i . This is the piecewise linear adaptation of the classic monotone likelihood ratio property assumption encountered in mechanism design [START_REF] Myerson | Optimal auction design[END_REF][START_REF] Correa | On the planners loss due to lack of information in bayesian mechanism design[END_REF]. It is true in particular for log-concave functions. The assumption ensures that the pointwise allocation resulting from the mechanism design problem reformulation is decreasing in the bids. We refer to this assumption in the proof of Theorem 7.11.

• Fourth, for §7.3 and §7.4 only, we assume that

d i - i ∈V (i) 1 2r i,i
< 0, and

d i + i ∈V (i) 3 2r i,i > N q, (7.11)
i.e. we require the r i,j to be small enough. Note that the bigger the demand, the smaller the r should be, which is a limit to the generality of the approach. This assumption ensures that, for any agent i and working zone k, no matter what the other agents are doing, it is still possible to find a (virtual) marginal price that would ensure a production of exactly k q in an optimal allocation. If the loss rates r ii are all too big for a given agent i, then the line losses can be bigger than the flow through the lines: the lines of agent i can be all saturated. This hypothesis is necessary to ensure the existence of one of the building block of the fixed point operator presented in §7.4. We point out that this is the multidimensional version of the assumption 1 -2rd ≥ 0 in [START_REF] Figueroa | Cost-minimizing regulations for a wholesale electricity market[END_REF].

• Fifth, for regularity issues we make the non restrictive assumption that it is not possible to produce a multiple of q at each node and satisfy exactly the nodal constraints.

This is non restrictive because if this was the case we could perturb the demand to ensure the condition is satisfied. This hypothesis will be important in the proof of the regularity of q (in lemma 7. [START_REF] Betts | Practical methods for optimal control and estimation using nonlinear programming[END_REF]), from which the regularity of Q follows.

To finish with the market presentation, we introduce the products of the type sets

C n = i∈I C i and C -i = i ∈I\{i} C i .

Mechanism Design

We start with the revelation principle as expressed in [START_REF] Gibbons | Game theory for applied economists[END_REF].

148CHAPTER 7. MECHANISM DESIGN AND ALLOCATIONS FOR NETWORK MARKETS Theorem 7.1 (Revelation Principle). To any Bayesian Nash equilibrium of a game of incomplete information, there exists a payoff-equivalent direct revelation mechanism that has an equilibrium where the players truthfully report their types.

According to the revelation principle, we can look for direct truthful mechanisms. There is a priori no reason why the agents should willingly report their types. So we need to add a constraint on the design to enforce truthfulness. This means that the profit of any agent i of type c i should be maximal when agent i bids her true type c i i.e. for all (c i , c i )

U i (c i , c i ) ≥ U i (c i , c i ). (IC) (7.12)
This is the incentive compatibility (IC) constraint. In addition, since we want all agents to participate in the market, we need the participation constraint imposing that for all c i

U i (c i , c i ) ≥ 0. (P C) (7.13)
Without this constraint, the principal would optimize as if the agents would accept any deal (even deals where they would make a negative profit). The last constraint is that the supply should be at least equal to the demand at every node. The supply available at a given node is equal to the production augmented by the imports minus the exports and the line losses. As explained earlier, there is a loss when some quantity h i,i of the divisible good is sent from one node i to another i . This loss is equal to r i,i h 2 i,i , where r i,i is a multiplicative constant. In order to obtain symmetric expressions, we will proceed as if half of this quantity was lost by the sender, and the other half by the receiver (see for instance [START_REF]Monopolistic competition in electricity networks with resistance losses[END_REF]). Note that we could have equivalently used signed flows, but we would have lost some symmetry in the formulation. Then the supply and demand constraint writes, for all i ∈ I and c ∈ C n ,

q i (c) + i ∈V (i) h i ,i (c) -h i,i (c) - h 2 i,i (c) + h 2 i ,i (c) 2 r i,i ≥ d i . (SD) (7.14)
We point out that for an optimal allocation (see §7.4) , h i,i h i ,i = 0.

The principal decision is a triple (q, x, h) ∈ (Q, X, H). This decision is made under the constraints (IC), (PC) and (SD). Since we assume that the principal is risk neutral, his goal is to minimize his average cost, i.e. mathematically his criterion is equal to the average of the sum of the payments. Finally the optimal mechanism is the solution of

7.3. MECHANISM DESIGN 149 Problem 1. minimize (q,x,h)∈(Q,X,H) i∈I Ex i (c) subject to ∀c ∈ C n , ∀i ∈ I : q i (c) + i ∈V (i) h i ,i (c) -h i,i (c) - h 2 i,i (c) + h 2 i ,i (c) 2 r i,i ≥ d i (SD) ∀c ∈ C n , ∀(i, i ) ∈ E : h i,i (c) ≥ 0 ∀i ∈ I, ∀(c i , c i ) ∈ C 2 i : U i (c i , c i ) ≥ U i (c i , c i ) (IC) ∀i ∈ I, ∀c i ∈ C i : U i (c i , c i ) ≥ 0 (P C).
We now proceed to solve the optimal mechanism design problem, which is a functional optimization problem with an infinity of constraints, some of which are expressed with integrals. The essential observation is that this complicated problem is equivalent to a much simpler one. The proof relies on the comparison with two intermediate problems: minimize

Problem 2. minimize (q,x,h)∈(Q,X,H) i∈I Ex i (c) subject to. ∀c ∈ C n , ∀i ∈ I : q i (c) + i ∈V (i) h i ,i (c) -h i,i (c) - h 2 i,i (c) + h 2 i ,i (c) 2 r i,i ≥ d i (SD) ∀c ∈ C n , ∀(i, i ) ∈ E : h i,i (c) ≥ 0 ∀i ∈ I, ∀j ∈ J, (c -j , t 1 , t 2 ), (c 1 , . . . , t k , . . . , c N ) ∈ C i , : V i (c 1 , .., c j-1 , t 1 , c j+1 .., c N ) -V i (c 1 , .., c j-1 , t 2 , c j+1 .., c N ) = t 2 t 1 Q j i (c 1 , .., c j-1 , s, c j+1 .., c N )ds (H1) ∀i ∈ I, ∀(c, c ) ∈ c 2 : (c -c ).(Q i (c) -Q i (c )) ≤ 0, (H2) ∀i ∈ I, ∀c i ∈ C i : V i (c i ) ≥ 0 (P C),
(q,h)∈(Q,H) E i∈I j∈J q j i (c)(c j i + K j i (c j i ))
subject to

∀(c, i) ∈ C n × I : q i (c) + i ∈V (i) h i ,i (c) -h i,i (c) - h 2 i,i (c) + h 2 i ,i (c) 2 r i,i ≥ d i (SD) ∀c ∈ C n , ∀(i, i ) ∈ E : h i,i (c) ≥ 0. ∀c ∈ C i , ∀i ∈ I : x i (c) = j∈J q j i (c)c j i + c j+ i c j i q j i (c 1 i . . . c j-1 i , t, c (j+1)+ 1 . . . c N + i ; c -i )dt.
The inequality on the scalar product in (H2) is the piecewise linear equivalent of a monotonicity condition already encountered in [START_REF] Figueroa | Cost-minimizing regulations for a wholesale electricity market[END_REF]. The first two problems are very similar, but (IC) has been replaced by (H1) and (H2) and (PC) is expressed in terms of V instead of U . This replacement is a trick introduced by Myerson in his 1981 paper. We will show later on how we can compare Problems 2 and 3, but note that Problem 3 is really simpler, as the optimization part can be solved pointwise (and x can be deduced from this pointwise optimization). The main result of this paper is that the three problems have the same solution.

Necessary conditions for Problem 1

We derive some necessary conditions for a solution of Problem 1. In fact, we only use constraint (IC) to deduce the two next results. The first lemma indicates that any solution of the first problem should be such that Q is monotonous. This is a classic result already introduced for instance in [START_REF] Myerson | Optimal auction design[END_REF] and [START_REF] Figueroa | Cost-minimizing regulations for a wholesale electricity market[END_REF]. The novelty here is that in the context of piecewise linear production cost functions, this monotonicity result is expressed in a vectorial sense.

Lemma 7.2 (Q monotonicity). If (q, x, h) is admissible for Problem 1, then for all agent i ∈ I and all

(c i , c i ) ∈ C 2 i (c i -c i ).(Q i (c i ) -Q i (c i )) ≤ 0 (7.15)
where . is the scalar product in R N .

Proof. We omit the i in the proof, as it plays no role. First, let (c, c ) ∈ C 2 i by the (IC) constraint,

U (c, c) ≥ U (c, c ) and U (c , c ) ≥ U (c , c) (7.16)
i.e. X(c) -

j∈J c j Q j (c) ≥ X(c ) - j∈J c j Q j (c ) X(c ) - j∈J c j Q j (c ) ≥ X(c) - j∈J c j Q j (c). (7.17)

MECHANISM DESIGN 151

We get the lemma after summation of the two inequalities and simplification.

Lemma 7.2 indicates that an agent should be producing less on average in her ith working zone if she is biding a higher marginal cost for this working zone.

Lemma 7.3. If (q, x, h) is admissible for Problem 1 then for any agent (omitting i) for any c, t 1 and t 2

V (c 1 , . . . , c j-1 , t 1 , c j+1 , . . . , c N ) =V (c 1 , . . . , c j-1 , t 2 , c j+1 , . . . , c N ) - t 1 t 2 Q j (c 1 , . . . , c j-1 , s, c j+1 , . . . , c N )ds (7.18) Proof. The inequality U (c, c) ≤ U (c, c ) implies that c → U (c, c ) is maximal at c for any c ∈ C i . Moreover, t → U ((c 1 , .., c j-1 , t, c j+1 .., c N ), c) = X(c) - k∈J\{j} c k Q k (c) -tQ j (c) (7.19)
is absolutely continuous, differentiable with respect to t for all c, and its derivative is

-Q j (c)
. By definition of q j , Q j ≤ q. So applying the envelope theorem we get the result.

Necessary conditions for Problem 2

We derive some necessary conditions for a solution of Problem 2.

Lemma 7.4. If (q, x, h) is an optimal solution of Problem 2 then (omitting i) for all c ∈ C i

V (c) = j∈J c j+ c j Q j (c 1 . . . c j-1 , t, c (j+1)+ , . . . , c N + )dt. (7.20)
Proof. According to (H1)

j∈J c j+ c j Q j (c 1 . . . c j-1 , t, c (j+1)+ , . . . , c N + )dt = j∈J V (c 1 , .., c j-1 , c j , c (j+1)+ , . . . , c N + ) -V (c 1 , .., c j-1 , c (j)+ , . . . , c N + ) = V (c) -V (c 1+ , . . . , c N + ).
This is an expression for V (c) as a sum of a positive function of c and a constant V (c 1+ , . . . , c N + ).

It is clear that to optimize the criteria, this constant should be as small as possible. The participation contraint (PC) imposes that V (c 1+ , . . . , c N + ) ≥ 0, therefore V (c 1+ , . . . , c N + ) = 0.

152CHAPTER 7. MECHANISM DESIGN AND ALLOCATIONS FOR NETWORK MARKETS

A consequence of this is:

Corollary 7.5. If (q, x, h) is an optimal solution of Problem 2 then for all i ∈ I,

V i (c 1+ i , . . . , c N + i ) = 0. (7.21)
Proof. See the proof of Lemma 7.4.

Corollary 7.5 means that if an agent bids a production cost functions that is the maximum of what he could bid, he should not make any profit, and so he should be paid exactly his production cost. We see with this lemma that if the public information is inaccurate and the real cost of an agent is higher than what could be expected, then there is a risk that the participation constraint is not satisfied. On the other hand, it should not be surprising that an agent can have a zero profit: remember that in the extreme case in which the principal knows everything (discussed in §7.2), the agents do not make any profit.

Another consequence of lemma 7.4 is Lemma 7.6. If (q, x, h) is an optimal solution of Problem 2, the expected profit of agent i (over his type) is

EV i (c) = j∈J (c 1 ..cn)∈C i Q j i (c 1 , . . . , c j , c (j+1)+ , . . . c N + )K j i (c)f i (c)dc. (7.22)
Proof. By Lemma 7.4 and Fubini's lemma, EV i (c) is equal to

E j∈J c j+ c j Q j i (c 1 , . . . , c j-1 , t, c (j+1)+ , . . . c N + )dt = j∈J c -j ∈C -j c j+ c j =c j- c j+ t=c j Q j i (c 1 , . . . , c j-1 , t, c (j+1)
+ i , . . . c N + i )f i (c)dtdc j dc -j .
Our task is now to compute the inner term. Applying again Fubini's lemma, this term is equal to

c j+ c j =c j- c j+ t=c j Q j i (c 1 , . . . , c j-1 , t, c (j+1)+ , . . . c N + )f i (c)dtdc j = c j+ t=c j- t c j =c j- Q j i (c 1 , . . . , c j-1 , t, c (j+1)+ , . . . c N + )f i (c)dc j dt = c j+ t=c j- Q j i (c 1 , . . . , c j-1 , t, c (j+1)+ , . . . c N + )( t c j =c j- f i (c)dc j )dt = c j+ t=c j- Q j i (c 1 , . . . , c j-1 , t, c (j+1)+ , . . . c N + )( t c j =c j- f i (c) f i (c -j , t) dc j )f i (c -j , t)dt = c j+ t=c j- Q j i (c 1 , . . . , c j-1 , t, c (j+1)+ , . . . c N + )K j i (t)f i (c -j , t)dt = 7.3. MECHANISM DESIGN 153 c j+ c j =c j- Q j i (c 1 , . . . , c j-1 , c j , c (j+1)+ , . . . c N + )K j i (c j )f i (c i )dc j
We get the lemma by summing all the inner terms.

Lemma 7.7. If (H1) is satisfied, then for any

(a, b) ∈ C 2 i (omitting i) X(a) -X(b) = j∈J [a j Q j (a) -b j Q j (b) + b j a j Q j (b 1 . . . b j-1 , t, a j+1 . . . a N )dt] (7.23)
Proof. Because of its length the proof is detailled in Appendix 7.7

Lemma 7.8. If (q, x, h) verifies (H1) and (H2) and

Q j i is independent of c j i for j > j, then for all (c, c) ∈ C 2 U (c, c) ≥ U (c, c). (7.24)
Proof. Since (H1) is satisfied, equation (7.23) of Lemma 7.7 applies. We combine this relation with the definition of the expected profit U from (7.5). We obtain:

U (c, c) -U (c, c) = j∈J c j Q j (c) -cj Q j (c)+ cj c j Q j (c 1 , ..., cj-1 , t, c j+1 , ...c N )dt + c j Q j (c) -c j Q j (c) = j∈J (c j -cj )Q j (c 1 , ..., cj-1 , cj )) + cj c j Q j (c 1 , ..., cj-1 , t)dt = j∈J cj c j Q j (c 1 , ..., cj-1 , t) -Q j (c 1 , ..., cj-1 , cj )dt,
where we used the independence hypothesis for the second equality. By (H2), which implies the decreasingness of Q j with respect to c j i when all other quantities are fixed, if c j < cj then for any t ∈ [c j , cj ], Q j (t) -Q j (c j ) ≥ 0. Otherwise, we use the formula

t ∈ [c j , c j ] verifies Q j (t) -Q j (c j ) ≤ 0. So U (c, c) -U (c, c) is non negative.

Necessary conditions for Problem 3

We derive some properties for Problem 3. Lemma 7.9. There is an optimal solution (q, x, h) for Problem 3 such that q j i (and

Q j i ) is independent of c k i for k = j.
Proof. First note that x is not taking any role in the optimization problem: it is defined afterward. The only real optimization variables are then q and h. Remember that q j i is 154CHAPTER 7. MECHANISM DESIGN AND ALLOCATIONS FOR NETWORK MARKETS defined as a function of q by q j i = min((q i -(j -1)q) + , q). The constraints are defined for each c ∈ C n and the integral criterion is in fact a sum of independent criteria depending on q(c) for c ∈ C n . Therefore we can solve Problem 3 with a pointwise optimization.

By the discernability assumption, for any c ∈ C n and i ∈ I, c j i + K j i (c j i ) is increasing in j. So for all c ∈ C n , i ∈ I, j∈J q j i (c)(c j i + K j i (c j i )) is a convex criteria in q i and so the pointwise problem corresponds to Problem 4 of §7.4. In particular, we can apply Lemma 7.15 from the next section. So q j i only depends on c j i and c -i . This property is preserved by integration over the c -i : Q j i only depends on c j i .

We point out that, since the pointwise problem has a unique solution, the pointwise optimal solution introduced in the proof is uniquely defined.

Theorem 7.10. If (q, x, h) is the pointwise optimal solution of Problem 3 and

K j i is smooth in c j i for (i, j) ∈ I × J and c ∈ C i , then for all i ∈ I, Q i is C ∞ over C i .
Proof. We will use some results and notations from 7.4.2. Remember that c j i → c j i +K j i (c j i ) is increasing, so by composition with smooth bijection, we can do the reasoning as if the costs involved were c j i instead of c j i + K j i (c j i ). First according to Lemma 7.16, q i is continuous. Since q i is bounded, we can apply the dominated convergence theorem to show that Q i is continuous. Then we proceed by mathematical induction. Assume that Q i is C l , then take c 0 i ∈ C i and c k i a sequence in C i that converges to c 0 i . Since Ŝ = ∪ k∈N S(c k i ) is a countable union of null measured set (by Lemma 7.34), its measure is zero. So without changing the results, we can compute the integrals on C -i \ Ŝ instead of C -i . Since q i and its derivatives are bounded, we can apply the dominated convergence theorem to compute the limit of

Q (l) i (c 0 i )-Q (l) i (c k i ) c 0 i -c k i
as k goes to +∞ as the integral of a limit. Since we removed the point over which this limit was not defined, we get that

Q (l) i (c 0 i )-Q (l) i (c k i ) c 0 i -c k i
has a limit, and this limit does not depend on the sequence c k i . So Q i is l + 1 times derivable at c i , for all c i . We conclude by induction.

Resolution of the mechanism design problem

Last but not least, we state the main result of the Section.

MECHANISM DESIGN 155

Theorem 7.11. Let (q j i , h) be defined such that for any c ∈ C n , (q j i (c j i , c -i ), h(c)) solves minimize q j i ,x,h i∈I j∈J

q j i (c j i , c -i )(c j i + K j i (c j i )) subject to 0 ≤ q j i ≤ q j∈J q i i (c j i , c -i ) + i ∈V (i) h i ,i (c) -h i,i (c) - h 2 i,i (c) + h 2 i ,i (c) 2 r i,i ≥ d i h i,i (c) ≥ 0,
and set

q i (c) = j∈J q j i (c j i , c -i ) and x i (c) = j∈J q j i (c j i , c -i )c j i + c j+ i c j i q j i (t, c -i )dt, (7.25)
then (q, h, x) solves the optimal mechanism design problem (Problem 1).

Proof.

• First note that (q, h, x) is the pointwise solution of Problem 3 so it is optimal for Problem 3, moreover, by construction (q, h, x) satisfies (SD) and h ≥ 0.

• Then note that by Lemma 7.6, (q, h, x) solves a relaxation of Problem 2, but is it admissible for Problem 2 ?

• By definition of V (omitting i),

V (c 1 . . . a j . . . c N ) -V (c 1 . . . b j . . . c N ) = Ex(c 1 . . . a j . . . c N ) -x(c 1 . . . a j . . . c N ) -[Q j (a j )a j -Q j (b j )b j ] = Eq j i (a j , c -i )a j + c j+ i a j q j i (t, c -i )dt -Eq j i (b j , c -i )b j - c j+ i b j q j i (t, c -i )dt -[Q j (a j )a j -Q j (b j )b j ] = E b j a j q j i (t, c -i )dt = b j a j Q j i (t)dt
where we used the definition of x, the definition of Q and Fubini lemma's for the second, third and fourth equalities. So (q, h, x) satisfies (H1).

• By construction, q j i is non-increasing in c j i + K j i (c j i ) then using the third assumption,

q j i is non-increasing in c j i so for any (a, b, c -i ) ∈ C 2 × C -i , (a j i -b j i )(q j i (a j i , c -i ) - q j i (b j i , c -i )) ≤ 0, so by integration with respect to c -i , (a j i -b j i )(Q j i (a j i ) -Q j i (b j i ) ≤ 0 and then by summation over j, (c -c ).(Q i (c) -Q i (c )) ≤ 0, i.e. (H2) is satisfied. • Since (H1) is satisfied, V i (c i ) ≥ V i (c + i ).
Moreover, V i (c + i ) = 0 by construction of x. So the participation constraint (PC) is satisfied.

156CHAPTER 7. MECHANISM DESIGN AND ALLOCATIONS FOR NETWORK MARKETS

• Therefore (q, h, x) is admissible for Problem 2. So it solves Problem 2.

• Since (q, h, x) solves Problem 2, by Lemma 7.8 the incentive compatibility constraint (IC) is satisfied. Moreover, by Lemma 7.4, (PC) is satisfied. So (q, h, x) is admissible for Problem 1, but is it optimal ?

• By Lemmas 7.2 and 7.3, any optimal solution of Problem 1 should be admissible for Problem 2. Since the criteria are the same, we conclude that (q, h, x) is an optimal solution of Problem 1.

Comments

In the optimal mechanism, the agents are paid at a marginal price that is equal to their bid augmented by an information rent. This information rent depends on the problem structure by the fact that it is built from a collection of allocation problems, and it depends on the available information by the fact that, in these optimization problems, the marginal prices are replaced by the virtual marginal prices c j i + K j i (c j i ). We point out that, as already noted for instance in [START_REF] Correa | On the planners loss due to lack of information in bayesian mechanism design[END_REF], the computation of such rent may pose a practical difficulty for large problems.

Notice that, by construction, the optimal mechanism is incentive compatible in dominant strategies no matter K as (H1) is verified anyway as long as the hypothesis are satisfied. If this market is repeated over time, the principal can dynamically enhance his probabilities.

The model extends to the more realistic case when some nodes do not have a producer and for some others, the demand is null. In particular, we can consider the buyer/suppliers setting where there is demand only at one node.

One may argue that one limit of the current result is that it does not take into account any network constraints. Nonetheless, the structure of the proof makes it clear that we exploited only some properties of the allocation problem. Therefore, the optimal mechanism construction is valid for any market for which the allocation problem satisfies these properties. We discuss more on this point in §7.3.6.

In addition, the optimal mechanism construction is valid for limiting case with r = 0 at some edges. In this case, one needs to specify the definition of q of as the solution of the allocation problem may not be a singleton. If all the agents are identical and r = 0 for all edges, this corresponds to a second best auction.

We have not tried any ironing techniques to get rid of the monotone likelihood ratio assumption ; this is probably something to look at.

Generalization

The study of this subsection could be postponed to a second reading. We extend Theorem 7.11 to a more general network market. In this subsection we use specific notations. The letter e is used generically to refer to a line. The network flow is now subject to a constraint of the form N (h) ∈ R m -, where N (h) is a convex and smooth function from R E to R m , where m ∈ N. We call this constraint the network constraint. To model the piecewise linear prices, we use positive variables q j i ≤ qj i . Thus, the working zones are not assumed to be of equal sizes anymore. The marginal rates c j i are assumed to be increasing in j. The criterion is still J(q) = i∈I j∈J q j i c j i . We write K 1 the set of decisions (q j i , h e ) such that N (h) ∈ R m -and 0 ≤ q j i ≤ qj i . We assume that K 1 is non-empty. The nodal constraints are replaced by constraints of the form (for all i ∈ I) j q j i + g i (h) ≥ 0 where the g i are smooth strictly concave functions from (R + ) E to R. We introduce the set K 2 = {(q j i , h e ) ∈ K 1 ; ∀i ∈ Ij q j ig i (h) ≤ 0}. Then the allocation problem corresponds to the following optimization program: minimize (q j i ,h) J(q) subject to (q j i , h e ) ∈ K 2 .

(7.26)

It is clear that q j i is non-increasing in c j i . We point out that at optimality, the nodal constraint should be binding. Moreover, by the strict concavity of the g i the solution of problem (7.26) is unique.1 Note that J is smooth and its gradient at (c j i , h e ) is (c 1 1 , . . . c N 1 , . . . c N n , 0, . . . , 0), where the last |E| null coordinates correspond to the variable h. We denote by N K 1 (q j i , h e ) and N K 2 (q j i , h e ) the normal cones to K 1 and K 2 at (q j i , h e ). Applying Theorem 10 from [START_REF] Rockafellar | Fundamental of optimization[END_REF] (we can check that the constraint qualification is satisfied if q is not identically equal to zero), we can express N K 2 (q j i , h e ) as

{ i∈I λ i ∇f i (q j i , h e ) + z; (λ 1 , . . . , λ n ) ∈ (R + ) n , z ∈ N K 1 (q j i , h e )} (7.27)
where f i (q, h) =j q j ig i (h). Applying Theorem 9 from [START_REF] Rockafellar | Fundamental of optimization[END_REF], the solution of (7.26) should satisfy -∇J(q j i , h e ) ∈ N K 2 (q j i , h e ). where λ 1 ≥ 0 and

z j          ≥ 0 if q j i = qj i ≤ 0 if q j i = 0 0 else (7.30)
Note that if z j = 0 then c j i = λ 1 , and since the c j i are increasing in j, there is at most one j such that z j = 0. Moreover, by 7.29 for all j we have z j = λ 1c j 1 . So the z j are strictly decreasing in j. From the product structure of K 1 we deduce the product structure of its normal cone. We can then write with obvious notations:

N K 1 (q, h) = N K 1 (q) × N K 1 (h)
From the rows corresponding to h in the first order condition we derive the relation:

i∈I λ i ∇g i (h) ∈ N K 1 (h).
(7.31) Lemma 7.12 is a generalization of Lemma 7.15.

Lemma 7.12. Let (q(c), h(c)) be a solution of Problem 7.26. Assume q i continuous with respect to c i , then for any i ∈ I, j ∈ J, q j i (c) does not depend on c l i for l = j.

Proof. Take (c i , c -i ) ∈ C n . If q j i (c i , c -i ) ∈]0, qj i [, then λ i = c j i and c k i (k = j)
does not intervene the first order conditions (7.30) and (7.31), so that the solution does not depends on it. So without loss of generality we assume q j i (c i , c -i ) = 0 (the case q j i (c i , c -i ) = qj i could be treated in the same manner). By the continuity assumption we can restrict even more to the case where q j-1 i = qj-1 i and q j i (c i , c -i ) = 0. Then by the first order condition,

λ i ∈ [c j-1 i , c j i ].
Using the same the first order condition argument we used at the beginning of this proof, we see that the solution only depends on c j-1 i and c j i . If c j-1 i increases, then q i decrease so that q j i stays equal to zero. If c j-1 i decreases, then the first order condition

λ i ∈ [c j-1 i
, c j i ] stays true for the current λ i , the whole first order condition is still satisfied. Therefore the solution does not change. The lemma follows.

Notice that we can write q i as a strictly convex function of h q i = -g i (h), and then the cost associated with q i is the composition of an increasing convex function of R and a convex function from R |E| to R, therefore it is convex with respect to h, then we can rewrite the problem with only h as a decision variable, the problem would be defined on a convex set and with a strictly convex cost, and parametrized by c ∈ C. Then we can apply Berge maximum principle (see Theorem 9.17 in [START_REF] Sundaram | A first course in optimization theory[END_REF]) in a convex setting to get the continuity of q. From Lemma 7.12 and the monotony of q, we conclude that we can extend Theorem 7.11 to a more general setting.

Examples with log-concave functions

We point out that a sufficient condition to check the monotone likelihood ratio property is that F/f is increasing. If F is a smooth cumulative distribution function with f the corresponding smooth and positive density, then F/f is increasing iff f /F is decreasing iff ln F is decreasing iff ln F is concave. A function f is said to be log-concave if ln f is concave. Many density functions encountered in the economic and engineering literature are logconcave: the uniform, the normal, the exponential, the power function and the Laplace distribution have log-concave density function. We refer to [START_REF] Bagnoli | Log-concave probability and its applications[END_REF] for the results we use on this class of functions. The class of log-concave is stable by monotonic transformation and truncation. Moreover, it happens that if a probability density distribution is log-concave, then the corresponding cumulative distribution is log-concave. In mechanism design theory, it is standard to assume F to be log-concave [START_REF] Laffont | The dynamics of incentive contracts[END_REF].

We want to see the implication of the discernability assumption. This assumption imposes a gap ∆ equals to K j i (c j+ i ) between c j+ i and c

(j+1)i

. We compute this gap for some standard cases. To simplify the notations and the computation, we assume without loss of generality that c j-= 0 and write c j+ = c + . We get the following table :   Table 7.1 -The gap ∆ for some standard probabilities

Name ∝ f (x) ∝ F (x) K(x) ∆ Uniform 1 x x c + Power Function λ( x c + ) λ-1 c + ( x c + ) λ x λ c + λ Weibull λ( x c + ) λ-1 e (-x c + ) λ c + (1 -e -( x c + ) λ ) c + λ ( c + x ) λ-1 (e ( x c + ) λ -1) c + e-1 λ Laplace 1 2 e -λ|x-c + 2 | x > c + 2 , 2-e -λ c + 2 e -λ(x-c + 2 ) 2λ 2
λ (e c + 2 λ -1) Exponential (reversed) λe -(c + -x)λ e -c + λ (e xλ -1)

1-e -xλ λ

1-e -c + λ λ

We truncate the probabilities so that they have support in [0, c + ]. The symbole ∝ means that we express f and F modulo the multiplication by a common constant (due to the truncation) and λ is a positive parameter that should be greater than 1 for the Power function and the Weibull probability. For the uniform distribution, we see that the interval should be of non-decreasing sizes. For instance, one could take

c 1 ∈ [c, 2c], c 2 ∈ [3c, 4c],
c 3 ∈ [5c, 6c], etc. For the Power function, the Weibull function and the exponential, we see that the gap could be made smaller. We do not address in this work the question of the practical implementation of an optimal mechanism. The discernability assumption raises an additional practical issue.

Study of the allocation problem

The standard auction problem

The previous section motivates the study of the allocation problem for different reasons.

First, as we have seen in the proofs, the results of §7.3 rely on some properties of the 160CHAPTER 7. MECHANISM DESIGN AND ALLOCATIONS FOR NETWORK MARKETS solution of the standard allocation problem. In addition to those properties, we derive in this section two algorithms to compute the solution of the standard allocation problem.

According to 7.11, those algorithms can be used for both the original auction problem and the optimal mechanism design. To benchmark the mechanism design equilibrium against an equilibrium of the Bayesian game related to the standard auction, numerical efficiency is pivotal: indeed the Bayesian equilibrium requires a lot of allocations computations.

Let us first introduce the standard allocation problem. In a standard mechanism, the principal solves an allocation problem based on the bids he receives. Those bids will be denoted by c j i , where as before i ∈ I corresponds to the ith agent and j ∈ J corresponds to the jth working zone with constant marginal price. To model the fact that the production costs are piecewise linear, we use some positive variables q j i so that q j i ≤ q, for any i ∈ I, the quantity produced by agent i is q i = j∈J q j i and the related production cost is j∈J c j i q j i . As before, an allocation should satisfy the constraint that production exceeds demand. We end up with Problem 4: Problem 4. minimize (q,h) i∈I j∈J q j i c j i subject to ∀i ∈ I :

j∈J q j i + i ∈V (i) h i ,i -h i,i - h 2 i,i + h 2 i ,i 2 r i,i ≥ d i (λ i ) ∀(i, i ) ∈ E : h i,i ≥ 0 (γ i,i )
∀(i, j) ∈ I × J : q j i ≥ 0 (µ i,j ) ∀(i, j) ∈ I × J : q j i ≤ q (ν i,j ).

(7.32)

The notations for the dual the variables associated with each constraint are indicated in parentheses. Those variables are in R + .

For any node i ∈ I, we define the function

F i for λ ∈ [min i c 1 i , max i c N i ] n F i (λ i , λ -i ) = d i + i ∈V (i) λ i -λ i r i,i (λ i + λ i ) + (λ i -λ i ) 2 2r i,i (λ i + λ i ) 2 .
(7.33)

We will justify later that this function could be interpreted as the production of agent i when the multipliers are λ i and λ -i . Its partial derivative with respect to λ i is

∂ λ i F i (λ i , λ -i ) = - i ∈V (i) 4 r i,i λ 2 i (λ i + λ i ) 3 < 0. (7.34)
The derivative is negative: when i increases its price it is assigned smaller production

∂ λ i F i (λ i , λ -i ) =    4 r i,i λ i λ i (λ i +λ i ) 3 > 0 if i ∈ V (i) 0
else. (7.35) When another agent becomes less competitive, i is assigned more production. Let k ∈ J ∪ {0}. The limit at +∞ and 0 of

F i (x, λ -i ) -k q are lim x→+∞ F i (x, λ -i ) -k q = d i -k q - j∈V (i) 1 2r i,j (7.36)
and

lim x→+∞ F i (x, λ -i ) -k q = d i -k q + j∈V (i) 3 2r i,j . (7.37)
Using the hypotheses (7.11), the first term is strictly negative and the second strictly positive, so by the intermediate value theorem, F ik q has a zero. Since F ik q is decreasing in λ i , this solution is unique. Now we define for i ∈ I and k ∈ J ∪ {0}, g k i as the function that associates any λ -i ∈ [min i c 1 i , max i c N i ] n-1 with the unique x such that and F i (x, λ -i ) = k q and x > 0:

F i (g k i (λ -i ), λ -i ) = k q g k i (λ -i ) > 0. (7.38)
Lemma 7.13. For any i ∈ I, k ∈ J ∪ {0}, λ -i ∈ [min i c 1 i , max i c N i ] n-1 and i ∈ V (i)

∂ λ i g k i (λ -i ) > 0. (7.39)
In particular, g k i is increasing in λ i for i ∈ V (i).

Proof. According to the implicit function theorem

∂g k i (λ -i ) ∂λ i = - ∂F i ∂λ i / ∂F i ∂λ i , (7.40)
It is clear that g k i (λ -i ) is decreasing in k. We proceed with the computation of the dual of Problem 4. If a strong duality theorem applies, then we should have min q,h max λ,γ,ν,µ i∈I,j∈J ν i,j (q j iq)µ i,j q j i = max λ,γ,νµ min q,h i∈I

q j i c j i + i∈I λ i {d i -( j∈J q j i + i ∈V (i) h i ,i -h i,i - h 2 i,i + h 2 i ,i 2 r i,i )} 162CHAPTER
λ i d i - i∈I,j∈J ν i,j q + q j i (c j i + ν i,j -λ i -µ i,j ) + (i,i )∈E h i,i {λ i -λ i -γ i,j } + h 2 i,i r i,i λ i + λ i 2 ,
so that for any (i, i ) ∈ E, by necessary and sufficient first order condition

h i,i = γ i,i + λ i -λ i r i,i (λ i + λ i ) . ( 7

.41)

By replacing h by its expression in the dual variables we get something equivalent to maximize (λ,γ,µ,ν) i∈I

{λ i d i - j∈J ν i,k q - i ∈V (i) (λ i -λ i -γ i,j ) 2 2r i,i (λ i + λ i ) } subject to ∀(i, j) ∈ I × J c j i + ν i,j ≥ λ i + µ i,j . (7.42)
The expression of γ with respect to λ follows. For any

(i, i ) ∈ E γ i,i =    0 if λ i ≤ λ i λ i -λ i else (7.43)
so the dual problem is equivalent to maximize (λ,µ,ν) i∈I

{λ i d i - j∈J ν i,j q - i ∈V (i) (λ i -λ i ) 2 4r i,i (λ i + λ i ) } subject to ∀(i, j) ∈ I × J c j i + ν i,j ≥ λ i + µ i,j , (7.44)
because µ does not play any role in the admissibility of the other variables nor in the objective, this is equivalent to maximize

(λ,ν) i∈I {λ i d i - j∈J ν i,j q - i ∈V (i) (λ i -λ i ) 2 4r i,i (λ i + λ i ) } subject to ∀(i, j) ∈ I × J c j i + ν i,j ≥ λ i , (7.45)
The expression of ν follows. For any (i, j)

∈ I × J ν i,j =    0 if λ i ≤ c j i λ i -c j i else. ( 7
{λ i d i -q j∈J (λ i -c j i )δ λ i ≥c j i - i ∈V (i) (λ i -λ i ) 2 4r i,i (λ i + λ i ) }, (7.47)
where

δ x≥y =    1 if x ≥ y 0 else. ( 7.48)
For i ∈ I we maximize the criteria

λ i d i -q j∈J (λ i -c j i )δ λ i ≥c j i - i ∈V (i) (λ i -λ i ) 2 4r i,i (λ i + λ i ) , (7.49)
which is strictly concave for any λ -i (sum of concave and strictly concave functions). We denote by Λ i (λ -i ) its maximizer. The first order necessary and sufficient condition on Λ i is:

0 ∈ F i (Λ i , λ -i ) -K i (Λ i ), (7.50)
where

K i (λ i ) =                0 if λ i < c 1 i [j -1, j]q if λ i = c j i j q if λ i ∈]c j i , c j+1 i [, j = N N q if λ i ∈ λ i ∈]c N i , c[, (7.51)
We conclude Lemma 7.14. For any i ∈ I and any

λ -i ∈ [min i c 1 i , max i c N i ] n-1 , Λ i (λ -i ) is the unique solution of F i (Λ i , λ -i ) ∈ K i (Λ i ). (7.52)
We point out that the primal (and dual) solution unicity is a desirable property that is not systematic for the allocation problems of centralized market models. The expression of h with respect to λ (7.41) and the fact the supply constraint should be binding at optimality justify the interpretation of F i proposed at the beginning of this subsection. In the following we use this property many times. We denote by q(c) the solution of Problem 4 with the cost vector c. Similarly, we define q i (c), q j i (c), λ(c) and λ i (c). We give here two properties of the allocation problem solution. By integration, we showed in the previous section that the solution of the mechanism design inherits those properties.

Lemma 7.15. Let (q(c), h(c)) be a solution of Problem 4, then q j i (c) does not depend on c l i for l = j: q j i (c 1 , . . . c j-1 , c j , c j+1 . . . , c N ; c -i ) = q j i (s 1 , . . . s j-1 , c j , s j+1 . . . , s N ; c -i ) (7.53)

Proof. Let i ∈ I, j ∈ J, c -i ∈ C n-1 , c = (c 1 , . . . , c N ) ∈ C and s = (s 1 , . . . , s N ) ∈ C such that s j = c j . We shall prove that q j i (s, c -i ) = q j i (c, c -i ). We denote by λ c (resp. λ s ) the dual variables associated with the nodal contraints for the allocation problem parametrized with c (resp. s). First if

q j i (c, c -i ) ∈]0, q[, (7.54)
then by lemma 7.14 λ c i = c j i and so using Lemma 7.14 again, λ s i = c j i . Therefore λ s = λ c , from which we deduce that q j i (c, c -i ) = q j i (s, c -i ). So without loss of generality, we can assume that q j i (c, c -i ) = q and q j i (s, c -i ) = 0. (7.55)

Then using Lemma 7.14 we get

λ c i ≥ c k and λ s i ≤ c k , (7.56)
so that λ c i ≥ λ s i . If λ c i > λ s i , then λ c -i ≥ λ s -i by non-decreasingness of Λ i , i ∈ I\{i} (explained in §7.4.3) Therefore all the other agents are producing less, which is absurd since i is already producing less.

We extend the notations by setting for all i ∈ I, c 0 i = c * . We consider the subset S of C for which at some nodes i, the multiplicator λ i is equal to the marginal cost and the production is a multiple of q (i.e. stuck in an angle): S = {c ∈ C n , q i (c) = j q and λ i (c) = c j i for some i ∈ I, j ∈ J ∪ {0}, j ∈ {j, j + 1}}. (7.57) The set S corresponds to the points of transition between the two possibilities defined by the first order condition (7.50). Because of the angle, it is natural to think that this is where irregularities may happen (see the proof of the next lemma). We introduce this set

STUDY OF THE ALLOCATION PROBLEM

165 to show some regularity properties of q and Q. We detail the proof in the Appendix. The approach consists in showing that S is a finit union of sets of zero measure. This is also true for the projection of S on the {c i } × C -i . Then we observe that on C\S, the relations between the primal and dual variables are smooth.

Lemma 7.16. The function q is C ∞ on C n \S and C 0 on C n .

Proof. We postpone the proof to Appendix 7.8

Fixed point

In this subsection we show that the solution of the dual problem is the unique fixed point of a monotone operator. We define

Λ(λ 1 , ..., λ n ) = (Λ 1 (λ -1 ), ..., Λ n (λ -n )). (7.58)
Lemma 7.17. For any i ∈ I, Λ i is non-decreasing.

Proof. Let λ -i < λ -i and the corresponding Λ i and Λ i . Assume Λ i > Λ i . Since F i is decreasing in the first variable and increasing in the second

F i (Λ i , λ -i ) < F i (Λ i , λ -i ) (7.59)
Moreover for any x ∈ K(Λ i ) and y ∈ K(Λ i ), x ≤ y and

F i (Λ i , λ -i ) ∈ K(Λ i ), F i (Λ i , λ -i ) ∈ K(Λ i ). Therefore F i (Λ i , λ -i ) ≤ F i (Λ i , λ -i ) which is absurd.
We will use the following classical result (see [START_REF]Supermodularity and complementarity[END_REF] for a proof and definition of complete lattice).

Theorem 7.18 (Knaster-Tarski fixed point). Let L be a complete lattice and let f an application from L to L and order preserving. Then the set of fixed points of f in L is a complete lattice.

In particular, the set of fixed points is non empty. Since Λ is order preserving and [c * , c * ] n is a lattice when we consider the natural order, there is a fixed point, and the set of fixed points is a lattice.

Lemma 7.19. λ is optimal for the dual ⇔ λ is a fixed point of Λ.

Proof.

• If λ is optimal for the dual, then each component i maximizes the criteria (7.49), so λ is a fixed point of Λ.

• If λ is a fixed point of Λ, then by definition, each component i maximizes the criteria (7.49). So since the problem is (strictly) concave, λ is optimal.

166CHAPTER 7. MECHANISM DESIGN AND ALLOCATIONS FOR NETWORK MARKETS

A consequence of the previous lemma is that Lemma 7.20. The set of fixed points of Λ is a singleton.

Definition 7.21 (Continuous for monotone sequence). We consider the natural partial order on R n . We say that a function G is continuous for monotone (resp. increasing, decreasing) sequences if for any monotone (resp. increasing, decreasing) sequence x n converging to a point x in the domain of G, G(x n ) goes to G(x) as n goes to infinity.

Obviously, a function is continuous for monotone sequences if and only if it is continuous for increasing and decreasing sequences.

Lemma 7.22. The operator Λ is continuous for monotone sequences.

The intuition of the proof is that we can use the monotony of the sequence and Lemma 7.14 to characterize the behaviour of Λ on the neighborhood. We find that Λ is either constant or characterized by the implicit function theorem.

Proof. Let λ-i , j ∈ [1 . . . N ],
we first deal with the 'nice' case, that corresponds to

F i (Λ( λ-i ), λ-i ) ∈]j -1, j[q • If Λ i ( λ-i ) ∈]c j i , c j+1 i
[ (we do not treat the case j = N , which is very similar to what follows) then since F i is C ∞ and of invertible derivative (non zero) in λ i , the implicit function theorem tells us that the solution ψ of F i (ψ( λ-i ), λ-i ) = j q is continous in a neighborhood B of λ-i . So we can take B small enough so that for λ -i ∈ B, ψ(λ -i ) ∈]c j i , c j+1 i [. On this neighborhood, ψ satisfies the first order conditions and so by unicity of the solution of the optimization problem, since those conditions are sufficient, ψ = Λ i on B. So Λ i is continous at λ-i .

• If Λ i ( λ-i ) = c j i (as before, we do not treat the case j = N ), then by Lemma 7.14

F i (Λ i ( λ-i ), λ-i ) = [j -1, j]q, if F i ∈]j -1, j[q (we
deal with the border case in the next point) then since F i is continuous, there is a neighborhood B of λ-i such that

F i (Λ i ( λ-i ), λ -i ) ∈]j -1, j[q, so on B Λ i is constant so continuous.
• We proceed with the borders. If F i (Λ i ( λ-i ), λ-i ) = (j -1)q and Λ i ( λ-i ) = c j i .

-Decreasing case: Let us take ∈ R n-1

+ such that F i (Λ i ( λ-i ), λ-i + ) ∈ [j -1, j]q
(F i is continuous and increasing in λ -i ). Then Λ i ( λ-i + ) = Λ i ( λ-i ) checks the first order condition so Λ is constant, so we get the continuity for decreasing sequences.

-Increasing case: F i (Λ i ( λ-i ), λ-i ) = (j-1)q and so there exists a ball B such that the implicit function theorem applies and there exists ψ such that F i (ψ( λ-i -

), λ-i -) = (j -1)q and ψ( λ-i ) = Λ i ( λ-i ) = c j i (remember that Λ i ( λ-i ) = c j i 7.4. STUDY OF THE ALLOCATION PROBLEM 167 by hypothesis) . Since F i is increasing in the second variable and decreasing in the first, ψ is increasing. For of positive components and sufficiently small,

ψ( λ-i -) ∈]c j-1 i , c j i [ (since ψ( λ-i ) = Λ i ( λ-i ) = c j i
) and so check the first order condition. So for of positive components and sufficiently small, ψ = Λ i by uniqueness of the solution. So Λ i is continuous for increasing sequence.

• We do the same analysis if F i (Λ i ( λ-i ), λ-i ) = j q and Λ i ( λ-i ) = c j i .

The conclusion follows.

We could have alternatively used Berge Maximum theorem for strictly concave criterion to get the continuity of Λ. Yet, we choose to present this proof for pedagogical reasons since it contains some key ideas we will use later (see appendix).

Theorem 7.23. The sequence (Λ k (c N 1 ...c N n )) k∈N converges to the solution of the dual.

Proof. Since Λ(c N 1 ...c N n ) ≤ (c N 1 ...c N n )
, and since Λ is order preserving, the sequence Λ k (c N 1 ...c N n ) = λ k is non increasing and bounded, so converge to a point x. Since Λ is continuous for monotone sequence, x is a fixed point. Theorem 7.24. For any i ∈ I, λ -i ∈ [c * , c * ] n-1 , Λ i (λ -i ) has the following explicite expression:

Λ i (λ -i ) = min{c N i , min j∈J {c j i 1 F i (c j i ,λ -i )<j q}, min k∈[0..N -1] {g k i (λ -i )1 g k i (λ -i )∈[c k i ,c k+1 i ] }} (7.60)
Proof. We denote by G i the RHS of (7.60) and show that for any i

F i (G i (λ -i ), λ -i ) ∈ K(G(λ -i )), (7.61)
and then we conclude with a uniqueness argument.

If there is j ∈ J such that G i (λ -i ) = c j i , then either F i (c j i , λ -i ) < j q or g j i (λ -i ) = c j i . This last possibility implies by definition of g j i that F i (c j i , λ -i ) = j q. So anyway F i (c j i , λ -i ) ≤ j q. Remember that K(G(λ -i )) = [j -1, j]q. So we need to prove that F i (c j i , λ -i ) ≥ (j -1)q. Suppose the contrary, i.e. F i (c j i , λ -i ) < (j -1)q. Then since G i (λ -i ) = c j i , F (c j i , λ -i ) < (j -1)q, which in turn implies that

g j i (λ -i ) < c j i . (7.62) Now observe that since G i (λ -i ) = c j i , F (c j-1 i
, λ -i ) > (j -1)q, which implies that

g j i (λ -i ) > c j-1 i . (7.63)
Combining (7.62) and (7.63) with the definition of G, we see that G(λ -i ) ≤ g j i (λ -i ). But G(λ -i ) = c j i and g j i (λ -i ) < c j i , so this is absurd. Therefore F i (c j i , λ -i ) ≥ (j -1)q.

168CHAPTER 7. MECHANISM DESIGN AND ALLOCATIONS FOR NETWORK MARKETS

Else let us assume that there is not such j. Then there is k ∈ [0 . . . N -1] such that

G i (λ -i ) = g k i (λ -i ). By definition of g k i , F i (G i (λ -i ), λ -i )) = k q and by definition of G, G i (λ -i ) ∈ [c k i , c k+1 i ]. So again F i (G i (λ -i ), λ -i )) ∈ K(G i (λ -i )).
We can now conclude that

Λ = G.
We can interpret the fixed point algorithm as if some benevolent agents situated at each node of the network were exchanging information. They collectively try to minimize the total cost and, to do so, they communicate their current marginal costs. This marginal cost is the minimum of their local marginal cost and the marginal cost of importation from the adjacent nodes. At each iteration, the agents compute how much they are going to produce based on their current marginal cost. Then they update their marginal cost based on the information they just received and transmit this marginal cost to the adjacent nodes. We point out that the information used by each agent is local.

Decreasing Rate

We derive in this section an estimate for the decreasing rate. We denote α = max (e,e )∈E 2 r e /r e .

We have the following bound:

Lemma 7.25. For any (i, i , k, λ -i ) ∈ E × [0, N ] × [c * , c * ] n-1 , ∂ λ i g k i (λ -i ) ≥ 1 N α ( c * c * ) 5 . (7.64)
Proof. We combine (7.40) with (7.34) and (7.35).

Lemma 7.26. Since (λ k i ) k∈N is non-increasing for all i ∈ I, there is a finite number of k for which at least one coordinate λ k i satisfies

λ k i > c q i and λ k+1 i ≤ c q i (7.65) or λ k i = c q i and λ k+1 i < c q i . (7.66)
We denote by for i ∈ V (i). We then take the i ∈ V (i) that maximizes (λ k-1 i λ k i ) and use the previous lemma to get the result.

K this set. Let (k 1 , k 2 ) ∈ N 2 such that [k 1 -1, k 2 + 1] ∩ K = ∅. Then for k ∈ [k 1 , k 2 ] and i ∈ I such that λ k-1 i = λ k i λ k i -λ k+1 i ≥ 1 N α ( c * c * ) 5 max i ∈V (i) (λ k-1 i -λ k i ) (7.67) Proof. By definition of λ k , λ k i -λ k+1 i = Λ i (λ k-1 -i ) -Λ i (λ k -i ). By construction, there exists j ∈ [0, N -1] such that Λ i (λ k-1 -i ) = g j i (λ k-1 -i ) and Λ i (λ k -i ) = g j i (λ k -i ). Then by monotony of g, g j i (λ k -i ) -g j i (λ k-1 -i ) is lower bounded by |∂ λ i g j i | ∞ (λ k-1 i -λ k i ), (7.68

Algorithm Implementation

We implemented this algorithm in Matlab. We use a dichotomy to compute the g k i . Note that for linear cost the analysis is similar. We define g i (λ -i ) as the unique x such that f i (x, λ -i ) = 0 and x ≥ 0 and define Λ such that

Λ i (λ) = min(c i , g i (λ -i )) (7.69)
We perform some numerical comparisons with CVX, a package for specifying and solving convex programs [START_REF] Grant | Graph implementations for nonsmooth convex programs[END_REF][START_REF]CVX: Matlab software for disciplined convex programming[END_REF] for both linear and piecewise linear production cost functions.

We generate a graph with 100 nodes connected randomly. To generate the graph, we use a Barabasi-Albert model [START_REF] Barabási | Emergence of scaling in random networks[END_REF] to ensure some scaling properties. Both CVX and the fixed point algorithm find the optimal value. The linear version of the fixed point algorithm is about ten times faster than the CVX resolution. Note that the algorithm could be distributed, since at each iteration, the computation at each node only depends on the values of the previous iteration. In addition, instead of computing the iterates of Λ at each step, we could use intermediate steps were we follow a decreasing

direction Λ(λ k ) -λ k and choose h > 0 such that λ k h = h(Λ(λ k ) -λ k ) + λ k satisfies Λ(λ k h ) ≤ λ k h
, which is easier to check than computing the g i . This makes the algorithm similar to more standard descent based approaches (see [START_REF] Bertsekas | Convex optimization algorithms[END_REF]).

Two-agent allocation problem

We propose another algorithm for the piecewise linear allocation problem when the network is limited to two agents. This section is motivated by the need for efficient (both in speed and precision) allocation algorithms to numerically compute Bayesian Nash equilibria of the standard setting. Indeed, the natural next step of this work would be to proceed with numerical benchmarks, by comparing the Bayesian Nash equilibrium of the standard

First order condition

The allocation problem with two agents of slopes c j i and demand vector d i is Problem 5. minimize

q j i ,h j∈J c j 1 q j 1 + c j 2 q j 2 subject to j q j 1 -h ≥ r 2 h 2 + d 1 j q j 2 + h ≥ r 2 h 2 + d 2 q j i ≤ q q j i ≥ 0 h ∈ R. (7.70)
We assume that N is big enough so that each agent could supply the whole amount without producing more than qN . This is not a restrictive assumption as we could put very high marginal cost to model some capacity constraints. We denote for h ∈ R and

j ∈ J q 1 (h) = d 1 + r h 2 2 + h, q 2 (h) = d 2 + r h 2 2 -h, (7.71)
φ j i (h) = min((q i (h) -(j -1)q) + , q). (7.72)

In order to reduce to an unconstrained problem, we assume that the constraints on the )] and h = q -1 2 (j 2 q).

We denote, for (i, j) ∈ I × J and (j 1 , j 2 ) ∈ J 2 :

a j i = q -1 i (j q) and b j 1 ,j 2 = g(c j 1 1 /c j 2 2 )/r. (7.82)

Those two quantities only depend on the problem data. We point out that a j i corresponds to the value of h when we set q i = j q and b j 1 ,j 2 corresponds to the optimal value of h when q i ∈](j i -1), j i [q. We sum up with the following Lemma: Lemma 7.27. There exist (j 1 , j 2 ) ∈ J 2 such that one of those propositions is true:

b j 1 ,j 2 ∈]a j 1 -1 i , a j 1 i [∩]a j 2 i , a j 2 -1 i [ (7.83) a j 1 1 ∈ [b j 1 +1,j 2 (a j 1 1 ) , b j 1 ,j 2 (a j 1 1 ) ] (7.84) a j 2 2 ∈ [b j 1 (a j 2 2 ),j 2 , b j 1 (a j 2 2 ),j 2 +1 ]. (7.85)
Then the optimal value of h is respectively b j 1 ,j 2 , a j 1 1 and a j 2 2 .

Algorithm

We denote by c - i the copy of the vector c i with the first coordinate removed, and q i the total production of agent i. We denote by q 1 (d, c 1 , c 2 ) and q 2 (d, c 1 , c 2 ) the optimal production allocation when the demand is d at both node and the cost vectors are c 1 and c 2 .

+ N j=1 a j Q j (b 1 . . . b j -1, a j , a j+1 . . . a N ) -b j Q j (b 1 . . . b j-1 . . . b j , a j+1 . . . a N ) = N j=1 {b j k>j [Q j (b 1 . . . b k-1 , a k , a k+1 . . . a N ) -Q j (b 1 . . . b k-1 , b k , a k+1 . . . a N )] +a j Q j (b 1 . . . b j-1 , a j , a j+1 . . . a N ) -b j Q j (b 1 . . . b j-1 . . . b j , a j+1 . . . a N ) + a j k<j [Q j (b 1 . . . b k-1 , a k , a k+1 . . . a N ) -Q j (b 1 . . . b k-1 , b k , a k+1 . . . a N )]} = N j a j Q j (a 1 . . . a N ) -b j Q j (b 1 . . . b N ) We end up with X(a) -X(b) = N j=1 (a j Q j (a) -b j Q j (b) + b j a j Q j (b 1 . . . b j-1 , t, a j+1 . . . a N )dt) (7.89)
7.8 On S and the regularity of q

Remember that the set S corresponds to the points of transition between the two possibilities defined by the first order condition (7.50): S = {c ∈ C n , q i (c) = j q and λ i (c) = c j for some i ∈ I, j ∈ J, j ∈ {j, j + 1}}.

Our first goal is to show that S is a finite union of sets of zero measure (Lemmas 7.30 and 7.32). To do so, we apply the implicit functions theorem. From this we deduce the regularity of q (proof of Lemma 7.16). For any I A , I B partition of I, and I C ⊂ I B not empty, j ∈ J I and j ∈ J I such that for all i, j ∈ {j i , j i + 1}, we denote by

S(I A , I B , I C , j, j ) the set          c ∈ C n such that for any i ∈ I          i ∈ I A ⇒ λ i (c) = c j i i and q i (c) / ∈ Nq i ∈ I B ⇒ q i (c) = j i q i ∈ I C ⇒ λ i (c) = c j i i          . (7.91)
For an element c of such set, we denote by M the matrix

M (c) = ∂F i (λ(c)) ∂λ j (i,j)∈I B . (7.92) 176CHAPTER 7

. MECHANISM DESIGN AND ALLOCATIONS FOR NETWORK MARKETS

We need to study the invertibility of M to apply the implicit functions theorem (Lemma 7.31). Note that the function S is defined on a finite set. We use the image of S to show that the measure of S with respect to the Lebesgue measure is zero. We first show in the next lemma that S is included in the finite union of the S(I A , I B , I C , j, j ) family. Then we will show that each element of this family has a measure equal to zero.

Lemma 7.30. S ⊆ ∪S(I A , I B , I C , j, j )

Proof. Take c ∈ S, then by definition of S, there exist i ∈ I, j ∈ J and j ∈ {j, j + 1} such that q i (c) = j q and λ i (c) = c j , so I C is not empty. By Lemma 7.14, for all i ∈ I, i is in

I A or I B .
So we have a set S(I A , I B , I C , j, j ) such that c is in this set, so S is included in the union of those sets.

Lemma 7.31. For any c ∈ C n the matrix M (c) is invertible.

Proof. Assume that there are some coefficients α i such that i α i M i = 0 where M i is the ith column of M . Then by (7.34) and (7.35), the ith row of this relation writes:

α i j∈V (i) λ 2 j r i,j (λ i + λ j ) 3 = j∈V (i),j∈I B α j λ i λ j r i,j (λ i + λ j ) 3 . (7.93)
We denote b i,j = λ 2 j λ i r i,j (λ i +λ j ) 3 and a i = α i λ i . Then (7.93) is equivalent to

a i = j∈V (i),j∈I B a j b i,j k∈V (i) b i,k (7.94)
Considering the biggest a i , we get that all a i are equal by convexity, and so either all are equal to zero or

j∈V (i) b i,j = j∈V (i),j∈I B b i,j (7.95)
which is not the case since I A is not empty by the fifth assumption.

Next we show that S(I A , I B , I C , j, j ) has a zero Lebesgue measure.

Lemma 7.32. For any I A , I B partition of I, and I C ⊂ I B not empty, j ∈ J I and j ∈ J I such that for all i, j ∈ {j, j + 1}, the measure of the set S(I A , I B , I C , j, j ) is zero.

Proof. We assume in the market description that it is not possible to produce a multiple q at each node and satisfy exactly the nodal constraints (fifth assumption). Therefore it is not possible that I B = I, so I A is not empty. By definition of S I A ,I B ,I C ,j,j , for all i ∈ I B ,

F i (c j I A , λ I B (c)) = q i (c) = j i q, (7.96)
Lemma 7.34. Let i ∈ I and c i ∈ C i , then the Lebesgue measure of the set

S i (c i ) = {c -i ∈ C -i , (c i , c -i ) ∈ S} (7.99) is zero. Proof. Using Lemma 7.30, S i (c i ) ⊆ {c -i ∈ C -i , (c i , c -i ) ∈ ∪S(I A , I B , I C , j, j )}. So let c -i ∈ S i (c i ), I A , I B a
partition of I, and I C ⊆ I B not empty, and j, j such that (c i , c -i ) ∈ S(I A , I B , I C , j, j ). There are three possible cases:

• i ∈ I A then as explained in the proof of Lemma 7.32, S(I A , I B , I C , j, j ) is locally a surface parametrized by c i so by projection over an hyperplane of the type c i = x it also a surface in C -i .

• i ∈ I B \I C locally, q is independant of c i so if S(I A , I B , I C , j, j ) ∩ (c i , S i (c i ))
is of strictly positive measure, then S(I A , I B , I C , j, j ) has also a strictly positive measure in C n , since this is not true, S(I A , I B , I C , j, j ) ∩ (c i , S i (c i )) is of zero measure in the neighborhood.

• Else i ∈ I C , which is the tricky part. First by definition of I C , for any element c of S(I A , I B , I C , j, j ), q i (c) = j i q and λ i (c) = c j i i . Without loss of generality, we assume j i = j i , the other case can be treated similarly. Then we make the observation that we do not modify the c -i of S(I A , I B , I C , j, j ) if we set c j+1 i = c j i . Since we are interested in S(I A , I B , I C , j, j ) ∩ (c i , S i (c i )), we can assume without loss of generality that c j+1 i = c j i . Then we have reduced to the case i ∈ I A .

We conclude as in the proof of Lemma 7.32.

Chapter 8

On a class of bidding games whose dynamics converges to the unique pure equilibrium We introduce a class of Bayesian bidding games for which we prove that the set of pure Nash equilibria is a (non-empty) sublattice and we give a sufficient condition for uniqueness that is often verified in the context of markets with inelastic demand. We propose a dynamics that converges to the equilibrium set and derive a scheme to compute the extreme Nash equilibria. This scheme is an alternative to the more standard best reply dynamics and 180 CHAPTER 8. BIDDING GAMES fictitious play. It shows better converging properties on the electricity auction instance that motivated its introduction. We apply this framework to the wholesale electricity procurement auctions that motivated this study.

Introduction

The interaction between firms (or individuals) competing on price to maximize their profits in an imperfect information environment constitutes a Bayesian game. Very often most of the private information concerns the production costs of the firms. Such situations occur for instance in procurement auctions, commodity markets and oligopolies. It is then natural to ask about the Nash equilibria of such kind of games. Do we have a guaranty of existence? Is the equilibrium unique? Do we have an algorithm to compute it? Those are generically hard questions when the classical results of game theory are not applicable. In this work we identify a class of games for which some of those questions can be answered using basic tools of lattice theory.

An essential observation is that a bid increase by one firm is very often an incitation for all other firms to increase their bids. The exploitation of such monotonic behaviors, summarized in the notion of strategic complementarity, is central in the study of many pricing games (and more generally in Bayesian games) and explains the intensive use of lattice theory in a literature that has many interesting results of pure Nash equilibria existence.

As opposed to what is required in most of game theory literature, those results usually do not need payoff functions to be quasiconcave. Those existence results, depending on the fixed point theorem over which they are constructed, differ by the underlying assumptions and the additional information they provide on the equilibria set.

What follows builds on a rich literature. We now briefly review some of its major achievements.

Optimization on lattices The development of this work was strongly inspired by a book from Topkis [START_REF]Supermodularity and complementarity[END_REF] in which the author surveys some fundamental results of monotone comparative statics, in particular [START_REF] Topkis | Minimizing a submodular function on a lattice[END_REF][START_REF]Comparing equilibria[END_REF][START_REF] Shannon | Weak and strong monotone comparative statics[END_REF][START_REF] Edlin | Strict monotonicity in comparative statics[END_REF]. Monotone comparative statics concerns settings where a parametrized collection of optimal decisions are monotone in the parameter.

Bayesian games and equilibrium existence The class we introduce belongs to the large class of Bayesian games, and more specifically has some strategic complementarity properties.

In [START_REF] Vives | Nash equilibrium with strategic complementarities[END_REF] Vives proves the existence of a pure Nash equilibrium for Bayesian games with general action and type spaces in action with a Tarsky fixed-point theorem on lattices.

More precisely, the equilibrium set is a non-empty complete lattice. Payoffs need to be In [START_REF] Athey | Single crossing properties and the existence of pure strategy equilibria in games of incomplete information[END_REF], Athey shows the existence of a monotone pure strategy equilibrium for finite Bayesian games satisfying a single-crossing condition. Actions and types should be one dimensional. The demonstration relies on Kakutani's fixed-point theorem. Athey generalizes the result to a continuum action set when the payoffs are continuous.

In [START_REF] Mcadams | Isotone equilibrium in games of incomplete information[END_REF], McAdams extends Athey results to a multidimensional setting. Like in [START_REF] Athey | Single crossing properties and the existence of pure strategy equilibria in games of incomplete information[END_REF] the extension to continuum action sets is obtained by taking the limit of finite approximations equilibria. McAdams, like Athey, uses a single-crossing condition, combined with a quasisupermodularity condition, and then applies the Glicksberg's fixed point theorem.

In [START_REF] Reny | On the existence of pure strategy monotone equilibria in asymmetric first-price auctions[END_REF], Reny and Zamir show that first price, one unit auctions with affiliated types and interdependent values have a pure equilibrium; they use Athey's [START_REF] Athey | Single crossing properties and the existence of pure strategy equilibria in games of incomplete information[END_REF] result for their demonstration. They combine a result by [START_REF] Milgrom | A theory of auctions and competitive bidding[END_REF] with Athey [5] approach of limit of finite action grids.

Vives surveys in [START_REF]Complementarities and games: New developments[END_REF] the use of monotone comparative static tools for games with complementarities. He points out some interesting properties of games with strategic complementaries that are still valid in our framework: general strategic spaces, existence of pure Nash equilibria, specific structure of the set of equilibria, existence of a Best reply dynamics algorithm to compute the extremal equilibria. In the seventh section of the article, he discusses some aspects specific to Bayesian games.

In [START_REF] Van Zandt | Monotone equilibria in bayesian games of strategic complementarities[END_REF], Van Zandt and Vives give a constructive proof of the existence of a pure Nash equilibrium for Bayesian games satisfying a strategic complementarity condition. The action and type sets can be infinite dimensional. The payoffs need to be supermodular and satisfy some increasing difference property. In addition, they show that one can compute such equilibria by best-reply iteration. We propose a different approach that turns out to be more stable on the numerical benchmark we use in this study.

In [START_REF] Reny | On the existence of monotone pure-strategy equilibria in bayesian games[END_REF] Philip J. Reny generalizes the results of Athey [START_REF] Athey | Single crossing properties and the existence of pure strategy equilibria in games of incomplete information[END_REF] and McAdams [START_REF] Mcadams | Isotone equilibrium in games of incomplete information[END_REF] on the existence of monotone pure strategy equilibria in generic Bayesian games. While Athey and McAdams proofs rely on the convexity of the best reply sets, Reny uses a fixed point theorem that relies on the notion of contractibility. He shows that the result applies when the payoff function is weakly quasi supermodular and satisfies a weak single crossing condition, and concludes that his result is strictly more general than [START_REF] Athey | Single crossing properties and the existence of pure strategy equilibria in games of incomplete information[END_REF] and [START_REF] Mcadams | Isotone equilibrium in games of incomplete information[END_REF]. In particular, the result can be applied when type and action sets are infinite dimensional.

The payoff functions need to be continuous in the actions.

Equilibrium computation, best reply dynamics and fictitious play Many approaches to compute an equilibrium consist in mimicking the behaviors of the players when the game is repeated sequentially. As time goes on, each player takes a decision based on the previous iterations of the game. Basically, an approach is characterized by the memory of the players (do they remember a joint probability of actions, marginals. . . )

and the way they choose the next action. The two historical approaches are the Cournot's tâtonnements and Brown's fictitious play [START_REF] Brown | Some notes on computation of games solutions[END_REF]. In the standard Cournot's tâtonnements (or Best Reply dynamics), actions are taken as best replies against the last actions of the other players. In fictitious play, the last action is modified in the direction of the Best Reply against the average of the other players past actions. There are no general results of fictitious play convergence for games with complementarities. Yet one may consult [START_REF] Berger | The convergence of fictitious play in games with strategic complementarities: A comment[END_REF][START_REF] Berger | Learning in games with strategic complementarities revisited[END_REF][START_REF] Milgrom | Rationalizability, learning, and equilibrium in games with strategic complementarities[END_REF][START_REF]Adaptive and sophisticated learning in normal form games[END_REF]. Vives discusses in [START_REF]Complementarities and games: New developments[END_REF] the tâtonnements in a context very close to ours.

The convergence is derived from some monotonicity properties but, as he points out, convergence cannot be ensured for an arbitrary starting point. Observe that most of these results are related to matrix games. We propose an alternative approach to fictitious play and Best Reply dynamics for a class of Bayesian games to which the electricity market introduced in [START_REF] Figueroa | Cost-minimizing regulations for a wholesale electricity market[END_REF] belongs.

In the next section, we introduce the game and present our main results. We illustrate those results on an example in §8.3. §8.4, §8.5 and §8.6 are dedicated to the proofs of the three main results: the existence of a Nash equilibrium, the uniqueness of the equilibrium and a convergence of a tâtonnement dynamics to the equilibrium. We discuss some possible extensions in the conclusion.

Game presentation and main results

Definitions

Definition 8.1 (Least Upper Bound (∨) and Greatest Lower Bound (∧) , see [START_REF]Supermodularity and complementarity[END_REF]). Let X be a partially ordered set, X ⊆ X. We say that x ∈ X is the least upper bound of X when ∀(x, x ) ∈ X × X x ≤ x ⇐⇒ x ≤ x. We say that x ∈ X is the greatest lower bound of X when ∀(x, x ) ∈ X × X x ≤ x ⇐⇒ x ≤ x . For (x, y) ∈ X 2 , we denote by x ∧ y and

x ∨ y the greatest lower bound and the least upper bound of the pair {x, y}.

Definition 8.2 (Lattice, Sublattice, Complete Lattice, see [START_REF]Supermodularity and complementarity[END_REF]). A partially ordered set X is a lattice iff it contains a least upper bound and a greatest lower bound for each pair of its elements. A subset X ⊆ X is a sublattice if it contains a least upper bound and a greatest lower bound for each pair of its elements. A lattice in which each nonempty subset has a greatest lower bound and a least upper bound is complete.

We will use the notion of increasing function in lattice, which differs from the usual definition. Observe that one may also encounter the term isotone in the literature.

Definition 8.3 (Increasing). We say that a function f from two ordered sets is increasing if for all x ≤ y, f (x) ≤ f (y).

GAME PRESENTATION AND MAIN RESULTS

Game Presentation

Notations

The game (I, T, B, Σ, K, p) consists in a set of players I = 1 . . . n, n ∈ N. For each player, there is a set of types T i and a set of bids (or action) B i . Types and bids are included in a compact [c * , c * ] (where c * > 0) such that T ⊂ B. The strategies are applications from T i to B i . For each player, we denote by Σ i his strategy set. For any i ∈ I, the demand response K i is a function from the bid set B to [0, K + ], where K + > 0. We generically denote by σ i the elements of the strategy set Σ i , c i the elements of T i (because it can be interpreted as a production cost and we want to avoid any confusion with the time variable), and b i the bids, elements of B i . We use the standard notation of game theory -i to refer to all but player i. Last but not least, p i is a probability density of support T -i .

For a strategy profile σ -i = (σ 1 . . . σ n ), the expected ex-ante payoff Π i of player i of

type c i bidding b i = σ i [c i ] is Π i σ -i (b i , c i ) = c -i ∈T -i π i (b i , c i , σ -i [c -i ])p -i (c -i )dc -i , (8.1)
with the payoff π i defined for

(b i , c i , σ -i , c -i ) ∈ B i × T i × Σ -i × T -i by π i (b i , c i , σ -i [c -i ]) = (b i -c i )K i (b i , σ -i (c -i )). (8.2)
In this expression, K i can be interpreted as the quantity i is asked to provide for a marginal price profile b i when the other players bid the marginal prices σ -i [c -i ]. So the integrand is the profit of this player if he has a marginal production cost c i . The kernel K i corresponds to the market (or auctioneer) response to the bids. We assume the Kernel to be continuous.

In what follows we assume π

i (b i , c i , σ -i [c -i ]) Lebesgue measurable with respect to c -i for all (b i , c i , σ -i ) ∈ B i × T i × Σ -i .
Definition 8.4 (Best Reply ). We denote by BR i the Best Reply set-valued mapping from Σ -i to the subsets of Σ i such that for any σ

-i ∈ Σ -i , BR i (σ -i ) = {β ∈ Σ i : ∀(c, σ) ∈ T i × Σ i , Π i σ -i (β[c i ], c i ) ≥ Π i σ -i (σ i [c i ], c i )} (8.3) Definition 8.5 (Pure Nash Equilibrium). A strategy profile σ ∈ Σ is a Pure Nash Equi- librium if for any i ∈ I, σi ∈ Σ i and c i ∈ T i Π i σ -i (σ i [c i ], c i ) ≥ Π i σ -i (σ i [c i ], c i ) (8.4)
We use the partial order ≤ Σ i on Σ i defined by

∀(σ 1 , σ 2 ) ∈ Σ i , (σ 1 ≤ Σ i σ 2 ) iff (∀c ∈ T i , σ 1 (c) ≤ σ 2 (c)). (8.5) • σ * (T) is included in ]b * , b * [ I ,
where σ * is the smallest equilibrium's strategy profile.

• For any (σ

-i , c) ∈ Σ i × T i , Π i σ -i (b, c) is concave in b.
Then the solution to the system of differential equations

∀(i, c) ∈ I × T i ∂ t σ i (c, t) = ∂ b Π i σ(,t) -i (σ i (c, t), c) (8.11) σ i (c, 0) = c (8.12)
converges to the smallest equilibrium strategy profile σ * as t goes to +∞.

Application

Consider a simple geographical electricity market with two nodes (Node 1 and Node 2).

The nodes are connected by a line through which electricity can be sent. There is a known (inelastic) demand d at each node. We assume marginal prices to be constant, within a compact [b * , b * ]. We consider that there is one producer at each node, namely a 1 and a 2 .

An independent operator has to allocate the production to meet the demand at each node and to minimize the total cost paid to the producers. When a quantity h of electricity is sent through the line, rh 2 is lost in the process (Joule effect). The players of the Bayesian game are the two producers, who want to maximize their expected profit (we say expected because they do not know the other player production cost). Solving the independent operator problem, we get

K i (b i , b -i ) =          F (b i , b -i ) if F (b i , b -i ) ≥ 0 and F (b -i , b i ) ≥ 0 0 if F (b i , b -i ) < 0 q if F (b -i , b i ) < 0, (8.13)
where

F (x, y) = d + 1 2r x -y x + y 2 - 1 r x -y x + y and q = 2 1 - √ 1 -2dr r . (8.14)
Therefore Assumption 5 is satisfied. Observe that the increasing difference property is not satisfied (see Picture 8.1) everywhere. In the following, we assume that F (b * , b * ) ≥ 0. Therefore the corner solutions are not to be considered and

K i (b i , b -i ) = F (b i , b -i ).
Moreover, we assume b * < 2b * . Then the payoff writes

π i c (b i , b -i ) = (b i -c)K i (b i , b -i ). Therefore ∂ xy π i c (x, y) = 4y r(x + y) 4 (x(2y -x) + c(2x -y)) > 0 (8.15)
Therefore the strict increasing differences condition 6 is satisfied. So Theorem 8.6 applies.

CHAPTER 8. BIDDING GAMES

Lemma 8.15. For any i ∈ I, for any (c,

σ -i 1 , σ -i 2 ) ∈ T i × Σ -i 2 , such that σ -i 1 < σ -i 2 , for any (β 1 , β 2 ) ∈ BR i (σ -i 1 ) × BR i (σ -i 2 ) β 1 (c) ≤ β 2 (c) (8.21)
In particular, BR i is increasing in the induced set ordering on Σ i . In addition, for any

σ -i ∈ Σ -i , BR i (σ -i ) is a complete sublattice.
Proof. By continuity and compactness, for any c ∈ T i , arg max b Π i c (b, σ -i ) is nonempty. Since Π i c is quasisupermodular (Lemma 8.12) and satisfies the strict single crossing property (Lemma 8.10). Therefore by Theorem 8.13,(8.21) is satisfied for any c. So any selection of BR i is increasing in σ -i . Therefore BR i in increasing in the induced set ordering. Since Π is continous in b (by continuity of the integrand) and supermodular in b (since b is monodimensionnal), by corollary 2.7.1 of [START_REF]Supermodularity and complementarity[END_REF],

BR i (σ -i )[c] is a complete sublatice of B i , therefore BR i (σ -i ) is a complete sublatice of Σ i .
Theorem 8.16 (Tarsky fixed point, see [START_REF]Supermodularity and complementarity[END_REF] Theorem 2.5.1). Suppose that X is a non empty complete lattice, Y (x) is an increasing correspondence (in the induced set ordering) from X to the set of the non empty complete sublattices of X. Then the set of fixed points of Y is a nonempty complete sublattice.

Proof of Theorem 8.6. With Lemma 8.15, Y = (BR 1 (σ -1 ) . . . BR n (σ -n )) is increasing in the induced set ordering on Σ. Since Σ is a non empty complete lattice (this comes from the definition of B), Theorem 8.16 ensures that the set of fixed points is a nonempty complete sublattice. The elements of this set satisfy the definition of a Nash equilibrium.

On the example: multinodal case Observe that the reasoning could be extended to a multinodal, non symmetric setting. One needs to use the strict increasing difference property with respect to the neighboring nodes.

Uniqueness Sufficient Condition

Proof of Theorem 8.7. Assume that the equilibria set is not a singleton. Then since it is a complete lattice, there exists a biggest and a smallest equilibria in the set. We denote by σ ∈ Σ and σ ∈ Σ the strategy profiles of those equilibria. The ratio where we applied the definition of BR, the scaling relation (8.8) and a change of variable. Now combining the last computation with (8.9), we have

σi [c] σ i [c] (8.
BR i (ασ -i )[c] < ασ i [c] (8.29)
The inequality should be understood in the sense that any element of the LHS set is smaller than the RHS. Combining the definition of an equilibrium, Lemma 8.15 on the monotonicity of the best replies, and the last relation, we get

σi [c] ∈ BR i (σ -i )[c] ≤ BR i (ασ -i )[c] < ασ i [c] (8.30)
which is not coherent with the definition of α. We conclude that the equilibrium is unique. Observe that for T small enough, D T is stable by φ, which is a contracting operator, and, moreover, D T associated with the || ∞ is a closed subset of a Banach space. Therefore we can apply Picard fixed point theorem and denote by σt the associated fixed point.

Iterating the reasoning we can extend the flow σt as long as it stays strictly below b * .

Using the single crossing property of Π (which is conserved by integration from π), the fact that Π is convex and that the dynamics cancel at any equilibrium point, we see that σt increases and stays below σ * . Therefore the flow is defined for all t ≥ 0, is bounded and increasing and therefore converges as t goes to +∞ to a stationary point. Using the convexity of Π, we deduce that the stationary point is an equilibrium, therefore the flow converges to σ * .

Remarks

Observe that we could build the same kind of scheme to compute σ * . We introduce this scheme because it showed better converging properties on our example than the Best Reply iterations. Our explanation is that the Best Reply dynamics requires a discretization of B and T, while an Euler scheme of the differential equation only requires a discretization of T (and the time). We display in Figures 8.

Conclusion and possible extension

We have identified a class of Bayesian games for which we showed that there exists a unique pure Nash equilibrium to which a simple dynamics converges. Numerical experiments seem to indicate that those results could be reinvestigated with weaker assumptions.

In addition, some extensions should be considered. In particular the use of affiliated types, atoms in the distribution and general bidding functions (not only constant marginal rates). Listing B.3 -dynamics # I n i t i a l and f i n a l time : time . i n i t i a l double 0 time . f i n a l double 24 # Dimensions : s t a t e . d i m e n s i o n i n t e g e r 1 c o n t r o l . d i m e n s i o n i n t e g e r 1 c o n s t a n t . d i m e n s i o n i n t e g e r 0 brownian . d i m e n s i o n i n t e g e r 0 # C o n t r o l : d i s c r e t i z a t i o n . c o n t r o l . type s t r i n g u nif orm c o m b i n a t i o n . c o n t r o l . type s t r i n g un ifo rm # Time d i s c r e t i z a t i o n : d i s c r e t i z a t i o n . time i n t e g e r 24 # Grid type : g r i d . ty pe s t r i n g uni for m # I n t e r p o l a t i o n : i n t e r p o l a t i o n . i n n e r s t r i n g l i n e a r i n t e r p o l a t i o n . o u t e r s t r i n g u s e r _ f u n c t i o n # S w i t c h i n g mode : s w i t c h i n g . mode i n t e g e r 1 # S i m u l a t i o n : s i m u l a t i o n . type s t r i n g from_computed_sol s i m u l a t i o n . n o i s e s t r i n g none s i m u l a t i o n . s t a r t i n g . mode s t r i n g u s e r _ f u n c t i o n s o l u t i o n . • Global optimization for both deterministic and stochastic optimal control problems.

• Handles switching between discrete modes of the system.

• Stopping time problems can be solved using switchings.

• Built-in simulation module to recompute optimal strategies.

• Supports advanced rules to define the discrete control set.

• Parallel execution with OpenMP.

• Matlab / Python scripts to read value function and simulated trajectories.

Algorithm

The original Bocop package implements a local optimization method. The optimal control problem is approximated by a finite dimensional optimization problem (NLP) using a time discretization (the direct transcription approach). The NLP problem is solved by the well known software Ipopt, using sparse exact derivatives computed by Adol-C.

The second package BocopHJB implements a global optimization method. Similarly to the Dynamic Programming approach, the optimal control problem is solved in two steps. First we solve the Hamilton-Jacobi-Bellman equation satisfied by the value fonction of the problem. Then we simulate the optimal trajectory from any chosen initial condition. The computational effort is essentially taken by the first step, whose result, the value fonction, can be stored for subsequent trajectory simulations.

Workflow

BocopHJB package contains core files and problem files. Core files implements the HJB solver and are problem independent. Each problem is defined by a set of c/c++ files and text files located in the problem folder. Solving an optimal control problem with BocopHJB involves the following steps:

1. Problem Definition Define the optimal control problem by completing the problem files. This files typically define the dimension, functions, and discretization (time, state and control) of the problem.

Build and Run

The build step will create the bocophjp executable. Running the executable will, depending on the options set in problemHJB.def, compute the value fonction and/or simulate an optimal trajectory.

Visualization

You can use provided python scripts in order to load and visualize the results of the solution and simulation files. Note that plotting the value fonction is not always available since it is a function of n variables, where n is the state dimension.

Problem description

To test the use of both several switching possibilities and controls, we designed the following maze problem. A mouse trapped in a maze tries to get out. This mouse has a "bomberman typed" control space. The state can be described by the variable (x, y) ∈ R 2 describing the position of the unlucky punctual mouse. The mouse has 4 modes modeling its direction: north, east, west, south. In addition to the direction modes, the mouse has a control variable for its velocity, which is positive and upper-bounded. We consider a running cost of 10 per unit of time in the maze, and each change of direction costs 1 as a switching cost. The mouse starts at the red square while the exit of the maze is at the green square. The optimal trajectory is shown on Fig. 1.

where is the running cost and φ the final cost.

Remark: Our framework includes additional state and control constraints of the form g(t, u(t), y(t)) ≤ 0. It also handles switchings between several modes, which allows in particular to solve stopping time problems, on/off state of plants, etc.

Dynamic Programming Principle

We define the value function V (x, t) such that V (x, t) := min Let us take τ ∈ (t 0 , T ). We can write V (y 0 , t 0 ) = min

We can discretize on time the stochastic process (using for instance an Euler scheme), so that we have y k+1 as a function of y k , σ k , u k . Let t k = h 0 k with t N = T . The discretized problem is min

u k ∈U E h 0 N -1 k=0 (t k , u k , y k ) + φ(y N )

Description of problem files

In BocopHJB a problem is defined by the following files:

• a set of (C/C++) files: -constraints.cpp for the constraints of the problem (state and/or control-state) -costFunctions.cpp for the running, final and switching cost functions -dynamicsHJB.cpp for the drift and volatility -simulation.cpp for the initial conditions of the simulated trajectory -optionalFunctions.cpp for several optional functions see 4.5

• a set of text files: -problemHJB.def for general definition and settings -stateDisc/ folder for state discretization -controlDisc/ folder for control discretization

Definition file: problemHJB.def

This file defines the dimensions and names for the variables, as well as several general parameters. Note that the ordering of the lines in this file does not matter. Blank lines can be used for more clarity, as well as comments beginning by #. We recommend renaming every variable and control, however this is not mandatory. The line format is the following: keyword type value, where the keywords are listed below and the type can be integer, double or string.

• Initial and final time time.initial: initial time t 0 time.final: final time t f

• Dimensions state.dimension: dimension of state variables y control.dimension: dimension of control variables u constants.dimension: number of numerical constants brownian.dimension: dimension of brownian motion W

• Control discretization discretization.control.type: discretization for each component of the control, can be "uniform" (automatic), "user function" (see 4.5.2), or "user file". The values for the i-th control component are in the files controlDisc/control.i.disc and must be filled manually if option is set to "user file".

combination.control.type: how to build the discretized control set. It can be "uniform" (automatic), "user function"(see 4.5.2), or "user file". The control set is written in the file controlDisc/control.combination, one element per row. As above, the file must be filled manually if option is set to "user file", in which case "discretization.control.type" is ignored.

• Time discretization discretization.time: number of time steps

• Grid type grid.type: type of state grid, for now the only available option is "uniform".

• Interpolation interpolation.inner: type of interpolation for the points inside the grid, for now the only available option is "linear interpolation".

interpolation.outer: type of interpolation for the points outside the grid, can be "final value" for the final value, "projection" for the projection on the nearest point of the grid, or "user function" (see 4.5.3) for a specific function coded by the user.

• Switching mode switching.modes: number of modes among which the system can switch. Set to 1 if there are no switchings.

• Simulation simulation.directory: the name of an existing directory inside the problem directory where the simulation results will be saved. The simulated trajectory consist in the files simulatedTrajectory.[times,states,controls, modes] that contain the values for (t, x(t), u(t)) and the mode.

simulation.type: can be "none" (only compute the value function, no trajectory simulation), "from computed sol" (first compute the value function, then simulate the optimal trajectory from the given initial conditions), or "from sol file" (read a previously computed value function file then simulate the optimal trajectory).

simulation.noise: type of noise (i.e. realization of the Brownian for the simulation), can be "none", "gaussian", or "user function" (see 4.5.5). This parameter has no effect for deterministic problem with brownian.dimension set to 0.

simulation.starting.mode: set the initial mode for the simulation; "auto" picks the initial mode i 0 giving the lowest value of V (t 0 , x 0 , i 0 ), "user function" lets the user set explicitly the initial mode i 0 in simulation.cpp (see 4.4).

• Names state.i: name of component i of y control.i: name of component i of u

• Constants constant.i: name and value of i th constant, the name replaces the type for constants (ex: constant.0 c0 1.0)

• Solution file solution.file: name of the solution file (default "valueFunction.sol")

• Output frequency timestep.output.frequency: frequency of the displayed output (in the terminal), can be 0 for no output at all, 1 to output every time step, or n (with n an integer less than the number of time step) to output only the time steps which are multiple of n.

switching cost to describe the criterion to optimize; if there are constraints, the functions to check the admissibility of the states and the controls; and some other optional functions, if the user wants to give its own functions to discretize the single controls, to make the control combinations, or to interpolate inside and/or outside the grid.

The dynamics functions f and σ are in dynamicsHJB.cpp:

More advanced features

In this part we describe some optional more advanced functions. This function allows to define explicitly the elements of the discret control set. Each element is an m-tuple, where m is the dimension of the control space. It can be used in particular to enforce some constraints on the control.

// User function to compute the combinations of controls. // Each line of the resulting matrix is a combination of controls (u_0,..., u_p) vector< vector<double> > userControlCombination(const int dim_constant, const double* constants)

The next function is similar but also take into account the state variables. In the following, <BOCOPHJB> is the directory in which you have extracted the package. Please make sure that there are no blanks or spaces in the path name to this folder.

A. PREREQUISITES BocopHJB requires the compiler g++ and CMake. Please install them if necessary (using yum, apt-get or the system tools).

B. HOW TO LAUNCH BOCOPHJB

First we recommend that you compile and run a test case. Title : Mathematical contributions for the optimization and regulation of electricity production

Keywords : electricity, microgrid, network markets, optimization, aging, mechanism design, auctions.

Abstract : We present our contribution on the optimization and regulation of electricity production.

The first part deals with a microgrid Energy Management System (EMS). We formulate the EMS program as a continuous time optimal control problem and then solve this problem by dynamic programming using BocopHJB, a solver developed for this application. We show that an extension of this formulation to a stochastic setting is possible. The last section of this part introduces the adaptative weights dynamic programming algorithm, an algorithm for optimization problems with different time scales. We use the algorithm to integrate the battery aging in the EMS.

The second part is dedicated to network markets, and in particular wholesale electricity markets. We introduce a mechanism to deal with the market power exercised by electricity producers, and thus increase the consumer welfare. Then we study some mathematical properties of the agents' optimization problems (producers and system operator). In the last chapter, we present some pure Nash equilibrium existence and uniqueness results for a class of Bayesian games to which some networks markets belong. In addition we introduce an algorithm to compute the equilibrium for some specific cases. We provide additional information on BocopHJB (the numerical solver developed and used in the first part of the thesis) in the appendix.

Contents 1 . 1 15 1. 2 18 1. 3 20 1. 4

 11152183204 Présentation générale . . . . . . . . . . . . . . . . . . . . . . . . . Quelques mots sur l'électricité . . . . . . . . . . . . . . . . . . . Résumé et contributions de la première partie . . . . . . . . . . Résumé et contributions de la seconde partie . . . . . . . . . . 23 1.5 BocopHJB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 1.6 Perspectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

16 CHAPTER 1 .

 161 INTRODUCTION d'électricité décentralisées. Cette idée peut sembler dans un premier temps étonnante, car le bon sens recommanderait plutôt a priori de centraliser pour faire des économies d'échelle et prendre des décisions qui soient optimales globalement. Néanmoins ce concept suscite un intérêt croissant dans le domaine [74]. L'étude des avantages et inconvénients du micro-réseau en tant que moyen de production d'électricité n'entre pas dans ce projet de recherche. Observons tout d'abord qu'il existe un scénario où l'intérêt du micro-réseau est indéniable : quand il ne s'agit pas d'un choix mais d'une nécessité. Ainsi les deux chapitres suivants portent sur l'optimisation d'un modèle de micro-réseau construit à partir d'un cas réel : le projet du village de Huatacondo dans le désert de l'Atacama, au Chili 1 . Ce village, parce qu'il est géographiquement isolé, n'est pas connecté au reste du réseau national chilien. Il s'agit d'une situation typique pour les lieux isolés et peu peuplés, tels que les endroits difficilement accessibles, les îles de petites tailles, etc. Le lecteur pourra se faire une idée du lieu avec les photographies 2 des illustrations 1.1, 1.2 et 1.3.

Figure 1 . 1 -Figure 1 . 2 -Figure 1 . 3 -

 111213 Figure 1.1 -Le village de Huatacondo, déconnecté du reste du reseau

CHAPTER 1 .

 1 INTRODUCTION des jeux Bayesiens. Le manuscrit contient plusieurs références à des résultats classiques d'optimisation convexe. La construction du solveur numérique BocopHJB ne fait pas l'objet d'une discussion spécifique au sein de ce manuscrit. J'aborde quelques points clefs de la théorie sous-jacente (le Principe de Programmation Dynamique et l'équation de Hamilton-Jacobi-Bellman) dans la suite de cette introduction. Le guide utilisateur ajouté en annexe fournit l'information nécessaire à son utilisation, et le guide d'exemples illustre les types de problèmes que l'on peut résoudre avec le logiciel. Quelques extraits du code de micro-réseau simplifié présenté au Chapitre 4 sont également donnés en annexe. Comme ce travail est une compilation de projets d'articles, les chapitres peuvent se lire indépendamment les uns des autres. Les noms de mes co-auteurs sont précisés au début de chaque chapitre. Les deux parties correspondent à des projets différents et indépendants. 1.2 Quelques mots sur l'électricité L'énergie (et donc la production d'électricité) est un sujet sociétal important. Pour preuve, la période pendant laquelle ce manuscrit a été élaboré fut le témoin de la COP21. Durant cette conférence, les dirigeants du monde entier ont débattu d'une politique pour lutter contre le réchauffement climatique. Les problématiques liées à l'énergie et la production d'électricité furent un des grands axes discutés au cours de ces échanges. Par ailleurs, l'électricité est aussi un sujet complexe. Le réseau électrique est un système gigantesque faisant interagir de nombreux agents à des échelles différentes dans un environnement incertain et sous des horizons temporels variés, auxquels s'ajoute un lot de contraintes techniques et légales.

1. 2 . 19 Figure 1 . 4 -Figure 1 . 5 -

 2191415 Figure 1.4 -Capacité en renouvelables (monde) en 2004 (en haut) et 2014 (en bas) Source: http://www.ren21.net/resources/charts-graphs/

1. 3 .Figure 1 . 6 -

 316 Figure 1.6 -Représentation synthétique de la microgrid de Huatacondo. En haut la demande en électricité, en bas la production non contrôlable, et au milieu les deux variables d'ajustement : la batterie et le générateur diesel. Puisque par bilan des puissances, la demande doit être égale à la somme des productions, et que seuls les deux éléments de la ligne du milieu (diesel et batterie) correspondent à des quantités contrôlables, on peut comprendre avec cette figure que la seule variable de décision sera la puissance du générateur diesel.

Chapter 3 :

 3 A Stochastic Continuous Time Model for Microgrid Energy Management Ce chapitre est paru comme article de conférence pour the European Control Conference 2016 (ECC2016), Aalborg Danemark 29 juin-1er juillet 2016.

  ) où r est le coefficient de perte en ligne, et d la demande aux deux noeuds du réseau. Après un chapitre introductif (chapitre 5), nous présentons un mécanisme d'incitation pour des coûts de productions linéaires (chapitre 6). Nous généralisons ce mécanisme dans le chapitre 7 au cas de coûts de production linéaires par morceaux dans un réseau avec des contraintes et des externalités plus générales. Nous discutons aussi des propriétés du programme d'allocation que résout l'opérateur central et en déduisons un algorithme de calcul d'allocation "décentralisé". Le dernier chapitre contient un résultat d'unicité de l'équilibre de Nash en stratégie pure du jeu Bayésien induit par ce modèle de marché, dans le cas de fonctions de coût linéaires. Nous introduisons ensuite un système d'équations différentielles couplées pour lequel cet équilibre de Nash est un point stationnaire. Nous en déduisons un schéma numérique pour calculer les stratégies d'équilibre. Pour la famille de jeux étudiée, ce schéma présente de meilleures propriétés de convergence numérique que l'algorithme d'itérations sur les meilleures réponses. Il nous a permis de calculer les stratégies d'équilibre du marché à partir desquelles on obtient le coût moyen payé par la société quand le mécanisme d'incitation n'est pas implémenté. De cette manière on peut estimer l'économie que représente pour le consommateur l'implémentation du mécanisme d'incitation (cf. chapitre 6).

Figure 2 . 2 -

 22 Figure 2.2 -The PMP trick illustrated

Figure 2 . 10 -

 210 Figure 2.7 -Summer Direct Simulation

  12), (3.13) and (3.14) correspond to physical properties and limitations of the battery, with P I and P O defined by equation (3.4). The sets I P O and I P I are segments of R + and I C is included in [0, 1]. The parameters A and M are positive constants.

3. 3

 3 and 3.4.

Figure 3 . 1 -

 31 Figure 3.1 -The estimated volatility

Figure 3 . 2 -

 32 Figure 3.2 -We simulate some scenarios with the load model, and compare them with historical day taken at random. The grey area corresponds to one standard deviation. The unit is the kW.

APPENDIX

Figure 3 . 5 -

 35 Figure 3.5 -Real model: Solar Production (in kW)

Figure 3 . 3 -Figure 3 . 4 -

 3334 Figure 3.3 -Deterministic simulation algorithm

Figure 3 . 8 -Figure 3 . 9 - 4 Long

 38394 Figure 3.8 -Load and Production for the deterministic simulation (in kW)

Contents 4 . 1

 41 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2 Setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2.1 Problem Formulation . . . . . . . . . . . . . . . . . . . . . . . . 4.2.2 Assumptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3 Bilevel Dynamic Programming . . . . . . . . . . . . . . . . . . . 4.3.1 Mathematical Justification . . . . . . . . . . . . . . . . . . . . . 4.3.2 Complexity Analysis . . . . . . . . . . . . . . . . . . . . . . . . . 4.4 Adaptative Weights . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.1 Preliminary Results . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.2 Nice Case: No Duality Jumps . . . . . . . . . . . . . . . . . . . . 4.4.3 Some comments on Γ . . . . . . . . . . . . . . . . . . . . . . . . 4.4.4 Generic Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.5 Complexity Analysis . . . . . . . . . . . . . . . . . . . . . . . . . 4.5 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4. 5 . 1

 51 Asymptotic Analysis . . . . . . . . . . . . . . . . . . . . . . . . . 4.5.2 Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.5.3 Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.6 Simulation and Implementation on a Microgrid Model . . . . . 4.6.1 Problem Presentation . . . . . . . . . . . . . . . . . . . . . . . .

69

 69

cF

  = ĉF . With direct dynamic programming, either we recompute the value function every time (a), or we keep it in memory (which requires a lot of resources)(b). If we keep the whole value function in memory, it requires a memory space proportional to N a N c N t N T , which is not realistic. If we only keep the value function at the end of each period, then we only need a memory space proportional to N a N , but we need to recompute the intermediate value function for a computation burden of N a N c N u N t T .

  by Lemma 4.4 and Lemma 4.1:

Figure 4 . 1 -

 41 Figure 4.1 -An example of Γ(α) profile: This drawing summarize the possible behaviors of ∆a(α), i.e the influence of the penalization parameter over the aging in the micro problem.It can be either continuous and strictly decreasing or constant, or it may "jump" for a given value of α. If there is a jump at α = α 0 then we cannot a priori say that Γ(α 0 ) is a singleton. In addition, it may happen that Γ 'misses' some values at α 0 .

4. 5 . DISCUSSION 87 Short

 587 Term and Long Term RandomnessWith Markovian dynamics and final constraints on the average age increment, the same arguments should apply. Moreover, we could add an integer state with Markovian dynamics to model the type of 'days'.

  the authors propose three ways to model battery aging: a physico-chemical model, a weighted Amp-hour (Ah) throughput model (or charge counting model) and an event oriented model. In [22] Borhan et al. propose a model predictive control approach where the aging is penalized in the criterion. They implement a weighted Ah throughput model. In [60] Koller et al. propose a discrete time, model predictive control where the aging factor is the Depth of Discharge (DoD), which is modeled with piece-wise affine dynamics.In[START_REF] Haessig | Aging-aware nas battery model in a stochastic wind-storage simulation framework[END_REF] Haessig et al. propose a simulation that includes an aging model in order to perform a cost analysis, yet the optimization of the operations is not in the scope of this work. In his PhD thesis[START_REF] Haessig | Dimensionnement et gestion d'un stockage d'énergie pour l'atténuation des incertitudes de production éolienne[END_REF] Haessig describes a battery aging model (among others) based on the total amount of energy exchanged during the lifetime of the battery. In[START_REF] Riffonneau | Optimal power flow management for grid connected PV systems with batteries, Sustainable Energy[END_REF] Riffonneau et al. use a a discrete time dynamic programming approach to solve an optimal power flow problem. The battery aging is proportional to the discharge of the battery. It linearly decreases the capacity of the battery.In[START_REF] Palma-Behnke | A microgrid energy management system based on the rolling horizon strategy[END_REF], Palma et al. integrate the battery aging in a rolling horizon strategy model.

91

 91

Figure 4 . 2 - 95 U

 4295 Figure 4.2 -On the left: The aging severity factor as a function of the charge. The severity factor is greater when the battery is depleted. This function was originally obtained by interpolation of a piece-wise constant severity factors model. Note that in the model the battery aging happens only when energy is taken from the battery.On the right: solar production and load during the day. Observe that the solar production only happens during mid-day, whereas the load profile has a constant component and two peaks, one in the morning and one in the evening. For both plots, we made the choice to use analytic expressions to produce synthetic data.

Figure 4 . 3 -

 43 Figure 4.3 -Three simulations for (α, a) equal to (0, 0) (solid), (0, 400) (dot and dash) and (250, 0) (dot). The bell shaped curve correspond to the solar production P s and the other one to the load P L .

Figure 4 . 4 -Figure 4 . 5 -Figure 4 . 6 -

 444546 Figure 4.4 -∆a(α) for a = 0 (solid line) and a = 450 (dashed line)

4. 6 .Figure 4 . 7 -Figure 4 . 8 -

 64748 Figure 4.7 -Two trajectories computed with AWA for a(0) ∈ {0, 100}

CHAPTER 4 .Figure 4 . 9 -Figure 4 . 10 -

 449410 Figure 4.9 -The daily age increments along the trajectories for a(0) ∈ {0, 100}

Figure 4 . 11 -

 411 Figure 4.11 -Envelope of u obtained by dynamic programming for the long term problem

Figure 4 . 12 -

 412 Figure 4.12 -The age profile computed with AWA (solid line) and bruteforce dynamic programming (dotted line) for two initial age values

Contents 5 . 1

 51 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 5.2 Setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 5.3 Literature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 5.4 Quantitative formulations . . . . . . . . . . . . . . . . . . . . . . 109 5.4.1 Generality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 5.4.2 The standard allocation problem . . . . . . . . . . . . . . . . . . 109 5.4.3 The agent problem . . . . . . . . . . . . . . . . . . . . . . . . . . 110 5.4.4 The optimal mechanism design problem . . . . . . . . . . . . . . 111 5.4.5 A differential equation . . . . . . . . . . . . . . . . . . . . . . . . 112 5.5 Important results . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 5.6 The ISO response for a binodal setting with piecewise linear cost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 5.6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 5.6.2 If d < q . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 5.6.3 Case d ≥ q . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 5.7 Ongoing work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 5.8 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 103 104CHAPTER 5.

5 . 1 a 2 rFigure 5 . 2 -

 51252 Figure 5.2 -In[START_REF] Figueroa | Cost-minimizing regulations for a wholesale electricity market[END_REF] and[START_REF]Monopolistic competition in electricity networks with resistance losses[END_REF], the authors consider a binodal market with quadratic line losses. The demand is the same at both nodes. The production cost functions are linear. There are no network and capacity constraints. A very intuitive justification of the market power induced by the line losses is given in[START_REF]Monopolistic competition in electricity networks with resistance losses[END_REF]. Indeed, in a symmetric perfect information setting with linear production cost function of slope c, the equilibrium strategy of both producers is to bid c 1-2dr > c.

Figure 5

 5 Figure5.3 -The average total cost for the ISO (in the market described in Figure5.3) as a function of the loss coefficient r for the standard mechanism and the optimal mechanism. We takef 1 (c) = f 2 (c) = 2c + (1 -2 4 )1 c≤ 1

120CHAPTER 5 .Figure 5 . 4 - 6

 5546 Figure 5.4 -Comparison of bidding strategy and information rent for the market described in Figure 5.3. The standard bid strategy corresponds to the equilibrium strategy of the Bayesian Game. The Honesty strategy correspond to a producer telling the truth. The optimal cost correspond to the sum of the truth-telling strategy and the information rent.

Contents 6 . 1

 61 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 6.2 The Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 6.3 A Mechanism Design Approach . . . . . . . . . . . . . . . . . . . 124 6.3.1 Some Basic Results . . . . . . . . . . . . . . . . . . . . . . . . . . 125 6.4 The Standard Mechanism . . . . . . . . . . . . . . . . . . . . . . 127 6.4.1 The Bayesian Game . . . . . . . . . . . . . . . . . . . . . . . . . 129 6.4.2 Approximation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 6.5 Some Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 6.6 Practical Implementation . . . . . . . . . . . . . . . . . . . . . . . 131 6.7 Sensitivity Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . 132 6.8 The social cost is not affine . . . . . . . . . . . . . . . . . . . . . 132 6.9 Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

a 1 a 2 rFigure 6 . 1 -

 261 Figure 6.1 -The binodal market

Figure 6 . 3 -Figure 6 . 4 -

 6364 Figure 6.3 -The social costs for the standard mechanism and the optimal mechanism

  The expected social cost (i.e. what is paid by the ISO) G(r) can be expressed as an integral 6.8. THE SOCIAL COST IS NOT AFFINE 133 over (c 1 , c 2 ) ∈ [0, 1] 2 :

c 1 +c 2 1 -

 21 and by P the polynomial P (Y ) = d + 1 2r Y 2 -1 r Y . We introduce y 0 (r) = 1 -√ 2rd the unique solution of P (y) = 0; 0 ≤ y ≤ 1. (6.22)

. 43 )Figure 6 . 5 -

 4365 Figure 6.5 -The social cost (red) is well approximated by an affine function (blue).

7. 5 . 1

 51 First order condition . . . . . . . . . . . . . . . . . . . . . . . . . 170 7.5.2 Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 7.6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 7.7 Proof of Lemma 7.7 . . . . . . . . . . . . . . . . . . . . . . . . . . 174 7.8 On S and the regularity of q . . . . . . . . . . . . . . . . . . . . . 175

and 150CHAPTER 7 .

 7 MECHANISM DESIGN AND ALLOCATIONS FOR NETWORK MARKETS Problem 3.

(7. 28 )

 28 Observe that since the problem is convex and the solution unique, this is in fact a necessary and sufficient condition for the unique solution of the problem. The N first rows of this relation gives:(-c 1 1 , . . . , -c N 1 ) = λ 1 (-1, . . . ,-1) + (z 1 , . . . , z N ). (7.29) 158CHAPTER 7. MECHANISM DESIGN AND ALLOCATIONS FOR NETWORK MARKETS

7. 4 .

 4 STUDY OF THE ALLOCATION PROBLEM 159

7. 4 .

 4 STUDY OF THE ALLOCATION PROBLEM 161 quantities. The partial derivative of F i for i ∈ I\{i} is

164CHAPTER 7 .

 7 MECHANISM DESIGN AND ALLOCATIONS FOR NETWORK MARKETS 7.4.2 Some properties of the solution If r and d are set, we can see the solution of Problem 4 as a function of the vector c ∈ C n .

170CHAPTER 7 .

 7 MECHANISM DESIGN AND ALLOCATIONS FOR NETWORK MARKETS (a) The network generated to test the linear implementation of the algorithm (b) The network generated to test the generic implementation of the algorithm setting and the solution of the optimal mechanism. In general the numerical search of such equilibrium requires to solve the allocation problems many times. A second motivation to present this piece of work here is the complementary insight it gives on the structure of the allocation problem.

  [START_REF] Borhan | Optimization-based power management of a wind farm with battery storage[END_REF] is bounded by b * /b * and therefore admits a supremum α > 1. By compactness of T and continuity of the extremal equilibrium strategies (hypothesis), there exist i * ∈ I and 8.6. A DYNAMICS THAT CONVERGES TO THE SMALLEST NASH EQUILIBRIUM189c * ∈ T i * such that σi * [c * ] σ i * [c * ] = α. (8.23)For any strategy profile σ ∈ Σ we denote by ασ the strategy profile defined by(ασ) i (c) = α(σ i (c)) (8.24)for any i ∈ I and c ∈ T i .By (8.10) ασ belongs to Σ. Now observe that for i ∈ I, c ∈ T,BR i (ασ -i )[c] = arg max b∈B i E c -i (bc)K i (b, ασ -i [c -i ])(8.25)= arg maxb∈B i E c -i (bc)K i (b/α, σ -i [c -i ]) (8.26) = arg max b∈B i E c -i (b/αc/α)K i (b/α, σ -i [c -i ]) (8.27) = α arg max u,αu∈B i E c -i (uc/α)K i (u, σ -i [c -i ])(8.28)

8. 6 A 8 . 6 . 1 8 Proof.

 68618 dynamics that converges to the smallest Nash Equilibrium Proof of theorem 8.First we need to show that (8.11) has a solution. Let T > 0 and D T the set of measurable functions σ from [0, T ] to Σ. On D T we consider the operator φ such that, for any σ ∈ D T , φ σ ∈ D T and for any (i, c, t)∈ I × T × [0, T ] [φ σ (t)] i (c) = c + t 0 ∂ b Π i [σ(s)] -i ([σ(s)] i (c), c)ds. (8.31) CHAPTER 8. BIDDING GAMES

2

 2

  and 8.3 a numerical experiment with the Best Reply iterations and the continuous time dynamics. Even when the hypotheses of Theorem 8.8 are not satisfied, the scheme displays good converging properties.

Figure 8 . 2 -

 82 Figure 8.2 -The iterated best replies algorithm does not converge

Figure 8 . 3 -

 83 Figure 8.3 -The differential approach converges when we start above or below the equilibrium strategy profil

  f i l e s t r i n g v a l u e F u n c t i o n Listing B.4 -problemHJB.def Frédéric Bonnans * Daphné Giorgi † Benjamin Heymann * Pierre Martinon * Olivier Tissot *

  BocopHJB package includes a folder examples/ with several sample problems to illustrate the features of the toolbox. These examples are described in more details in the document 'A collection of examples' 2 Example: the mouse & maze problem 2.

Figure 1 :

 1 Figure 1: The Maze and the mouse trajectory according to BocopHJB

  u s , y s )ds + φ(y T ) y t = x and V (x, T ) = φ(x)

u∈U E t 0 τ t 0 (

 0 t, u s , y s )ds + T τ (t, u s , y s )ds + φ(y T ) which leads to the dynamic programming equation V (y 0 , t 0 ) = min u∈U u s , y s )ds + V (y τ , τ )

4. 5 . 5

 55 Brownian realization for the simulation If simulation.noise is set to user function, user noise() in optionalFunctions.cpp defines the Brownian realization used in the simulation.// User function to compute the noise for the simulation. std::vector<double> user_noise() A Install notes (INSTALL file) ************************* BOCOP HJB INSTALL NOTES ************************* ----------------------------------------LINUX

  2.4.1 Comments on the Inputs: Solar Power and Power LoadWe test the algorithms on two historical data sets. Both data sets correspond to representative[START_REF] Heymann | A stochastic continuous time model for microgrid energy management[END_REF]-hour periods, one data set was obtained with winter data, the other one with summer data. Figures 2.3 and 2.4 show the load power and the solar power for the two

			CHAPTER 2. OPTIMAL CONTROL OF MIGROGRID
									P S
									P L
	5	10	15	20	25	30	35	40	45	50
					TIME (H)
		Figure 2.3 -Summer data in kW
									P S
									P L
	5	10	15	20	25	30	35	40	45	50
					TIME (H)
		Figure 2.4 -Winter data in kW
	days of each period.

Table 2 .

 2

	100
											SOC * 100
											SOLAR
											LOAD
	80										INVERTER INV. LIMIT
											SLACK
											DIESEL
	60
	40
	20
	0
	-20	0	5	10	15	20	25	30	35	40	45	50
						TIME (H)
	Name		Notation Value Unit
	Min Diesel Power	P min		5	kW
	Max Diesel Power	P max		120	kW
	Unserved Energy Cost C U S Diesel Start-Up Cost -		250 1000	CLP/kWh CLP
	Diesel Price		C D		500	CLP
	Table 2.1 -Model parameters, CLP means Chilean Pesos
			MILP		DIRECT	DP
	Diesel range		[18.66,29.69] [2.63,14.23] [8.15,28.66]
	Switchings		2		3			2
	Total Cost		34785		36244		34378
	Cpu Time		3.92 s		4.41 s		0.88 s
	SOC(0)=SOC(T) 0.7		0.641		0.7
	SOC range		[0.20,0.89]	[0.38,0.75]	[0.30,0.83]
	Slack Range		[0,0]		[0,0]		[0,0]

2.5 and 2.6 for the DP approach, in Figures 2.7 and 2.8 for the direct approach and in Figure 2.5 -Summer DP Simulation Figures 2.9 and 2.10 for MILP method. The numerical results are summarized in Table 2.2. 2 -Results: MILP, direct and DP (summer case)

Table 3

 3

	.1 contains the numerical values

  Λ k is the historical average of the load at time t k , i.e. Λ k = i∈1..N days Li k /N days .

	) k is a standard centered Gaussian variable and k ∈ {1, . . . , 96}. Note that as dis-where i 57 Table 3.1 -Numerical parameters Notation Value Q B 117 kWh A 1320 kW M 1000000 CLP 2K 1000 CLP (d, s) 500d 0.9 + 25000|s| CLP ρ O 0.95 ρ I 0.95 I d [5,120] kW I P I [0,13.2] kW I P O [0,40] kW I c [0.2,1] kW cussed in §3.2.2, 3.5. SIMULATION Set for all k ∈ {1, . . . , 96} and i ∈ {1, . . . , N days

  Battery Aging Model . . . . . . . . . . . . . . . . . . . . . . . . . 89 4.6.3 The Optimal Control Formulation . . . . . . . . . . . . . . . . . 91 4.6.4 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 4.6.5 Results for the Micro Problem . . . . . . . . . . . . . . . . . . . 94 4.6.6 Results for the Macro Dynamic Programming Phase of AWA (Adaptative Weights Algorithm) . . . . . . . . . . . . . . . . . . 94 4.6.7 Comparison with the Bruteforce Results . . . . . . . . . . . . . . 97 4.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

	64	CHAPTER 4. ADAPTIVE WEIGHTS ALGORITHM
	4.6.2

Table 4 .

 4

		1 -The offline computation burdens for the general case
	Approach	Computation burden offline	online	Memory requirement
	BF	(b)

Table 4 .

 4

3 -Model Constants and

Table 4 .

 4

		4 -Discretization parameters
	algorithm	micro (total) macro total AWA bruteforce
	Comp. time 12.8 min	0.2 sec 12.8 min	> 10 hours
		Table 4.5 -The computing times

Table 4

 4

	.6.

Table 4 .

 4

6 -Estimates of the value function

  7. MECHANISM DESIGN AND ALLOCATIONS FOR NETWORK MARKETS

	-	i∈I,j∈J	γ i,j h i,j +	i∈I,j∈J

  .46)7.4. STUDY OF THE ALLOCATION PROBLEM163So we can a posteriori justify that we have strong duality: the operator is continuous, convex-concave and the dual variables are restricted to be in a bounded set.

	So the dual of the allocation problem writes:
	maximize λ≥0	i∈I

  )

		Fixed Point CVX		Fixed Point CVX
	cost	83.2	83.195	cost	4971.4	4971.4
	time (s) 2.03	30.23	time (s) 28.39	35.23
	Table 7.2 -Results for a linear (a) and piecewise linear (b) instances of the problem solved with the fixed point algorithm and CVX.

  Uniqueness Sufficient Condition . . . . . . . . . . . . . . . . . . . 188 8.6 A dynamics that converges to the smallest Nash Equilibrium . 189 8.6.1 Proof of theorem 8.8 . . . . . . . . . . . . . . . . . . . . . . . . . 8.6.2 Remarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.7 Conclusion and possible extension . . . . . . . . . . . . . . . . . 190

This is a joint work with Alejandro Jofré

Contents 8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 8.2 Game presentation and main results . . . . . . . . . . . . . . . 182 8.2.1 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.2.2 Game Presentation . . . . . . . . . . . . . . . . . . . . . . . . . . 8.2.3 Main results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.3 Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 8.4 Existence of a Nash Equilibrium . . . . . . . . . . . . . . . . . . 186 8.4.1 General Preliminary Results . . . . . . . . . . . . . . . . . . . . . 8.4.2 Existence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.5

  2.2 Files for the mouse & maze problem 2.2.1 Definition files problemHJB.def, stateDisc/state.grid, controlDisc/control.grid, controlDisc/control.combination.Let y t be a stochastic process described bydy t = f (t, u t , y t )dt + σ(t, u t , y t )dW t y 0 = x (1)where the control u t ∈ U and t ∈ [0, ∞[, W t is a standard Brownian motion and the drift f and the volatility σ are Lipschitz and bounded.We define U the set of mappings with value in U adapted to the filtration generated by the Brownian motion (which means that we can take u(t) as a function of the past history of the Brownian). We want to solve the stochastic optimal control problem

	3 Algorithm description
	3.1 Stochastic optimal control problem
	# This file defines all dimensions and parameters
	# values for your problem :
	# Initial and final time :
	time.initial double 0
	time.final double 3
	# Dimensions :
	state.dimension integer 2
	control.dimension integer 1
	constant.dimension integer 0				# Discretization of the state :
	brownian.dimension integer 0				discretization.state.0 integer
					discretization.state.1 integer
	# Control :
	discretization.control.type string uniform				# Minimum of the state grid :
	combination.control.type string uniform				minimum.state.0 double 0
					minimum.state.1 double 0
	# Time discretization : discretization.time integer 50			T	# Maximum of the state grid :
	# Grid type : grid.type string uniform	min u∈U	E	t 0	maximum.state.0 double 1 maximum.state.1 double 1
	# Interpolation :
	# Inner : linear ; other				# Discretization :
	# Outer : final value ; projection ; user function		discretization.control.0 integer
	interpolation.inner string linear
	interpolation.outer string user_function				# Minimum of the control grid :
					minimum.control.0 double 0
	# Switching mode :
	switching.mode integer 4				# Maximum of the control grid :
					maximum.control.0 double 1
	# Names :
	state.0 string x1
	state.1 string x2
	control.0 string u
	# Simulation :
	simulation.type string from_computed_sol
	simulation.noise string none
	solution.file string valueFunction.sol
	2.2.2 Source files
	dynamicsHJB.cpp

(t, u s , y s )ds + φ(y T )

  For the simulation step, one has to set the initial state and mode in simulation.cpp. Modes are numbered from 0 to NbModes-1.

	// Drift function which describes the deterministic part of the dynamics.
	void drift(const double& initial_time,
	const double& final_time,
	const double& time,
	const vector<double>& control,
	const vector<double>& state,
	const int mode,
	const int dim_constant,
	const double* constants,
	vector<double>& state_dynamics)
	// Volatility function which describes the stochastic part of the dynamics.
	void volatility(const double& initial_time,
	const double& final_time,
	const double& time,
	const vector<double>& control,
	const vector<double>& state,
	const int mode,
	const int dim_constant,
	const double* constants,
	vector<double>& volatility_dynamics)
	Cost functions are in costFunctions.cpp:
	// Running cost for the computation of the criterion.
	void runningCost(const double& initial_time,
	const double& final_time,
	const double& time,
	const vector<double>& control,
	const vector<double>& state,
	const int mode,
	const int dim_constant,
	const double* constants,
	double& running_cost)
	// Final cost for the computation of the criterion.
	void finalCost(const double& initial_time,
	const double& final_time,
	const vector<double>& state,
	const int mode,
	const int dim_constant,
	const double* constants,
	double& final_cost)
	// Starting point definition.
	void simulationStartingPoint(vector<double>& starting_point)
	// Starting mode definition.
	void simulationStartingMode(int& starting_mode)

  4.5.1 State and/or control constraints State and control admissibility functions are in constraints.cpp: // User function used to check if a combination of controls is admissible or not. User function used to check if a combination of controls and a state is admissible or not. Control discretization functions are in optionalFunctions.cpp. : This function allows to define explicitly the discretized values taken by each component of the control.

	bool checkAdmissibleControl(const vector<double> control,
	const int dim_constant,
	const double* constants)
	// User function used to check if a state is admissible or not.
	bool checkAdmissibleState(const double initial_time,
	const double final_time,
	const double time,
	const vector<double> state,
	const int mode,
	const int dim_constant,
	const double* constants)
	// bool checkAdmissibleControlState(const double initial_time,
	const double final_time,
	const double time,
	const vector<double> control,
	const vector<double> state,
	const int mode,
	const int dim_constant,
	const double* constants)
	4.5.2 Non uniform control discretization

// User function used to define the discretized controls. // The user has to fill the values of m_discretizedControl[i][j] with i=0,...,m_dimControl // and j=0,...,m_discretizedControl

[i]

.size() int userControlDiscretization()

  // User function to compute the combinations of controls when it depends on state. // Each line of the resulting matrix is a combination of controls (u_0,...Interpolation of the value function when it is out of the grid is in optionalFunctions.cpp:// User function to compute the value of the value function for the points outside the grid.If the system has several modes (set in problemHJB.def) we must define the cost of switching from one mode to another. Modes are numbered from 0 to NbModes-1.

	4.5.3 Out of grid evaluation
	void userOutOfGridValueFunction(const double initial_time,
	const double final_time,
	const double time,
	const vector<double>& state,
	const int dim_constant,
	const double* constants,
	double& result)
	4.5.4 Switching modes
	// Switching cost for the computation of the criterion.
	void switchingCost(const int initial_mode,
	const int final_mode,
	const int dim_constant,
	const double* constants,
	double& switching_cost)
	, u_p)
	vector< vector<double> > userControlCombinationStateDependent(const double initial_time,
	const double final_time,
	const double time,
	const vector<double> state,
	const int mode,
	const int dim_constant,
	const double* constants)

  To do so you can call the following commands from <BOCOPHJB>: > ./bocop build examples/maze > ./bocop run examples/maze To define a new problem you can call the following command: > ./bocop create_problem PROBLEM_NAME Once you have completed the input files located in <BOCOPHJB>/problems/PROBLEM_NAME as described in the documentation. You have to compile (build) and run BocopHJB: > ./bocop build problems/PROBLEM_NAME > ./bocop run problems/PROBLEM_NAME If you want to visualize the simulation results you can call the following command: > ./bocop visualize -s -d problems/PROBLEM_NAME To visualize the value function you can call the following commands: > ./bocop visualize -v -d problems/PROBLEM_NAME -m MODE_VALUE -t TIME_VALUE First we recommend that you compile and run a test case. To do so you can call the following commands from <BOCOPHJB>: > sh bocop build examples/maze > sh bocop run examples/maze /!\ Please note that the check need python installed to be passed /!\ To define a new problem you can call the following command: > sh bocop create_problem PROBLEM_NAME Once you have completed the input files located in <BOCOPHJB>/problems/PROBLEM_NAME as described in the documentation. You have to compile (build) and run BocopHJB: > sh bocop build problems/PROBLEM_NAME > sh bocop run problems/PROBLEM_NAME If you want to visualize the simulation results you can call the following command: > sh bocop visualize -s -d problems/PROBLEM_NAME To visualize the value function you can call the following commands: NB: you can use the -h option to print an help message. production d'électricité Mots clefs : électricité, micro réseau, marchés en réseaux, optimisation, vieillissement, mécanismes d'incitation.Résumé : Nous présentons notre contribution sur la régulation et l'optimisation de la production d'électricité. La première partie concerne l'optimisation de la gestion d'un micro réseau. Nous formulons le programme de gestion comme un problème de commande optimale en temps continu, puis nous résolvons ce problème par programmation dynamique à l'aide d'un solveur développé dans ce but : Boco-pHJB. Nous montrons que ce type de formulation peut s'étendre à une modélisation stochastique. Nous terminons cette partie par l'algorithme de poids adaptatifs, qui permet une gestion de la batterie du micro réseau intégrant le vieillissement de celle-ci. L'algorithme exploite la structure à deux échelles de temps du problème de commande.La seconde partie concerne des modèles de marchés en réseaux, et en particulier ceux de l'électricité. Nous introduisons un mécanisme d'incitation permettant de diminuer le pouvoir de marché des producteurs d'énergie, au profit du consommateur. Nous étudions quelques propriétés mathématiques des problèmes d'optimisation rencontrés par les agents du marché (producteurs et régulateur). Le dernier chapitre étudie l'existence et l'unicité des équilibres de Nash en stratégies pures d'une classe de jeux Bayésiens à laquelle certains modèles de marchés en réseaux se rattachent. Pour certains cas, un algorithme de calcul d'équilibre est proposé. Une annexe rassemble une documentation sur le solveur numérique BocopHJB.

	> sh bocop visualize -v -d problems/PROBLEM_NAME -m MODE_VALUE -t TIME_VALUE
	Example:
	> sh bocop visualize -v -d <BOCOPHJB>/examples/maze -m 0 -t 0

voir https://building-microgrid.lbl.gov/huatacondo

en particulier, cf. l'hypothèse 3 dans le chapitre sur le vieillissement.

4

We assume differentiability of Ji just for simplicity, the proof can be done without it.

Take two optimal solutions, then check that the solution build with the average of the two flow vectors is admissible by convexity of the problem and strictly better by concavity of g.

Université Paris-Saclay Espace Technologique / Immeuble Discovery Route de l'Orme aux Merisiers RD 128 / 91190 Saint-Aubin, France

Remerciements

Chapter 7

Mechanism design and allocation algorithms for network markets with piece-wise linear costs externalities and externalities This is a joint work with Alejandro Jofré. positiveness of the production are not bounding (else we can already conclude). This can be checked numerically by computing the gradients at q i (h) = 0. Since the nodal constraints are bounding, we reformulate the problem:

By definition of φ for (i, j, h) ∈ I × J × R,

q i (h) -(j -1)q if q i (h) ∈ [j -1, j]q q if q i (h) ≥ j q.

(7.74)

So we can express the derivative of φ j i :

(7.75)

The function C is convex, the expression of its subdifferential ∂C(h) follows from (7.75):

](rh + 1) + c j 2 2 (rh -1) if q 2 (h) ∈](j 2 -1), j 2 [q and q 1 (h) = j 1 q c j 1 1 (rh + 1) + [c j 2 2 , c j 2 +1 2 ](rh -1) if q 1 (h) ∈](j 1 -1), j 1 [q and q 2 (h) = j 2 q

By the fifth assumption, we eliminate the last possibility. We denote

so that 0 ∈ ∂C(h) is equivalent to

] if q 2 (h) ∈]j 2 -1, j 2 [q and q 1 (h) = j 1 q g(rh) ∈ [

] if q 1 (h) ∈]j 1 -1, j 1 [q and q 2 (h) = j 2 q (7.77) 172CHAPTER

MECHANISM DESIGN AND ALLOCATIONS FOR NETWORK MARKETS

We denote

and

By (7.77), 0 ∈ ∂C(h) is equivalent to one of those propositions being true:

Proof. Fix q 1 i = q, the resulting optimization problem is equivalent to

We set

which is the 2-agent equivalent of F i . We already know that if (λ 1 , λ 2 ) are the solution of the dual, then q 1 = F (λ 1 , λ 2 ) and q 2 = F (λ 2 , λ 1 ). The main result of this part is:

and the second and third propositions of Lemma 7.27 are not satisfied, then let k be the smallest element of J ∩ {0} such that

Proof. If (B), then we show that q 2 ≥ q. Indeed, if we assume q 2 < q, then since we have eliminated the corner solution cases λ 2 = c 1 2 . If we assume in addition that q 1 < (k -1)q, then λ

2 ) > (k -1)q because of the definition of k, which is absurd. So if q 2 < q then necessarily q 1 > (k -1)q (The case q 1 = (k -1)q is a corner solution case that has been eliminated by hypothesis). So

> q which is in contradiction with the assumption. So if (B), then q 2 > q, and since c 1 1 < c 1 2 , q 1 > q. Else, by definition, (A) is true. Note that q 1 = F (c k 1 , c 1 2 ) and q 2 = F (c 1 2 , c k 1 ) solve the linear problem with c 1 = c k 1 and c 2 = c 1 2 and it is admissible. So by convexity, this is the solution.

Combining this result with the previous subsection, we can build an algorithm that first checks that we do not have a corner solution, and then recursively computes the solution.

Conclusion

We have shown how to characterize and compute the mechanism design. In addition, the allocation problem for the optimal and the standard mechanism are the same. We have proposed an algorithm based on a fixed point to solve the allocation problem. This work raises some questions. Can we weaken the Assumptions used in this work? Can we 174CHAPTER 7. MECHANISM DESIGN AND ALLOCATIONS FOR NETWORK MARKETS estimate the social benefit of using such mechanism? How to build numerical benchmarks to compare the optimal mechanism and the standard setting? How to implement the optimal mechanism in practice? Which real markets enter in the framework described in §7.3.6? 7.7 Proof of Lemma 7.7 Proof. By definition

We use (H1) for the last equality. Then we apply a telescopic formula

Reordering the last three terms, we get

7.8. ON S AND THE REGULARITY OF Q which is a system of equations in λ I B parametrized by c j I A . Let c ∈ C such that the system is satisfied, by Lemma 7.31, we can apply the implicit function theorem, so there is a ball around c in which S(I A , I B , I C , j, j ) is included in a smooth surface. By compacity of C, we can choose a sequence dense in S(I A , I B , I C , j, j ). We apply the result to each element of this sequence. By density, S(I A , I B , I C , j, j ) is a countable union of smooth surfaces.

Therefore the measure of S(I A , I B , I C , j, j ) is zero.

A direct consequence of Lemma 7.32 and Lemma 7.30 is Lemma 7.33. The measure of S is zero.

We proceed with the proof of Lemma 7.16. of lemma 7.16. Let c = (c 1 . . . c n ) ∈ C n \S. Let us show that q is infinitely differentiable at c. We consider the two assertions:

By Lemma 7.14 and by defintion of S, for any i ∈ I either A i or B i is true, but never both.

We denote by I A (resp. I B ) the set of elements of I for which A i (resp. I B ) is true. If A i is true for all i then there is a neighborhood V of c such that for any element c of V ,

then M is invertible (see lemma 7.31), the implicit function theorem applies and there exists a function λ I B so that in a neighborhood V of c, for all i ∈ I B , we have

checks the first order condition so by uniqueness c I A , λ I B (c) is the dual solution, and so,

) for all i ∈ I on V , so q i is C ∞ at c. This concludes the proof of the first part of the lemma.

The continuity of q comes from Berge maximum principle (see Theorem 9.17 in [START_REF] Sundaram | A first course in optimization theory[END_REF])

in a convex setting.

The next lemma is an important component for the proof of Theorem 7.10.

CHAPTER 8. BIDDING GAMES

We denote by ≤ Σ the induced product order on Σ.

Assumption 5 (Kernel Monotonicity). For any

The Kernel Monotonicity assumption corresponds to the fact that the bidding occurs in a competitive setting, and the demand tends to go to the cheapest bidder.

Assumption 6 (Strict Increasing Differences). For any i ∈ I, c ∈ T i , set π i c = π i (., c, .). Then π i c satisfies the Strict Increasing Differences Property:

Main results

Theorem 8.6 (Existence of a Pure Nash Equilibrium). The set of pure Nash equilibra is a nonempty complete lattice.

Theorem 8.7 (Uniqueness Sufficient Condition). If

• for any α > 0, (x, y) ∈ B,

• for any σ ∈ Σ equilibrium strategy profile, i ∈ I, and

are continuous

then the set of pure Nash equilibria is a singleton.

Relation (8.8) means that if every player multiplies his bid by the same constant, then the resulting allocation does not change. This should be satisfied with inelastic demand.

Theorem 8.8 (Converging dynamics). Assume:

we show as in [START_REF] Van Zandt | Monotone equilibria in bayesian games of strategic complementarities[END_REF] that (8.9) is satisfied.

Observe that

Therefore π is strictly concave with respect to its first variable, and by integration, so is Π.

Therefore by Berge theorem, the best reply is continuous in c. To show that (8.10), we first observe that in full information, symmetric setting, if the cost is c for both players, then the best reply is c 1-2rd . We combine this observation with the monotonicity of the best reply with respect to the type and the opponent strategy to conclude that any optimal bid

Therefore condition (8.10) is satisfied for b * large enough and Theorem 8.7 applies.

We have already checked that all conditions to apply Theorem 8.8 were satisfied.

Existence of a Nash Equilibrium

General Preliminary Results

Definition 8.9 (Strict Single crossing property, see [START_REF]Supermodularity and complementarity[END_REF]). Let X, Y and Z be partially ordered set, let f (x, z) be a function of a subset S of X × Z into Y, then f (x, z) satisfies the strict single crossing property in (x, z) on S if for all x 1 and x 2 in X and z 1 , z 2 in Z with

Lemma 8.10. The application (b,

. By increasing differences, for any c -i ∈ T -i , we have

) so multiplying by p -i (c -i ), and integrating, we get

where the first inequality comes from the hypothesis.

Definition 8.11 (Quasisupermodularity, see [START_REF]Supermodularity and complementarity[END_REF]). Let X be a lattice, Z a partially ordered set and f a function from X to Z, then we say that f is quasisupermodular if for all x 1 and

Lemma 8.12 (Quasi Supermodularity).

Proof. Trivial since we are in a monodimensional setting.

Existence

We will need the following result: Theorem 8.13 (Increasing Optimal Strategies (see [START_REF]Supermodularity and complementarity[END_REF]) page 83). Suppose that X is a lattice, Z is a partially ordered set, S z is a subset of X for each z in Z, S z is increasing in

Hence if one picks any x z in arg max x∈Sz for each z in Z with argmax non empty, then x z is increasing in z on {z : z ∈ Z, arg max x∈Sz f (x, z) non empty }. Definition 8.14 (Induced Set ordering). Let X be a lattice, X 1 and X 2 two non empty subsets of X. We say that X 1 X 2 iff for any

Combining Lemma 8.10, Lemma 8.12 with Theorem 8.13, we get:

collection of examples

We provide some toy problems solved with BocopHJB.

A.1 Car with obstacle

We consider a very simplified car model. The state (x, y) describes the coordinates of a pointlike car in R 2 . The controls u and θ are the velocity and the direction of the car.

The dynamics is

Our criteria is to reach a prescribed final position as fast as possible, therefore

where f (x, y) is 0 if we are close enough to (x f , y f ) = (0.2, 0.75), and 1 else. We define the part of the space where the car can go in order to illustrate the use of state contraints with BocopHJB:

A.2 Thermostat

We use a very simple thermostat model to illustrate the mode switching. The state x represents the temperature in the room. There is no control, but only two modes for the thermostat (on or off). The dynamics of the thermostat is ẋ = +10 when the thermostat is on ẋ = -10 when the thermostat is off.

We have to pay a constant cost of 1 per-unit of time when the thermostat is on. We set an additional cost of 10 per-unit of time when the temperature goes below 50. We also have a switching cost of 1 when turning the thermostat on. Remark: we recall that for a call option the Black-Scholes formula gives the solution

A.5 Portfolio allocation

As an example of a stochastic control problem, we consider the Merton portfolio allocation problem in finite horizon, for which the solution is known (see for instance [START_REF] Pham | Continuous-time stochastic control and optimization with financial applications[END_REF]). The portfolio consists in a risky asset whose value S follows dS = S(µdt + σdW ) and a nonrisky asset whose value S 0 follows dS 0 = S 0 rdt. The portfolio is invested in the risky asset with proportion α, and the value of the portfolio X is the state variable with dynamics

We want to solve the utility maximization problem V (x) = sup α E(U(X x,α T )), where U is the CRRA utility function defined by U (x) = x p p . The solution is given by

and the optimal control is constant, equal to α = µ-r σ 2 (1-p) . The results for p = 0.5 and A.6. OSCILLATIONS 197 other parameters as in [START_REF] Pham | Continuous-time stochastic control and optimization with financial applications[END_REF] are displayed in figure A.5.

A.6 Oscillations

We consider the optimal control problem

The Hamiltonian is H = y 2u 2 + up. A minimizing control u * is either -1 or 1. The intuition is that the control has to oscillate very quickly between -1 and 1 to obtain the optimal value.

Consider that the control is randomized at any time, with probability α for u = 1. We can formulate the relaxed problem

The optimal solution for the relaxed problem is given by α = 0.5. Therefore when solving numericaly the original problem, we expect the simulated trajectory to present a sequence of very fast oscillations. where we set y k = y(t k ) and u k = u(t k ). The value function is defined as

with final condition

We can extend this reasoning to cases where the dynamics and the cost functions depend of a mode : a diesel engine for example which can be turned off or on. If we denote M the number of modes, with a subscript i (or j) the functions corresponding to the mode i and c ij the switching cost from mode i to mode j (assuming that c ii = 0), this leads to

The algorithm used to compute the Value function at t k is the following

end for for i ∈ {0, . . . , M } do

This algorithm is independent of the way of calculating E x V k+1 j y k+1 . A classical method is to use an interpolation on the grid of V k+1 and an Euler scheme for the dynamics: this is the semi-Lagrangian method, as used in BocopHJB.

Semi Lagrangian scheme 3.3.1 Time discretization

Remark: in the following we drop the argument t k in functions f, l for clarity.

In the deterministic case, we naturally discretize the dynamics:

In the stochastic case, remembering that a Brownian motion has independent increments following a Normal law, W (t k+1 ) -W (t k ) ∼ √ h 0 N (0, 1), we obtain

According to [3], N (0, 1) can be replaced by any law with the same first two moments. We use a binary choice and obtain

P(e = 1) = P(e = -1) = 1 2

where X follows an uniform distribution on {1, . . . , q} and we have to choose α such that the expected value and the variance of this approximated process correspond to the ones of the original process in [START_REF] Aussel | Electricity spot market with transmission losses[END_REF]. Since the normal distribution and the random variable e are centered, and e and X are independent, the expected value is the same for any α.

The variance in ( 8) is h 0 σσ T . The variance in ( 9) writes

σ s σ T s = α 2 q h 0 σσ T therefore we have α = √ q. Plugging ( 9) in ( 3) we obtain

Space discretization

We know the value of V at the points of the grid, and we want to interpolate at the point y. We choose the coefficients α i ∈ [0, 1] such that y j = (1α j )x i j + α j x i j +1 . We interpolate the value function at the point y as follows (see [2]):

where the sum is made on the 2 n elements of {0, 1} n .

When a point doesn't belong to the grid we cannot interpolate the value function at this point. A typical choice is to take the value of the nearest point of the grid. Depending on the problem, another sensible choice can be to take the final cost.

Control discretization

The minimizer of ( 10) is approximated by discretizing the control set U .

BocopHJB includes a built-in module to simulate the optimal strategies provided by the dynamic programming algorithm. At each time step, the optimal control is taken as the minimizer of (4) over the discrete control set. The files to be completed depend on the options "discretization.control.type" and "control.combination.type".

• Discretized control set: if "control.combination.type" is set to -"uniform", the control set will be built automatically by taking the values from each control component (see below).

-"user function" or "user function statedependent": the control set will be built by the corresponding user function (see 4.5.2).

-"user file": complete the file control.combination, each row containing a m-tuple where m is the dimension of the control space.

• IF CONTROL.COMBINATION.TYPE=UNIFORM. Individual control components: if "discretization.control.type" is set to -"uniform": complete the file control.grid with a syntax similar to state.grid. Individual files control.i.disc will be written automatically.

-"user function": the control component will be discretized by the corresponding user function (see 4.5.2).

-"user file": complete the individual files control.i.disc for each component of the control. Each file contains the set of discretized values for the corresponding component.

Example: Assume we have a problem with a two-dimensional control u with u 0 ∈ {0, 1} and u 1 ∈ {0, 1}. Setting control.combination.type to "uniform" gives the discretized control set {(0, 0), (0, 1), (1, 0), (1, 1)}. If we want to impose the constraint u 0 ≥ u 1 , we can define directly the control set with control.combination.type set to user file, and write the file controlDisc/control.combination as follows 0 0 1 0 1 1

Basic Functions for the optimal control problem

The user has to write the functions which define the problem: the drift and the (optional) volatility to describe the dynamics, the running cost, the final cost and the (optional)

Example: > ./bocop visualize -v -d <BOCOPHJB>/examples/maze -m 0 -t 0 NB: you can use the -h option to print an help message.

----------------------------------------MAC OS

In the following, <BOCOPHJB> is the directory in which you have extracted the package. Please make sure that there are no blanks or spaces in the path name to this folder.

A ----------------------------------------WINDOWS

In the following, <BOCOPHJB> is the directory in which you have extracted the package. Please make sure that there are no blanks or spaces in the path name to this folder.

WARNING : BocopHJB must be installed in a directory without any blanks or spaces, in particular not in Program Files ! A. PREREQUISITES BocopHJB requires MinGW and CMake to run on Windows.

A.1 MINGW Due to some incompatibilities with the latest MinGW version, we recommend that you use the provided full MinGW archive, available on the Download page of bocop.org. Simply extract the archive to a location without spaces in its name (for instance C:\, but NOT C:\Program Files\).

In the following, <MINGW> is the installation target directory (for example C:\MinGW which is the preferred one).

* Change the Path environment variable, as explained here :

-Right-click on your "My Computer" icon and select "Properties".

-Click on the "Advanced" tab, then on the "Environment Variables" button.

-Click on the PATH entry and edit it.

-Scroll to the BEGINNING of the string and add the directories for your MinGW: <MinGW>\msys\1.0\bin;<MinGW>\bin;

Note: we recommend to put the two directories for MinGW at the beginning of the PATH to avoid the confusion with other versions of files such as sed.exe or libtools that may be present in your system folders. Such files can be installed by other applications, and may not be compatible with the building process in Bocop.

A.2 CMAKE

The building process requires CMake. You can download the installer here: http://www.cmake.org/cmake/resources/software.html

During the installation process choose the option to add the CMake path in the Path environment variable.