Alexandre Rio
email: alexandre.rio@okwind.fr

Yoann Maurel

Olivier Barais

Yoran Bugni
email: yoran.bugni@okwind.fr

Efficient use of local energy: An activity oriented modeling to guide Demand Side Management

Keywords: Simulation, What-if Scenario Analysis, Case study

Self-consumption of renewable energies is defined as electricity that is produced from renewable energy sources, not injected to the distribution or transmission grid or instantaneously withdrawn from the grid and consumed by the owner of the power production unit or by associates directly contracted to the producer. Designing solutions in favor of self-consumption for small industries or city districts is challenging. It consists in designing an energy production system made of solar panels, wind turbines, batteries that fit the annual weather prediction and the industrial or human activity. In this context, this paper reports the context of this business domain, its challenges, and the application of modeling that leads to a solution. Through this article, we highlight the essentials of a domain specific modeling language designed to let domain experts run their own simulations, we compare with existing practices that exist in such a company and we discuss the benefits and the limits of the use of modeling in such context.

INTRODUCTION

An interesting aspect of renewable energies is that they can be produced locally, close to the consumers, thus considerably reducing infrastructures and distribution costs [START_REF] Daniel E Olivares | Trends in microgrid control[END_REF]. These developments have led to significant gains that make credible the use of these energies on a daily basis as the main source of energy for a large number of industrial and agricultural activities. The autonomy of sites with micro-generation capabilities is then greatly increased by self-consumption of locally produced energy. Self-consumption of renewable energies is defined as electricity that is produced from renewable energy sources, not injected to the distribution or transmission grid or instantaneously withdrawn from the grid and consumed by the owner of the power production unit or by associates directly contracted to the producer. Self-consumption is seen as a solution to improve the use of renewable energy and decreases energy-network costs. Logically, the higher the self-consumption, the more the investments in solar panels or wind turbines will be worth the expense -feeding production surplus into the grid presupposes suitable collection infrastructures and is not always possible nor desirable.

One striking challenge to self-consumption of renewable energies is the disparities between power generation from solar panels or wind turbines and the actual demand. Efficient use of renewable energy requires the adaptation of consumption practices. These practices and the current organization of activities have been indeed strongly influenced by the traditional energy production model. In city districts, for instance, most of the power production takes place when residents are not at home, pursuing their profession or other daily life activities [START_REF] Daniel E Olivares | Trends in microgrid control[END_REF]. Of course, this situation and the possible adaptations of activities are very different depending on whether one considers residential, industrial, services or agricultural areas. This paper focuses on the two latter.

Commercial enterprises could, due to the alignment of working hours with power production from solar panels or wind turbines, achieve higher rates of self-consumption depending on the type of enterprise. Demand Side Management (DSM) [START_REF] Palensky | Demand side management: Demand response, intelligent energy systems, and smart loads[END_REF] refers to a set of measures to optimize the use of energy including Demand Response (DR) and storage strategies. DR represents the practice of managing electricity demand in a way that peak energy use is shifted to off-peak periods enabling higher rates of self-consumption. With electricity storage and DR, rates of self consumption can be raised.

On of the keys is thus to align production and consumption either by planning processes differently or by relying on storage capabilities. Autonomy and self-consumption are intertwined: achieving high levels of autonomy with renewable energies has a negative impact on self-consumption if no storage is available. Designing a system that enables almost 80% or even 100% self-consumption and a high autonomy of 50% to 70% is, therefore, a complex problem when competitiveness in electricity costs prevails. It requires a) to dimension the nominal power to be produced according to the weather and the characteristics of production facilities (e.g, solar panels or wind turbines), b) to assess the maximum volume of energy to store to absorb peaks, c) to infer consumption of activities in the business processes, and d) to identify the ones that can (and are worth to) be shifted. An expert designing such energy management system will likely be interested in how to size energy production facilities and storage. What trade-off between autonomy and selfconsumption have to be done to ensure an acceptable price level? Which regions are best suited for the implementation of such a solution? And, which process reorganizations allow the optimal use of the energy produced?

Building a model of some real-world phenomenon seems to be an intrinsic human endeavor to understand and predict occurrences in the world [START_REF] Bruel | MDE in Practice for Computational Science[END_REF]. If lots of approaches discuss the benefits of Model-Driven Engineering (MDE) approach to help experts in designing simulators, this paper proposes an industrial case study for representing industrial process and energy management constraints.

This experience report discusses the benefits and current limitations of MDE to build such a simulator. We go in-depth in the domain specific language that has been designed to provide abstractions to an expert to define its installation and its business process. We also compare this approach regarding the practices of a local company that design such system for medium size industry. We validate our approach in showing the design of such a DSL and discussing how we improve the accuracy of the simulation compared to the state of the practices in this company. Next, we discuss some findings regarding MDE technologies.

The rest of this paper is organized as follows. Section 2 presents the concrete case study and provides a journey in a renewable energy engineer's day. Section 3 illustrates our approach and introduces the domain specific language and the associated simulator that has been designed to assist a renewable energy engineer. Section 4 provides the evaluation of this work. Section 5 discusses related work. Section 6 discusses some findings regarding MDE technologies and highlights future work.

CASE STUDY

This work is carried out as part of a collaboration between OKWind 1 and researchers in computer science. OKWind's focus is to bring energy production and consumption closer together without creating new infrastructures. The company is specialized in the production of renewable sources of energy. It proposes to deploy self-production units directly where the consumption is done. It has developed expertise in vertical-axis wind turbines, photo-voltaic trackers, and heat pump. For example, the company produces several models of double-sided solar trackers ranging from 75 to 117 square meters capable of producing 25 to 40MWh/year or 17 to 23kW in peak conditions.

The company mainly targets businesses and has accumulated a great deal of expertise in the instrumentation of agricultural and industrial sites, as well as service companies. It has a network of several hundred customers which allows it to study in detail the uses of its products. Experiments are currently underway at a number of sites to study how the reorganization of activities can improve selfconsumption. This is conducted in synergy with the site managers. OKWind's long-term objective is to be able to achieve an autonomy of around 70% by offering competitive energy rates compared to traditional operators. To achieve this goal, the company intends to design a system that integrates its business experience and as well as site operators to tackle the following questions.

(1) How to size local renewable energy production units to meet a site's energy consumption? This study breaks down into the review of several factors for a given site: What is the desired level of autonomy? Are the weather conditions more favorable to wind or solar? Would it make sense to use a combination of multiple energy sources over long periods of time? Does consumption occur when energy is produced or is it necessary to install batteries to store surplus production? Are there any specific tariff policies to integrate, for example, feed-in tariffs? In particular, energy cost constraints must be taken into account: self-consumption must be maximized if return on investment is the main priority.

1 http://www.okwind.fr/

(2) Which organization of activities enables the best autonomy and self-consumption? Shifting processes, however, is conditioned by many business constraints: some activities cannot be performed at night, are intertwined, or have a significant impact on employees or animals' health.

The determination of the best organizations is generally done through a complex iterative task which requires a good knowledge and modeling of the processes. The idea is to build a system that provides sufficient guidance to operators to allow them to gradually optimize their practice. (3) Which region would be the most interesting for the expansion of its business? On the basis of meteorological data, business knowledge and the results of previous projects, one may want to estimate whether an equivalent site in a different region could benefit from renewable energy production. If a simulation tool is available to estimate a site on the basis of meteorological knowledge and description of activities, it is then possible to estimate the ecological viability of such a project.

These questions, and the variability of the factors to be taken into account, naturally led us to use a model-driven approach to conduct (What-If Scenario Analysis) 2 .

MODEL

In this section we present the model on which our Energy Management System (EMS) is based. The goal is to provide a Domain Specific Language (DSL) that enables experts to quickly integrate their knowledge and algorithms, and to provide a library of reusable components and algorithms. This library can be improved by extending existing components or adding new ones. Flexibility and extensibility is mandatory as the number of machines, producers, and algorithms is important. Some of these components will also allow to play back historical data, which is a common use for sizing purposes. Using a DSL and components that clearly separate the different concerns avoids code redundancies and facilitates the work of domain experts [START_REF] Kosar | A preliminary study on various implementation approaches of domain-specific language[END_REF].

The first intent of our DSL is to let an expert model a site. The sites considered are always structured around five components: the grid that provides traditional energy, a set of local production means (generally renewable), storage/batteries to meet needs in periods of low production and finally a set of processes that use 2 What-if scenario analysis (WISA) is a business planning and modeling technique used to yield various projections for some outcome based on selectively changing inputs. As we are mainly interested in industrial/agricultural sites we use Machine rather than Appliance -a term that often comes up in literature Figure 1 shows our simplified model capturing these aspects. Some information, such as the name of the modeled site or physical location (GPS coordinates) are common to all objects, hence we have a central class named Site to hold every aspect of our regulation system.

We will see that we dedicate an important part to the modeling of processes and the use of machines. In general many models only consider fine-grained consumers such as machines. This makes recommendations difficult because a machine can be used by different activities at different times of the day. Our aim here is to be able to link consumption to business activities in order to guide users in planning their activities.

The storages and the grid have a particular role here: they can both absorb surpluses of local energy production, and meet needs when local energy production is not sufficient. Their presence is optional, but to be able to operate 24 hours a site must generally have one of the two. It could be noted here that we have deliberately chosen to represent them separately in this first version of the model, but it would be quite possible to consider them as a special case of ProductionsMeans and Machine. This choice, which in practice has a measured impact on implementation, comes partly from the fact that we wanted to be able to use these parts independently.

The rest of this section describes in depth the five main parts of our language introduced in Figure 1. It ends in showing how we handle flexibility in activity modeling.

Production

Our work is mainly motivated and constrained by production aspects. As a result of the intermittent nature of renewable energy production and its high dependence on external (mainly meteorological) conditions, sites need to be constantly adapted. For that reason, we need to define a GPS coordinate at site level so that each module can access it.

Figure 2 shows a significant portion of the concepts we use for production modeling. ProductionsMeans indirectly extends the ISimulatorPluдin interface that gives the possibility to start and discover the different components of our project. This is the case for most of the components of our model (Machine, Grid, Storaдe). It is mainly a utility interface.

ProductionMeans also extends the IPricedEnerдy interface. This allows assigning a price per kWh to the energy produced locally. This part is important since it is related to the return on investment. There are several ways to infer this cost by taking into account the lifetime of the equipment and its cost of use. A rather rudimentary way is to use a fixed cost estimated on the basis of accumulated experience. That is what we are doing at the moment, but it is possible to change this behavior and implement more advanced techniques and make the price evolve dynamically if necessary.

ProductionMeans is then specialized by implementations such as turbines or solar trackers. In the figure, we have chosen to present solar trackers in more detail. Solar production is affected by multiple factors: Multiple factors can impact the power production, such as the ground albedo impacting the RNI. All these factors make the power production hard to compute. Commercial services provide solar irradiation data accessible from a web service using. To get reliable results the web service is expecting: a GPS coordinate, information about the type of solar cells, the ground albedo etc. We have written components to interact seamlessly with them.

Considering a GNI value from a third-party service we can apply formulas such as:

Tracker P = GN I × P anel pp P anel S ×1000 × 60 × дranularity × Tracker S • Where GN I is expressed in W h/m 2
• Tracker P power of the solar tracker expressed in Watt.

• Panel pp the power peak of a single panel • Panel S surface of a single panel • Tracker S total surface of the solar tracker This formula is typical of the one we must regularly integrate into our components. Once the component is implemented, the expert can configure an instance in the DSL with the required parameters or in some cases modifies the formula. We do not expect any advanced programming skills from a domain expert.

By extending the Photovoltaic class that already provides a production estimate for a fixed panel, it is possible to implement more complex panels such as the two-axis trackers we mainly use. This allows us to refine the forecasting algorithms that require grasping the specifics of these trackers. Thus, depending on the sites, it will be possible to estimate the production of different types of solar panels and to make an informed choice.

Grid

Although optional, the grid is often essential for the consumption of most sites. Indeed, often to reach a reasonable level of autonomy at times when local production is low, it would require batteries of large capacities therefore expensive. It is sometimes more profitable in these cases to rely on the energy supplied by the grid. The integration of the grid into a model is interesting because pricing policies are varied. It is therefore, necessary to provide a flexible model that can be adapted to the specificities of each site and region.

Site Grid IPricedEnergy

ISimulatorPlugin Figure 3: Grid related meta classes Figure 3 shows the main classes for the grid. IPricedEnerдy and ISumulatorPluдin are extended for the same reasons as for production. We often want to consider the maximum power intensity we can draw from the grid as well as the price per kWh for a given time. This price is fixed by the customer's contract and may vary considerably depending on the time of day and the season. For example, a two-tiered tariff can easily be implemented by adjusting the result depending on the parameter t of the method дetPrice. This allows to model a basic residential energy contract with expensive peak hours between 8 a.m and 7 p.m. On this basis, we could approximate energy costs on the basis of a consumption history and evaluate the benefits of shifting these consumptions to times when energy is affordable.

Energy storage

Storage is an alternative and a complement to the grid when it comes to meeting demands outside local production periods. It is an easy way to perform peak-shaving and valley-filling techniques. The energy excess is stored in the battery during peak hours and then discharged when the local production is insufficient. Figure 4 shows the implementation of a class allowing the simulation of different types of batteries. The expert can configure this component or extend it to refine predictive behaviors if necessary.We model specifications such as the capacity in Wh and various level of usage such as depth of discharge and a safety cap, both expressed in percent. Meaning that we don't want the battery to be under a certain level of energy to protect its integrity A performance level is used to represent the loss of energy due to various effects such as Joule effect or transformation (i.e. AC to DC then DC to AC).

Besides the charge level, a common way of maximizing the lifetime of a battery is to limit the number of charge cycle performed daily. The behavior can be specified in the implementation or use default ones based on the battery_type attribute, 1 cycle per day for lithium batteries and no limits for fuel cell batteries. Generally, the cycle limit is based on the wear attributes impacting the battery capacity. The maximum power allowed during charge and discharge of the battery can either be defined by its type, for example, a 1 C

Machines

Machines are the counterpart of producers. A balance must be maintained between their consumption and production, whether the latter is local or drawn from the grid or storages. In practice, it uses common concepts : as for Grid and ProductionMeans, the Machine class extend ISimulatorPluдin and IPricedEnerдy classes. The relationships between machines and processes are shown in Figures 6. Simplemachine consists in a nominal power representing the power needed to this machine whenever it is used.

Our system provides multiple ways of modeling devices: either by using historical data, physical or statistical model or by introducing new simple devices by providing only the nominal power. Moreover, complex machine can be seen as a composition of much simpler machines. The system supports the implementation of composite machine by composing different simple activities as described in the following section. These components can then be shared, extended, and reused.

Extending the model to implement complex behaviors is straightforward. Let's take the example of an expert that wants to introduce stochastic behavior to bring dynamicity in the simulation. The idea is to simulate a device whose power oscillates from -5% to +5% around its nominal power. Listing 1 shows an implementation. The expert can simply define its behavior in plain old Java by extending the default MachineImpl abstract class. During the simulation, the parameter of time is provided as a parameter. Using a General Purpose Language such as Java offers a lot of freedom in the configuration of the behavior: using complex math library as well as network library to query external services. A machine has a unique name that is used for discovery and instantiation in the Domain Specific Language (see Listing 2). The DSL allows experts with little programming skills to use the components easily. machine l i g h t _ b u l b a s " p l u g i n . M y S p e c i f i c L i g h t B u l b " Listing 2: External plugin used as internally defined machines.

Most industrial machines use three-phase electric power, this means that to properly monitor the consumption of such machine three sensors are needed and three data log files are produced. A machine can, therefore, reference other machines as depicted in listing 3.

Activity modeling

As we have already stressed, the modeling of business processes is a key to provide effective recommendations to users. Modeling machines alone is often not enough because they are frequently used for multiple activities. The idea is to induce behaviors that promote self-consumption by aligning energy demanding activities and local production periods. If this idea is difficult to implement for residential activities which are relatively unforeseeable as Bourgeois [START_REF] Bourgeois | Interactive Demand-Shifting in the Context of Domestic Micro-Generation[END_REF] pointed out, it applies well to the industrial and agricultural world where the processes are known, industrialized, reproducible and planned several months in advance. Furthermore, consumption scales and potential gains are much higher than in the residential sector, encouraging stakeholders to participate proactively. Finally, it is easier to reuse the experience gained on a type of business to simulate the operation of similar ones.

Figure 6 details the model developed to represent business processes and their relationship with energy-using machines. Process is the main class and holds both scheduling description and flexibility. Flexibility is captured through Reduction and Shift classes and is discussed further in Section 3.6. Based on this model, it is possible for our EMS to apply scheduling algorithms to minimize locally produced energy excess and grid usage so as to raise the site autonomy. Such system is very close to a Cyber-Physical System that integrates embedded sensors to monitor various metrics such as the power consumption of physical devices. A study by [START_REF] Facchinetti | Real-Time Modeling for Direct Load Control in Cyber-Physical Power Systems[END_REF] StartUp:Process showed that classic scheduling algorithms in operating systems can be reused in our case.

A process is linked to none, one or multiples Machines (see Section 3.4): we consider a machine to be active if one of its activities is active and logically it is not possible for two processes to use the same machine at the same time. Process planning is very classic in its representation. We made it similar to the one expressed in the company's or farm's task schedule: a list of tasks with a start date time and a duration or an end time. This allows to easily connect company calendars and the information reported by our system: we can, for example, evaluate the energy consumption of meetings or rooms such as conference rooms by knowing the activities that take place there.

As stated before industrial processes are predictable mostly due to the constant frequency of some activities, to that extent we propose to link a Frequency to an activity. A frequency can specify a particular recurrence of events: every day or every Monday at 08:00 for 4 hours for instance. For more complex activities such as a sanitary emptying or holidays, activities are incorporated into periods of a given duration called Window. For fine grain control, one can also link activities with pauses between them as shown in Figure 5. With these concepts, it is possible to model an activity running every day during day time using a specific machine A.

It is also possible to model various mode of a machine. For instance, we could define an activity StartU p using a device machineA working at 100W for 30 s, pausing for 15 s then working again for 5min, on Monday on Tuesday at 8 am. This example is instantiated as an object diagram in Figure5 using Process linked as dependencies, which means that a process must first be completed before a new process can start.

Modeling Flexibility

The language is thus expressive enough to represent how the activities follow each other and deduce their consumption by observing the consumption of the machines. This can help replay complex scenarios involving power consumption and help to size of production means. However, modeling the sequence of activities in time is not sufficient to take measures: it is also necessary to be able to represent the level of flexibility offered to reduce their consumption or shift them. Optimizing self-consumption by modifying processes can be done mainly in two ways: shifting activities to times when energy is produced and less expensive or reducing the intensity of activities where possible -it may be possible to reduce the light intensity of lighting in certain rooms for instance.

The adaptation of activities cannot be done suddenly without a good understanding of the users, their process and their constraint. This requires the cooperation of the users. It is necessary to understand how the activities are carried out at the present time and to understand the elements of variability: is it possible to reduce the intensity of a machine? what is the impact on comfort and the acceptable level of comfort? To what extent is it possible to move some activities and over what time range? Starting from activity modeling, see Section 3.5, we provide a way of capturing the set of possible actions to take.

For instance, ventilation systems or cleaning devices can operate at a lower nominal power but need more time to be as efficient. An expert could know how to accurately measure the impact of a power reduction and use this information to model more precisely its activities.

Example 3.1. An activity could last 2 hours at nominal power but with a 20 percent power reduction last it would 30 more minutes. This information could then be used by a regulation system to perform recommendation in order to improve the global industrial site autonomy.

Another variability aspect we want to address is the flexibility in schedules. Unlike factories, primary sector industries such as animal husbandries are more flexible and most constraints come from the animal well being.

We noticed multiple times employees arriving at work early in the morning, turning on machines and either doing something else first that requires less energy consuming, that could have been done later on. This highlights the need of an energy-aware monitor, able to know the flexibility of every, or at least most consuming, activities of an industry.

What we want is to distinguish activities that have to be done at an exact moment from those more flexible.

Example 3.2. The cleaning of the room can be done at anytime in the morning. Example 3.2 can be modeled as a Process running at 10:00 in the morning with a possible Shift of 2 hours both before and after. This means that the default start time of this task is 10 am but if it can be beneficial for the global energy management of the site we allow a time shift of two hours. The earliest start time becomes 8 am and the latest start time becomes 12 am. This only gives information to know how much an activity can be moved, not if it is beneficial or profitable to do it.

In our approach this set of information is modeled by the Reduction and Shift classes. Our EMS is thus able to make the right recommendations.

IMPLEMENTATION AND VALIDATION

We first implemented the metamodel presented in Section 3 using the Eclipse Modeling Framework (EMF). One of its benefits is the graphical view on the metamodel allowing to include collaborators and experts in the loop and show them how their field of expertise has been modeled along with the other aspects of the energy regulation.

We use this model to generate an Xtext grammar to model equipments installed in a given site. This corresponding DSL is used in our simulator to play various scenarios or replay logged data. This model-first basic Xtext grammar has then been modified to better suit our needs. Especially:

• every value has its unit specified right after, this avoids confusion, i.e batteries capacity is often expressed in Ah but also in kWh, • some key concepts have been renamed to fit expert habits and vocabulary.

Figure 7 illustrates the architecture of our simulator running in standalone based on a site description written in our DSL. Experts can write DSL files with the help of an eclipse editor plugin. Our simulator discretises time on the smallest time step possible, usually a 1 minute time step. Based on that time step the simulator will ask each energy producer about its current production, each energy consumer about its current consumption.

Every simulation performed stores the step by step results in a time-series oriented database named InfluxDB 4 . The simulator also creates a Grafana 5 dashboard per simulation configured to easily navigate through the stored data. These dashboards allow us to easily compare simulations and input parameters and their impact on output metrics: global autonomy, reduction of grid usage etc. Figure 7 depicts the simulator architecture and its various components. In this figure, expert 1 does not know the DSL. He provides through a web interface a form describing an industrial site and CSV files for the consumption and production. The simulator runs it, stores the results in the database and returns metrics and a link pointing to the Grafana dashboard illustrating these results. Expert 2 knows the DSL and writes her site description directly in the DSL, references physical power sensors remotely accessible. She can have process organization recommendations on the web interface and energy monitoring information on the Grafana interface.

Our simulator can be used to answer various questions an expert can have.

Q1, Sizing production and storage

Our first type of question is what type of energy producers and batteries should be installed to meet a site's need. For this question, we assume we have logged a significant amount of data to represent our consumption profile. We will generate variants of site descriptions to various "what if" scenarios. Variants can be generated either manually or using a form on the web interface of the simulator. Our base will be to use the global consumption logged as a CSV file over the year of 2017. Since we just want to properly size our production and storage means we only need the global consumption of the site. To have a base of production we will use production data logged on a geographically close site, production with no data are demonstrated in Section 4.3. A base of simulation can be expressed in our DSL as shown in Listing 4. This simulation describes one energy consumer and one producer, both using an external plugin to use a CSV file. This will tell the simulator to look for a file globcons_sensor.csv and prod_case1.csv A lithium battery of 30kWh is modeled in Listing 5. For each simulation, we want to look at the total energy production and the share that was used locally, either to directly feed the local consumption or to charge the batteries.

As the cost of Lithium batteries is high, we try to minimize their capacity and maximize their lifetime. To do so Lithium batteries are modeled to only allow one cycle per day. A full cycle is going from 100% capacity to the depth of discharge then charge back to full capacity. Based on this usage we consider a wear per year slowly reducing the maximum capacity.

When using batteries the simulator will use the energy excess of the day to charge the batteries and discharge the battery to shave consumption peaks during the day and reduce the grid usage in the night. If the grid tariff depends on the time of the day, high-cost periods will be favored to use the batteries in discharge.

Figure 8a shows the energy mix, in particular, the consumption, in red on the graph, much more important in winter while the production is more important during the summer season. It is also in summer that we have the more energy excess even with the usage of the battery. Figure 8b shows battery usage to help experts estimate if its capacity is appropriate, considering its cost and evaluating its Return On Investment (ROI).

Q2, Activity organization recommendation

As stated before most industries have organized their process based on what they thought logic, only taking into account the grid flat price or peak and off-peak prices. We want to provide a tool to account local energy availability to best organize processes based on expert knowledge of the process and its implication on productivity, outcome or animal well being. We want to answer the question: which organization of activities enables the best autonomy and self-consumption?. In Listing 6, we describe three phases in a day using two devices. Lines 8 and 13 allow the process to start from 0 to 3 or 5 hours after the initial start time, this possible shift is illustrated in Figure 9. Because of the local energy available the morning phase has been shifted to begin when energy is available while the evening one has been left untouched because they would have been no benefit of shifting it. For now, the simulator looks for shift flexibility and tries to use them to put a maximum number of processes under the production curve. Our idea is to let experts write their own scheduling algorithm to try them out and see which one is most effective for a particular industry type. We are planning on implementing Bin Packing: First Fit and Best Fit algorithms as Sendama [START_REF] Benjamin Sendama | New Renewable Energy Allocation Algorithms based on Bin Packing in a Smart Home[END_REF] et al. did and bottom left decreasing height packing from Ranjan [START_REF] Ranjan | Smart grid power scheduling via bottom left decreasing height packing[END_REF] et al. in order to benchmark which algorithm gives the best results considering a particular business sector. Figure 9 shows that for this day shifting the morning process is beneficial for the self-consumption rate. The decision to shift or not a process is based on the context of the regulation system, for instance, local production state, storage rate etc.

Q3, Geographic comparison

Last type of question we address in this paper is a "what-for" question. Which region is most interesting for the expansion of a business? The underlying question is to know which region has the weather better suited for my activity. Of course sunny regions produce more solar energy but bigger production systems mean bigger inverter, cable section and in fine more indirect costs. Producing less and yet enough for a process can be more cost-effective. Some services such as PVGis6 can help size a photovoltaic installation by providing an estimated monthly production based on more than 20 years of historical data. The pitfall is that monthly data can't help us properly size a system: we want to be able to align the consumption on the production and to know the ratio of energy directly used from production and the quantity taken from the grid. Thus, we need more accurate data, with a granularity of a point per minute or every five minutes.

Commercial third-party services provide irradiation data for a particular GPS coordinate and given some solar cell specifications. They can take into account distant relief casting shadows at a certain time of the day or period of the year. We have integrated their API to query their server for a given site GPS coordinate giving our production model as a parameter.

Listing 7 shows how we specify the GPS coordinate in our DSL and a 110m 2 two-axis solar tracker. Each panel produces 310 Watt peak. Other parameters, such as tilt and azimuth constraints are left to their defaults value by our proxy program. Data are retrieved with a granularity of 1 point per minute, which is enough to perform simulation as previously done in Question 1 and 2.

To answer our "what-for" question we need to generate variants of our DSL with a different GPS coordinate for each variant. For each region, we have a fine grain simulated production an expert can then use to size his production installation or optimize his activities. In this particular case, if we want the city with the biggest production we can choose Bourges, Laguiole or Montpellier. We could also have estimated the best geographic installation for battery life management, based on the consecutive number of "good" or "bad" weather day.

RELATED WORK

Individually, every component of a smart grid has been studied thoughtfully. This goes from local production means, in particular, the most common ones such as solar photovoltaic systems and wind turbine to Energy Management Systems.

Solar energy is the most common renewable energy because of its almost constant production during the day. Furthermore, modern techniques such as Machine Learning [START_REF] Sharma | Predicting solar generation from weather forecasts using machine learning[END_REF] or Support Vector Machine [2][15] are becoming more and more reliable and are giving results at a shorter term than it used to. Moreover, their granularity becomes finer. Other external varying constraints are impacting regulation systems: the wind impacting local production, grid prices etc. Scheduling activities have been done under these multiple variable factors. Forecasting and learning techniques are important to take more reliable decisions. Predictions could either be focused on the energy price and site own consumption history [START_REF] Fusco | Smart AMI based demand-response management in a micro-grid environment[END_REF] or human activity.

People model machine consumption with state machines [START_REF] Dietmair | Model-based energy consumption optimisation in manufacturing system and machine control[END_REF] in order to optimize the various states of a single appliance to optimize its energy efficiency considering a particular task. Synchronization between machines has been modeled using petri net [8][9]. A common way of aligning consumption on production is to use an energy storage unit as a buffer such as batteries [START_REF] Alharbi | Stochastic Optimal Planning of Battery Energy Storage Systems for Isolated Microgrids[END_REF]. We believe that to be effective a regulation system must consider all the aspect above. Some approaches try to combine some of them but never address what we consider the whole picture.

Vivekananthan [START_REF] Vivekananthan | Real-Time Price Based Home Energy Management Scheduler[END_REF] et al. propose a Home Energy Management System able to control appliances depending on a variable energy price to reduce energy costs. Because of the domestic sector and its uncertainty the activity cannot be modeled. Chen [START_REF] Chen | Heterogeneous Delay Tolerant Task Scheduling and Energy Management in the Smart Grid with Renewable Energy[END_REF] et al. propose a similar system. To limit this uncertainty, one idea is to address a group of apartments [START_REF] Comodi | Multi-apartment residential microgrid with electrical and thermal storage devices: Experimental analysis and simulation of energy management strategies[END_REF], this also has the benefits of mutualizing the investment costs. All these approaches lack the activity modeling aspect, important to better understand the consumption: how it will behave in upcoming days and how it can be adapted.

Some approaches, such as Langer [START_REF] Langer | A modelbased approach to energy-saving manufacturing control strategies[END_REF] et al. or Onar [START_REF] Onar | Modeling, control and simulation of an autonomous wind turbine/photovoltaic/fuel cell/ultracapacitor hybrid power system[END_REF] et al. require too much detailed specifications about the generation units or the consuming devices. This prevents coarse-grained modeling or prototyping and can be too complicated for a non-expert. Focusing on market energy price hides local aspect and local return on investment, this kind of approach cannot be used in our context because of the local production and storage impacting the real cost of the consumed energy.

On another side, Sendama [START_REF] Benjamin Sendama | New Renewable Energy Allocation Algorithms based on Bin Packing in a Smart Home[END_REF] et al. propose a discrete Bin Packing allocation algorithm taking into account local production and batteries. They validate it on their Home Energy Management System. Other algorithms from real-time systems exist [START_REF] Caprino | Peak shaving through real-time scheduling of household appliances[END_REF], like Earliest Deadline First, and are good candidates for scheduling industrial activities. We would like to integrate some of them as modules.

Finally, graphical user interfaces such as Tiree Energy Pulse [START_REF] Simm | Tiree energy pulse: exploring renewable energy forecasts on the edge of the grid[END_REF] tells us about the importance of including the end user in the loop and how displaying the live state of a system can provide an Eco-Feedback by reconfiguring rules defined by experts to better suit their habits and benefit the whole system. Bourgeois [START_REF] Bourgeois | Interactive Demand-Shifting in the Context of Domestic Micro-Generation[END_REF] et al. work focuses on domestic demand-shifting and human integration.

In our opinion, no real solution has a global vision of an industrial site in all its aspects to achieve efficient energy regulation with properly sized energy sources and energy storage units.

LESSON LEARNED AND PERSPECTIVES

In this paper, we focused on designing an integrated tool-suite to assist the engineers in dimensioning an Energy Management System (EMS) for an isolated site to reduce the construction of new network infrastructure and reduce its dependence on the grid. We advocate that the MDE is a very good candidate to integrate the various technological and business knowledge on the renewable energy production and consumption forecasting techniques, the planning of processes, energy costs, grid, and batteries. This model allows an engineer to address various concerns: sizing of production units, adapting of storage resources, choice of production technologies, choice of geographical location, or even and above all recommendations for process reorganization. The purposes of our EMS are quite different from grid-centered approaches or larger grain approaches to energy distribution. Here our long-term goal is not to complete the grid occasionally but to do without as much as possible. That is why we are focusing on renewable energies and modeling of single sites at the moment. A good understanding of a site provides huge savings levers on consumption from the grid.

As we pointed out, if there are many approaches to building such system, to the best of our knowledge, this model is one of the very few that focuses specifically on one site and not on the grid as a whole and covers so many aspects of modeling. In particular, we believe that modeling activities are essential to make good forecasts and recommendations. The model is also very extensible, which enables the integration of the various techniques produced by the literature. It is thus very easy to integrate new means of production and their forecasting techniques, new types of activities or new appliances for instance.

After highlighting the different aspects of the model and our system, we discussed how the first version of our model could answer simple simulation questions: how to size a site, or install production equipment, and which activities could be moved to maximize the use of local production means. These are the very questions that a company like OKWind, a specialist in the field, is regularly addressing. The implementation was done with very classical and well-known tools such as EMF. The system was built in a little more than 9 months, from a skills upgrade on the business problem to technologies integration and packaging for end users. It results in the end 4500 loc of Java, 1300 loc of Lua and 78kloc of generated files. The great interest of our tool is that it enables to simulate easily a very wide range of situations and thus allows to determine quickly the best options. If we compare with the company's past practices, engineers mainly used homemade excel sheets and R script. Many scenarios discussed in the paper were not possible. Sharing information among experts was very difficult. Detecting errors in site modeling was challenging. Building this domain specific language and its associated simulator saves lots of time and produces more precise results compared to the traditional manual approaches used before. Within the framework of this experiment which was conducted on real historical data, we were able to show that it was easy to integrate the various algorithms used by the company and that it was easy to extend them. The results obtained are very comparable to those obtained by OKWind experts but in much shorter times. The tool itself is an improvement on those available to the company and should make it possible to assist their experts in studies on a wider scale.

The system is, therefore, promising and the modeling approach is valid. Nevertheless, the implementation of a model-driven approach has not been without challenges or lessons learned. The first surprise was the lack of native support within a framework as EMF for the notion of measurement units. It is easy to specify its own data-types but we expected to find either reusable libraries to incorporate the international system of Units as data-types within a new meta-model or a native support within EMF. In the same vein, no native support makes it possible to simplify the management of time-series data. Again, redeveloping this support is tedious, it surprised us not to find support within a commonly used modeling framework like EMF. On these two points, it could be great if the community provides mechanisms to improve the reuse when designing a new metamodel. It means an algebra to import parts of a meta-model or a grammar but also a marketplace to automatically search and import libraries of metamodel such as maven central. The last challenge we identify for the modeling community is the co-evolution of meta-model and concrete syntax. While Xtext provides an excellent approach for building DSL, the joint evolution of meta-model and concrete syntax remains complex and tedious.

We are now conducting an experiment at several sites to see how adapting activities can improve production equipment profitability. This experience over a long period should provide us with relevant feedback on what can and cannot be requested from a site operator. This should allow us to use our tool not only to simulate upstream but also to make observations and recommendations on a weekly basis. At the same time, we also want to compare similar sites to see which variables are relevant for a particular business. Our intuition is that it is possible to define, for certain specific domains or profiles, parameters that will assist the configuration of the model and refine the recommendations and simulations: the number of animals on a farm is an example. Finally, we would like to explore how this model can be used as a basis for artificial intelligence algorithms to manage real-time operations. All the information described is indeed very complementary to the type of information that a continuous management system such as those proposed by a company like Ubiant [START_REF] Mazac | On bootstrapping sensori-motor patterns for a constructivist learning system in continuous environments[END_REF] would seek.

Figure 1 :

 1 Figure 1: Simplified version of our metamodel

Figure 2 :

 2 Photovoltaic surface : EShort singlePanelSurface : EFloat = 0.0 powerPeak : EShort

  safetyCap : EFloat = 0.0 depthOfDischarge : EFloat = 0.0 performance : EFloat = 100.0 selfDischarge : EFloat = 0.0 wear : EFloat = 0.0 maxPowerUsage : EFloat = 0.0 batteryType : BATTERY_TYPE = LITHIUM getAvailableEnergy(t ZonedDateTime) : Double canBeCharged(t ZonedDateTime) : Boolean getChargeableEnergy(t ZonedDateTime) : Double charge(q : Double, t ZonedDateTime) : Boolean discharge(q : Double,t ZonedDateTime) : Boolean getAbsoluteEnergyLevel(t ZonedDateTime) : Double canBeDischarged(t ZonedDateTime) : Boolean dailyCheckup(t ZonedDateTime)

Figure 4 :

 4 Figure 4: Storage meta class rate 3 cycle for a lithium battery or defined by an attribute expressed in W.

  p u b l i c c l a s s L i g h t B u l b extends M ac h in e Im p l { p r i v a t e f i n a l i n t NOMINAL_POWER = 5 0 ; p u b l i c L i g h t B u l b ( ) { t h i s . s e t I D ( " p l u g i n . M y S p e c i f i c L i g h t B u l b " ) ; } @Override p u b l i c f l o a t g e t C o n s u m p t i o n ( ZonedDateTime t ) { return NOMINAL_POWER + NOMINAL_POWER * ThreadLocalRandom . c u r r e n t ( ) . n e x t I n t ( -5 , 6 ) ; } } Listing 1: Extension of an machine through a Java plugin

  d e v i c e { machine A_phase1 a s " p l u g i n . t i m e d c s v c o n s u m e r " machine A_phase2 a s " p l u g i n . t i m e d c s v c o n s u m e r " machine A_phase3 a s " p l u g i n . t i m e d c s v c o n s u m e r " machine A { composed o f ( A_phase1 , A_phase2 , A_phase3 ) } } Listing 3: Three-phase electric power example

Figure 5 :

 5 Figure 5: machine behavior modeled with Process

Figure 6 :

 6 Figure 6: Activities meta classes

Figure 7 :

 7 Figure 7: Simulator architecture and use cases

  5 https://grafana.com/ S i t e d e m o _ s i t e { from 2017 -01 -01 t o 2018 -01 -01 d e v i c e { A p p l i a n c e g l o b c o n s _ s e n s o r a s " p l u g i n . t i m e d c s v c o n s u m e r " } a c t i v i t i e s { P r o c e s s w h o l e B u s i n e s s { d e v i c e ( g l o b c o n s _ s e n s o r ) f r e q u e n c y Always } } p r o d u c t i o n { P r o d u c e r p r o d _ c a s e 1 a s " p l u g i n . t i m e d c s v p r o d u c e r " } g r i d { G r i d e d f a s " e d f . b l e u -tempo " } } Listing 4: Description of our site B a t t e r y b a t t e r y _ p a c k { c a p a c i t y 3 0 0 0 0 . 0 Wh s a f e t y C a p 1 0 . 0 % d e p t h O f D i s c h a r g e 1 0 . 0 % wear 2 . 0 %/ y e a r p e r f o r m a n c e 9 0 . 0 % t y p e LITHIUM } Listing 5: Example of lithium battery modeling

Listing 6 :Figure 8 :

 68 Figure 8: Visualization of the Case 2 simulation, from January 1st 2017 to December 31st 2017

Figure 9 :

 9 Figure 9: Question 2 : Shifting an activity to a production period when possible increase our self-consumption rate from 9% to 20% for this specific day c o o r d i n a t e s 4 8 . 8 5 8 8 3 7 7 N 2 . 2 7 7 0 2 0 6 E . . . T r a c k e r t 1 { s u r f a c e 1 1 0 m^2 powerPeak 3 1 0 Wp a l b e d o 0 . 8 s i n g l e P a n e l S u r f a c e 1 . 6 6 6 7 m^2 } Listing 7: Generic solar tracker at Paris, France coordinatesFigure10shows an estimation of the production in 14 variants in France. For each region, we have a fine grain simulated production an expert can then use to size his production installation or optimize his activities. In this particular case, if we want the city with the biggest production we can choose Bourges, Laguiole or Montpellier. We could also have estimated the best geographic installation for battery life management, based on the consecutive number of "good" or "bad" weather day.

Figure 10 :

 10 Figure 10: Simulated production taking into account relief shadows for 14 different cities in France : greenest points represent the sites where the estimated production is best.

For a battery of 10Ah, a 1 C rate is equivalent at charging and discharging during an hour at 10A.

https://www.influxdata.com/

http://photovoltaic-software.com/pvgis.php