Highlights
- •GP CC-OPF hybrid approach for chance-constrained OPF is proposed.
- •A sparse Gaussian process model is considered for the trade-off between accuracy and complexity.
- •The proposed approach does not require information about the topology and parameters of the electrical grid.
- •GP CC-OPF can help the power system operator to plan generation dispatch under injection uncertainties.
Abstract
The Gaussian Process (GP) based Chance-Constrained Optimal Power Flow (CC-OPF) is an open-source Python code developed for solving economic dispatch (ED) problem in modern power grids. In recent years, integrating a significant amount of renewables into a power grid causes high fluctuations and thus brings a lot of uncertainty to power grid operations. This fact makes the conventional model-based CC-OPF problem non-convex and computationally complex to solve. The developed tool presents a novel data-driven approach based on the GP regression model for solving the CC-OPF problem with a trade-off between complexity and accuracy. The proposed approach and developed software can help system operators to effectively perform ED optimization in the presence of large uncertainties in the power grid.
Keywords
Code metadata
Tabled
1
Current code version | |
Permanent link to code/repository used for this code version | https://github.com/SoftwareImpacts/SIMPAC-2023-55 |
Permanent link to Reproducible Capsule | https://codeocean.com/capsule/9532852/tree/v1 |
Legal Code License | MIT |
Code versioning system used | none |
Software code languages, tools, and services used | Python |
Compilation requirements, operating environments & dependencies | NumPy, Pandas, SciPy, CasADi |
If available Link to developer documentation/manual | |
Support email for questions | [email protected] |
1. Introduction
The optimal power flow (OPF) plays an important role for the secure and economic operation of the power grids. As an optimization tool, the OPF is typically used to solve the Economic dispatch (ED) problem by finding the optimal output of the controllable generators with the lowest possible cost that meets the load and physical constraints of the grid. However, the OPF is a complex non-linear problem with many constraints that can be hard to solve. In addition, the rapid integration of renewable energy resources (RES) with intermittent outputs propagates uncertainty through the grid and thus leads to a higher degree of complexity in power grid operations. To take into account the impacts of uncertainty within the OPF, the researchers have recently proposed several stochastic approaches such as robust optimization [
[1]
], probabilistic OPF [2
, 3
], and Chance-Constrained (CC) OPF [4
, 5
]. Robust optimization often leads to conservative solutions, while probabilistic OPF is difficult to implement in practice. The CC-OPF implies satisfying probability constraints with a given acceptable violation probability, balancing operating costs and security in the power grid in that way.In this paper, we put focus on the practical CC-OPF approach. However, model-based CC-OPF is notoriously hard to solve for the full non-linear alternating current (AC) power flow model. To overcome this problem, the novel data-driven approach based on Gaussian Process (GP) regression model is proposed [
6
, 7
]. The proposed approach uses a hybrid GP model by combining a linear model, based on the direct current (DC) power flow, with the data-driven estimation of the residuals between DC and AC power flow models. Thus, we provide a more robust and accurate GP CC-OPF. To provide a general and scalable approach, applicable to a larger power grid, we have added a sparse GP option to select the most important data in the feature space for hybrid GP estimation. Accordingly, the computational complexity is significantly reduced without compromising the accuracy of the solution.Finally, we provide Python code to simulate and run the proposed GP CC-OPF approach. The goal of the software is to provide a tool for performing stochastic OPF under uncertain generation resources that can be used both by the industry and academia.
2. Description of GP CC-OPF
The GP CC-OPF approach has been implemented in Python. The general scheme of the GP CC-OPF approach is shown in Fig. 1. Code details are presented below.

Fig. 1General scheme of GP CC-OPF approach.

Fig. 2Cost function values, probability of a failure and CPU time for IEEE9 (red) and IEEE39 (blue) systems. (For interpretation of the references to color in this figure legend, the reader is referred to the web version of this article.)
2.1 Data preparation
There are two ways to provide labeled data for training the Linear and GP regression models. The first option is using synthetic data by modeling the power grid. This tool uses pandapower [
[8]
] Python library for simulating IEEE9 and IEEE39-bus power grids. The second option is to use data from the real power grid provided by the system operator.In both cases, the GP model is learned on standardized data. The data sent to the GP model consists of the residuals between datasets obtained from the AC and DC power flow models. The linear model illustrates the ordinary least squares Linear Regression model provided in scikit-learn library [
[9]
], and it uses data generated from a linear DC power flow model.The SLSQP [
[10]
] non-linear solver is used to minimize the objective function and find the optimal hyperparameters of the GP model. In the case of sparse GP approximation, variational learning is applied to find inducing points and better approximate marginal likelihood [[11]
].2.2 GP CC-OPF setup
The GP CC-OPF approach presents the conventional chance-constrained optimization problem with an integrated data-driven machine learning model, as shown in Fig. 1. The data-driven model replaces the standard non-linear AC power flow equations. To make the task more accurate, the data-driven model consists of a combination of two models: a linear model and an additive GP model. Considering this, hybrid GP model, we make the approximated model more robust and in the worst case, the hybrid GP model will be equal to the standard DC convex power flow model. Moreover, GP can fit any smooth non-linear function very well and thus avoid some local minima. This fact can simplify the solution of the CC-OPF problem by ensuring that the engineering constraints are reliably feasible for any uncertainty realization.
The advantage of the proposed hybrid GP CC-OPF approach is that there is no need to know the grid configuration and parameters. Thus, problems with uncertain or unreliable power system parameters encountered by conventional model-based algorithms are avoided. This makes the proposed data-driven approach more robust. As input data, it is enough for the user to provide the active power of the load and RES, as well as their standard deviations as uncertainty factors. The input uncertainties are propagated to output variables and their impact is modeled using the first-order Taylor approximation (TA1) by linearizing the data-driven function at the decision point. The active power and uncertainty factor of the controllable generators are optimized according to the cost function and participation factor, which are also considered as inputs in the data-driven model.
The algorithm is implemented in the non-linear optimization framework CasADi [
[12]
] using the available IPOPT solver [[13]
] to solve the optimization problem.2.3 Outputs of the tool
Based on the results of the GP CC-OPF and the developed tool, the user obtains the optimal solution of controllable generators with the optimal cost. Moreover, the tool provides output variables and their propagated standard deviations, such as voltage magnitude at non-controllable buses, reactive power at controllable buses and apparent power flow in the lines of the grid. Accordingly, the user can monitor whether the solution is feasible and accurate.
2.4 Approach validation
For performance evaluation, we compared the proposed data-driven approach with two alternative sample-based reformulations of the CC-OPF based on the scenario approach (SA) with a different number of scenarios and the Monte Carlo (MC) simulation (full-resources and base-case). In Fig. 2, we present the values of the cost function, CPU time, and probability of failure for both IEEE9 and IEEE39-bus systems. The simulations are performed with the acceptable violation probabilities of all constraints set to 2.5%. The numerical evaluations from Fig. 2 show that the proposed hybrid GP CC-OPF provides a trade-off between cost and computational effort without sacrificing the accuracy of the given violation limits.
3. Software impacts
At the moment, there is no developed software in the industry that solves an uncertainty-aware OPF. System operators still use deterministic OPF solutions without considering generation uncertainties. As for the scientific community, a significant amount of work has been done in the field of stochastic OPF, but the algorithms proposed in the literature are typically not available to the public. Accordingly, researchers face difficulties in comparing the performance of newly proposed methods with the existing work. Moreover, it requires additional effort to re-implement the existing algorithms, as we have done in our recent work [
6
, 7
]. Because of these facts, the proposed open-source code can have a significant impact on both industry and academia.In future versions, we plan to provide this tool with a friendly user interface that is easy to use. In the current version, the proposed tool works with IEEE9 and 39-bus grids. Our next task will be to make the existing tool universal for working with any scale of the system.
We firmly believe that the proposed data-driven approach in the form of a public code will have a positive impact on future research in the field of stochastic OPF and motivate engineers to apply it in the industry.
Declaration of Competing Interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.
Acknowledgments
Software code implementation was supported by the Russian Science Foundation grant No 22-19-00773, https://rscf.ru/project/22-19-00773/.
The authors M. Mitrovic, P. Vorobev and V. Terzija acknowledge support from the AMPaC Megagrant project, supported by The Ministry of Science and Higher Education of Russian Federation
, under Grant Agreement No 075-10-2021-067, Grant identification code 000000S707521QJX0002.
References
- Distributionally-robust chance constrained and interval optimization for integrated electricity and natural gas systems optimal power flow with wind uncertainties.Appl. Energy. 2019; 252113420
- Probabilistic optimal power flow considering dependences of wind speed among wind farms by pair-copula method.Int. J. Electr. Power Energy Syst. 2017; 84: 296-307
- Importance sampling approach to chance-constrained DC optimal power flow.2021 ([Online]. Available: https://arxiv.org/abs/2208.14814)
- Chance constraints for improving the security of AC optimal power flow.IEEE Trans. Power Syst. 2019; 34: 1908-1917
- Chance-constrained optimal power flow with non-parametric probability distributions of dynamic line ratings.Int. J. Electr. Power Energy Syst. 2020; 114105389
- Data-driven stochastic AC-OPF using Gaussian processes.2022 ([Online]. Available: https://arxiv.org/abs/2207.10781)
- Data-driven chance constrained AC-OPF using hybrid sparse Gaussian processes.2022 ([Online]. Available: https://arxiv.org/abs/2208.14814)
- Pandapower—An open-source python tool for convenient modeling, analysis, and optimization of electric power systems.IEEE Trans. Power Syst. 2018; 33: 6510-6521
- Scikit-learn: Machine learning in Python.J. Mach. Learn. Res. 2011; 12: 2825-2830
- A software package for sequential quadratic programming.Forsch.- Deutsche Forsch.- Und Versuchsanstalt Fur Luft- Und Raumfahrt. 1988;
- Variational learning of inducing variables in sparse Gaussian processes.in: Artificial Intelligence and Statistics. PMLR, 2009: 567-574
- CasADi: A software framework for nonlinear optimization and optimal control.Math. Program. Comput. 2019; 11: 1-36
- On the implementation of an interior-point filter line-search algorithm for large-scale nonlinear programming.Math. Program. 2006; 106: 25-57
Article info
Publication history
Published online: March 15, 2023
Accepted:
February 27,
2023
Received:
February 8,
2023
Footnotes
The code (and data) in this article has been certified as Reproducible by Code Ocean: (https://codeocean.com/). More information on the Reproducibility Badge Initiative is available at https://www.elsevier.com/physical-sciences-and-engineering/computer-science/journals.
Identification
Copyright
© 2023 The Author(s). Published by Elsevier B.V.
User license
Creative Commons Attribution (CC BY 4.0) | How you can reuse
Elsevier's open access license policy

Creative Commons Attribution (CC BY 4.0)
Permitted
- Read, print & download
- Redistribute or republish the final article
- Text & data mine
- Translate the article
- Reuse portions or extracts from the article in other works
- Sell or re-use for commercial purposes
Elsevier's open access license policy