<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article  PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "http://dtd.nlm.nih.gov/publishing/3.0/journalpublishing3.dtd"><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="3.0" xml:lang="en" article-type="research article"><front><journal-meta><journal-id journal-id-type="publisher-id">SGRE</journal-id><journal-title-group><journal-title>Smart Grid and Renewable Energy</journal-title></journal-title-group><issn pub-type="epub">2151-481X</issn><publisher><publisher-name>Scientific Research Publishing</publisher-name></publisher></journal-meta><article-meta><article-id pub-id-type="doi">10.4236/sgre.2015.611025</article-id><article-id pub-id-type="publisher-id">SGRE-62019</article-id><article-categories><subj-group subj-group-type="heading"><subject>Articles</subject></subj-group><subj-group subj-group-type="Discipline-v2"><subject>Earth&amp;Environmental Sciences</subject><subject> Engineering</subject></subj-group></article-categories><title-group><article-title>
 
 
  Multi-Energy Simulation of a Smart Grid with Optimal Local Demand and Supply Management
 
</article-title></title-group><contrib-group><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>hristian</surname><given-names>Kuschel</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Harald</surname><given-names>Köstler</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Ulrich</surname><given-names>Rüde</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib></contrib-group><aff id="aff1"><addr-line>Friedrich-Alexander Universit&amp;amp;auml;t Erlangen-N&amp;amp;uuml;rnberg Chair for System Simulation, Erlangen, Germany</addr-line></aff><pub-date pub-type="epub"><day>18</day><month>12</month><year>2015</year></pub-date><volume>06</volume><issue>11</issue><fpage>303</fpage><lpage>315</lpage><history><date date-type="received"><day>13</day>	<month>November</month>	<year>2015</year></date><date date-type="rev-recd"><day>accepted</day>	<month>15</month>	<year>December</year>	</date><date date-type="accepted"><day>18</day>	<month>December</month>	<year>2015</year></date></history><permissions><copyright-statement>&#169; Copyright  2014 by authors and Scientific Research Publishing Inc. </copyright-statement><copyright-year>2014</copyright-year><license><license-p>This work is licensed under the Creative Commons Attribution International License (CC BY). http://creativecommons.org/licenses/by/4.0/</license-p></license></permissions><abstract><p>
 
 
  A simulation approach of a smart grid by cooperative bargaining is presented in this paper. Each participant of the smart grid determines its optimal schedule to meet its power and heating demand at minimal costs employing solar panels, fuel cells and batteries. This is done by solving a quadratic optimisation problem which takes the energy prices and the available devices into account. The energy prices are related to the demand and supply in the smart grid, so that a lower demand yields lower prices. The cooperative bargaining game is used to tune the participants’ optimal solution to obtain a Nash equilibrium. The computed solutions of the participants are validated against the capacities and structure of the smart grid by solving a multi-commodity flow problem. The presented model features multiple types of energy, so that they may be substituted to meet the participants’ demand. Furthermore, the participants may also act as supplier and not only as consumer, which allows decentralised generation of energy. The approach is validated in several experiments where effects like negative energy prices if generated energy exceeds the smart grid’s total demand and peak-shaving with even small-capacity batteries are exhibited.
 
</p></abstract><kwd-group><kwd>Cooperative Bargaining</kwd><kwd> Pricing Model</kwd><kwd> Multi-Agent System</kwd><kwd> Multi-Commodity Flow</kwd><kwd> Smart Grid</kwd></kwd-group></article-meta></front><body><sec id="s1"><title>1. Introduction</title><p>With the emergence of renewable energy generation and storage technologies, like e.g. solar panels or batteries, the notion of smart grids has been developed [<xref ref-type="bibr" rid="scirp.62019-ref1">1</xref>] . Buildings can be equipped with these technologies to generate, store and (re-)distribute energy [<xref ref-type="bibr" rid="scirp.62019-ref2">2</xref>] . Moreover, a smart grid also suggests that (almost) all devices in a building are equipped with smart-meters to measure their consumption and are connected to a (local) network [<xref ref-type="bibr" rid="scirp.62019-ref3">3</xref>] [<xref ref-type="bibr" rid="scirp.62019-ref4">4</xref>] . In addition, the buildings of the smart grid are connected to a communication network to exchange information. Following this approach, a (software) agent may be employed in a building to autonomously and economically manage demand and supply of the building’s inhabitants. Such an agent also acts as energy consumption scheduler (ECS) [<xref ref-type="bibr" rid="scirp.62019-ref5">5</xref>] to optimally plan ahead and operate its associated devices accordingly. This can be extended from one building to the entire grid by allowing the agents to communicate with each other and coordinate their demand and supply. Consequently, peaks in the demand can be alleviated by temporarily shifting their loads to obtain a flatter load profile (load-shifting). This reduces the maximal grid load (peak-shaving) and also has beneficial monetary effects in demand-response scenarios, e.g. [<xref ref-type="bibr" rid="scirp.62019-ref6">6</xref>] .</p><p>The smart grid model in this paper adopts approaches from [<xref ref-type="bibr" rid="scirp.62019-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.62019-ref7">7</xref>] . It is represented by a discrete time dependent optimisation problem. The constraints describe the capabilities and limits of each agent. The objective function in [<xref ref-type="bibr" rid="scirp.62019-ref7">7</xref>] maximises global welfare, and in [<xref ref-type="bibr" rid="scirp.62019-ref5">5</xref>] minimises each agent’s costs. Both approaches consider only electrical power as energy and the demand-side of agents. In this paper, the above approaches are extended by additional types of energy, namely thermal energy (heat) and gas. Moreover, the energy production of each agent is also taken into account, i.e. the supply-side, to minimise each agent’s costs. The supply-side allows the agents not only to optimise the demand, but also to act as small-scale supplier, permitting decentralised energy generation. In addition, the smart grid structure is taken into account to realise distances between buildings, connectivity and line capacities, which was not done in [<xref ref-type="bibr" rid="scirp.62019-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.62019-ref7">7</xref>] , but e.g. in [<xref ref-type="bibr" rid="scirp.62019-ref8">8</xref>] .</p><p>In order to be able to represent an agent which is capable to utilise the three types of energy, manage the demand-side and also act as a supplier, a selected set of prototype devices are modelled in detail (Section 3). A solar panel can generate power “for free”. It generates power from insolation which requires taking weather data into account. Moreover, the insolation and environmental temperature from weather data influence not only the solar panels’ power generation but also the temperature in the building. A fuel cell is used as a prototype appliance for cogeneration. It is used to generate thermal energy and power by consuming gas. Its purpose is to allow gas as an alternative resource for heating. A battery is used to store power which is essential for peak- shaving, because the required power can be bought at off-peak times and stored until it is needed, as in e.g. [<xref ref-type="bibr" rid="scirp.62019-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.62019-ref9">9</xref>] [<xref ref-type="bibr" rid="scirp.62019-ref10">10</xref>] . Finally, a smart refrigerator as a sample smart appliance is taken into account. Its dependence on the temperature and the usage is a good example to represent optimal control with respect to fixed environmental influence. The agent is in addition associated with a fixed base power demand and a fixed base thermal energy emission by other appliances (such as e.g. TV or stove) which cannot be changed.</p><p>The agents participate in a cooperative bargaining game according to which they determine their respective optimal strategy to minimise costs (Section 4). This game is introduced to relate energy prices with demand. This allows the agent to compute price-aware optimal strategies. As a consequence, the prices rise at high demand and drop, even below zero, at higher supply than demand.</p><p>The bargaining game is designed such that a unique Nash equilibrium exists and is attained by iteratively computing each agent’s best-response independently. The computation of the best-response is determined by solving a quadratic optimisation problem with complementarity constraints (Section 3) which includes, aside a base power load profile, the employment of solar panels, fuel cells, batteries, central heating, and refrigerators. After the Nash equilibrium has been found, the demand and supply are distributed in the smart grid to meet each agent’s requirements. This is done by solving a multi-commodity flow problem through the smart grid (Section 2). If no feasible multi-commodity flow exists, the agents are restricted in their actions to enforce a feasible flow.</p><p>Concluding this paper, in Section 5 test cases are presented and discussed. The impact of the different devices and combination of devices are pointed out. In particular, the total and relative costs reduction with respect to other device combinations along with the relation to the peak-to-average ratio (PAR) is elaborated. Peak-shaving could be observed even for a relative small-capacity battery which makes the power load profile almost flat. The fuel cells are used as a surrogate for heating, reducing the costs, but increasing the PAR. The high power generation of solar panels forces the prices of power to drop below zero when the sun shines, if the demand is not high enough to consume the generated power.</p></sec><sec id="s2"><title>2. Flow through the Smart Grid</title><p>Numerous approaches to model smart grids have been published, e.g. [<xref ref-type="bibr" rid="scirp.62019-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.62019-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.62019-ref11">11</xref>] . When modelling a smart grid, the main focus is in formulating the capabilities and limitations of each agent and how they can interact. The smart grid structure itself is neglected, assuming no limitations as e.g. in [<xref ref-type="bibr" rid="scirp.62019-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.62019-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.62019-ref11">11</xref>] . In this paper, however, the smart grid structure and capabilities are incorporated, similar to [<xref ref-type="bibr" rid="scirp.62019-ref8">8</xref>] , to be able to model an energy grid.</p><p>The presented approach is used to compute a feasible solution. This is done by computing the multi-com- modity flow set by the agents. If this is a feasible solution, nothing else needs to be done. If no feasible solution exists, the demand of all agents in total is reduced by the amount by which the capacities are exceeded. Incorporating this reduction into the agents’ optimisation process (Section 3) yields a feasible solution, excluding the cases where the agents cannot comply with the reduction. This is the case when the line capacities are inadequate, but this is not further treated in this paper.</p><p>Extending the approach from [<xref ref-type="bibr" rid="scirp.62019-ref8">8</xref>] , the smart grid is represented by a multi-commodity flow network. Since the smart grid in this paper deals with three types of energy and is time dependent, the standard notation for multi- commodity networks is extended by the types of energy and a temporal variable t. Therefore, consider a fixed discrete time interval <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x7.png" xlink:type="simple"/></inline-formula> for which the simulation is carried out. Furthermore, let the set of all three types of energy (power, heat and gas) be denoted by<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x8.png" xlink:type="simple"/></inline-formula>. A multi-commodity flow network for a type of energy <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x9.png" xlink:type="simple"/></inline-formula> is a directed, connected graph <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x10.png" xlink:type="simple"/></inline-formula> with a set of nodes<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x11.png" xlink:type="simple"/></inline-formula>, a set of arcs<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x12.png" xlink:type="simple"/></inline-formula>, a set of commodities<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x13.png" xlink:type="simple"/></inline-formula>, and a capacity function <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x14.png" xlink:type="simple"/></inline-formula> [<xref ref-type="bibr" rid="scirp.62019-ref12">12</xref>] . A commodity is defined as a triple <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x15.png" xlink:type="simple"/></inline-formula> which specifies a demand <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x16.png" xlink:type="simple"/></inline-formula> which is routed from source <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x17.png" xlink:type="simple"/></inline-formula> to sink<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x18.png" xlink:type="simple"/></inline-formula>. The entire grid is given by</p><p><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x19.png" xlink:type="simple"/></inline-formula>. The nodes in <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x20.png" xlink:type="simple"/></inline-formula> can be associated with different roles, such as power plants (source), another</p><p>grid operator (sink), agents, and substations. Let<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x21.png" xlink:type="simple"/></inline-formula>, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x21.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x22.png" xlink:type="simple"/></inline-formula>, and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x21.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x22.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x23.png" xlink:type="simple"/></inline-formula> denote the set of the network’s sinks, sources, and agents, respectively. Note that the flow of each type of energy is independent from each other. Each type of energy uses its own sinks and sources, substations and arcs. The only intersection of the networks are the agents, so that <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x21.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x22.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x23.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x24.png" xlink:type="simple"/></inline-formula> for any<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x21.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x22.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x23.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x24.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x25.png" xlink:type="simple"/></inline-formula>.</p><p>The multi-commodity flow of each type of energy can be computed separately. Therefore, in the following, the solution of an energy type e is exemplarily elaborated. The textbook approach to express the multi-com- modity flow as a linear optimisation problem is given by [<xref ref-type="bibr" rid="scirp.62019-ref12">12</xref>] as</p><disp-formula id="scirp.62019-formula94"><label>(1)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-6401427x26.png"  xlink:type="simple"/></disp-formula><disp-formula id="scirp.62019-formula95"><graphic  xlink:href="http://html.scirp.org/file/1-6401427x27.png"  xlink:type="simple"/></disp-formula><disp-formula id="scirp.62019-formula96"><graphic  xlink:href="http://html.scirp.org/file/1-6401427x28.png"  xlink:type="simple"/></disp-formula><p><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x29.png" xlink:type="simple"/></inline-formula>denotes the flow of energy type e through the arc from N to M at time t and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x29.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x30.png" xlink:type="simple"/></inline-formula> denotes a constant line loss. The constraints must hold for all<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x29.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x30.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x31.png" xlink:type="simple"/></inline-formula>. The first constraint conserves the flow in the network. <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x29.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x30.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x31.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x32.png" xlink:type="simple"/></inline-formula>can take arbitrary real values. <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x29.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x30.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x31.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x32.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x33.png" xlink:type="simple"/></inline-formula>represents a demand, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x29.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x30.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x31.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x32.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x33.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x34.png" xlink:type="simple"/></inline-formula>a supply. The second constraint ensures that the line capacities are not exceeded. The objective function minimises the flow from sources and to sinks. A convenient effect of this is that only the minimal flow through the network is computed.</p><p>If no feasible multi-commodity flow exists, we want to be able to determine why it does not exist. Two parameters can be changed to make the flow feasible: The agents’ demands and the grid capacities. Augmenting the grid capacities is a long-term and (financially) expensive process, whereas changing the demands is a short-term process. In this paper, the possibility of increasing the grid capacities is not discussed, because the presented approach aims at a fine temporal resolution (about 15 minutes). Limiting the demands may be unfavourable for the agents, in particular if the demands need to be changed in a way which is difficult to comply for the agent. The case that agents cannot comply is not discussed.</p><p>The amount of insufficient grid capacity needs to be identified and then communicated to all agents. This amount is determined by extending the linear optimisation problem (1) by a penalty term<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x35.png" xlink:type="simple"/></inline-formula>:</p><disp-formula id="scirp.62019-formula97"><label>(2)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-6401427x36.png"  xlink:type="simple"/></disp-formula><disp-formula id="scirp.62019-formula98"><graphic  xlink:href="http://html.scirp.org/file/1-6401427x37.png"  xlink:type="simple"/></disp-formula><disp-formula id="scirp.62019-formula99"><graphic  xlink:href="http://html.scirp.org/file/1-6401427x38.png"  xlink:type="simple"/></disp-formula><disp-formula id="scirp.62019-formula100"><graphic  xlink:href="http://html.scirp.org/file/1-6401427x39.png"  xlink:type="simple"/></disp-formula><p><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x40.png" xlink:type="simple"/></inline-formula>is an arbitrary chosen penalty factor and the constraints must hold for all<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x40.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x41.png" xlink:type="simple"/></inline-formula>. This optimisation problem minimises the violation of excess of the grid’s capacities and the minimum flow. In particular,</p><p><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x42.png" xlink:type="simple"/></inline-formula>is the total excess at time t. If this sum is equal to zero, the agents’ demands do not exceed the</p><p>grid’s capacities and a solution is found. If the sum is greater than zero, the agents need to reduce their demands in total by that amount. A straight-forward approach is to uniformly distribute this excess over all agents.</p><p>The multi-commodity flow problem essentially depends on the demands <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x43.png" xlink:type="simple"/></inline-formula> which have to be met. In the following section, the computation of the values <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x43.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x44.png" xlink:type="simple"/></inline-formula> is elaborated by introducing agents in detail.</p></sec><sec id="s3"><title>3. Agents in the Smart Grid</title><p>The actions and decisions an agent can autonomously perform are computed by a discrete time dependent quadratic optimisation problem. Its objective is minimising the costs. The details of the cost function are presented in Section 4. In this section, the incorporation of the agents’ demand and supply is elaborated, i.e. the constraints of the optimisation problem. The notation from the previous section is used to denote the considered discrete time interval by <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x45.png" xlink:type="simple"/></inline-formula> and the set of all types of energy by<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x45.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x46.png" xlink:type="simple"/></inline-formula>. Furthermore, all optimisation variables are non-negative and have an finite upper bound, unless otherwise noted.</p><p>The balance constraint of an agent N at time step <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x47.png" xlink:type="simple"/></inline-formula> for type of energy <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x47.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x48.png" xlink:type="simple"/></inline-formula> is directly derived from the first constraint of the optimisation problem (2). So</p><disp-formula id="scirp.62019-formula101"><label>(3)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-6401427x49.png"  xlink:type="simple"/></disp-formula><p>holds. This balance equation must be satisfied for all time steps t and for all types of energy<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x50.png" xlink:type="simple"/></inline-formula>. <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x50.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x51.png" xlink:type="simple"/></inline-formula>is the produced energy and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x50.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x51.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x52.png" xlink:type="simple"/></inline-formula> is the energy demand of device d from the set of devices <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x50.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x51.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x52.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x53.png" xlink:type="simple"/></inline-formula> of energy type e. The devices in <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x50.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x51.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x52.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x53.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x54.png" xlink:type="simple"/></inline-formula> are presented below and contain solar panels, batteries, fuel cells, central heating, refrigerators, as well as a fixed base demand/supply of all other appliances. Every agent N requires a minimum amount of</p><p>power <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x55.png" xlink:type="simple"/></inline-formula> and generates a minimum amount of thermal energy by operating devices<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x55.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x56.png" xlink:type="simple"/></inline-formula>. Both quantities</p><p>are fixed but vary over time and are derived from a standard load profile [<xref ref-type="bibr" rid="scirp.62019-ref13">13</xref>] . Following [<xref ref-type="bibr" rid="scirp.62019-ref14">14</xref>] , the power base load is computed by using the standard load profile as mean value in a geometric distribution; the thermal energy base generation is used in a normal distribution.</p><p>An agent is restricted to either buy or sell energy of the same type within one time step. This is ensured by adding the complementarity constraint</p><disp-formula id="scirp.62019-formula102"><label>(4)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-6401427x57.png"  xlink:type="simple"/></disp-formula><p>Since the inflow or outflow must be zero, only the net flow to and from an agent is considered in the optimisation problem. This is an important property when determining the optimum of the objective function in Section 4.</p><p>In the following sections, the devices an agent N operates are presented and how they contribute to the total energy produced <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x58.png" xlink:type="simple"/></inline-formula> and the total demanded energy<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x58.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x59.png" xlink:type="simple"/></inline-formula>. With the constraints presented in these sections a feasible set of solutions <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x58.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x59.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x60.png" xlink:type="simple"/></inline-formula> for the agent N is defined. It is assumed that <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x58.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x59.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x60.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x61.png" xlink:type="simple"/></inline-formula> is non-empty as to exclude infeasible scenarios. For the sake of simplicity of the notation, in the following the index denoting the building in the smart grid is omitted, so e.g. <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x58.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x59.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x60.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x61.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x62.png" xlink:type="simple"/></inline-formula>is written as<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x58.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x59.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x60.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x61.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x62.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x63.png" xlink:type="simple"/></inline-formula>.</p><sec id="s3_1"><title>3.1. Solar Panel</title><p>The solar panel is a prototype of renewable energy generation. It generates power from environmental influences, in this case insolation, with respect to the temperature. A wind power plant would also fall in this category. The solar panel is of more interest in this paper, because only residential buildings are considered. These buildings can easily be equipped with solar panels, whereas a wind power plant in the backyard is rather undesired.</p><p>The solar panel is modelled according to [<xref ref-type="bibr" rid="scirp.62019-ref15">15</xref>] [<xref ref-type="bibr" rid="scirp.62019-ref16">16</xref>] . In [<xref ref-type="bibr" rid="scirp.62019-ref15">15</xref>] an implicit formulation of the generated electrical energy is given with respect to the outside temperature and insolation. With this approach the generated electrical energy is computed from real weather data, e.g. [<xref ref-type="bibr" rid="scirp.62019-ref17">17</xref>] . Since it is only dependent on the (fixed) properties of the solar panel, the temperature, and the insolation, the generated electrical energy can be pre-computed for all time steps, independent of the optimisation problem. So the electrical energy <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x64.png" xlink:type="simple"/></inline-formula> generated by a solar panel is merely a fixed term for each time step:</p><disp-formula id="scirp.62019-formula103"><graphic  xlink:href="http://html.scirp.org/file/1-6401427x65.png"  xlink:type="simple"/></disp-formula></sec><sec id="s3_2"><title>3.2. Fuel Cell</title><p>The fuel cell is a prototype device for cogeneration. It consumes gas and generates both, electrical power and thermal energy, in this paper. So it can be used as alternative to heat the building. The fuel cell is represented by two coupled generators, one for heat and one for power, similar to [<xref ref-type="bibr" rid="scirp.62019-ref14">14</xref>] . Both generators are described by the constraints</p><disp-formula id="scirp.62019-formula104"><graphic  xlink:href="http://html.scirp.org/file/1-6401427x66.png"  xlink:type="simple"/></disp-formula><disp-formula id="scirp.62019-formula105"><graphic  xlink:href="http://html.scirp.org/file/1-6401427x67.png"  xlink:type="simple"/></disp-formula><p><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x68.png" xlink:type="simple"/></inline-formula>is the amount of the consumed gas to produce energy and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x68.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x69.png" xlink:type="simple"/></inline-formula> is the (constant) efficiency. The right-hand side of both constraints model start-up and shut-down phases. <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x68.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x69.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x70.png" xlink:type="simple"/></inline-formula>is the duration of the start-up and shut- down phase in time steps, and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x68.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x69.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x70.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x71.png" xlink:type="simple"/></inline-formula> is the upper energy production bound of the respective generator. <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x68.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x69.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x70.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x71.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x72.png" xlink:type="simple"/></inline-formula>indicates how the generator is operated.</p></sec><sec id="s3_3"><title>3.3. Battery</title><p>Batteries play a substantial role in the smart grid. It is possible to store power from, e.g. solar panels, for a later point in time, in case it is currently not needed. Additionally, in demand-response scenarios, they flatten the peaks in the grid’s load profile [<xref ref-type="bibr" rid="scirp.62019-ref9">9</xref>] [<xref ref-type="bibr" rid="scirp.62019-ref10">10</xref>] and thus relieve the grid capacities. From a modelling point of view, however, a battery is abstracted from its physical realisation to its capabilities: A battery can either be charged by <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x73.png" xlink:type="simple"/></inline-formula> or discharged by <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x73.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x74.png" xlink:type="simple"/></inline-formula> in a time step, and has a maximum capacity <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x73.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x74.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x75.png" xlink:type="simple"/></inline-formula> [<xref ref-type="bibr" rid="scirp.62019-ref6">6</xref>] . This is represented by the constraint</p><disp-formula id="scirp.62019-formula106"><graphic  xlink:href="http://html.scirp.org/file/1-6401427x76.png"  xlink:type="simple"/></disp-formula><p><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x77.png" xlink:type="simple"/></inline-formula>specifies an efficiency of the storage, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x77.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x78.png" xlink:type="simple"/></inline-formula>the charge efficiency, and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x77.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x78.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x79.png" xlink:type="simple"/></inline-formula> the discharge efficiency. <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x77.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x78.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x79.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x80.png" xlink:type="simple"/></inline-formula>is the amount by which the battery is charged and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x77.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x78.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x79.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x80.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x81.png" xlink:type="simple"/></inline-formula> by which it is discharged. To prohibit charging and discharging at the same time, effectively bypassing the storage loss, the complementarity constraint</p><disp-formula id="scirp.62019-formula107"><label>(5)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-6401427x82.png"  xlink:type="simple"/></disp-formula><p>is employed.</p></sec><sec id="s3_4"><title>3.4. Central Heating</title><p>A thermodynamic model similar to [<xref ref-type="bibr" rid="scirp.62019-ref7">7</xref>] is developed in this section with the goal to describe how much thermal energy is required to keep the temperature inside a building within a certain comfort interval, i.e. between the boundaries <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x83.png" xlink:type="simple"/></inline-formula> and<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x83.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x84.png" xlink:type="simple"/></inline-formula>. In order to derive a suitable discrete time formulation for the optimisation problem, we start off with continuous time formulas which in turn are temporally discretised.</p><p>The total thermal energy flux inside a building <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x85.png" xlink:type="simple"/></inline-formula> is the sum of all contributing energy sources and sinks</p><disp-formula id="scirp.62019-formula108"><label>(6)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-6401427x86.png"  xlink:type="simple"/></disp-formula><p>where <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x87.png" xlink:type="simple"/></inline-formula> denotes the combined fluxes of thermal convection and conduction, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x87.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x88.png" xlink:type="simple"/></inline-formula>the flux caused by insolation, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x87.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x88.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x89.png" xlink:type="simple"/></inline-formula>is the heat flux of the devices (see (3)). <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x87.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x88.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x89.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x90.png" xlink:type="simple"/></inline-formula>is the energy added or removed by heating, ventilating, and air conditioning and thus allows to actively change the temperature in a building. The terms of (6) other than<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x87.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x88.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x89.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x90.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x91.png" xlink:type="simple"/></inline-formula>, which are elaborated below, rather represent passive changes due to the environment.</p><p>The thermal conduction and convection are expressed only with respect to the temperature difference of the inside and outside temperature <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x92.png" xlink:type="simple"/></inline-formula> and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x92.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x93.png" xlink:type="simple"/></inline-formula> [<xref ref-type="bibr" rid="scirp.62019-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.62019-ref18">18</xref>]</p><disp-formula id="scirp.62019-formula109"><graphic  xlink:href="http://html.scirp.org/file/1-6401427x94.png"  xlink:type="simple"/></disp-formula><p><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x95.png" xlink:type="simple"/></inline-formula>comprises thermal conductivity, heat transfer coefficient and the building properties. <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x95.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x96.png" xlink:type="simple"/></inline-formula>is assumed to be constant. <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x95.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x96.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x97.png" xlink:type="simple"/></inline-formula>is a fixed quantity which is determined by real weather data [<xref ref-type="bibr" rid="scirp.62019-ref17">17</xref>] .</p><p>The thermal energy flux by insolation through windows is determined by</p><disp-formula id="scirp.62019-formula110"><graphic  xlink:href="http://html.scirp.org/file/1-6401427x98.png"  xlink:type="simple"/></disp-formula><p>with <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x99.png" xlink:type="simple"/></inline-formula> representing the sensitivity to insolation and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x99.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x100.png" xlink:type="simple"/></inline-formula> the flux of insolation. This is treated separately from conduction effects, because, as with the solar panel, real weather data from [<xref ref-type="bibr" rid="scirp.62019-ref17">17</xref>] was used to compute<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x99.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x100.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x101.png" xlink:type="simple"/></inline-formula>.</p><p>The above continuous time equations are discretised with the implicit Euler method. Thus we obtain from (6)</p><disp-formula id="scirp.62019-formula111"><label>(7)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-6401427x102.png"  xlink:type="simple"/></disp-formula><p>using a fixed time step size<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x103.png" xlink:type="simple"/></inline-formula>. If <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x103.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x104.png" xlink:type="simple"/></inline-formula> is positive, its energy is used to heat the building and thus contributes to the heat demand of the central heating <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x103.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x104.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x105.png" xlink:type="simple"/></inline-formula> with<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x103.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x104.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x105.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x106.png" xlink:type="simple"/></inline-formula>. Whereas if <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x103.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x104.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x105.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x106.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x107.png" xlink:type="simple"/></inline-formula> is negative, it cools down the temperature with an air conditioner. Consequently, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x103.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x104.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x105.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x106.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x107.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x108.png" xlink:type="simple"/></inline-formula>and<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x103.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x104.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x105.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x106.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x107.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x108.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x109.png" xlink:type="simple"/></inline-formula>. With the computed total thermal energy within the building its temperature <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x103.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x104.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x105.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x106.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x107.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x108.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x109.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x110.png" xlink:type="simple"/></inline-formula> is computed from</p><disp-formula id="scirp.62019-formula112"><graphic  xlink:href="http://html.scirp.org/file/1-6401427x111.png"  xlink:type="simple"/></disp-formula><p>m is the mass, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x112.png" xlink:type="simple"/></inline-formula>the specific heat capacity of the building. Since a building is composed of several types of components, the term <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x112.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x113.png" xlink:type="simple"/></inline-formula> is assembled by the weighted average of its components.</p><p>With this thermodynamic model, it is possible to compute the required thermal energy to keep the temperature within the admissible bounds. In fact, the relation</p><disp-formula id="scirp.62019-formula113"><label>(8)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-6401427x114.png"  xlink:type="simple"/></disp-formula><p>can readily be used as constraint in the optimisation problem to enforce a temperature within the comfort interval.</p></sec><sec id="s3_5"><title>3.5. Smart Refrigerator</title><p>As example of smart appliances the smart refrigerator is introduced here. A smart appliance is a device which is entirely operated by an agent, e.g. refrigerator, freezer, dish washer. [<xref ref-type="bibr" rid="scirp.62019-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.62019-ref7">7</xref>] suggest different types of smart appliance models. The feature about being operated by an agent is that it can be flexibly operated to shift load away from peak loads and/or reduce operation costs.</p><p>The refrigerator model is directly derived from the thermodynamic model (7) and (8) by changing the parameters and constants accordingly. This way also a freezer model can be derived.</p><p>There are two peculiarities to mention. One is that the temperature within the refrigerator is dependent on the temperature within the building, which in turn is dependent on the environmental temperature. So the temperature in the refrigerator can also be influenced by the central heating.</p><p>The other peculiarity is that items may be put in or removed from the refrigerator and thus the mass m of the refrigerator’s content is time dependent. When items are added, convective thermal energy is added and the mass of the refrigerator’s content increase. Analogous when items are removed, energy is removed and the mass is decreased.</p><p>Since the required thermal energy to stay within the admissible bounds is known from (7) and<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x115.png" xlink:type="simple"/></inline-formula>, the electrical energy demand and thermal energy emission from the operating refrigerator are written as</p><disp-formula id="scirp.62019-formula114"><graphic  xlink:href="http://html.scirp.org/file/1-6401427x116.png"  xlink:type="simple"/></disp-formula><disp-formula id="scirp.62019-formula115"><graphic  xlink:href="http://html.scirp.org/file/1-6401427x117.png"  xlink:type="simple"/></disp-formula><p><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x118.png" xlink:type="simple"/></inline-formula>specifies how much thermal energy is emitted to the surroundings per unit of cooling when operating the refrigerator and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x118.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x119.png" xlink:type="simple"/></inline-formula> specifies how much electrical energy is required to operate the refrigerator per unit of cooling.</p></sec></sec><sec id="s4"><title>4. Cooperative Bargaining Game</title><p>The prices of the types of energy play an essential role in the solution of the optimisation problem presented in Section 3 for each agent in the smart grid. The agents are assumed to act rationally and economically, so that they preferably consume energy when the prices are low and save or possibly sell energy when the prices are high. In contrast, the prices should reflect the efforts of the grid operator to supply its agents, and thus the production costs increase with increasing demand. Such a pricing model has to be designed which takes the above aspects into account.</p><p>At first, the total costs in the entire grid are determined with respect to the total demand and supply in the smart grid. Note that supply in this context refers to the agent generated supply and not to the grid operator’s supply. Subsequently, the total costs are fairly broken down to each agent. This results in the costs objective function which the respective agents seek to minimise.</p><p>There have been cooperative game theoretical approaches [<xref ref-type="bibr" rid="scirp.62019-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.62019-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.62019-ref19">19</xref>] which allow agents to schedule their demands in coordination with each other to achieve a fair, global optimum. The method in [<xref ref-type="bibr" rid="scirp.62019-ref19">19</xref>] is based on [<xref ref-type="bibr" rid="scirp.62019-ref5">5</xref>] and improves the fairness of the pricing scheme. In [<xref ref-type="bibr" rid="scirp.62019-ref7">7</xref>] a utility function is used rather than prices for optimisation.</p><p>The three mentioned references only deal with the demand-side. The approach presented in this paper expands [<xref ref-type="bibr" rid="scirp.62019-ref5">5</xref>] by allowing the agents to sell energy (supply-side), too. Fairness is achieved by applying the presented approach of [<xref ref-type="bibr" rid="scirp.62019-ref19">19</xref>] . However, no utility function is used in the presented approach; the entire behaviour of the players is determined by the prices. Furthermore, not only one type of energy is considered but three, in accordance with the smart building model in Section 3.</p><sec id="s4_1"><title>4.1. Total Costs in the Smart Grid</title><p>The central role in the price model has the grid operator. It acts budget balanced, i.e. neither generates profit nor suffers losses. Consequently, the energy is sold for the production price. The costs of a type of energy <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x120.png" xlink:type="simple"/></inline-formula> for the grid operator <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x120.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x121.png" xlink:type="simple"/></inline-formula> is written as function of total demand of the agents <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x120.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x121.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x122.png" xlink:type="simple"/></inline-formula> and total supply of the agents <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x120.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x121.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x122.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x123.png" xlink:type="simple"/></inline-formula> in the smart grid. The newly introduced variables are defined as</p><disp-formula id="scirp.62019-formula116"><label>(9)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-6401427x124.png"  xlink:type="simple"/></disp-formula><p>Below some properties of the cost function are stated from which a function <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x125.png" xlink:type="simple"/></inline-formula> is defined. Consider the balance between demand and supply <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x125.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x126.png" xlink:type="simple"/></inline-formula> at a time step t. If this difference is zero, the grid is self- sustaining. In this case the grid operator does not supply the agents implying zero cost. If<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x125.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x126.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x127.png" xlink:type="simple"/></inline-formula>, the grid operator uses its power plants to produce energy or buys energy from another grid operator to meet the demand of the agents. These costs must be covered. If<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x125.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x126.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x127.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x128.png" xlink:type="simple"/></inline-formula>, the agents generate more energy than can be reasonably used in the smart grid. Since this surplus of energy cannot be stored in the smart grid, it is mandatory to transfer the energy to another grid (competitor); selling the energy at any price. Consequently, selling to a competitor yields a potential financial loss which is passed to the agents by increasing prices accordingly, and therefore discouraging overproduction.</p><p>Summarising the three cases, an interpretation which penalises any deviation of a self-sustaining equilibrium <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x129.png" xlink:type="simple"/></inline-formula> is possible. <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x129.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x130.png" xlink:type="simple"/></inline-formula>is therefore defined as the quadratic deviation from the equilibrium</p><disp-formula id="scirp.62019-formula117"><label>(10)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-6401427x131.png"  xlink:type="simple"/></disp-formula><p><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x132.png" xlink:type="simple"/></inline-formula>is a constant which allows differentiated weighting of the deviation for each type of energy. It is easy to check that <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x132.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x133.png" xlink:type="simple"/></inline-formula> is continuously differentiable, convex, and its minima are on the line<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x132.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x133.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x134.png" xlink:type="simple"/></inline-formula>. The entire costs in the smart grid for all types of energy <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x132.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x133.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x134.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x135.png" xlink:type="simple"/></inline-formula> over all time steps <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x132.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x133.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x134.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x135.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x136.png" xlink:type="simple"/></inline-formula> is given by</p><disp-formula id="scirp.62019-formula118"><label>(11)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-6401427x137.png"  xlink:type="simple"/></disp-formula><p>Summing up (10) the differentiability and convexity is preserved.</p><p>The cost function <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x138.png" xlink:type="simple"/></inline-formula> encourages the agents to use their devices to generate as much energy as demanded. This is an essential aspect of this function: If agents are encouraged to produce energy, they can supply their neighbours, because this yields a financial benefit for them. Additionally, in the entire grid the load is reduced, because energy generation is decentralised this way and the energy can be consumed where it is generated and does not need to be transferred through the entire grid.</p></sec><sec id="s4_2"><title>4.2. Individual Costs of Each Player</title><p>With the global costs in the smart grid defined in (11), fair prices for each agent are derived such that the global costs are covered. Based on [<xref ref-type="bibr" rid="scirp.62019-ref19">19</xref>] the fair pricing is proportional to each agent’s contribution to the global costs. So (10) can be reformulated with respect to the proportional contribution of agent N</p><disp-formula id="scirp.62019-formula119"><label>(12)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-6401427x139.png"  xlink:type="simple"/></disp-formula><p>By applying (9), (10) and (12) can be shown to be equivalent. Through division by <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x140.png" xlink:type="simple"/></inline-formula> singularities are introduced, but these are removable. So the total costs (12) may be simplified:</p><disp-formula id="scirp.62019-formula120"><label>(13)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-6401427x141.png"  xlink:type="simple"/></disp-formula><p>From (13) the costs for an agent N with respect to its demand/supply and energy prices are given by</p><disp-formula id="scirp.62019-formula121"><label>(14)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-6401427x142.png"  xlink:type="simple"/></disp-formula><p>This can be rewritten with respect to agent N and all other agents. For an agent N, only the variables indexed with N can be changed, the other terms are considered fixed. Therefore the game theoretic notation of the negative index <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x143.png" xlink:type="simple"/></inline-formula> is applied to denote a variable depending on all agents except agent N. So the costs for an agent N for energy type e in game theoretic notation is given by</p><disp-formula id="scirp.62019-formula122"><graphic  xlink:href="http://html.scirp.org/file/1-6401427x144.png"  xlink:type="simple"/></disp-formula><p>The total cost of an agent N can be expressed analogously to the total cost in the grid in (11) by</p><disp-formula id="scirp.62019-formula123"><label>(15)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-6401427x145.png"  xlink:type="simple"/></disp-formula></sec><sec id="s4_3"><title>4.3. Bargaining Algorithm</title><p>With (15) it is possible to define a cooperative bargaining game. Since the configuration varies from agent to agent, the feasible set of the optimisation problem of agent N, as presented in Section 3, is denoted by<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x146.png" xlink:type="simple"/></inline-formula>. Let the bargaining game be defined by:</p><p>• Players: All agents<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x147.png" xlink:type="simple"/></inline-formula>.</p><p>• Strategies: Each player N selects <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x148.png" xlink:type="simple"/></inline-formula> to maximise its pay-off.</p><p>• Pay-offs: <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x149.png" xlink:type="simple"/></inline-formula>for agent N.</p><p>In game theory, a pay-off is maximised which in this case is equivalent to minimising costs. The pay-off interpretation is merely a game theoretic convention.</p><p>The above game falls in the category of N-person game with a concave pay-off function. By applying (4), the pay-off function becomes strictly concave. The existence and uniqueness of Nash equilibria in strictly concave N-person games was shown in [<xref ref-type="bibr" rid="scirp.62019-ref20">20</xref>] . A nash equilibrium characterises the optimal strategy of a game. It states that any unilateral deviation by a player from this equilibrium leads to a worse pay-off [<xref ref-type="bibr" rid="scirp.62019-ref21">21</xref>] . Consequently, if <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x150.png" xlink:type="simple"/></inline-formula> are the strategies of the Nash equilibrium,</p><disp-formula id="scirp.62019-formula124"><label>(16)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-6401427x151.png"  xlink:type="simple"/></disp-formula><p>holds for all <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x152.png" xlink:type="simple"/></inline-formula> and for all<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x152.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x153.png" xlink:type="simple"/></inline-formula>. If each agent iteratively plays its best-response strategy to maximise their pay-off, eventually the Nash equilibrium is attained [<xref ref-type="bibr" rid="scirp.62019-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.62019-ref20">20</xref>] . This procedure is illustrated in Algorithm 1 [<xref ref-type="bibr" rid="scirp.62019-ref9">9</xref>] . With this algorithm, the earlier defined bargaining game computes a global optimum which in turn is optimal for each agent.</p><p>The optimisation problem which needs to be solved for each agent is a quadratic optimisation problem with complementarity constraints. The objective function and the constraints (4) and (5) are complementary. The other constraints, as presented in Section 3, are linear. By means of the penalty method it is possible to move the complementarity constraints to the objective function and leave the linear constraints unchanged [<xref ref-type="bibr" rid="scirp.62019-ref22">22</xref>] [<xref ref-type="bibr" rid="scirp.62019-ref23">23</xref>] . As a result a new pay-off function for an agent N is given by</p><disp-formula id="scirp.62019-formula125"><label>(17)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-6401427x154.png"  xlink:type="simple"/></disp-formula><p>with a penalty factor r. This optimisation problem has the same optimum as the original optimisation problem for <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x155.png" xlink:type="simple"/></inline-formula> [<xref ref-type="bibr" rid="scirp.62019-ref23">23</xref>] . In [<xref ref-type="bibr" rid="scirp.62019-ref22">22</xref>] [<xref ref-type="bibr" rid="scirp.62019-ref24">24</xref>] [<xref ref-type="bibr" rid="scirp.62019-ref25">25</xref>] it was shown that the above approach converges despite of the complementarity constraints which violate the linear independence constraint qualification.</p><p>With the reformulation in (17), only linear constraints are left. So merely a quadratic linear optimisation problem needs to be solved. There are various ways to solve such kind of problems, e.g. interior point method, augmented Lagrangian methods, or conditional gradient method [<xref ref-type="bibr" rid="scirp.62019-ref23">23</xref>] [<xref ref-type="bibr" rid="scirp.62019-ref26">26</xref>] [<xref ref-type="bibr" rid="scirp.62019-ref27">27</xref>] . In this paper, the conditional gradient method [<xref ref-type="bibr" rid="scirp.62019-ref28">28</xref>] is used, because it can be easily obtained by extending the simplex algorithm, see e.g. [<xref ref-type="bibr" rid="scirp.62019-ref29">29</xref>] , which is already used to compute the multi-commodity flow in Section 2. In the following section, test cases are presented to illustrate the fairness and the economical usefulness of this approach.</p></sec></sec><sec id="s5"><title>5. Simulations</title><p>The tests in this section are carried out in scenarios in which the energy demand and weather data are known for all time steps. The simulation of one day during winter with time step size of 15 minutes of nine buildings used the following specifications for each building: The building’s admissible room temperature is from 2025. The fuel cell losslessly generates thermal and electrical energy in a 2:1 ratio and needs 30 minutes to start-up and shut-down, respectively. The maximal thermal power generation is 2.6. The battery can store up to 1 of electrical energy losslessly and at most 0.4 can be fed in or out of it. The solar panel has a peak output power of 2.4. The refrigerator has a temperature tolerance interval of 37 and cooling power of 0.09. Note that the devices in the buildings are identical, but the base demand of electrical power and base thermal energy generation varies from building to building, because they are probabilistically generated as described in Section 3.</p><p>The grid operator distributes electrical power, thermal energy and gas over the smart grid. The agents can only sell electrical power and thermal energy; gas can only be consumed.</p><p>Algorithm 1. Bargaining game algorithm over a time interval<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x156.png" xlink:type="simple"/></inline-formula>.</p><p>In the tested scenarios, the buildings were equipped with every possible combination of the above mentioned devices. Only the refrigerator was included in every test case. GNU linear programming kit (glpk) [<xref ref-type="bibr" rid="scirp.62019-ref29">29</xref>] was used to solve the optimisation problem by applying its provided simplex routines in the conditional gradient method.</p><p>In the simulation the peak-to-average ratio (PAR) and the average costs per energy type are evaluated. The PAR relates the peak load in a time interval to the average load. If the peak load is identical to the average load, the PAR is equal to one and represents a perfectly flat load, which is desired. The PAR is depicted in <xref ref-type="fig" rid="fig1">Figure 1</xref>, the average unit costs and the total costs are shown in <xref ref-type="fig" rid="fig2">Figure 2</xref>.</p><p><xref ref-type="fig" rid="fig1">Figure 1</xref> shows that the PAR for heat is about 1.4 which is quite flat. This is owed to the fact that the central heating is part of the optimisation problem and minimising the costs for heating also entails a flat load. A similar relation between PAR and costs minimisation was already shown in [<xref ref-type="bibr" rid="scirp.62019-ref5">5</xref>] . In contrast, the power demand is mostly prescribed and therefore possesses fluctuations which cannot entirely be compensated but alleviated at best. The PAR for power is about 3.7 and can only be reduced by employing a battery. It reduces the PAR by 19% to approximately 3.0. The PAR for gas consumption is only plotted for the three cases which employ fuel cells, in the other cases the gas cannot be processed and is thus unused. It is, however, remarkable that in the scenarios with a fuel cell and fuel cell &amp; solar panel the PAR for heat and power does not decrease. In fact, in most cases it increases. Since the objective function minimises the costs, the reduction of the PAR is a beneficial side-effect but not imperative.</p><fig id="fig1"  position="float"><label><xref ref-type="fig" rid="fig1">Figure 1</xref></label><caption><title> PAR of each energy type for all test cases</title></caption><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/1-6401427x167.png"/></fig><fig id="fig2"  position="float"><label><xref ref-type="fig" rid="fig2">Figure 2</xref></label><caption><title> Total costs of the smart grid for each type of energy</title></caption><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/1-6401427x168.png"/></fig><p>In <xref ref-type="fig" rid="fig2">Figure 2</xref>, the virtual costs for the above mentioned scenarios are plotted. The virtual costs are derived from (13) by setting <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x169.png" xlink:type="simple"/></inline-formula> and summing over all time steps<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x169.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x170.png" xlink:type="simple"/></inline-formula>, so that for a type of energy <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x169.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x170.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x171.png" xlink:type="simple"/></inline-formula> the virtual costs are</p><disp-formula id="scirp.62019-formula126"><graphic  xlink:href="http://html.scirp.org/file/1-6401427x172.png"  xlink:type="simple"/></disp-formula><p>where demand and supply are measured in kilojoule. The virtual price is <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x173.png" xlink:type="simple"/></inline-formula> evaluated at each time step with<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x173.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-6401427x174.png" xlink:type="simple"/></inline-formula>. In <xref ref-type="fig" rid="fig2">Figure 2</xref>, using the same colours and layout, the fuel cell significantly reduces the costs of heat and power. The reduction of costs is achieved by using gas in the fuel cell for heating instead the grid operator’s provided heat, because it is cheaper. The fuel cell cogenerates heat and power, so in addition to heat cheaper with gas, power generation is also included in this process “for free”. The other cases without fuel cell only have an impact on the prices of power, because they only relate to power. The solar panel hardly has an impact on the power prices, whereas the battery reduces them significantly. The total power costs drop by at least 36% when employing a battery.</p><p>In another set of tests, the following devices’ properties were significantly increased: Solar panel’s peak output power was increased to 9.6, battery’s maximum capacity was increased 10 along with increased in-/outflow rates of 4, respectively, and fuel cell’s maximum thermal power generation was increased to 24; the other parameters and other devices and settings were left unchanged. The following test setting uses only one of the above augmented devices. This was carried out to ensure that certain effects can be attributed to a specific device and their properties. The relative change of quantities below refer to the same scenario with the non-augmented properties of the devices.</p><p>With the solar panels’ power generation increased a further drop in cost of 8% maximum could be observed along with an increase of the PAR between 1.5% to 4%. This causes the power prices to drop below zero when the sun shines, meaning that one is paid to consume power, as shown in <xref ref-type="fig" rid="fig3">Figure 3</xref>.</p><p>With the batteries’ increased properties, both, the PAR and costs, reduce further. The power costs decrease by 8% to 9.5%; the PAR is reduced up to 10%. With this behaviour the peak load in the grid can be alleviated by storing power when it is cheap (or is abundantly available) and use it or sell it when it is expensive, as depicted in <xref ref-type="fig" rid="fig4">Figure 4</xref>. The first two plateaus are due to the initial transient. From about hour 4 the plot is perfectly flat and even the highest peak in the simulation, just before hour 24, does not increase the overall load. Even with the 1 battery, the fluctuation could be significantly flattened.</p><p>Increasing the fuel cell’s power does not have any impact in the above scenarios. The reason for that is that the fuel cell is primarily used for heating and there is only a certain amount of demand to be meet. Thus being able to produce more has no further benefit.</p></sec><sec id="s6"><title>6. Conclusions</title><p>In this paper a game theoretic approach for a multi-energy smart grid simulation has been proposed. The</p><fig id="fig3"  position="float"><label><xref ref-type="fig" rid="fig3">Figure 3</xref></label><caption><title> Power prices in contrast to heat prices</title></caption><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/1-6401427x175.png"/></fig><fig id="fig4"  position="float"><label><xref ref-type="fig" rid="fig4">Figure 4</xref></label><caption><title> Total power demand with and without battery</title></caption><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/1-6401427x176.png"/></fig><p>feasibility of the flow through the smart grid is computed by solving a modified multi-commodity flow problem. The demand and supply itself are computed by finding unique Nash equilibrium in a concave N-person game by iteratively computing the players’ best-response strategies to obtain minimal costs. These strategies are the solutions to the respective player’s quadratic optimisation problem with complementarity constraints. The objective function relates demand and supply to the costs by applying a fair pricing scheme.</p><p>The test results show that with this model solar panel, batteries and fuel cells can be used to reduce the energy prices to varying extent. The peak-to-average ratio (PAR) can only be reduced significantly by employing batteries. Solar panels increase the PAR when the sun shines. Moreover, when solar panels generate more power than can be consumed, the prices for power drop below zero. Fuel cells replace the heating and therefore do not flatten the demand but use gas as a heating surrogate. This entails that the heat demand is reduced but the gas demand is increased, which overall yields a financial profit.</p><p>A further step is to increase the simulation to city-sized grid to compute the individual behaviour and compare local sub-grid (distributed) optimisation with centralised (global) optimisation. Since the implementation was carried out in C++ and the open source GNU linear programming kit [<xref ref-type="bibr" rid="scirp.62019-ref29">29</xref>] for solving the optimisation problems, much larger scenarios than the ones presented here are possible to simulate. In particular, running distributed parallel computations allows simulating realistic-sized smart grids.</p></sec><sec id="s7"><title>Cite this paper</title><p>ChristianKuschel,HaraldK&#246;stler,UlrichR&#252;de, (2015) Multi-Energy Simulation of a Smart Grid with Optimal Local Demand and Supply Management. Smart Grid and Renewable Energy,06,303-315. doi: 10.4236/sgre.2015.611025</p></sec><sec id="s8"><title>NOTES</title></sec></body><back><ref-list><title>References</title><ref id="scirp.62019-ref1"><label>1</label><mixed-citation publication-type="other" xlink:type="simple">Biswas, M.M., Azim, M.S., Saha, T.K.S., Zobayer, U. and Urmi, M.C. (2013) Towards Implementation of Smart Grid: An Updated Review on Electrical Energy Storage Systems. Smart Grid and Renewable Energy, 4, 122-132. 
http://dx.doi.org/10.4236/sgre.2013.41015</mixed-citation></ref><ref id="scirp.62019-ref2"><label>2</label><mixed-citation publication-type="other" xlink:type="simple">Karl, J. (2006) Dezentrale Energiesysteme: Neue Technologien im liberalisierten Energiemarkt. Oldenbourg. 
http://dx.doi.org/10.1524/9783486593341</mixed-citation></ref><ref id="scirp.62019-ref3"><label>3</label><mixed-citation publication-type="other" xlink:type="simple">Ekanayake, J., Jenkins, N., Liyanage, K., Wu, J. and Yokoyama, A. (2012) Smart Grid: Technology and Applications. Wiley, New York. http://dx.doi.org/10.1002/9781119968696</mixed-citation></ref><ref id="scirp.62019-ref4"><label>4</label><mixed-citation publication-type="other" xlink:type="simple">Monti, A. and Ponci, F. (2010) Power Grids of the Future: Why Smart Means Complex. Proceedings of the Complexity in Engineering, COMPENG’10, Rome, 22-24 February 2010, 7-11.</mixed-citation></ref><ref id="scirp.62019-ref5"><label>5</label><mixed-citation publication-type="other" xlink:type="simple">Mohsenian-Rad, A.-H., Wong, V., Jatskevich, J., Schober, R. and Leon-Garcia, A. (2010) Autonomous Demand-Side Management Based on Game-Theoretic Energy Consumption Scheduling for the Future Smart Grid. IEEE Transactions on Smart Grid, 1, 320-331. http://dx.doi.org/10.1109/tsg.2010.2089069</mixed-citation></ref><ref id="scirp.62019-ref6"><label>6</label><mixed-citation publication-type="other" xlink:type="simple">Atzeni, I., Ordonez, L.G., Scutari, G., Palomar, D.P. and Fonollosa, J.R. (2013) Demand-Side Management via Distributed Energy Generation and Storage Optimization. IEEE Transactions on Smart Grid, 4, 866-876. 
http://dx.doi.org/10.1109/TSG.2012.2206060</mixed-citation></ref><ref id="scirp.62019-ref7"><label>7</label><mixed-citation publication-type="other" xlink:type="simple">Li, N., Chen, L. and Low, S.H. (2011) Optimal Demand Response Based on Utility Maximization in Power Networks. Proceedings of the IEEE Power &amp; Energy Society General Meeting, Detroit, 24-29 July 2011, 1-8.  
http://dx.doi.org/10.1109/pes.2011.6039082</mixed-citation></ref><ref id="scirp.62019-ref8"><label>8</label><mixed-citation publication-type="other" xlink:type="simple">Lo, C.-H. and Ansari, N. (2013) Decentralized Controls and Communications for Autonomous Distribution Networks in Smart Grid. IEEE Transactions on Smart Grid, 4, 66-77. http://dx.doi.org/10.1109/tsg.2012.2228282</mixed-citation></ref><ref id="scirp.62019-ref9"><label>9</label><mixed-citation publication-type="other" xlink:type="simple">Arif, M.T., Oo, A.M. and Ali, A.S. (2013) Role of Energy Storage on Distribution Transformer Loading in Low Voltage Distribution Network. Smart Grid and Renewable Energy, 4, 237-251. http://dx.doi.org/10.4236/sgre.2013.42029</mixed-citation></ref><ref id="scirp.62019-ref10"><label>10</label><mixed-citation publication-type="other" xlink:type="simple">van de Ven, P.M., Hegde, N., Massoulie, L. and Salonidis, T. (2013) Optimal Control of End-User Energy Storage. IEEE Transactions on Smart Grid, 4, 789-797.</mixed-citation></ref><ref id="scirp.62019-ref11"><label>11</label><mixed-citation publication-type="other" xlink:type="simple">Giuntoli, M. and Poli, D. (2013) Optimized Thermal and Electrical Scheduling of a Large Scale Virtual Power Plant in the Presence of Energy Storages. IEEE Transactions on Smart Grid, 4, 942-955.</mixed-citation></ref><ref id="scirp.62019-ref12"><label>12</label><mixed-citation publication-type="other" xlink:type="simple">Gross, J.L., Yellen, J. and Zhang, P. (2013) Handbook of Graph Theory. 2nd Edition, Chapman &amp; Hall/CRC, Boca Raton.</mixed-citation></ref><ref id="scirp.62019-ref13"><label>13</label><mixed-citation publication-type="other" xlink:type="simple">Bayernwerk, A.G. (2013) Netzrelevante Daten. 
https://www.bayernwerk.de/pages/eby_de/Netz/Stromnetz/Netzinformationen/Netzrelevante_Daten</mixed-citation></ref><ref id="scirp.62019-ref14"><label>14</label><mixed-citation publication-type="other" xlink:type="simple">Houwing, M., Negenborn, R.R. and De Schutter, B. (2011) Demand Response with Micro-CHP Systems. Proceedings of the IEEE, 99, 200-213. http://dx.doi.org/10.1109/JPROC.2010.2053831</mixed-citation></ref><ref id="scirp.62019-ref15"><label>15</label><mixed-citation publication-type="other" xlink:type="simple">Hansen, A.D., Ris&amp;Oslash;, F., S&amp;Oslash;rensen, P., Hansen, L.H., Bindner, H. (2000) Models for a Stand-Alone PV System. RIS&amp;OSLASH;-R-1219, Ris&amp;Oslash; National Laboratory, Roskilde.</mixed-citation></ref><ref id="scirp.62019-ref16"><label>16</label><mixed-citation publication-type="other" xlink:type="simple">Tsai, H.-L., Tu, C.-S. and Su, Y.-J. (2008) Development of Generalized Photovoltaic Model Using Matlab/Simulink. Proceedings of the World Congress on Engineering and Computer Science, San Francisco, 22-24 October 2008.</mixed-citation></ref><ref id="scirp.62019-ref17"><label>17</label><mixed-citation publication-type="other" xlink:type="simple">Weather Underground (2015) Weather Forecast &amp; Reports. http://www.wunderground.com</mixed-citation></ref><ref id="scirp.62019-ref18"><label>18</label><mixed-citation publication-type="other" xlink:type="simple">Doering, E., Schedwill, H. and Dehli, M. (2008) Grundlagen der Technischen Thermodynamik: Lehrbuch für Studierende der Ingenieurwissenschaften: Mit 303 Abbildungen, 45 Tabellen sowie 56 Aufgaben mit L&amp;ouml;sungen: Studium. Vieweg + Teubner.</mixed-citation></ref><ref id="scirp.62019-ref19"><label>19</label><mixed-citation publication-type="other" xlink:type="simple">Baharlouei, Z., Hashemi, M., Narimani, H. and Mohsenian-Rad, H. (2013) Achieving Optimality and Fairness in Autonomous Demand Response: Benchmarks and Billing Mechanisms. IEEE Transactions on Smart Grid, 4, 968-975. 
http://dx.doi.org/10.1109/TSG.2012.2228241</mixed-citation></ref><ref id="scirp.62019-ref20"><label>20</label><mixed-citation publication-type="other" xlink:type="simple">Rosen, J.B. (1965) Existence and Uniqueness of Equilibrium Points for Concave n-Person Games. Econometrica, 33, 520-534. http://dx.doi.org/10.2307/1911749</mixed-citation></ref><ref id="scirp.62019-ref21"><label>21</label><mixed-citation publication-type="other" xlink:type="simple">Nash, J.F. (1950) Equilibrium Points in N-Person Games. Proceedings of the National Academy of Sciences of the United States of America, 36, 48-49. http://dx.doi.org/10.1073/pnas.36.1.48</mixed-citation></ref><ref id="scirp.62019-ref22"><label>22</label><mixed-citation publication-type="other" xlink:type="simple">Fukushima, M. and Lin, G.-H. (2004) Smoothing Methods for Mathematical Programs with Equilibrium Constraints. Proceedings of the International Conference on Informatics Research for Development of Knowledge Society Infrastructure, Kyoto, 1-2 March 2004, 206-213. http://dx.doi.org/10.1109/icks.2004.1313426</mixed-citation></ref><ref id="scirp.62019-ref23"><label>23</label><mixed-citation publication-type="other" xlink:type="simple">Reinhardt, R., Homann, A. and Gerlach, T. (2013) Nichtlineare Optimierung. Theorie, Numerik und Experimente, Springer-Lehrbuch, Springer-Spektrum, Berlin Heidelberg.</mixed-citation></ref><ref id="scirp.62019-ref24"><label>24</label><mixed-citation publication-type="other" xlink:type="simple">Bouza Allende, G. and Still, G. (2007) Mathematical Programs with Complementarity Constraints: Convergence Properties of a Smoothing Method. Mathematics of Operations Research, 32, 467-483.  
http://dx.doi.org/10.1287/moor.1060.0245</mixed-citation></ref><ref id="scirp.62019-ref25"><label>25</label><mixed-citation publication-type="other" xlink:type="simple">Hu, X. and Ralph, D. (2004) Convergence of a Penalty Method for Mathematical Programming with Complementarity Constraints. Journal of Optimization Theory and Applications, 123, 365-390. 
http://dx.doi.org/10.1007/s10957-004-5154-0</mixed-citation></ref><ref id="scirp.62019-ref26"><label>26</label><mixed-citation publication-type="other" xlink:type="simple">Bertsekas, D.P. (1999) Nonlinear Programming. Athena Scientific, Belmont.</mixed-citation></ref><ref id="scirp.62019-ref27"><label>27</label><mixed-citation publication-type="other" xlink:type="simple">Jaggi, M. (2013) Revisiting Frank-Wolfe: Projection-Free Sparse Convex Optimization. Proceedings of the 30th International Conference on Machine Learning, Atlanta, 16-21 June 2013, 427-435.</mixed-citation></ref><ref id="scirp.62019-ref28"><label>28</label><mixed-citation publication-type="other" xlink:type="simple">Frank, M. and Wolfe, P. (1956) An Algorithm for Quadratic Programming. Naval Research Logistics Quarterly, 3, 95-110. http://dx.doi.org/10.1002/nav.3800030109</mixed-citation></ref><ref id="scirp.62019-ref29"><label>29</label><mixed-citation publication-type="other" xlink:type="simple">GLPK (2015) GNU Linear Programming Kit. www.gnu.org/software/glpk</mixed-citation></ref></ref-list></back></article>