GRENAD
GRENAD
15439/2015F310
Computer Science and Information Systems pp. 1781–1792 ACSIS, Vol. 5
Figure 1) and can be stored nearby the CHP. The system is also C. Planing and operation
connected to the main power grid (component 4 in Figure 1). Due to the temporal inertia of most of the components
The gas and the power main grids are considered in our model (e.g. time to start or change generator command level;
as controllable producers, it is, we consider that the quantity of thermal inertia on houses and distribution networks; time
gas or the power drawn from the main grids can be controlled. to charge/discharge storage systems) and the use of non-
In the real system only the gas flow can be directly controlled, controllable sources (that are intermittent and variable), the
the drawn power from the main grid is indirectly controlled energy usage needs to be planned before actual generation and
and corresponds to balance needed power, it is, the consumed delivery. In our approach, we consider planning strategies that
power minus the local producer power. are combined to real-time operation strategies. Planning is
2) Storage components: The behavior of a storage com- based on estimation of the consumption loads and generation
ponent depends mainly on its nominal capacity, its rate of capabilities and allows to establish negotiated (i.e. agreed by
charge/discharge and its instantaneous state of charge (SoC). all parties) generation, storage and consumption schedules.
Other important variables are the efficiency of the conversion For the renewable based generators, the estimation depends
in the charge and discharge phases and the self-discharge rates. on weather and generation capabilities forecasting. For end
The usage of some storage systems, for instance batteries, is consumers, the estimation depends mainly on weather and us-
constrained by the charge/discharge cycling conditions that age forecasting, as well as on thermal inertia evaluation. Those
optimize their efficiency and increase their lifetime. In our different forecasting based estimations lead to inaccuracies at
scenario we consider a thermal storage component (see com- the planning phase. In order to maintain the balance between
ponent 6 in Figure 1). consumption and generation and minimize the use of external
generated energy, we implement and operate a mechanism that
3) Distribution components: The distribution of energy allows the near real-time correction of energy schedules when
generates losses due to the physical characteristics of the deviations of generation and load are detected (monitored or
transportation system used (i.e. transmission capabilities, dis- forecasted). This mechanism can be seen as a capacity market
sipation rates, etc.) and the distances of transmission of the where global flexibility is provided by the combined individual
energy. In general, at the district level, the electricity losses due flexibility capabilities (e.g. deferrable load, dedicated storage
to distribution are negligible while the heating and hydraulic capabilities, etc.)
(heating network related) losses are not. Some distribution
components (as valves in heating networks and some types D. Real-Time payment
of transformers) allow the dispatching of input energy among Smart-Grid also aims to adapt the consumption to the energy
different outputs. While the availability of energy over elec- production capacity. This is particularly critical when some
trical networks is instantaneous (electricity is transmitted at producers are not controllable (e.g. weather dependant renew-
about the speed of light), the transmission of energy over able energy source). By exploiting for instance a building
heating and cooling networks, due to the transport inertia, thermal inertia, it is possible to respect a required comfort
needs significant time (several minutes per km) to go from level while adapting the actual consumption.
the injection to the consumption points. In our scenario we A commitment of the consumer on how it will consume
consider local heating and power networks: all the production energy allows to optimise energy production and distribution
and consumption components considered in the scenario are during the planning. Several payment approaches [22] propose
connected to at least one of these distribution networks. to impose penalties if such a commitment is not respected
4) Consumer components: The characteristics of the energy during operation phase. The actual payment of a consumer
consumed, basically their load curves, depend mainly on the is thus computed by comparing its planned and operational
buildings physical characteristics (i.e. thermal inertia, storage consumption along with some other production-related and/or
capabilities), the behaviors of the inhabitants (presence/ab- conventional parameters.
sence, used services) and the comfort constraints (e.g. ambient III. R ELATED W ORKS
temperature set points). In our scenario we consider two
Actual testing and deployment of smart grid software
consumers, the components 7 and 8 in Figure 1.
require platforms able to directly support the execution of
5) Prosumer components: Besides the characteristics that control software developed following as well as the ability
define the load curves of the consumer components, prosumers simulate or even pilot power systems. Among the few available
can partially or totally cover their needs in energy and under commercial systems that target specifically smart grids, only
some conditions produce energy surplus that can be injected a bit of them follow the MAS approach.
into the main or local energy grids. In our scenario we consider The available commercial software that simulate and control
one prosumer (component number 5 in figure 1), that locally traditional grids [15], [7], can to some extent be used to
produces power thanks to the PV solar panels installed on its simulate parts of a smart grid, notably for the distribution
roof. It uses part of this energy for self-consumption and is aspect. However, smart grids possess several specificities that
able to inject part of this energy into the power distribution preclude the use of such software for the full chain control.
network. On the other hand, smart grid software have not reached
1784 PROCEEDINGS OF THE FEDCSIS. ŁÓDŹ, 2015
this level of maturity and are mostly experimental or at the We first present our agent model, then we present our smart-
level of academic research. Dedicated software solutions for grid model and last we describe how to formalize the scenario
smart grids exist independently, for different aspects presented thanks to this model.
in this scenario: storage simulation and dimensioning [10],
DER integration [5], demand side management [9] and VPP A. Agent Model
[2]. While none of these commercial software uses a MAS GRENAD is implemented as an overlay of JADE. It pro-
approach, PowerMatcher [17] is an exception. It can perform vides a Domain Specific Language (DSL) that exploits a
simulation and piloting and uses auction protocols to interact component-based approach in order to describe the agents and
over a market of flexibilities. enhance JADE with a set of native services (agent building
Among non commercial software, GridLab-D [4] is a no- system, ergonomic agent messaging service, generalized sup-
table one, it is a low level electrical simulation tool based port of a publish/subscribe system, . . . ). The agent building
on a MAS paradigm. It allows to assign different profiles system simplifies the use of JADE for defining agents at
of consumption to the devices on the network, but fails to compile time and runtime (initialisation step). The first class
represent economic actors and is not able to endow agents to understand in the agent building system is GrenadAgent.
with advanced smart behaviours that react to change in their A GrenadAgent<ID extends GrenadIdentifier>
environment. can be viewed as a pair made of an identifier of type Id and
Most academic works in smart grids consider separately the a list of components. It is an implementation of the builder
development of a platform, a model and control algorithms. pattern from [6, p. 97]: the identifiers and components hold all
As such they provide very limited reusability and interoper- the information required to build a JADE Agent exposing all
ability between the different layers. Platforms in the literature the natively proposed features of JADE as well as non natively
mostly act as a middleware and focus on the coupling of a proposed ones.
MAS platform (JADE [11] being the most popular) with an A GrenadIdentifier is the specification of a JADE
electrical simulator and data exchange formats[1], [23], [21]. AID (the JADE Agent IDentifier): GrenadIdentifier
The designs provided in papers that present models [16], [8] allows to obtain the AID once the JADE agent is set up by
fail to acknowledge either the simulation or the control aspects JADE1 . A component is a stateful and active object that is
and often both of them, limiting their applicability. Finally, executed within the environment of the hosting agent. Such
while most control algorithms are backed by experimental an environment provides access to a set of services shared by
simulations, they are coded specifically for non smart grid all the components of the same agent. We distinguish three
environments and therefore fail to be reused and extended. We groups of components:
believe this shows a clear need for a generic and flexible tool • Action components are components that produce a list
for smart grid algorithms conception, testing and deployment. of JADE Behaviour objects that are to be added in the
In this paper we propose such a tool: a platform and a model to-be-constructed JADE Agent.
that have been thought for reusability in smart grid applications • Runtime components allow to modify the way a
and aims at supporting different smart grid applications at GrenadAgent is handled by JADE. They can modify
all levels. We demonstrate this by exhibiting the coupling the GrenadAgent or execute side effects that depend
of a state of the art distributed control algorithm. Previously on it, at agent set up or take down. They can specify
mentioned works lack an abstract representation encompassing actions to realise while cloning or moving the agent. They
both the socio-economical actors and the physical devices, in can also catch and handle exceptions issued by the agent
GRENAD both are explicitly modeled. execution, which is a functionality not natively proposed
The implementation of GRENAD is based on JADE. JADE by JADE.
is a widely popular generic purpose MAS execution platform • Composite components are collections of components
providing primitives to ease the development of agents and (as such they follow the composite pattern from [6,
deployment of agents [11]. This platform, by being generic, p. 163]). They allow to manipulate a bag of components
lacks support for smart grid elements needed to represent, as if it was a single one. From the agent point of view,
simulate or even control a smart grid. GRENAD extends JADE loading a Composite component is equivalent to
and enrich its capabilities with additional communication loading each component of the collection it represents.
mechanisms and smart grids specific objects and proposes a By definition a component is an independent piece of
component based architecture. software: it has its own state (set of constants, variables and
methods) and has no access to the other components of the
IV. O UR M ODULAR AGENT-BASED S MART-G RID M ODEL hosting agent (except for certain Runtime Components, as it
In this section we present and illustrate our contribution: an is their goal). Certain actions allow to specify their state in a
agent model implemented on top of JADE and a smart-grid separate class and thus easily share it with other components
model implemented on top of our agent model. The conception 1 JADE agent life cycle starts by building the agent, then executes the
has been driven by the Design Pattern approach. For more method setup once the agent is alive. It then executes the method
information about Design Patterns please have a look at [6]. takeDown if the agent is required to terminate, and finally kills it
SYLVAIN DUCTOR ET AL.: GRENAD, A MODULAR AND GENERIC SMART-GRID FRAMEWORK 1785
of the same agent. The goal is to enhance component re- in the latter the sender of a message is decided by the receiver.
usability by separating configuration/decision aspects to ac- Natively proposing both approaches brings a great flexibility
tion/communication ones. For example, different behaviours or in the way of establishing communication neighbourhoods.
protocols may require at some point to have access to the agent Publish/Subscribe Pattern is also well suited for the event-
launch date, its neighbourhood, its preferences or abilities driven approach that characterizes reactive agents.
such as computing an optimal path. Exploiting the Template The approach proposed so far achieves modularity in the
Method Pattern from [6, p. 325] allows to identify those production of multi-agent systems by applying the Builder
methods that ought to be placed in interfaces implemented Pattern on a class that encapsulates its own strategy (i.e.
by the component state. It is then the responsibility of the the list of components), thus allowing to get rid of the
agent to globally implement them in states shared by its “extends” keyword for varying the characteristics of the in-
components, thus ensuring both coherence of its actions and stantiated agent. Indeed the Strategy Pattern, by promoting
efficient factorisation of its code. encapsulation, is more suited than inheritance when it comes
Let us consider, for instance, an auction about a certain to flexibility, re-usability and modularity. Modularity comes
type of objects that runs between an auctioneer and several from the fact that a component can informally be seen as a
bidders. In this process each bidder is characterized by the full and independent functionality. It can be assembled with
value it attributes to the objects. Except for this decision other components in order to easily define a complex agent.
function, all other actions executed during this auction process Component independence is the first root of re-usability. The
are conventions specified by the auction rules. A correctly second root lies in the ability to delegate the responsibility of
factorized implementation would thus define a component the configuration or decision methods to the agent rather than
that encodes the behaviours resulting from those rules and to the components. Hence, given a set of already implemented
exploits the evaluation function on the considered bidders, components, it is possible to build heterogeneous agents
implemented in a separated state. Let us suppose now that by varying their preferences, planning methods, etc.. Lastly,
one of these same bidders has latter participates in a different flexibility is provided by the simultaneous native support
kind of auctions about the same type of objects. The expected of traditional mail-box based message sending and reactive
behaviour for this agent is to evaluate the objects in the same Publish/Subscribe Pattern, which avoids imposing constraints
way. Our "correctly factorized" approach does it naturally upon the initial coupling of neighbours.
since the agent will only need to share the previously used
state with the component executing this new process. B. Smart-Grid Model
Please note that we strongly recommend to avoid data muta-
bility in this approach by only sharing constants and methods. On the basis of the agent structure presented in section IV-A,
If the state has variables, it is up to the programmer to ensure, we propose here a model that allows to describe, simulate
when building the agent, that the different components that and pilot complex smart-grids. In order to do so, it exploits
exploit it do not modify them in an incoherent way. physical models of atomic components as well as simulators
Besides, all the components of a same agent share three of groups of components. It allows a fine-grained remote
services : monitoring and control of the energy distribution given infor-
• Access to the unique identifier of the agent. mation about consumption, production and a “configuration”
• Access to the agent communication service, which allows of each component (i.e. an instantiation of its actuators).
to send messages and have access to the mailbox. Also, actuators can be remotely controlled, thus allowing the
• Access to the publish/subscribe service of the agent. smart-grid to be controled by a user interface (GUI, service
The Publish/Subscribe Pattern (also known as the Observer web, . . . ) or an autonomous decision mechanism. Considered
Pattern, see [6, p. 293]) is natively proposed by GRENAD, be- energy information is projected over time and includes generic
cause it provides an efficient way to decouple communication, multi-flow energy demand, generic offer characteristic and
as opposed to the natural approach of message sending. In the whether the offer can meet the demand at each point of the
Publish/Subscribe Pattern, an agent, the publisher, publishes grid. Relevant physical model can simulate the propagation
whenever it decides any information it finds relevant. It does of blackouts or brownouts. Also several simulations can run
not know a priori who is interested by this information. A simultaneously on the same smart-grid, made mutually depen-
published information is identified by its type, a name set by dent (e.g. planning and operation) and easily compared (e.g.
the publisher, and the identifier of the publisher. A subscriber real-time payment).
agent knows a priori which publication of which publisher it The model proposed here has been implemented in
is interested in. It thus subscribes to it, and indicates at the GRENAD as a collection of components (see Section IV-A).
same time the action it will execute upon the reception of a Hence it can naturally be integrated with other components
new publication (how it will react). It may stop this behaviour and distributed over a network in order to be used in various
at any time by unsubscribing. situations. For instance, it can get its values and set its
Simple direct message exchange and the Publish/Subscribe actuators from and to a physical smart-grid ; it can be used
Pattern are opposed approaches to communication: in the for- as an isolated simulator ; it can be used in conjunction with
mer, the receiver of the message is decided by the sender, while a coordination protocol ; encapsulating agents may interact
1786 PROCEEDINGS OF THE FEDCSIS. ŁÓDŹ, 2015
with real clients ; encapsulating agents may negotiate on stock may define an IncoherentNeighbourhood while it has
market, . . . not received the updated information of the other component.
In this section we present the different aspects of our smart- We distinguish five types of SGField. The first,
grid model: how energy is represented by the different roles, Fixed<A>, has a constant value and, thus, should always
how information about energy is stored and updated, how it be valued. The second and third fields have dynamic values
is transmitted between the agents and projected over time. and exploit the Publish/Subscribe pattern: Output<A> is an
1) Energy and Roles: We consider three roles. observable field that is observed by a Sensor<A> field of a
• A consumer expresses a demand as an amount of energy neighbour. Whenever a new value is set in an Output<A>, it
on the different flows considered (e.g. heat, electricity, is published. The neighbour’s Sensor<A>, upon the recep-
. . . ). tion of the publication, will trigger the occurrence of a new
• A producer expresses an offer, as a function that, given event within the component. This will typically result to the
a demand, returns whether it can be produced. If so, it call of the internal model of the component, which may in
returns also what would be the Quality of Service (QoS) turn update some outputs, thus propagating the information.
(e.g. CO2 impact (in kgCO2 ), base cost (in euros), . . . ). The fourth field, Actuator<A>, is an Output<A> that can
• A distributor distributes the energy among its neigh- be remotely controlled by the fifth field, Controller<A>,
bours. It associates with each consuming neighbour an which is a Sensor<A> that may send a request to implement
offer and each producing neighbour a demand. a new value on the actuator it observes, thus modifying the
A given component has a specific representation of the configuration of the smart-grid.
energy. This representation is structured among two aspects: Each class representing a smart-grid role (consumer, pro-
amount and QoS. No constraints at all are put on these objects: ducer or distributor) is associated in one hand to a set of fixed,
they are only defined w.r.t. the information required by the outputs, sensors and actuators (its state) and, in another hand,
physical models and the simulators used in the considered to an internal model. As stated above, the internal model is
application. However, some components require a manipula- triggered upon the reception of a new event, either a new
tion function to be provided. For this reason, we consider a value observed by some sensors, or the modification of some
dedicated algebra over amounts or QoS. This algebra allows actuators. When called, the internal model will read the value
the component to manipulate energy information as a black of the fixed fields, the sensors and the actuators and update
box, thus ensuring genericity. For instance, let A be an amount, the outputs. The internal model is an abstract method whose
⊕A : A × A 7→ A is an additive operator over A. It allows to implementation is application specific and may rely on some
compute the overall demand of two consumers. ∅A represent simple Java models or complex external physical simulators.
a null amount, i.e. the neutral element of ⊕A . The same goes 3) Links and Information Propagation: In our smart-grid
for QoS. model, the neighbourhood relation is defined using outputs
A Demand<A> is a container of several flows of energy and sensors: each component associates an output to each of
of type A. We implements a flow as a class that extends its neighbours. It also defines a sensor for each output that has
the class A. A Demand<A> can be manipulated, given been associated to him.
an aforementioned algebra over A by simply applying it Sensors may transform the observed information. This al-
independently on each of its flow. lows to easily implement link losses or maximal capacity. Sen-
An offer Offer<A, QoS> is a function from sors may also change the type of the information. Hence, given
a Demand<A> to an Optional<QoS>. An a function from A to B, an Output<A> can be observed by
Optional<QoS> can either be a value of type QoS, a Sensor<B>. This allows to easily connect heterogeneous
if the producer has the capacity to satisfy the demand, or be components.
empty if it cannot. Note that each component is associated to a group. Only
2) State, Fields and Internal Model: The state of a smart- outputs and sensors of the same group can interact. This
grid component is defined as a collection of a dedicated allows a same agent to load different instances of the same
class of fields, SGField<A>. An SGField<A> allows to component, each being uniquely identified by its group.
handle asynchronicity by outputting four types of values: (1) Thanks to this architecture, it is easy to do simultaneously
an object of type A if it has been correctly instantiated (in the current operation phase and tomorrow planning phase
this case, the field is said to be valued), (2) NotReady if on a same agent. The latter may easily compute its real-
some information is still missing or some computation is still time payment by comparing the outputs of its planning and
running on, (3) IncoherentNeighbourhood if an infor- operation components.
mation received from some neighbour is incoherent and (4) The three roles (consumer, producer or distributor) rely
InvalidInternalState if the instantiation of the state on a strict neighbourhood architecture. Figure 2 presents the
of the component is invalid w.r.t. the internal model. Note that neighbourhood relation between the roles. Next to the role
we do not throw any exception, since the states 2, 3 and 4 can is represented the type of its output; each output is mirrored
come from a delay of communication due to asynchronicity by a sensor of the neighbour. For clarity, we always consider
or distribution. For instance, if two neighbours are required to in this article homogeneous components: they use the same
modify their configuration, the first that receives the request energy representation, (A, QoS).
SYLVAIN DUCTOR ET AL.: GRENAD, A MODULAR AND GENERIC SMART-GRID FRAMEWORK 1787
with a demand expressed on the considered flow at the 4) Storage: The Storage unit is a distributor with two
considered time point, as 3, 2 and 5 kWh. Let us suppose neighbours that can be decomposed as three internal compo-
that there are two producers, the first assuming 30% of the nents. It holds a consumer, which defines a demand, an internal
consumption and the second 70%, as such, the first will assume state, which holds the information about the stored energy, and
3 kWh and the second 7. Let us suppose that the first producer a producer, which defines an offer. The demand is output to
emits 4 kgCO2 for producing 3 kWh and the second 6 for one of the neighbours and the offer to the other.
producing 7 kWh. Hence, the first consumer demand will be The decision related to the storage is about how much
associated to a QoS of 3 kgCO2 , the second to a QoS of 2 energy is stored and at which time, this is why the storage
kgCO2 and the third to a QoS of 5 kgCO2 demand is held by an actuator. The internal state is a pri-
However, our model requires the distributor to output not vate output that holds the stored energy in the form of a
a QoS but an offer, that is to say, a function that associates demand, which may be initially not null. It is updated by
to any demand a QoS, if this demand is satisfiable. The offer the storage demand, which adds energy, and the observed
output to each consumer is computed under the hypothesis consuming neighbour demand, which subtracts energy. Also a
that it is the only one changing its demand. Let proddist be special function defines losses by modifying the internal state
the offer function associated of a given distributor, dist. A accordingly.
given demand a is distributed by dist to each of its producing The maximum capacity offer is defined by the internal state.
neighbor, n, according to their associated pn . This offer is The QoS of energy offered to the storage consuming neighbour
computed for the demand a as the sum of the QoS returned by is independent of the consuming neighbours demand. Indeed,
each those neighbours for their associated part of the demand. the offered energy has already been produced at the time it is
Let P roducingdist be the set of the considered producing stored. Hence, the consuming neighbours are informed of this
distributor neighbours, QoS even if their demands are null. For any time point t, let
t
QoSstor be the QoS returned by the application of the demand
of the storage at time t to the offer of its producing neighbour
∀a ∈ Demand < A >, proddist (a) =
( at time t (assuming this demand is sustainable). Let storedt
empty if some neighbour can’t supply it’s part be a demand indicating the stored energy at time t (i.e., the
(1)
internal state). For any demand at of the consuming neighbour,
P
n∈P roducingdist of f ern (a × pn ) else
the storage can assume at if at is inferior to storedt , and the
t
The offer output to a consumer cons, outputcons , considers offered QoS is always equals to QoSstor .
proddist as if all other consumers had already consumed. Note that, if necessary, you can encode the fact that the stor-
Let Consumingdist be the set of the considered consuming age unit can not simultaneously store and deliver by triggering
distributor neighbours, and, for any c ∈ Consumingdist , let an InvalidInternalState whenever a positive value of
ac be its demand, the demand actuator matches a positive value of the observed
demand of the consuming neighbour.
∀a ∈ Demand < A >, outputcons (a) = 5) Main Grids: Main gas and power grids are typically
X producers that are out of the scope of control of the considered
proddist ( ca ⊕ a) (2) smart-grids. Hence, they do not provide any actuators. If
c∈Consumingdist \cons GRENAD is used as a simulator, they will be implemented
with a predefined offer to output. If it is used as a piloting tool,
Please note that this approach is coherent with the above they exploit the interface pattern for two purposes. Firstly, to
mentioned examples. It also provides more information and get the information from the external system they represent
allows to still use a simple model that only considers two and construct from it an offer, and secondly, ot transmit the
types of information, demand and offer. demand computed by GRENAD in the appropriate format.
3) Prosumer: The prosumer house with PV panel needs to 6) CHP: The CHP unit offers energy both on the heat
be separated into 3 components. One defining the offer (PV and the electricity flows. It is a distributor since it transforms
Panel), the other the demand (ProsHouse) and the third the energy by consuming it from the main gas grid and supplying
distribution (Dist3). Please note that, in case the PV panel it to Dist0. The CHP offer to Dist0 is computed from the main
does not have any actuator and provides energy only to the gas grid offer, and an internal actuator that indicates how much
house, it is possible to remove this component and only use of the energy consumed is used to produce electricity and how
a “gain” on the links, implemented thanks to the sensors much is used to produce heat. CHP demand to the main gas
(see Section IV-B3). In this case, the sensors of Dist3 and grid is computed back from Dist0 demand given the internal
ProsHouse both transform the observed output over time by actuator value.
applying the weather-dependent prediction of the production 7) Wind Farm: In our scenario, the orientation of the wind
of the PV Panel. If it is not the case, a separate element is farm turbines is controlled by the application. Hence, the
required, either to be able to receive actuator modifications wind farm producer provides a collection of actuators, each
or to be seen by Dist 3 as a source of energy that can be one defining the orientation of the turbine it is associated
distributed to the network. with, along the time. Those actuators can either be manually
1790 PROCEEDINGS OF THE FEDCSIS. ŁÓDŹ, 2015
controlled by a remote end-user or dynamically optimised by that the demand is satisfied or detects any demand that would
a coordination mechanism run by GRENAD (see for instance violate the flow conservation constraint or the capacity.
Section V). The algorithm requires the network to be tree shaped (e.g.
In the application we are considering, the objective is electric network), and proceeds in two phases. In the first,
typically to optimise the energy production, distribution, and the collect phase, information is going from the leaves to the
consumption as a whole. The optimisation of the wind farm root: each node acquires and transmits to its parent the overall
production is not about maximising independently their pro- consumption and production information about its subtree. In
duction but coordinating the production of the different pro- the second, the propagation phase, information is going from
ducers (main grids and CHP) as well as the storage units in the root to the leaves: each node decides an optimal power
order to optimise the overall QoS of the energy supplied to dispatching given the one of its parent.
the consumer. One may also wants to include the consumer in Implementing this algorithm in GRENAD is done in the fol-
order to match the consumption with the production capaci- lowing way: each distributor possesses an actuator named pro-
ties. GRENAD ergonomically supports the implementation of posal for each of its distributor neighbours, and observes with
such a coordination protocol by exploiting the state pattern a sensor the proposals of these respective neighbours. This
coupled with the natively proposed publish subscribe pattern, communication network allows the information required by
as described in the next section. However, the definition of the proposal phase to be transmitted from point to point. Each
such a protocol in the complex case of this rich scenario is actuator is updated by the optimisation algorithm. GRENAD
behind the scope of this article. allows transparently this optimisation algorithm to be either
located at the level agent or in a remote controller. For the
V. O PTIMISATION OF ENERGY DISTRIBUTION sake of clarity, in this section, we refer to the initial state of
sensors and outputs of the KirchoffStar as regular sensors
In order to present the genericity and flexibility of GRENAD
and outputs.
we describe in this section the port in GRENAD of a dis-
The implementation exploits the state pattern: a given
tributed algorithm that performs an optimal distributed dis-
behavior is associated to a certain instantiation of the proposal
patching of electrical power over radial networks. The pre-
and regular sensors, output and actuator. We distinguish three
sented algorithm solves a distributed constraint optimisation
states:
problem and is a part of [14], the port to GRENAD introduces
some modifications. First, GRENAD generic way of handling 1) Not Ready distributor: the distributor did not already
energy allows to easily apply the presented algorithm in a receive enough information from its neighbours to be
more general context than [14] (see Section V-B). Second, the able to act. It is therefore waiting.
combination of the State Pattern, from [6, p. 305], with the na- 2) Collect Ready distributor: all but one of the distributor
tively implemented publish/subscribe pattern allows a simple neighbours has instantiated their proposal actuator, the
description and implementation of the distributed algorithm. only neighbour that has not instantiated its proposal
In particular, no effort have to be put on the communication, is then considered as its parent and the others as its
one only needs to focus on how each component reacts to the children. When a distributor is in this state, it computes
observed state of its neighbourhood. and instantiates its proposal actuator.
We first expose an overview of the distributed algorithm, 3) Propagation Ready distributor: all distributor neighbours
then we describe some hypothesis on the production, and last, have instantiated their proposal actuator. The distributor
we details the two phases of the algorithm. has then enough information to compute an optimal
distribution between itself and its neighbours. The opti-
A. Overview of the Distributed Algorithm mal distribution for this component is implemented by
instantiating its regular outputs. Also, it is propagated
The application cases of the algorithm are composed of by providing instructions to its children by the mean of
consumers and producers with a static demand and offer. its proposal outputs.
All of them can be directly represented using the proposed
In the next section we detail how a proposal is computed
model, the nodes being modeled as distributors, which extend
and how the optimal configuration is determined.
the KirchoffStar class. We also use the sensor/output
algorithm, described in Section IV-B3 to implement maximum B. Production Characteristics
capacity of the links. The solution computed by the algorithm
defines: for each producer, the demand it will have to deliver, In order to compute an optimal distribution, certain hypoth-
for each consumer, the QoS resulting from its demand, and, esis have to be made on producers. We consider a smart-grid
for each distributor, the percent of the overall demand of where the energy demand is modeled as an amount A and
its consuming neighbours it will require from each of its the quality of production as QoS. We consider the following
producing neighbours. At the end, if the offer can answer algebra over A and QoS, required by the computation of the
the demand, an optimal distribution will be implemented, following sections:
A
otherwise all consumers will be informed that the network is • ⊕ is a binary operator over A,
QoS
overused. The use of the KirchoffStar class either ensures • ⊕ is a binary operator over QoS
SYLVAIN DUCTOR ET AL.: GRENAD, A MODULAR AND GENERIC SMART-GRID FRAMEWORK 1791
• ≻A is a preorder over A. neighbours, d,˙ which is its parent. The overall demand of
• ≻QoS is a preorder over QoS. d subtree4 is computed as the sum of the demands of its
In this section, a producer refers to a tuple (p, maxPp , ∝p consumer neighbours and its children proposals. The list of
, of f erp ), where p is its identifier, maxPp is the maximum producers of d subtree is computed as the union of both its
amount of energy it can produce, ∝p is a comparable object producer neighbours and the producers listed in its children
that allows to compare producers with respect to their quality proposals.
of production and of f erp is their offer function. A higher ∝ Let Excessd be the difference between the line capacity
(given ≻∝ ) is equivalent to a better quality of production, i.e. and the overall demand of d subtree. Two cases are possible:
: (1) Excessd is negative or null, in which case the parent can
answer the demand without any restriction. In this case, the
∀p, q producers, ∀a ∈ A, a ≺A maxPp ∧ a ≺A maxPq , proposal of d is defined as the list of producers and the overall
∝p ≻∝ ∝q ⇐⇒ of f erp (a) ≻QoS of f erq (a) (3) demand of its subtree; (2) Excessd is positive, in which case
the answer of the parent is limited by the transmission line.
In [14] the author considers a single energy flow whose amount The exceeding amount has then to be assumed by the subtree.
is expressed in kW h, and encodes ∝ as the slope of a linear In this case, d proposal demand is defined as the line transmis-
function that associates a CO2 impact to the production of a sion capacity. The exceeding power is dispatched in an optimal
given amount of energy. way using distopt on d subtree list of producers. For each
In this setting, given a set of producers, an optimal distri- producer p of d subtree, let localp be the demand attributed
bution is obtained by saturating the production of producers to p by the aforementioned call of distopt . d proposal offer
in decreasing order of ∝. This is done by distopt , a function is then a modified list of producers of its subtree. First, for
that considers a set of producers and an amount of energy that any p, localp is subtracted from maxPp . Second, for any p,
returns for each producer the amount of energy it must produce of f erp is modified into of f erp′ by assuming that localp is
ˆ opt is a function that exploits
in the optimal distribution. dist produced, i.e. :
the result of distopt and returns the part of the consumption
attributed to each producer in the optimal distribution, in order ∀a ∈ Demand < A >, of f erp′ (a) =
to instantiate the actuator of the KirchoffStar. of f erp (a ⊕Amount localp ) (4)
C. Collect Phase D. Propagation Phase
A proposal is computed by a Collect Ready Distributor A distributor, d,˙ is in the Propagation Ready state if all
and transmitted to its parent, which will have to decide the of its neighbours have either defined their proposal (i.e. they
flow of energy between them. The information provided by are its children) or they outputs (i.e. there is exactly one,
a Collect Ready Distributor in a proposal to its parents is which is its parent in the network tree or zero if it is the
(1) the list of producers of its subtree, composed of the root of the network). Such a distributor has the responsibility
producer neighbours listed in its children proposals and its to determine a globally optimal distribution to each of its
own producer neighbours, and (2) the overall demand of the neighbour by instantiating its outputs. To do so it considers
consumers of its subtree, computed from the overall demand the overall demand and the list of producers of its subtree.
provided by its children proposals and the demand of its Those information are computed from the children proposals,
consumer neighbours. Given this proposal, the parent has to the consumer and producer neighbours and the possible parent,
decide, during the implementation phase, whether it considers which can either be seen as a producing or as a consuming
neighbouring distributors to be producing or consuming. It neighbour.
also has to decide of the amount of energy demanded to For each producer p of its subtree, let prodopt p be the
producers, the remaining energy of the overall consumption demand it must assume in an optimal distribution. prodopt p
being assumed by the producers of the subtree. Please note is computed by distopt applied on the overall demand and
that the transmitted energy between a distributor and its parent the list of producers of d˙ subtree. To each child d of d,˙ is
cannot exceed the maximum capacity of their power line. attributed the total amount of energy, P rodopt
d , the child should
Hence, proposals are modified so that the overall demanded supply in a globally optimal solution. P rodopt d is computed
consumption does not exceed this limit. Exceeding energy is as the sum of prodp for any p belonging to P ropOf
opt
d
f er
.
deduced from the subtree producers offer. Three cases are possible: (1) P rodopt Demand
d = P ropd , which
The proposal of a Collect Ready Distributor, d, is a tuple means that in an optimal solution d subtree supports exactly
(P ropOf
d
f er
,P ropDemand
d ) where P ropOf
d
f er
is a list of pro- its demand. No energy is transmitted between d and d.˙ This
Demand
ducers and P ropd a demand. They are computed as subnetwork can be isolated; (2) P rodopt > P ropDemand ,
d d
follow: Let Consd be the set of consumer neighbours of d, which means that in an optimal solution d subtree supports
P rodd , the set of its producer neighbours, and Childd , the set its own demand and offers some exceeding energy. In this
of its distributor neighbours that have defined their proposals. case d˙ is configured so that it is demanding this exceeding
To say that d is a Collect Ready Distributor is equivalent
to say that Childd refers to all but one of its distributor 4 the subtree of the network whom root is d
1792 PROCEEDINGS OF THE FEDCSIS. ŁÓDŹ, 2015