Hydro-economic optimization under inflow uncertainty using the SDP _ GAMS generalized optimization tool

The use of methodologies that explicitly take into account inflow uncertainties in the optimization of the management of water resource systems is hindered by the lack of a generalized software. A general-purpose package named SDP_GAMS has been developed, facilitating the resolution of the stochastic dynamic programming problem. It obtains optimal policies, associated optimal benefits and optimal decisions in response to specific inflow time series and demands. The tool has been tested in the Mijares River basin (Spain), with two reservoirs and four major demands. Inflow variability has been described by the use of a 1-lag Markov chain, and a 91-class two-reservoir discrete mesh was used in calculations. Polynomial economic demand curves were used. The results showed that the use of the SDP hydro-economic modelling procedure obtains optimal policies taking into account inflow uncertainty, which can lead to an improvement in the efficiency of water resources systems.


INTRODUCTION
Stochastic dynamic programming (SDP; Nandalal and Bogardi 2007) has been proven to be a powerful optimization methodology.Some of its advantages are: its ability to handle non-linearities in the objective function; the inflow uncertainty representation; and the sequential treatment of the decision-making process (Labadie 2004).However, the use of SDP in large water resources systems is hindered by the "curse of dimensionality": the computational burden increases exponentially with the number of state variables.This drawback has been worked out during recent years by developing additional methodologies, following three main different directions (Goor 2010): -System simplification through decomposition techniques (Archibald et al. 1997) and further combinations of results.-Benefit-to-go function interpolation mechanisms (Tejada-Guibert et al. 1993) followed by forward-moving reoptimization strategies.-Other strategies such as reinforcement learning (Lee and Labadie 2007) or Stochastic Dual Dynamic Programming (SDDP; Tilmant and Kelman 2007).
Recent applications of SDP and its derivatives include the use of ensemble prediction forecasts in optimization procedures (Faber and Stedinger 2000), estimation of the economic value associated with stored water (Tilmant et al. 2012); assessment of benefit-sharing operations (Tilmant et al. 2009); operation of multipurpose multireservoir water resources systems (Tilmant and Kelman 2007); development of an intelligent agent for optimal water resources system management (Rieker and Labadie 2012); and estimation of the economic value associated with different levels of coordination between reservoirs (Marques and Tilmant 2013).Although several computer tools have been developed in various studies focused on specific methodologies, a software able to apply SDP methodologies to multipurpose multireservoir systems is still lacking.
The main goal of this contribution is to present a generalized-purpose software, named SDP_GAMS, that links the concepts of hydro-economic stochastic optimization and Decision Support System (DSS).This tool has been built using the GAMS code (General Algebraic Modelling System; Brooke et al. 1998) connected to a graphic interface in Microsoft Excel.SDP_GAMS solves the stochastic dynamic programming using the regular SDP approach (Nandalal and Bogardi 2007), obtaining optimal generally-defined policy tables and time series of optimal decisions regarding specific time series of inflows.

THE SDP_GAMS TOOL
The SDP_GAMS software is a generalized DSS that solves the hydro-economic stochastic dynamic programming problem in multireservoir systems, facilitating optimal policies and optimal expected performance in an uncertain environment.The program solves the stochastic version of Bellman's recursive equation (see Nandalal and Bogardi 2007), obtaining the total benefits between the current time stage t and the end of the planning horizon T, named Ft, as a summation of immediate and future forecasted benefits: where St is the initial system state (storages); Qt the inflow during time stage t; Dt the management decisions made in time stage t; B the benefits obtained in time stage t with the management decisions (immediate benefits; p t p,q the transition probability between the inflow class p in time stage t and the inflow class q in time stage t+1 (Markov chain); Ft+1 the benefits between time stage t+1 and the end of the planning horizon T (benefit-to-go function); St+1 the system state in time stage t+1; and Qt+1 the forecasted inflow during time stage t+1.
This equation is solved backwards starting with the final time stage T (in which the SDP_GAMS assumes FT+1 = 0) of the recursive cycle.After reaching time stage t = 1, a new iteration is started by using the previously-obtained F1 value as FT+1 in the next iteration, unless the convergence criteria are achieved.The Markov Chain is used as an inflow uncertainty descriptor, incorporating the transition probabilities of the time series based on historical records.To solve the equation, SDP_GAMS requires the discretization of the storage (St) and inflow (Qt) variable spaces, allowing only transitions between St and St+1 discrete values when solving the Bellman's recursive equation, whereas transitions between Qt and Qt+1 values are governed by the Markov chain.The need to use discretization processes implies that the program is subject to the "curse of dimensionality".
In order to confront the curse of dimensionality and save computation time, the SDP_GAMS implements a modular approach.Therefore, the operations performed within the SDP algorithm framework are divided into several computational phases or modules that are sequentially executed.Each calculation module works separately, allowing a better package of the GAMS code and a clear differentiation between the algorithm operations.The user does not need to execute the whole program, being able to choose which operations desires to perform depending on the previous runs and the required results.The program comprises five modules: (a) data entry; (b) optimization; (c) recursion; (d) reoptimization; and (e) results retrieval.(a) The data entry module of the SDP_GAMS consists of a set of data calls from Excel to GAMS.Data needed include the physical and economic features of the system (like the connectivity matrices, demand curves, etc.), the discretized variables, the reoptimization data series, and the control parameters of the algorithm (maximum number of recursion iterations, convergence criterion value, etc.).The development of the connectivity matrices representing the topology of the system network can be facilitated by using software such as HydroPlatform (Harou et al. 2010).After these features are introduced in an Excel datasheet, the SDP_GAMS algorithm retrieves them into the GAMS code.The SDP_GAMS package does not require GAMS skills, as its execution is fully controlled from a user-friendly interface in Excel.(b) The optimization module calculates the optimal value of the immediate benefits B given each possible combination between St, Qt and St+1.The decision Dt is therefore determined depending on the discrete St and St+1.This module bears the longest computational time as it checks for each possible combination between the state variables.In order to save time, a "quick mode" option can be activated.This option, allowable only for systems with reservoirs in serial configuration, makes a previous check of each combination between St, Qt and St+1, finding out if a combination is either infeasible (meaning that it cannot be solved) or ultrafeasible (meaning that all the demands can be fulfilled).If a combination is found to be infeasible, the solver routine is not executed and a huge penalty is given to prevent its interference in the recursion module execution.On the other hand, if a combination is found to be ultra-feasible, the solver routine is not executed, and the decision and benefits are the ones corresponding to the fulfilment of all the demands.This module can be skipped if it has been executed before.(c) The recursion module solves the Bellman's recursive equation (1) iteratively until convergence criteria (steady benefits and steady policies) are fulfilled.This module's results are the steady-state optimal policies (final storage values and deliveries to the demands) and the steady-state optimal benefits Ft.The model informs the user if the convergence criteria are achieved (either one or both) or the computation is halted due to iteration limits.This module can be skipped if it has been executed before.The optimization module's results are needed for its execution.(d) The reoptimization module uses the recursion's module Ft results to interpolate them by either a global cubic (single equation, not recommended in multireservoir systems) or a piecewise linear approach.Then, a forward-moving loop is performed, solving (1) at each time step using the interpolated Ft+1 values (Tejada-Guibert et al. 1993).The results obtained with this module are the end-of-time-step storage values, the flows in the system streams, the deliveries to the demands, and the benefits obtained with them.This module can be skipped if it has been executed before.The recursion module's results are needed for its execution.(e) The results' retrieval module performs a call-back, from GAMS to Excel, of the results obtained in the recursion and the reoptimization module, if executed.The results call-back is stated in the previous modules and presented in the form of Excel columns and tables.In addition, the tool has an alternative module that solves the problem in a deterministic way.This module allows the user to quickly perform a deterministic optimization after, before or in place of a stochastic one, being able to compare both of them.In that way, the effect that inflow uncertainty has in the performance of the system can be assessed.

CASE STUDY: THE HYDRO-ECONOMIC OPTIMIZATION OF THE MIJARES RIVER BASIN (SPAIN)
The SDP_GAMS tool was tested with the development of a hydro-economic stochastic optimization model in the Mijares River basin (eastern Spain).Details concerning the physical and economic characterization of the system used in this model can be seen in Alvarez-Mendiola (2012) and Macian-Sorribes (2012).The hydro-economic model built is depicted in Fig. 1, consisting of seven nodes, seven river reaches (two of them subjected to seepage losses), two surface reservoirs (Arenos, with active storage capacity of 93 Mm 3 , and Sichar, 49 Mm 3 , and subject to seepage losses), two inflow time series (Upper and Middle sub-basin discharges), four agricultural demands (devoted to orange tree crops), and one minimum flow downstream of the Sichar Reservoir.In addition to the SDP economic optimization with SDP_GAMS, two additional models were built: one deterministic optimization model, using the deterministic module of SDP_GAMS, and a simulation model reproducing current management strategies (water allocation based on priorities), based on a previously-built MatLab model (Macian-Sorribes 2012).
Inflow discretization was carried out by dividing the inflow historical data series (Upper and Middle sub-basin), from 1940 to 2010 into four discrete intervals per month and sub-basin, combining together into a total of 16 discrete inflow classes per month.Storage discretization was carried out by dividing the storage space in the reservoirs of the system into 13 (Arenos) and seven (Sichar) discrete classes, combining together into a total of 91 discrete storage intervals per month.The system data introduced in SDP_GAMS consisted of the connectivity matrices, inflow and storage discrete values, reservoirs' physical characteristics (storage-surface area curves, evaporation loss rates and seepage loss equations); maximum and minimum flows per stream; stream seepage; and demand characterization (maximum values and economic demand curves); the 1-lag Markov chain that links the 16 discrete inflow classes between two consecutive months; and the inputs specifically required by the reoptimization and the deterministic modules (inflows time series, reservoirs' capacity and reservoirs' initial states).
The outputs of the stochastic optimization procedure were optimal policies regarding the initial state of the system, and optimal decisions and benefits associated to the reoptimization stage, based on the 1940-2010 historical inflow time series.After the reoptimization stage, the deterministic module of SDP_GAMS was run with the same data series to obtain the deterministic optimization results.The simulation model in MatLab was updated with the same inflow data series and initial state of the system to obtain the month-by-month storage volumes and demand deliveries, obtaining the benefits associated to the current operation of the system.Figure 2 and Table 1 show the comparison of the benefits obtained for the 1940-2010 and 1977-1986 periods.The last one corresponds to the most severe drought found in the Mijares River basin.
The results offered by the deterministic optimization correspond to the upper bound, whereas the ones obtained with the current management rules are at the bottom.The SDP benefits are located  between them.This is consistent with the expectations, as the deterministic optimization possesses the advantage of the perfect foresight of future hydrology.However, differences between alternatives for the whole period are not significant: the deterministic optimization results improve the current management ones by only 2% (1.3 M€/year).This situation is caused by the inherent robustness of the Mijares system, in which streamflow is fed by several groundwater springs in the Upper basin, which provide a highly stable discharge preventing the system falling into severe drought situations that be expected from low rainfall conditions.However, the use of economic criteria in water allocation causes an improvement of the system's efficiency.The SDP optimal policy cover 60% of the gap between the current operation and the ideal deterministic optimization, outperforming current policies by 0.80 M€/year.It is worth further analysis of a certain period in order to illustrate the different performance of the three methods that are compared: in the SDP approach there are years in which the annual benefit is lower than the one obtained by current management, as happens for the 1965 inflows.This is caused by the stochasticity of inflows, since in these years the SDP algorithm previews incorrectly (as the stochastic optimization does not possess perfect foresight) the possibility of a near future drought and, in consequence, starts to unnecessarily curtail water deliveries in advance; whereas neither the deterministic optimization (which knows in advance that there will be no drought) nor the current management (which takes no account of inflow forecasts) apply any supply curtailments.Focusing on the most severe drought faced by the Mijares River system, the prevalence relationship between alternatives is maintained, as the SDP performs between the current policies and the deterministic optimization.However, the gaps between them have enlarged, as the deterministic optimization outperforms the current policies by 7% (3.40 M€/year).The SDP covers over 62% of the gap between the other policies, similarly to the one corresponding to the whole period of analysis.Therefore, the SDP improvement with respect to the current policies is higher than in the entire period.This situation is consistent with the expectations, as inflow forecasts increase their value in drought situations.In addition, it must be noted that the shape of the SDP performance graph in the right figure in Fig. 2 closely resembles the current management one, while it departs from the deterministic optimization line.This is caused by the perfect foresight, which allows the deterministic algorithm to massively transfer and save water in time.

DISCUSSION AND CONCLUSIONS
The following conclusions can be drawn regarding the method, the tool and the case study: -The SDP_GAMS software is a valid tool to apply stochastic optimization techniques in multireservoir systems.It can be used to obtain optimal operating policies, which can be applied in a general way, or to assess optimal decisions in response to specific time series of inflows.-The use of stochastic optimization methods allow the decision-makers to be provided with possible-to-be assessments, whereas the perfect foresight turns the results of the deterministic optimization into something impossible to obtain in real-time operation.-The incorporation of stochastic optimization techniques into real-time decision-making can be encouraged by generalized software packages like SDP_GAMS spreading its use.The SDP methodology takes into account the uncertainty concerning future flows.The main advantages of the SDP_GAM tool are: (a) the friendly graphical user interface (in MS Excel), which make it unnecessary to operate within the GAMS environment, although GAMS must be installed and be fully operative to work; (b) its generalized-purpose character, being possible to solve optimization problems in different water resources systems without the need to readapt the code; (c) the possibility of obtaining optimal policies in the form of tables and optimal decisions in response to specific inflow time series; and (d) its modular package that saves time of execution, adapts its structure to the user's needs, and allows its connection with other software packages.However, as with all software and methodology, it has several drawbacks, with the curse of dimensionality being the main one.The tool is suitable for solving water resources systems from one to three reservoirs without noticeable simplifications, and larger ones using aggregation techniques.
Future planned further developments of SDP_GAMS include improvements in the Excel interface, and mainly to overcome of the curse of dimensionality that prevent its usage in larger systems by resorting to stochastic dual dynamic programming (Tilmant and Kelman 2007).More elements for the simulation of water resources systems will be added in order to better simulate the complexity of real water resources systems, like for example the simulation of stream-aquifer interaction using eigenvalue and embedded multireservoir approaches (Pulido-Velazquez et al. 2005).Further planned extended applications are the exploration of climate change effects in water resources systems and adaptation, and coupled water quantity-quality analysis.

Fig. 1
Fig.1Mijares River water resources system introduced in SDP_GAMS.

Fig. 2
Fig. 2 Comparison between yearly benefits obtained with stochastic and deterministic optimization and simulation.

Table 1
Comparison between mean benefits obtained with stochastic and deterministic optimization and simulation.