A strategic decision support system framework for energy-efficient technology investments

Energy systems optimization under uncertainty is increasing in its importance due to on-going global de-regulation of the energy sector and the setting of environmental and efficiency targets which generate new multi-agent risks requiring a model-based stakeholders dialogue and new systemic regulations. This paper develops an integrated framework for decision support systems (DSS) for the optimal planning and operation of a building infrastructure under appearing systemic de-regulations and risks. The DSS relies on a new two-stage, dynamic stochastic optimization model with moving random time horizons bounded by stopping time moments. This allows to model impacts of potential extreme events and structural changes emerging from a stakeholders dialogue, which may occur at any moment of the decision making process. The stopping time moments induce endogenous risk aversion in strategic decisions in a form of dynamic VaR-type systemic risk measures dependent on the system’s structure. The DSS implementation via an algebraic modeling language (AML) provides an environment that enforces the necessary stakeholders dialogue for robust planning and operation of a building infrastructure. Such a framework allows the representation and solution of building infrastructure systems optimization problems, to be implemented at the building level to confront rising systemic economic and environmental global changes.


Introduction
Energy systems optimization is increasing its importance due to de-regulations in energy sector and the setting of targets such as the European Union (EU) 20-20-20 (see Appendix "Literature review and background"). In turn, these changes increase exposure to new risks shaped by decisions of various agents, which motivate new regulations and policies. For example, emissions trading schemes, renewable energy and/or efficient generators subsidies, or efficiency requirements such as buildings labeling, among others. This new situation is motivated by several concerns of the postindustrial era, namely: global warming, economy globalization, resources scarcity, and awareness for sustainability.
In spite of the above-mentioned globalization, usually global changes must be tackled at a regional or local scale. Thus, utilities and fuel producers, yet global, must fulfill local market requirements, e.g., enough amount of electricity for a given city. Moreover, final users of energy have their own requirements whose satisfaction depends on decisions made at the shop-floor stage. Users' comfort, security, and energy availability are challenges for decision makers at the building level, who have to deal with limited budgets in addition to the regulations regardless their global, regional or local scope. Furthermore, new technologies and refurbishment options are available and continuously evolving, widening the range of options for main concerns of stakeholders including decision makers, operators, consultants, modelers, and data managers. There can also be external stakeholders, such as policy makers or mass media.
Considering the complexity of the emerging problem, this paper develops a modelbased decision support system (DSS) for optimal strategic planning and operation of a building infrastructure. Although, stakeholders usually have different or even conflicting goals, they all are able to have a tailored dialogue with the DSS by means of interfaces and output reporting at different detail levels, but consistent between them. The DSS includes by design capabilities that enforce this dialogue. Specific attention is paid for developing new dynamic stochastic optimization models involving ex-ante strategic and ex-post operational variables. The model developed in this paper has moving time horizons defined by stopping time moments generated by potential extreme events and the stakeholders dialogue. This integrated framework provides an environment that enforces the necessary stakeholders communication.
As shown in Fig. 1, the purpose of this dialogue is twofold: on the one hand, a dialogue between the stakeholders and the DSS; on the other hand, among the stakeholders themselves, likely with different motivations and targets. The dialogue between stakeholders and the DSS is self-contained. Regarding the dialogue among stakeholders (internal and external), it can take place at any point of the decision making process, and a user communication is crucial for the accurateness of the inputs. Therefore, this dialogue may provide exogenous feedback to the decision process. In addition, since decision making is a possibly iterative process, the outcomes may Regarding DSSs, this term is usually defined as "an information system that supports decision making" with more or less detail and its use is often abused in Computer Science and in Management. Thus, any information system could claim to be a DSS. However, more specific boundaries are needed to capture the preferred analysis approach (see Appendix "Literature review and background"). Under that paradigm the model plays an important role in a DSS. Both the model and the data are the basis for decisions. Therefore, the proposed DSS is also capable of preparing the data in a model-suitable way. Appropriate algorithms are applied once the model is defined and the data is available. Decisions obtained by the DSS, regardless of their category (descriptive, normative, or prescriptive) include interpretation and analysis, probably requiring some posterior data analysis.
The developed framework provides a new flexible approach for DSS-based decision making process on optimal planning and operation of a building infrastructure in a dialogue with stakeholders. The proposed use of both human and machine readable formats through the use of algebraic modeling languages (AMLs) boosts the dialogue between stakeholders remarked in this section. On the other hand, the reproducible research approach (Leisch 2002) adopted in the following allows to record and track consistent updates throughout the time, and to provide a sort of balanced scorecard (BSC) to stakeholders consistent with all the components of the DSS. Furthermore, the results obtained are reproducible for any of the stakeholders, which increase the efficiency in multi-agent, multi-disciplinary and changing environments, and the quality of the communication processes.
Finally, it is important to remark that this framework has been successfully applied within the EnRiMa (Energy Efficiency and Risk Management in Public Buildings) project. 1 EnRiMa is a 7th Framework Program (FP7) research project whose overall objective is to develop a DSS for operators of energy-efficient buildings and spaces of public use. This paper is organized as follows: in Appendix "Literature review and background", a brief literature review is made. Subsection "Optimization of building infrastructure systems under uncertainty" provides an overview of the decision making problem on optimization and operation of a building infrastructure. The model and the data for the DSS are developed in Sects. 2 and 3 respectively. Section 4 proposes a framework for DSS and implements the model developed. Concluding remarks are provided in Sect. 5.

A baseline example
To illustrate the proposed model, a simple example will be used. It shows that explicit introduction of a second-stage ex-post decisions induces risk aversion in strategic firststage ex-ante decisions in the form of a dynamic CVaR risk measure and corresponding discounting. This example is inspired by the classical news vendor problem (e.g., Ermoliev and Wets (1988); Birge and Louveaux (2011)). In Sect. 2.4 this example is extended to illustrate specifics of dynamic two-stage stopping time models. Suppose a building manager can decide each year the energy capacity x of the building. For simplicity in the exposition, aggregated values and decisions are assumed. The price of each unit of capacity, e.g., kW, is c. During the year, the energy demand varies following a probability distribution described by a random variable ξ . We have to specify in which sense x = ξ for a random ξ . If the demand is larger than the capacity, i.e., ξ > x, then the building manager has to increase the capacity to fulfill the demand, but at a higher cost d + > c. If the demand is lower than the capacity x, i.e., ξ < x then the building manager can sell energy at a lower price d − < c. Let y − (y + ) be such excess (shortage) of capacity. Then, for a given ξ , the balance equation is defined as x = ξ + y + − y − , and the cost function for the building energy procurement is: (1) Note that in these types of problems, there are strategic first-stage decisions x that are to be made before uncertainty ξ is resolved and operational second-stage decisions y that are made once uncertainty is resolved. As we have seen above, the optimal value of the second stage decision depends on both the random variable ξ and the first-stage decision x: y + * = max{0, ξ − x} and y − * = max{0, x − ξ }. Therefore, the expected value of the cost function we want to minimize can be expressed as: where E[·] is the mathematical expectation function. Developing the following optimality condition under optimal x > 0: where C (x) denotes the first order derivative of C(x) evaluated at x, yields the following expression (Cano et al. 2014b): where P[·] is the probability function. So, the probability of the demand being lower than the optimal is defined by the whole structure of the energy supply systems, i.e., the structure of unite costs and the distribution of threats. Given that d + > c > d − , Eq. (4) assures a level of security for the solution. Namely, this solution depends on the probability distribution of ξ and costs d + , d − , c. Therefore, the solution of two-stage (strategic-operational) stochastic problems ends up in the fulfillment of some security level, whereas P [ξ > x] characterizes the Value-at-Risk (VaR). Such solutions x * , y + * , y − * are optimal for all the scenarios at a time, thereby providing robust solutions for strategic x * and operational decisions y + * , y − * decisions. In contrast, the solution of the deterministic problem, i.e., substituting the uncertain parameters ξ by its expectation E [ξ ] and solving the optimization problem, is a degenerated solution for an average scenario, which might never occur. Likewise, solving the worst case scenario problem, i.e., using max{ξ } as fixed, would be too conservative and unrealistic, consequently leading to very high costs.
In this example, both first-and second-stage decisions are represented within a given time horizon. Due to the problem own structure, operational decisions induce risk aversion on strategic decisions.

The dynamic two-stage model with random horizons
The main specifics of the following model is its ability to inforce a dialogue among stakeholders (internal and external). It can take place at any point of the decision making process and provide feedback to the DSS structure including the model, sets of decisions, and data. We define these points as a stopping time moments, which may also be associated with the occurrence of extreme weather related events, earthquakes, failures of markets, or learning new information. Proper adjustments of strategic decisions after these moments reduce irreversibilities of decisions (Arrow and Fisher 1974). In this section we develop a new two-stage dynamic optimal planning and operation of a building infrastructure model with random duration of stages bounded by stopping time moments.
Strategic and operational decisions concern demand and supply sides of different energy loads and resources (electricity, gas, heat, etc.). The demand side is affected by old and new equipment and activities including such end uses as electricity only, heating, cooling, cooking, new types of windows and shells, and energy-saving technologies, etc. The supply side is affected by decisions on new technologies. The notion of technology must be understood in a rather broad sense. This may be either direct generation of electricity and heat, or the purchase of certain amounts of, e.g., electricity from a market, i.e., the market can also be viewed as energy generating technology with specific cost functions. Independently of the content, different options i are available at time t to satisfy energy demand, i ∈ I = {1, . . . , I }, t ∈ T = {1, . . . , T }, where T is a random planning horizon. For each case study, feasible options at time t have to be characterized explicitly.
The model is dynamic and the planning horizon comprises T years. Uncertainties pertaining to demands, fuel prices, operational costs, and the lifetime of technologies are considered. Demand may be affected by weather conditions. It may also substantially differ by the time of the day and the day of a week. However, instead of considering 8760 hourly values per year, demands and prices are aggregated into J periods representatively describing the behavior of the system within a year. Similar approaches can be found in the literature (Conejo et al. 2007).
The demand profile within each year t, can be adequately characterized by the demand within representative periods j, j ∈ J = {1, . . . , J }. This time structure is represented in Figure 2, where D t j , CO t i, j denote the energy demand and costs of technology i in period j of year t, and y t i, j are operational decisions for technology i in period j of year t. The goal of the strategic model is to find technologies i and their capacities x t i , installed at the beginning of year t to satisfy demands D t j , in each period j.
In the following ω is used to denote a sequence ω = (ω 1 , ω 2 , . . . , ω t , . . . , ω T ) of uncertain vectors ω t of general interdependent parameters which may affect outcomes of the strategic model, e.g., market prices, perceived outcomes of the stakeholder dialogue, or weather conditions. Formally, assume planning time horizon of T years. Let x t i be the additional capacity of technology i installed in year t, and s t i the total capacity by i available in t. Then, where LT i is in general random lifetime of technology i and s 0 i is initial capacity of i existent before t = 1.
In addition to operational costs CO t i, j , investment costs CI t i are considered. In general, the operational and investment costs, as well as energy demand D t j , are uncertain. Strategic first stage investment decisions x t i , are made at the beginning of the planning horizon t = 1 using a perception of potential future scenarios CI t i (ω), CO t i, j (ω), D t j (ω) of costs and energy demands dependent on the stochastic parameter ω. Second stage adaptive operational decisions y t i, j are made after observing real demands and costs. They depend on observable scenario ω, i.e., y t i, j = y t i, j (ω). Therefore, any choice of investment decisions x = x t i , may not yield feasible second stage solutions y(ω) = y t i, j (ω) satisfying the following equations for all ω: where G t i, j may be interpreted as the availability factor corresponding to the technology operating in period j in t (G t i, j = 0 for not yet existing technologies). Thus, the set of feasible solutions is characterized by the decision variables (x, y(ω)), where the strategic decisions x = (x 1 , ..., x T ) are made before observing a scenario ω, and operational decisions y(ω) = (y i j t (ω)), t = 1, ..., T for all technologies i and periods j are made after learning scenarios ω and τ (ω)) The feasibility of constraints (7)-(9) for any scenario ω can be guaranteed by assuming the existence of a back-stop technology with high operating costs that can also be viewed as purchasing without delay but at high price. In particular, it can be viewed as a contingent credit or a catastrophe (black-out) bond, similar as in Ermoliev et al. (2012). Without loosing generality it can be assumed that for any period j and time t it is the same technology i = 1. Then the basic dynamic stochastic two-stage model is formulated as the minimization of the expected total cost function: This problem can be easily extended to deal with advanced energy systems features such as efficiency, emissions, or storage (Cano et al. 2014b, a).

Numerical methods: learning by doing and moving random time horizons
The model (5) where the set of scenarios may include a finite number of implicitly given scenarios, e.g., by scenario trees (Kaut et al. 2013) or other scenario generating methods based on requirement equations and perceptions of stakeholders. A realistic practical model (5)-(10) excludes analytically tractable solutions, although the model has an important block-structure that is usually utilized for most effective numerical solutions in DSS. In a rather general case, contains or can be approximated by scenarios ω n , n ∈ N , characterized by probabilities p n , n ∈ N . e.g., by sample mean approximations with p n = 1/N , where N is the number of scenarios. Then the model (5)-(10) is formulated as the minimization of the function: subject to: Sequential decision making process under a dialogue of stakeholders can be written in the following form. The model (11)-(16) is focused on a sample τ (ω) of random time horizons. The robust strategic solution solving the model (11)-(16) can be denoted as: ..., τ (ω)i ∈ I, are implemented at t = 1, 2, ... until a stopping time moment τ 1 (ω) ≤ T , that may reveal significant new information about necessary systemic changes and future uncertainties. Let us denote scenario ω for interval [1, T ] as ω [1,T ] . New information provides a basis for readjustments of scenarios ω [1,T ] perceived at the beginning of time horizon [1, T ]. Then, new set of scenarios ω [τ 1 ,τ 1 +T ] are generated, robust strategic solutions x τ 1 ,τ 1 +T are obtained, and so on. Thus, initially a long-term strategic trajectory x [1,T ] is evaluated, the solutions x 1,τ 1 are implemented, new data are received, new scenarios ω [τ 1 ,τ 1 +T ] are generated, solutions x [τ 1 ,τ 1 +τ 2 ] for a stopping time τ 2 are calculated, and solutions x [τ 1 ,τ 1 +T ] are implemented, and so on. This approach introduces a new type of models incorporating endogenous scenario generation shaped by previous decisions, i.e., learning-by-doing procedures.
Let us remark that the specific case of this model with deterministic stopping time interval τ = 1 or, in general, equal to some positive τ , defines models with rolling time horizons. The use of these models significantly reduces difficulties of the traditional multi-stage models.

Endogenous dynamic systemic risks and discounting
In this section we extend the illustrative model presented in Sect. 2 to a dynamic with random horizon model. In this more general form, the problem becomes similar to catastrophic-risk-management problems discussed in Ermoliev et al. (2000). Here, we show that the dynamic with random horizon model has strong connections with endogenously generated, i.e. systemic, dynamic versions of VaR and CVaR risk measures.
Let us consider the total energy capacity (capacity) of the building defined by R t = t k=1 x k before a stopping time τ , where x k denotes the additional energy capacity of the building installed in year k, i.e., decision variables x k ≥ 0, k = 1, ..., t, t ≤ T . At time t = τ , the target value on total capacity R t in period t is given as a random variable ρ t . It is assumed that the first replacement of technologies due to aging processes, arriving a disaster, or adopting a new regulation occurs at random stopping time moment τ . Since τ is uncertain, the decision path x = (x 1 , ..., x T ) for the whole time horizon has to be chosen ex-ante in period t = 1 to "hit" the target ρ t , R τ ≥ ρ τ , at t = τ in a sense specified further by (10). At random t = τ , the decision path can be revised for the remaining available time. Similar to the model of Sect. 2, consider random costs .., T are known ex-ante and ex-post costs. The expected value of costs can be written as: where Let us consider a path x * minimizing V (x) subject to x t ≥ 0, t = 1, ..., T . Assume that V (x) is a continuously differentiable function (e.g., a component of random vector ρ = (ρ 1 , ..., ρ T ) has a continuous density function). Also, assume for now that there exist positive optimal solution Then from the optimality condition (Ermoliev 2009) for stochastic minimax problem (17), similar to the one in Sect. 2.2, it follows that for x = x * , From this sequentially for t = T, T − 1, ..., 1, follow the equations which can be viewed as a dynamic VaR-type endogenous (systemic) risk measure. Equations (18) can be used for analyzing desirable dynamic risk profiles, say, time independent risk profiles with a given risk factor γ : c T / p T d T = (c t −c t+1 )/ p t d t , t = 1, ..., T − 1, which can be achieved by decisions affecting parameters c t , d t , p t , i.e. by adjusting costs (penalties).
Equations (18) are derived from the existence of the positive optimal solution x * . It is easy to see that the existence of this solution follows from c T / p T d T < 1, 0 ≤ (c t −c t+1 )/ p t d t < 1, t = 1, ..., T −1, and some other technical requirement discussed by O'Neill et al. (2006).
We can see that a simplest case of dynamic two-stage model (11)-(16) with random (stopping) time horizons induces endogenous risk measures, which take the form of a dynamic VaR-type systemic (dependent on the structure of the system) risk measures. Values p t = P[τ = t] can be viewed as endogenous discounting (see discussion in Ermoliev et al. (2010). Misperception of this discounting can lead to wrong policy implications.

Two-stage problem instance
In this section, real data from the EnRiMa project are used to demonstrate the modeling approach. In particular, historical data from an EnRiMa test site in Asturias (Spain) have been used. Let us consider the model defined by (11)-(16). Starting from base values, the future development of the parameter values have been modeled through expert opinions getting average values and standard deviations for annual variations, see Table 1.
Assuming normal distributions, a set of 100 scenarios ω n have been simulated. In general cases, scenarios ω n are simulated using rather general scenario generators based on partial observations and experts perception. Figure 3 shows a representation of this simulation, which is basically a representation of the stochastic parameters' possible evolution throughout the decision horizon: demand (left), strategic costs (cen-  For the sake of simplicity, only four representative periods (set J ) have been defined: winter, spring, summer and autumn. The input technologies (set I) are Regulated Tariff of Electricity (RTE), Photovoltaic (PV) and Combined Heat and Power (CHP). In this simple example with only electricity demand, it is assumed that the heat produced by the CHP technology is not used. Regarding the technologies availability, RTE and CHP are always available (G t i, j = 1), whereas PV availability depends on the season as shown in Table 2 (assuming the same values for all the years). A Sunmodule SW 245 by Solarworld has been considered. 2 The availability factor has been computed using the on-line PGIS tool (Photovoltaic Geographical Information System) by the European Commission Joint Research Center -Institute for Energy and Transport. 3 As for investment costs C I t i , the price for the PV panels has been taken from the PREOC price database, 4 whilst the price for the CHP has been gathered from the on-line seller myTub. 5 A 40% reduction has been applied to the investment costs to 2 http://www.solarworld.de/en/home/. 3 http://re.jrc.ec.europa.eu/pvgis/apps4/pvest.php. 4 http://www.preoc.es/. 5 http://www.mytub.co.uk/product_information.php?product=465447. take into account available subsidies in the market. 6 This parameter also gathers a cost of contracting RTE of 50 EUR/kW, which increases at the same rate as the energy cost. For the operational costs C O t i, j , the base fuel prices for electricity and natural gas are 0.134571 EUR/kWh and 0.05056 EUR/kWh for RTE and CHP, respectively, based on the EnRiMa project deliverable D1.1 "requirement assessment", and no cost for PV. As a short horizon is considered, the lifetime parameter LT i , which has been set to 20 years, has no influence on the result. Finally, the duration time is set to 91 days × 8 hours, considering 13 weeks each period.
Solving the SP problem the strategic decisions to be made are (see Table 3): contracting 45.65 kW to RTE and installing 57.65 kW of PV the first year, and extend the PV installation the second year in 1.77 kW. Note that the actual decisions to be made are those for the first year.
The total cost stemming from those decisions is 68,595 EUR. If we assumed average values for the uncertain parameters, i.e., solve the deterministic problem using the mean values represented in Fig. 3 as the solid thick line, we would get a total cost of 66.920 EUR and slightly different values for the decision variables. The deterministic problem can be seen as a single-scenario version of the stochastic problem (11)-(16). Given the figures, one could think that the deterministic solution is better than the stochastic one. But this is an illusion, because if we analyze the variability (robustness) of solutions using separately the 100 different scenarios, we realize that the solution returned by the deterministic optimization is unfeasible for 56 of them. This means that more than half the times the capacity of the building will not be able to fulfill the requirements of energy. On the contrary, the solution returned by the SP problem is a robust solution against all the scenarios.
To compute the value of stochastic solution (VSS), the first-stage decisions obtained in the deterministic problem, i.e., considering parameters' average values, are fixed in the SP problem (11)-(16), which is then solved. The solution of this problem is called the expected result of using the expected value problem (Birge 1982) and represented by F(x * det ), while the solution of the SP problem is represented by F(x * sto ). In this case, as F(x * det ) is unfeasible, it is considered infinite and therefore, the VSS is infinite: It is important to remark that even if F(x * det ) is feasible, the VSS is positive, and the magnitude will depend on the uncertainty structure. The value F(x * sto ) is smaller than F(x * det ) because the stochastic model has a richer set of feasible solutions, i.e., the deterministic solution x * det is a degenerated version of x * sto .

DSS framework 4.1 Overview
The proposed framework relies on the use of Algebraic Modeling Languages (AMLs), in contrast to the use of whole matrices to represent the optimization problems. The advantages of AMLs versus matrix-like systems have been largely discussed (Fourer 1983;Kuip 1993). Recent advances on AMLs can be found in Kallrath (2012b). Nevertheless, usually optimization software accepts matrix files with the model coefficients and actually modeling software generates the matrix from the algebraic language. However, the process is usually more straightforward and less prone-error when using AMLs, as the modeler has just to write the model, and the coefficients are generated combining the data and the model. Despite AMLs have been selected to build the framework, it is important to remark that other structured formats, e.g., markup languages, can be used as far as they are useful to accomplish the DSS main mission, i.e., the stakeholders dialogue. For example, OS (optimization services) 7 is a COIN-OR (Computational Infrastructure for Operations Research) 8 project that uses the XML format to represent optimization problems and that is suitable to effectively communicate within an eventual DSS. As for AMLs, they are "declarative languages for implementing optimization problems" (Kallrath 2012a). They are able to include the elements of optimization problems in a similar way they are formulated mathematically using a given syntax that can be interpreted by the modeling software. This approach is essential for representing the models not only for machines, but also for humans, and allows to organize the stakeholders dialogue. There are several AMLs available both commercial and open source.

A reproducible research approach
Against the "copy-paste" approach frequently used to reach the final outcome of a decision making problem, the reproducible research one adopted in the framework proposed has a series of advantages worthy to consider, namely: (1) when coming back to the research in the future, i.e., due to moving time horizon, the results can be easily obtained again; (2) in case other researchers have to contribute to the work, all the process is at hand; changes on any step of the process (e.g., a new index in the mathematical model) are made seamlessly just changing the appropriate data object, the whole analysis is made again with the new information, and the changes are automatically reflected in the output results; and (3) the results can be verified by independent reviewers. The latter is particularly important in health research and other disciplines where security is an issue. A paradigmatic example to realize the importance of reproducible research is the scandal of the Duke cancer trials (CBS 2015; The New York Times 2011). For an example on energy issues see Jelliffe (2010), where reproducible research is pointed out as a powerful tool for the mainstream climate scientists.
To fulfill the requirements for a DSS detailed in Sect. "Optimization of building infrastructure systems under uncertainty", a reproducible research approach is advisable. In the following subsection, a specific implementation of the general framework reflected in Fig. 1 is presented, including the model, the data, the algorithms and the solution, covering the needs for stakeholders dialogue at any level.

Implementation
The general framework outlined above can be implemented using different technologies according to the stakeholders needs, as far as their dialogue is assured. In this subsection, a possible implementation using the programming language and statistical software R (R Core Team 2013) is shown. The R Project for Statistical Computing is becoming the "de-facto standard for data analysis", according to more and more authors from a variety of disciplines, from Ecology to Econometrics (Cano et al. 2012).
Some of the advantages of choosing R as the statistical software for a DSS are: It is Open Source; it has Reproducible Research and Literate Programming capabilities (Leisch 2002); it can be used as an integrated framework for models, data and solvers; it supports advanced data analysis (pre-and post-), graphics and reporting; interfacing with other languages such as C or Fortran is possible, as well as wrapping other programs within R scripts.
These capabilities allow the researcher to apply innovative methods and coherent results increasing the productivity and reducing errors and unproductive time. Moreover, R runs in almost any system and configuration, the installation is easy, and there are thousands of contributed packages for a wide range of applications available at several repositories. This extensibility provides the framework with the capability of adaptation to the stakeholders dialogue's requirements through the creation of new libraries and functions, either public or private. Last but not least, the active R-Core development team jointly with the huge community of users provide an incredible support level (without warranty, skeptics would say), difficult to surpass by other support schemes.
One of the capabilities of this implementation of the framework is to represent the models in L a T E X format, which is one of the "Practitioner's Wish List Towards Algebraic Modeling Systems" according to Kallrath (2012c). The AML selected for this implementation of the framework has been GAMS. Nonetheless, the classes explained Fig. 4 The optimr package structure below can be easily extended to other languages. This is possible due to the fact that the SMS is generically represented within the DSS using specific R data structures. Moreover, R provides functionality for all the required tasks within the DSS, including data analysis, visualization and representation tasks, allowing communicating to different optimization software through inner interfaces. Data cleaning and management can also be easily done with R and user interfaces can be provided, both through other technologies or through libraries devoted to user interfacing. Note that the spirit of the framework can apparently be applied using other programming and analysis tools.
An R package called optimr. 9 has been developed as an implementation of the framework described in this paper to deal with the model, the data, and the solutions. The optimr package revolves around two classes of objects: optimSMS and optimInstance. The former contains the Symbolic Model Specification (SMS), i.e., the mathematical model including all the entities such as parameters and variables and their interrelations. The latter contains the data of the particular instance of the problem to be solved. Figure 4 shows an outline of the package structure. Once the model is defined as an optimSMS object, the data are used to feed the model by means of an optimInstance object. Both levels of information can be represented in both human and machine readable formats through standard R objects of class data.frame.
The optimSMS class is composed by several members: Descriptive strings name, sDes, and lDes; Model entities consts, sets, vars, and pars for constants (scalars), sets, decision variables and model parameters respectively; Relations are stored in eqs and terms, for the equations and the terms respectively, using a tree structure. It also has a bunch of methods to get and represent the SMS. Thus, we can get expressions of any model entity in a given format, e.g., GAMS or L a T E X, or data structures containing the information. The creation and addition of elements in a SMS is made through specific functions. The models in Sect. 2 can be easily created using R scripts (see the optimr package documentation). Moreover, the inclusion of risk measures such as Conditional Value at Risk (CVaR) as described in Cano et al. (2014b) is also possible. Once the SMS is in an optimSMS object, any expression can be straightforwardly obtained. Combining different expressions and working with text in R, complex representations of the models can be produced.
As for the instance, i.e., the concrete model to be solved using specific data, it can be stored in optimInstance class objects. An instance always corresponds to a model, and, therefore, to create an optimInstance object it is needed an optimSMS object. Once created, elements (actual sets, parameter values and equations to include) are added to the instance, related to its SMS. The slots (members) of an instance can be also accessed easily using self-explained functions. Then, the optimization problem can be automatically generated in the appropriate format, e.g., a GAMS file, through a specific method, then solved with the own R optimization capabilities or calling an interface such as that included in the gdxrrw 10 package, creating an output file with the solution. Finally, the solution can be imported to the optimInstance object and present the results to the stakeholders. Note that at any point data analysis and visualization can be straightforwardly performed over the data, as they are stored in homogeneous and consistent data structures. Finally, the package and the framework is intended to be available for generic problems use, beyond the models and problem tackled in this article.
It is important to remark that the process described above and outlined in Fig. 4 fulfills, in an outstanding way, the stakeholders dialog approach represented in Fig. 1 and detailed throughout the paper. Examples of (downloadable) data and code to use with the optimr package can be found in Cano et al. (2015).

Concluding remarks
The model and DSS presented in this paper have been tested using real data from the EnRiMa project. Results demonstrate the importance of using stochastic strategicoperational models improving the outcomes of deterministic models, i.e., providing robust solutions for long-term energy supply planning under uncertainty and risks management. In particular, using average values, deterministic models provide degenerated solutions violating simplest energy supply security requirements and even being infeasible for all real scenarios.
Decision support is not a static action, but rather an iterative process that requires stakeholders dialogue. Moreover, strategic decisions under uncertainty require the application of advanced models that provide robust solutions against all the possible scenarios under security requirements. Applications of inadequate DSS (regarding data treatment, models' structure, analysis of results, etc.) generates serious risks of adopt-ing wrong policies and irreversible developments. The proposed framework explicitly deals with those requisites in a flexible and extensible way. The DSS's model includes random horizons and stopping time moments, which are necessary to enforce the stakeholders-DSS dialogue at any point of a decision making process that may provide feedbacks to the DSS structure including the model and data. Reproducible research techniques can be applied over different decision problems and environments taking advantage of a common structure and acquired knowledge. Moreover, as remarked in Sect. 4, the framework fulfills one of the "Practitioner's Wish List Towards Algebraic Modeling Systems", which represents in fact an example of the stakeholders' needs that this work solves. As already mentioned, the framework as a whole has been successfully implemented in the EnRiMa project, including complete models gathering the building energy features (Cano et al. 2014a) and risk management (Cano et al. 2016). Moreover, the optimr R package is available to be used with other models and instances.
Future work will include the use of the models in other real-world situations, exploring further energy features such as energy storage. As far as the R package is concerned, to enhance stakeholders dialogue capabilities, further formats will be implemented, in addition to the ones supported in the current version, i.e., L a T E X and GAMS. Further research over these results will be the in-depth analysis of global policies and long-term uncertainty modeling, as well as the benchmarking of the strategic two-stage dynamic model against computationally-intensive multi-stage models. Definitely, the proposed idea of learning-by-doing based on the moving time horizon (Sect. 2.3) provided a way to escape from irreversible predetermined in advance (at t = 0) decisions using adaptive endogenous scenario generators.
gets (roughly, 20 % emissions reduction, 20 % energy consumption from renewables, and 20 % energy efficiency improvement); the Energy Efficiency Plan 2011; 12 The liberalization of energy markets (first directives for electricity in 1996 and for gas in 1998, second ones in 2003, and the third liberalization package based on the Commission's energy package as of 2007); Renewable sources policies (Directive 2009/28/EC on the promotion of renewables, Net-Zero Energy Building (NZEB) strategies, see for example Hernandez and Kenny (2010) or Pless and Torcellini (2010), Net metering, or Feed-In-Tariffs).
Regarding the strategic energy systems planning, different approaches can be found in the literature. Some of them deal with specific technologies (Siddiqui et al. 2005;Stadler et al. 2009). Other optimization models are designed from the production point of view (Hobbs 1995;El-Khattam et al. 2004;Heydari and Siddiqui 2010). In Villumsen and Philpott (2012), Stochastic Optimization (STO) is applied to capacity planning of electricity transmission networks with transmission switching, while Cai et al. (2008) focus on a regional perspective. The type of two-stage stochastic models with a fixed time horizon T presented in Sect. 2 can be found in the book by Conejo et al. (2010). Random time horizons are analyzed in relation to stopping time moments in catastrophic risk management by Ermoliev et al. (2010). Only recent papers tackle systems planning at the building level (Salvador and Grieu 2012;Kumbaroglu and Madlener 2011).
In terms of Information and Communication Technologies (ICT) solutions for energy-efficient buildings and areas of public use, most of the existing analyses follow either a power systems engineering framework (Weinberg et al. 1991;van Sambeek 2000), or a deterministic optimization approach (Hobbs 1995;Siddiqui et al. 2005;King and Morgan 2007;Marnay et al. 2008;Stadler et al. 2009) that is unable to provide robust decisions against inherent uncertainties (Ermoliev and Wets 1988). Even though STO has been applied for a long time to cope with uncertainties in other fields, there were not approaches based on the use of STO techniques to treat uncertainties for energy efficiency in buildings.
The solution of the stochastic problem involves adjusting operational decisions to hit long-term targets if additional information about prices, demand and weather is revealed in the future (Gritsevskii and Nakicenovic 2000;Gritsevskii and Ermoliev 2012). A key innovation of the dynamic stochastic DSS presented in this paper is a combination of the proven methodology for modeling energy flows in buildings (Siddiqui et al. 2005) with the advances in effective coping with uncertainty (Ermoliev and Wets 1988;Gritsevskii and Ermoliev 2012).
With regard to DSSs, different approaches can be found in the literature. Some of them focus on the model as a way to provide decision support, other focus on the infrastructure of the DSS, or on a particular application (Salewicz and Nakayama 2004). In Tanaka et al. (1995) a DSS for multicriteria decision making which includes decision maker interaction was proposed. A generic core to build optimization-based DSSs is presented in González et al. (2009), Conejo et al. (2010, defining a framework for developing a DSS with web services. An implementation of machine-readable models can be found as Structure Modeling Language (SML) in Geoffrion (1992a) and Geoffrion (1992b). A brief history of DSS can be found in Power (2007). Some of the topics discussed in Shim et al. (2002) are tackled in the framework proposed in this paper. Though a cutting-edge topic, only very recent works deal extensively with Reproducible Research (Stodden et al. 2013). This approach is crucial in conducting dialogues in our dynamic stochastic DSS. As for decision making problems, it is a vast area entailing a considerable number of contributions, see for example Bell et al. (1988);French et al. (2009);Klein et al. (1993).

Optimization of building infrastructure systems under uncertainty
Energy systems: Energy systems are conceived at the scope of this paper as the technologies and devices used to provide people with the energy needed for their everyday activities. From this standpoint, we find different types of energy systems, namely: appliances, networks, generation and transformation technologies, storage technologies, passive technologies. In what follows, the building level extent is assumed. The meaning of building in this case can refer to different aggregation typologies, such as single buildings, set of buildings, or spaces of public or private use. Examples of buildings under this conception are university campuses, sports centers, administrative buildings, hospitals, and airports. Therefore, the target buildings are those that are managed by an identified party (individual or organization) that can make decisions regarding energy systems.
Two types of decisions can be made regarding energy systems. On the one hand, there are decisions on which systems are feasible or available. These are strategic decisions. On the other hand, there are decisions on how to use the available systems. These are operational decisions. Strategic decisions are made in the long term (e.g., years) whereas operational decisions are made in the short term (e.g., hours). Examples of strategic decisions are: type of contract to sign with the grid; number of PV panels to install; renovation of building's envelope elements. Examples of operational decisions are: how much electricity to buy from the grid at a given hour; how much fuel to input into a generator. Note that both types of decisions are interdependent.
Sources of uncertainty: Some decisions are made under perfect information, i.e., knowing all the outcomes and relevant facts affecting such decision. For example, one can decide whether to vent a room or not knowing the inside and outside temperatures and one's desired comfort level. However, this is not always the case. In many decision making processes, there is uncertainty pertaining relevant facts and figures around the decision. In particular, decision making on energy systems is strongly affected by both short-term and long-term uncertainties. Some of these sources of uncertainty are: energy demand, energy costs, investment costs, or availability and efficiency of new technologies.
DSS model component: Within the structure of the DSS outlined in Figure 1, the model component is represented by the so-called Symbolic Model Specification (SMS). The SMS defines the mathematical representation of the optimization model, including all relevant subsystems and their interactions. This mathematical representation is composed of variables, parameters, and relations between them. Such relations are, in turn, represented by equations and inequalities. Sets are used to represent parameters, variables, and equations domains, as well as to model conditions and boundaries within equations. The models applied to the specific problem of energy systems optimization at the building level are developed in Sect. 2. Details about the implementation of the models within the framework can be found in Sect. 4. DSS data component: Some of the available AMLs and optimization software packages include data import and export capabilities, and even some analysis functionality. However, it is common that analysts and modelers use specific data analysis software to make the data available for the DSS. In this regard, there are a wide range of options both commercial and open source. The data component of a DSS can be also developed using general-purpose programming languages or specific programming language libraries. Moreover, interfaces to diverse data sources may be needed to import and export data from/to the existing data sources. For stochastic programming (SP) or stochastic optimization (STO), scenario generators are also needed to combine the data and the uncertainty modeling to provide the DSS with the appropriate inputs for designing robust solutions.
The system part of the DSS: There is a component of the DSS in charge of running the optimization, that in our case is given by the dynamic strategic-operational model of Subsect. 2.2. Usually it is a piece of software containing the algorithms to solve optimization problems, and it is in general named the solver. Solvers are usually available as stand-alone, low-level applications that can be embedded in high-level applications, i.e., with a user interface. Solvers may be specific for a given optimization type of problem or for different types of problems. There are a number of solvers both commercial and open source available. The AMLs, as well as other optimization software, include solvers that are called once the model and the data are available. In addition to AMLs, other software packages such as spreadsheets can solve optimization problems.
In summary, it is common to find different components of a DSS. A heterogeneous set of tools is often being used for similar tasks that unfortunately blocks stakeholders dialogue.