Implementation of the Optimization Problem for an Energy Management System
Total Page:16
File Type:pdf, Size:1020Kb
Final Examination MSc SENSE Implementation of the Optimization Problem for an Energy Management System MASTER THESIS Author: Manuel Ostertag Supervisor: Oriol Gomis Bellmunt Company: GreenPowerMonitor Handed in: June 2017 Escola Tècnica Superior d’Enginyeria Industrial de Barcelona Pg. 2 Master Thesis Implementation of the Optimization Problem for an Energy Management System Pg. 3 Review This master thesis project contributes to the development of an energy management system (EMS), whereby the thesis is part of a bigger project carried out by the Barcelona-based software company GreenPowerMonitor. The developed EMS coordinates the different components of a hybrid power plant by repeatedly solving an optimization problem over one day and computing the optimal setpoints of the components’ controllers for the next minutes. In the context of the EMS project, optimality is defined as maximizing the amount of used solar power while minimizing the battery losses for several future generation and consumption scenarios over the course of one day. This thesis project focuses on examining ways to improve the computational costs of solving the optimization problem that lies at the core of the EMS and to implement the optimization problem in C++ as a “first draft” on its way towards a final product. Thereby, an already existing EMS prototype on the basis of Matlab/GAMS embedded in a simulation environment modeling a hybrid power plant in Cobija (Bolivia) is utilized. This prototype is translated into the open source modelling environment Julia/JuMP. The solver used throughout most of the project is the commercial mixed-integer linear problem (MILP) solver CPLEX. However, it is shown that the open-source solver CBC can be a serious alternative, especially for smaller power plants than the example case Cobija. Test are conducted with the aim to qualitatively evaluate ways to keep the computation time of the solver within boundaries, while at the same time maintaining the quality of the results. As a measure of the EMS performance, the accumulated objective values over one day are compared. The conducted tests show, that setting a time limit to the solver, or extending the time to solve the problem, are good measures to keep the computation time within boundaries. The negative effects on the results are less pronounced than expected. Furthermore, the optimization problem is implemented in the CPLEX solver specific application programming interface (API) in C++. The new C++ prototype is able to reproduce the expected results. In a future project, the input and output data processing will need to be implemented and refined. Finally, an accumulated cost analysis is conducted that is able to show the economic utility of the EMS for a power plant operator. Pg. 4 Master Thesis Summary REVIEW _____________________________________________________ 3 SUMMARY ___________________________________________________ 4 1. GLOSSARY ______________________________________________ 7 2. INTRODUCTION ___________________________________________ 8 2.1. Motivation ....................................................................................................... 8 2.2. About GreenPowerMonitor ............................................................................ 9 2.3. Previous requirements ................................................................................. 10 2.4. Objectives and scope of the project ............................................................. 11 3. PROJECT FOUNDATIONS _________________________________ 14 3.1. The EMS project .......................................................................................... 14 3.1.1. Type of system ................................................................................................. 15 3.1.2. Stochastic model of uncertainty ....................................................................... 16 3.1.3. System stability ................................................................................................ 18 3.1.4. Mathematical model of the system ................................................................... 22 3.1.5. Existing scripts and the Simulink model ........................................................... 25 3.2. The theory behind solving MILPs ................................................................. 29 3.2.1. Branch and bound algorithm ............................................................................ 29 3.2.2. Cutting plane method ....................................................................................... 31 3.2.3. Other extensions and tools .............................................................................. 32 3.3. The underlying theory of solving LPs ........................................................... 33 3.3.1. Primal simplex method ..................................................................................... 34 3.3.2. Dual simplex method ....................................................................................... 37 3.4. Deployed modelling tools ............................................................................. 39 3.4.1. JuMP modeling language for mathematical optimization ................................. 39 3.4.2. CPLEX Concert technology – CPLEX’s C++ API............................................. 40 4. DECISION ON SOLVER ____________________________________ 42 4.1. Solver Tests ................................................................................................. 42 4.2. License considerations ................................................................................ 44 5. EMS IMPLEMENTATION IN JUMP ___________________________ 46 5.1. Implementation of the mathematical model ................................................. 48 5.2. Embedding the Julia script ........................................................................... 51 5.2.1. Embedding the OP for simulations ................................................................... 51 5.2.2. Embedding the OP for emulations ................................................................... 54 Implementation of the Optimization Problem for an Energy Management System Pg. 5 6. EXAMINATIONS FOR THE FINAL EMS IMPLEMENTATION ______ 56 6.1. Adapting the OP execution period ................................................................ 58 6.2. Enforcing the OP execution period ............................................................... 60 6.2.1. Setting a time limit in the CPLEX optimizer ..................................................... 60 6.2.2. Using previous results ..................................................................................... 61 6.2.3. Discussion and comparison ............................................................................ 61 6.3. Reducing the number of scenarios ............................................................... 62 6.4. Warm start / solver change........................................................................... 64 6.5. Modelling the problem as a LP instead of a MILP ........................................ 66 6.6. Conclusions .................................................................................................. 67 7. EMS IMPLEMENTATION IN C++ _____________________________ 70 7.1. Core EMS and testing environment ............................................................. 71 7.2. Input and output data format ........................................................................ 73 7.3. Visual Studio settings ................................................................................... 76 7.4. Program structure ......................................................................................... 77 7.4.1. LoadForecasts.cpp ......................................................................................... 77 7.4.2. Other external source files .............................................................................. 78 7.4.3. Main function ................................................................................................... 79 7.5. Test............................................................................................................... 82 8. COSTS OF THE PROJECT _________________________________ 84 CONCLUSIONS ______________________________________________ 88 APPENDIX __________________________________________________ 96 Pg. 6 Chapter 1 Glossary Pg. 7 1. Glossary EMS Energy Management System OP Optimization Problem PV Photovoltaic LP Linear Program/Problem MILP Mixed-Integer Linear Program/Problem API Application Programming Interface VS Microsoft Visual Studio xml Extensible Markup Language csv Comma-Separated Values PPC Power Plant Controller GPM GreenPowerMonitor UPC Universitat Politècnica de Catalunya Pg. 8 Chapter 2 2. Introduction The project presented in this master thesis is part of a bigger project to develop an energy management system (EMS) for the optimal operation of hybrid power plant in islanded power grids that contain a set of grid stabilizing diesel generators, a photovoltaic (PV) generator, and a storage system. The overlying project is initiated and supervised by GreenPowerMonitor (GPM) in Barcelona as a R&D project for the company. In the following, the reader is introduced into different aspects of this thesis project including its objectives. 2.1. Motivation Due to the falling prices of photovoltaic (PV) generators and batteries, many islanded power systems all over the world that have been powered by diesel generators, are