Skip to main content

Part of the book series: Springer Optimization and Its Applications ((SOIA,volume 149))

Abstract

We present a unified method, based on convex optimization, for managing the power produced and consumed by a network of devices over time. We start with the simple setting of optimizing power flows in a static network, and then proceed to the case of optimizing dynamic power flows, i.e., power flows that change with time over a horizon. We leverage this to develop a real-time control strategy, model predictive control, which at each time step solves a dynamic power flow optimization problem, using forecasts of future quantities such as demands, capacities, or prices, to choose the current power flow values. Finally, we consider a useful extension of model predictive control that explicitly accounts for uncertainty in the forecasts. We mirror our framework with an object-oriented software implementation, an open-source Python library for planning and controlling power flows at any scale. We demonstrate our method with various examples. Appendices give more detail about the package, and describe some basic but very effective methods for constructing forecasts from historical data.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 19.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 29.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD 29.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

References

  1. R. Baldick. Applied Optimization: Formulation and Algorithms for Engineering Systems. Cambridge University Press, 2006.

    Book  Google Scholar 

  2. A. Bemporad. Model predictive control design: New trends and tools. In 45th IEEE Conference on Decision and Control, pages 6678–6683. IEEE, 2006.

    Google Scholar 

  3. D. Bertsekas. Nonlinear Programming. Athena Scientific, 3rd edition, 2016.

    Google Scholar 

  4. S. Boyd, E. Busseti, S. Diamond, R. Kahn, K. Koh, P. Nystrup, and J. Speth. Multi-period trading via convex optimization. Foundations and Trends in Optimization, 3(1):1–76, August 2017.

    Article  Google Scholar 

  5. S. Boyd and L. Vandenberghe. Convex Optimization. Cambridge University Press, 2004.

    Book  Google Scholar 

  6. S. Boyd and L. Vandenberghe. Introduction to Applied Linear Algebra – Vectors, Matrices, and Least Squares. Cambridge University Press, 2018.

    MATH  Google Scholar 

  7. M. Cain, R. O’Neill, and A. Castillo. History of optimal power flow and formulations. Federal Energy Regulatory Commission, pages 1–36, 2012.

    Google Scholar 

  8. J. Carpentier. Contribution à l’étude du dispatching économique. Bulletin de la Société Française des Electriciens, 3:431–447, 1962.

    Google Scholar 

  9. F. Clarke. Generalized gradients and applications. Transactions of the American Mathematical Society, 205:247–262, 1975.

    Article  MathSciNet  Google Scholar 

  10. G. Davison. Dividing load between units. Electrical World, 80(26):1385–1387, 1922.

    Google Scholar 

  11. S. Diamond and S. Boyd. CVXPY: A Python-embedded modeling language for convex optimization. Journal of Machine Learning Research, 17(83):1–5, 2016.

    MathSciNet  MATH  Google Scholar 

  12. J. Friedman, T. Hastie, and R. Tibshirani. The Elements of Statistical Learning. Springer, 2nd edition, 2008.

    Google Scholar 

  13. A. Fu, B. Narasimhan, and S. Boyd. CVXR: An R package for disciplined convex optimization. https://web.stanford.edu/~boyd/papers/cvxr_paper.html, 2017.

  14. M. Grant and S. Boyd. Graph implementations for nonsmooth convex programs. In V. Blondel, S. Boyd, and H. Kimura, editors, Recent Advances in Learning and Control, Lecture Notes in Control and Information Sciences, pages 95–110. Springer-Verlag Limited, 2008. http://stanford.edu/~boyd/graph_dcp.html.

  15. M. Grant and S. Boyd. CVX: Matlab software for disciplined convex programming, version 2.1. http://cvxr.com/cvx, March 2014.

  16. H. Happ. Optimal power dispatch – A comprehensive survey. IEEE Transactions on Power Apparatus and Systems, 96(3):841–854, 1977.

    Article  Google Scholar 

  17. C. Harris. Electricity Markets: Pricing, Structures and Economics. John Wiley & Sons, 2006.

    Book  Google Scholar 

  18. M. Kraning, E. Chu, J. Lavaei, and S. Boyd. Dynamic network energy management via proximal message passing. Foundations and Trends in Optimization, 1(2):73–126, 2014.

    Article  Google Scholar 

  19. J. Lavaei and S. Low. Zero duality gap in optimal power flow problem. IEEE Transactions on Power Systems, 27(1):92–107, 2012.

    Article  Google Scholar 

  20. W. Liu, J. Zhan, and C. Chung. A novel transactive energy control mechanism for collaborative networked microgrids. IEEE Transactions on Power Systems, early access, 2018.

    Google Scholar 

  21. J. Löfberg. YALMIP: A toolbox for modeling and optimization in MATLAB. In Proceedings of the IEEE International Symposium on Computer Aided Control Systems Design, pages 284–289, 2004.

    Google Scholar 

  22. S. Long, O. Marjanovic, and A. Parisio. Generalised control–oriented modelling framework for multi–energy systems. Applied Energy, 235:320–331, 2019.

    Article  Google Scholar 

  23. D. Luenberger. Microeconomic Theory. McGraw-Hill College, 1995.

    Google Scholar 

  24. T. Ma, J. Wu, L. Hao, H. Yan, and D. Li. A real–time pricing scheme for energy management in integrated energy systems: A Stackelberg game approach. Energies, 11(10):2858, 2018.

    Article  Google Scholar 

  25. J. Mattingley, Y. Wang, and S. Boyd. Receding horizon control: Automatic generation of high-speed solvers. IEEE Control Systems Magazine, 31(3):52–65, June 2011.

    Article  MathSciNet  Google Scholar 

  26. E. Munsing, J. Mather, and S. Moura. Blockchains for decentralized optimization of energy resources in microgrid networks. Available at https://escholarship.org/uc/item/80g5s6df, 2017.

  27. N. Padhy. Unit commitment – A bibliographical survey. IEEE Transactions on power systems, 19(2):1196–1205, 2004.

    Article  Google Scholar 

  28. A. Papavasiliou. Analysis of distribution locational marginal prices. IEEE Transactions on Smart Grid, 2017.

    Google Scholar 

  29. T. Rockafellar. Convex Analysis. Princeton University Press, 1997.

    MATH  Google Scholar 

  30. F. Schweppe, M. Caramanis, R. Tabors, and R. Bohn. Spot Pricing of Electricity. Kluwer Academic Publishers, 1988.

    Book  Google Scholar 

  31. R. Shumway and D. Stoffer. Time Series Analysis and its Applications. Springer, 4th edition, 2017.

    Google Scholar 

  32. M. Steinberg and T. Smith. Economy Loading of Power Plants and Electric Systems. J. Wiley & Sons, Inc., 1943.

    Google Scholar 

  33. J. Taylor. Convex Optimization of Power Systems. Cambridge University Press, 2015.

    Book  Google Scholar 

  34. M. Udell, K. Mohan, D. Zeng, J. Hong, S. Diamond, and S. Boyd. Convex optimization in Julia. SC14 Workshop on High Performance Technical Computing in Dynamic Languages, 2014.

    Google Scholar 

  35. W. Wood and B. Wollenberg. Power Generation, Operation, and Control. John Wiley & Sons, 2012.

    Google Scholar 

Download references

Acknowledgements

This research was partly supported by MISO energy; we especially thank Alan Hoyt and DeWayne Johnsonbaugh of MISO for many useful discussions.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Enzo Busseti .

Editor information

Editors and Affiliations

Appendices

Appendix 1: Forecasts

Forecasts or predictions of time series, such as loads or power availability of renewable generators, are critical components of the MPC formulation of Section 4 or the robust MPC formulation of Section 5. We have already noted that the forecasts do not need to be very good to enable MPC or robust MPC to yield good performance. Even simple forecasts of quantities, such as predicting that future values will simply be equal to the current value, can give reasonable MPC performance in some cases.

Time series modeling and forecasting is a well-studied problem in a variety of fields, such as statistics [12], machine learning, and econometrics [31]. These and many other references describe sophisticated forecasting techniques that can be used.

In this section we describe a simple method to forecast a scalar time series. Our simple model takes into account seasonal variations, both long and short term, in a baseline time series, that depends only on time. It also takes into account short-term deviations from the baseline, based on recent past deviations. Similar techniques can be applied to vector time series, either by separating them into their scalar components or by swapping the vector of model parameters with an appropriate matrix of parameters.

General Model Fitting Methods

The simplest method to fit a model from data uses basic least squares or regression [6]; more sophisticated methods based on convex optimization use loss functions and regularizers that give robust estimates or sparse parameters (i.e., regressor selection) [5, Chapter 6]. Much more sophisticated forecasts can be developed using advanced techniques like random forest models or neural networks [12]. We recommend starting with simple forecasts (even the constant one described above) and slowly increasing the complexity and sophistication of the forecast and evaluating the improvement (if any) on the control performance using MPC or robust MPC. In a similar way we recommend starting with least squares fitting techniques before moving to more sophisticated methods.

1.1 The Baseline-Residual Forecast

We consider a time series x t ∈R, where the index t = 1, 2, … represents time or period. We think of t as the current time; t − 1 then refers to the previous period, and t + 2 refers to the period after the next period. The series might represent the power availability of a renewable generator, or the power of a fixed load, with t representing, e.g., the hours or 5 min periods. At any time t we assume we have access to the current and past observations

$$\displaystyle \begin{aligned} x_t, x_{t-1}, x_{t-2}, \ldots \end{aligned}$$

and we are to make future predictions

$$\displaystyle \begin{aligned} \hat x_{t+1 | t}, \hat x_{t+2 | t}, \ldots, \hat x_{t+T-1| t}, \end{aligned}$$

where by \(\hat x_{t+\tau |t}\) we mean the prediction of the value at time t + τ, made at time t. (We use superscript \(\hat {\ }\) to denote a predicted, and not actual, value.) In the notation t + τ|t, the left-hand part t + τ refers to the time of the quantity being forecast; the right-hand part t refers to the time at which the forecast is made. We can interpret τ as the number of time periods into the future we forecast; for example, \(\hat x_{t+1|t}\) is called the one-step-ahead predictor or forecast. It is our prediction of the next value of the series, given what we know now.

Using our forecast notation, we can express the simple constant forecast as \(\hat x_{t+\tau |t}=x_t\). This predicts that all future values will be the same as the current value. While this is rarely a good forecast for a time series (unless the time series is very slowly changing) it can be adequate for MPC. In the next few subsections below we describe forecasts that are a bit more sophisticated than the constant forecast, and often work very well.

Baseline-Residual Decomposition and Forecast

We model the time series as the sum of two components: a seasonal baseline b t ∈R, which takes into account variations due to, e.g., hourly, daily, annual, and weekly seasonalities and periodicities, and a residual r t, which is the deviation from the baseline,

$$\displaystyle \begin{aligned} x_t = b_t + r_t, \quad t = 1, \ldots.\end{aligned} $$

The residual time series is also sometimes called the seasonally adjusted or baseline adjusted time series. It tells us how much larger or smaller the values are, compared to the baseline. We fit the baseline b t using some past or historical data, as explained below.

Our predictions have the form

$$\displaystyle \begin{aligned} \hat x_{t+\tau | t} = b_{t+\tau} + \hat r_{t+\tau | t},\end{aligned} $$

where \(\hat r_{t+\tau |t}\) is our prediction of the residual at time t + τ made at time t. We form these predictions of future residual values using simple regression, again on past and historical data. Note that the baseline component of the prediction only depends on t + τ, and not t, i.e., the baseline value depends only on the time t + τ of the predicted quantity, and not on the time t at which the forecast is made. The second term, our forecast of what the residual will be at time t + τ, does depend on t, the time of the forecast.

1.2 Seasonal Baseline

The baseline is meant to capture the variation of the time series due to time, typically, periodically repeating patterns. A simple model for the baseline is a sum of K sinusoids (i.e., Fourier terms),

$$\displaystyle \begin{aligned} b_t = \beta_0 + \sum_{k = 1}^{K} \alpha_k \sin (2 \pi t / P_k) + \beta_k \cos (2 \pi t / P_k),\end{aligned} $$

where P k are the periods. Typically we would use as periods the fundamental period P (e.g., 1 day, 1 year) and those associated with the first few harmonics, i.e., P∕2, P∕3, …. We fit the coefficients α k, β k, k = 1, …, K using simple least squares on historical data.

An example will illustrate the method. Suppose the time period is 15 min and we wish to model diurnal (24 h) and seasonal (annual) periodicities, with four harmonics each. We choose

$$\displaystyle \begin{aligned} P_1 = 96, \quad P_2 = 48, \quad P_3 = 24, \quad P_4 = 12,\end{aligned} $$

as the periods for diurnal variation, and

$$\displaystyle \begin{aligned} P_5 = 8766, \quad P_6 = 4383, \quad P_7 = 2101.5, \quad P_8 = 1095.75, \end{aligned}$$

for seasonal variation. (One solar year is roughly 365 days and 6 h, or 8766 periods of 15 min.) This baseline model would have 17 parameters (including β 0, the constant). If the time series is impacted by human or economic activity, we can also include weekly seasonality or a weekend/holiday term.

Note that the value of the baseline model can be found for any time, past or future, once the baseline model coefficients are fixed, since it is then a fixed function of time. We can, for example, evaluate the baseline load value, or renewable generation availability, at some specific time in the future. In some applications of MPC, the baseline model is good enough to provide good performance.

1.3 Auto-Regressive Residual Forecasts

Once we have the baseline forecast, we subtract it from our historical data to obtain the sequence of historical residuals, r t = x t − b t. This sequence is sometimes referred to as the baseline adjusted sequence. (For example, with an annual baseline, r t is called the seasonally adjusted time series.) Roughly speaking, r t contains the part of the sequence that is not explained by the periodicities.

To make forecasts of r t+1, …, r t+T−1 at time t, we use simple least squares regression based on the previous M values, x t, x t−1, …, x tM+1. Our model is

$$\displaystyle \begin{aligned} \hat r_{t+\tau|t} = \sum_{\tau' =0}^{M-1} \gamma_{\tau, \tau'} r_{t-\tau'}, \quad \tau = 1, \ldots, T-1,\end{aligned} $$

and we choose the (T − 1) × M matrix of model parameters \(\gamma _{\tau , \tau '}\) to minimize the mean square error on the historical data. These auto-regressive coefficients are readily interpretable: \(\gamma _{\tau ,\tau '}\) is the amount by which \(\hat r_{t+\tau |t}\) (our τ-step-ahead prediction) depends on \(r_{t-\tau '}\) (the value τ′ steps in the past).

We can fit the coefficients associated with the forecast \(\hat r_{t+\tau | t}\), i.e., \(\gamma _{\tau ,\tau '}\) for τ′ = 0, …, M − 1, separately for different values of τ. Each of these is a separate least squares fit or regression, based on historical data. We note here a common error made in forecasting. The bad method first builds a “one-step-ahead” forecast, which gives \(\hat r_{t+1|t}\). Then, to forecast two steps ahead, the bad method iterates the one-step-ahead forecast twice. This method of iterating a one-step-ahead forecast is more complicated, and produces far worse forecasts, compared to the method described above.

1.4 Forecasting

In summary, at time t we predict the future values of the time series as

$$\displaystyle \begin{aligned} \hat x_{t+\tau|t} = b_{t+\tau} + \sum_{\tau'=0}^{M-1} \gamma_{\tau, \tau'} (x_{t-\tau'} - b_{t-\tau'}), \quad \tau = 1, \ldots, T-1. \end{aligned}$$

This forecast depends on the baseline model coefficients, as well as the residual auto-regressive coefficients.

There are many useful extensions of the basic forecasting method described above. First, the baseline could form predictions based not just on the time, but also on other observable quantities, for example, weather. In this case the baseline is not known ahead of time; it depends on the values of the other observable quantities at that time. Another simple and useful extension is to project the forecast values onto some set of values that the quantity is known to have. For example, if we are forecasting a renewable generator power availability, which must lie between 0 and some upper limit (the capacity) P max, we clip our forecast value to lie within this range. (That is, we replace the forecast value with 0 if it is negative, and P max if it is larger than P max.)

While we have described the construction of the forecast as a two-step process, i.e., fitting a baseline, and then fitting an auto-regressive model for the residuals, the two steps can in fact be done at the same time. We simply fit a predictor of x t+τ for each τ, using a set of regressors that include current and previous values, the baseline basis functions, and indeed any other regressors that might help, e.g., weather or futures contract prices. (That approach would give a predictor very close, but not equal, to the one described here.) We have described the construction of the forecast as a two-step process because it is easy to interpret.

1.5 Generating Sample Trajectories

In the forecasting method described above, the goal is to come up with one estimate of the future of the time series. In this section we describe a simple method for generating a set of sample forecast trajectories

$$\displaystyle \begin{aligned} x_{t+\tau|t}^{(k)}, \quad k=1, \ldots, K. \end{aligned}$$

These sample trajectories can be used for robust MPC, as described in Section 5.4. They are also useful as a sanity check on our forecasting method. If the generated sample forecasts don’t look right, it casts some doubt on our forecasting method. If our forecasts look plausible, we gain confidence in our forecast method. The method we describe here works with any forecasting method, including even the simplest ones, such as forecasting the value as the current value, i.e., \(\hat x_{t+\tau |t} = x_t\).

We let e t ∈R T denote the vector of forecast errors for x t+τ|t, i.e.,

$$\displaystyle \begin{aligned} (e_t)_\tau = x_{t+\tau} - \hat x_{t+\tau|t}, \quad \tau = 0, \ldots, T-1. \end{aligned}$$

(For simplicity we index the vectors e t from 0 to T − 1.) We collect these forecast error vectors over a historical data set, and then fit these vectors with a Gaussian distribution \(\mathcal N(\mu ,\varSigma )\). The simplest method uses the empirical mean and covariance of e t over the historical data as μ and Σ, and in many cases, we can take μ = 0. More sophisticated methods for choosing μ and Σ involve adding a regularization term or fitting a low-rank model.

To generate K forecasts at time t, we sample K vectors \(e_t^{(k)}\), k = 1, …, K from \(\mathcal N(\mu ,\varSigma )\), and then form the sample forecasts as

$$\displaystyle \begin{aligned} \hat x_{t+\tau|t}^{(k)} = \hat x_{t+\tau|t} + e^{(k)}_\tau, \quad \tau = 0, \ldots, T-1, \quad k=1, \ldots, K. \end{aligned}$$

These samples are meant to be plausible guesses as what the next T − 1 values of the time series might be. Their average value is our forecast. We add to our forecast the simulated forecast errors that have the same mean and covariance of historically observed values.

1.6 Wind Farm Example

We consider a time series of the power output of a wind farm, in MW (which depends on the available wind force) on data by the National Renewable Energy Laboratory (NREL) for a site in West Texas. The code can be seen in the Python notebook at https://github.com/cvxgrp/cvxpower/blob/master/examples/WindForecast.ipynb. Observations are taken every 5 min, from January 2010 to December 2012. We use data from 2010 and 2011 to train the models, and data from 2012 for testing. Our model has a baseline component that uses four periodicities to model diurnal variation, and the other four to model annual variation. Our predictor uses an auto-regressive predictor of the residuals to the baseline (i.e., the seasonality-adjusted series) of size T = M = 288, i.e., it forecasts every 5 min power availability for the next 24 h, using data from the past 24 h. Finally, since the power output lies between 0 and 16 MW (the minimum and maximum power of the turbine), we project our forecast onto this interval.

Figure 15 shows the result of the forecast on a day in June 2012, which is in the test set. Figure 16 shows K = 3 generated sample trajectories, or scenarios, for the same day. At least to the eye, they look quite plausible.

Fig. 15
figure 15

Wind farm power availability example. Powers shown over 2 days, with the vertical bar representing the time the forecast is made. Top. True and baseline power. Middle. Residual and residual prediction. Bottom. True power and forecast

Fig. 16
figure 16

Wind farm power availability example, forecast and three generated scenarios

Appendix 2: Code Example for cvxpower

We show here the Python source code to construct and optimize the network of Section 2.5.2. We define objects for each load, generator, transmission line, net, and then combine them to formulate, and solve, the static optimal power flow problem. More examples (in the form of Python notebooks) can be seen in the “examples” folder of the software repository (at https://github.com/cvxgrp/cvxpower).

from cvxpower import * load1 = FixedLoad(power=50, name="load1") load2 = FixedLoad(power=100, name="load2") gen1 = Generator(power_max=1000, alpha=0.02, beta=30,     name="gen1") gen2 = Generator(power_max=100, alpha=0.2, beta=0,     name="gen2") line1 = TransmissionLine(power_max=50, name=’line1’) line2 = TransmissionLine(power_max=10, name=’line2’) line3 = TransmissionLine(power_max=50, name=’line3’) net1 = Net([load1.terminals[0], gen1.terminals[0],             line1.terminals[0], line2.terminals[0]],

    name = ’net1’) net2 = Net([load2.terminals[0], line1.terminals[1],             line3.terminals[0]], name = ’net2’) net3 = Net([gen2.terminals[0], line2.terminals[1],             line3.terminals[1]], name = ’net3’) network = Group([load1, load2, gen1, gen2,     line1, line2, line3],     [net1, net2, net3]) network.init_problem() network.optimize() network.results.summary()

The output is:

Terminal                  Power --------                  ----- load1[0]                  50.00 load2[0]                 100.00 gen1[0]                  -90.00 gen2[0]                  -60.00 line1[0]                  50.00 line1[1]                 -50.00 line2[0]                 -10.00 line2[1]                  10.00 line3[0]                 -50.00 line3[1]                  50.00 Net                       Price ---                       ----- net1                    33.6000 net2                   199.6002 net3                    24.0012 Device                  Payment ------                  ------- load1                   1680.00 load2                  19960.02 gen1                   -3024.00 gen2                   -1440.07 line1                  -8300.01 line2                    -95.99 line3                  -8779.95

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Springer Nature Switzerland AG

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Moehle, N., Busseti, E., Boyd, S., Wytock, M. (2019). Dynamic Energy Management. In: Velásquez-Bermúdez, J., Khakifirooz, M., Fathi, M. (eds) Large Scale Optimization in Supply Chains and Smart Manufacturing. Springer Optimization and Its Applications, vol 149. Springer, Cham. https://doi.org/10.1007/978-3-030-22788-3_4

Download citation

Publish with us

Policies and ethics