# Demand Response Optimization Using Particle Swarm Algorithm Considering Optimum Battery Energy Storage Schedule in a Residential House

^{*}

## Abstract

**:**

## 1. Introduction

- (1)
- To perform DR without any contract with the DR service provider—this presented methodology allows the user to perform DR actions without any connection with DR services provider. The consumer is provided with independent management that approaches the several resources capabilities and contributions for the minimization of bought energy from the grid.
- (2)
- The implementation of PSO which is a very simple metaheuristic to implement, open access, multiplatform (Windows, MacOS, Linux, etc.), executable from an Arduino/Raspberry and also is the cheapest implementation option. Referring to the presented solution in [16], which uses a CPLEX solver for MATLAB/TOMLAB platform, the implementation of the PSO is a much affordable solution, once that MATLAB and TOMLAB are non-open access. PSO can be implemented in an open access environment and can be executed in free simple platforms, such as Python.
- (3)
- The proposed methodology represents an optimization problem that can considerably improve the consumer’s energy savings—the combined use of resources (PV production, storage capacity, and loads flexibility) allows for a significant reduction in daily operation costs. The optimal solution obtained by PSO has a daily cost of 3.28 €, while an operation without PV production, storage capacity and loads flexibility has a cost of 16.83 € per day, which is five times higher than PSO result for best scenario. If one considers a base scenario that was obtained by using a simple management mechanism considering the PV production and storage capacity, the daily cost is 9.33 €, which is three times higher than PSO result for the best scenario. The assessment of PSO can be verified in the comparison of the base scenario and the optimized base scenario with the PSO. The daily costs with PSO decreases 1.38 €.

## 2. Proposed Methodology

## 3. Problem Formulation

## 4. Particle Swarm Optimization

Algorithm 1. PSO pseudocode. |

INITIALIZESet control parameters ${w}^{max}$,${w}^{min}$,${c}_{1}^{max}$,${c}_{1}^{min}$,${c}_{2}^{max},$${c}_{2}^{min}$, ${j}^{max}$, and ${i}^{max}$. Create an initial Pop (Equation (21)) and initial velocities. IF Direct repair is used THENApply direct repair to unfeasible individuals END IFEvaluate the fitness of Pop (Equation (25)). Create a ${P}_{best}$ vector for every particle. Create $\mathrm{a}{G}_{best}$ vector of the swarm. FOR $i$ = 1 to ${i}^{max}$ FOR $j$ = 1 to ${j}^{max}$Velocity update (Equation (13)) Position update (Equation (14)) Update ${w}_{i}$, $c{1}_{i}$ and $c{2}_{i}$ (Equations (15)–(17)) Verify boundary constraints for ${P}^{bat}$ (Equation (9))and ${X}^{cut}$ (Equation (10)) IF Boundary constraints are violated THENApply boundary control (Equation (22)) END IFVerify boundary constraints for ${E}^{stor}$ (Equation (8)) and ${P}^{bat}$ (Equation (9)) IF Boundary constraints are violated THENApply direct repair (Equations (23) and (24)) END IFEvaluate fitness of $\overrightarrow{x}$ (Equation (25)). Verify boundary constraints for ${P}^{grid}$ (Equation (6)) IF ${P}^{grid}$ is out of limits THENApply penalty function (Equation (26)) Update fitness value (Equation (25)) END IFUpdate ${P}_{best}$ vector for $i$ particle. END FORUpdate ${G}_{best}$ vector of the swarm. END FOR |

## 5. Case Study

## 6. Results

## 7. Conclusions

## Author Contributions

## Funding

## Conflicts of Interest

## Glossary/Nomenclature

Abbreviations | |

AI | Artificial Intelligence |

DR | Demand Response |

DG | Distributed Generation |

ESS | Energy Storage System |

LP | Linear Programming |

MATLAB | Matrix Laboratory |

MILP | Mixed-integer Linear Programming |

MINLP | Mixed-integer Nonlinear Programming |

NLP | Nonlinear Programing |

PSO | Particle Swarm Optimization |

PV | Photovoltaic |

RESs | Renewable Energy Sources |

SET | Strategic Energy Technology |

Indices | |

$b$ | Battery unit |

$n$ | Dimension |

$i$ | Iteration |

$l$ | Load unit |

$j$ | Particle |

$t$ | Period |

$p$ | Photovoltaic unit |

Parameters | |

${C}_{t}^{gridin}$ | Cost of buying electricity to the grid |

${C}_{t}^{gridout}$ | Cost of selling electricity to the grid |

${W}_{l,t}^{cut}$ | Cut weight of load |

$DCP$ | Daily contracted power cost |

$xl{b}^{j}$ | Lower bond for ${\overrightarrow{x}}^{j}$ |

${P}_{t}^{gridmax}$ | Maximum limit for ${P}_{t}^{grid}$ |

${i}^{max}$ | Maximum number of iterations |

${j}^{max}$ | Maximum numbers of particles |

${P}_{l,t}^{cutmax}$ | Maximum value for cut load |

${P}_{b,t}^{chmax}$ | Maximum value for energy charge |

${P}_{b,t}^{dchmax}$ | Maximum value for energy discharge |

${c}_{2}^{max}$ | Maximum value for global acceleration coefficient |

${w}^{max}$ | Maximum value for inertia weight |

${c}_{1}^{max}$ | Maximum value for personal acceleration coefficient |

${E}_{b,t}^{stormax}$ | Maximum value of accumulated energy in battery |

${P}_{t}^{gridmin}$ | Minimum limit for ${P}_{t}^{grid}$ |

${c}_{2}^{min}$ | Minimum value for global acceleration coefficient |

${w}^{min}$ | Minimum value for inertia weight |

${c}_{1}^{min}$ | Minimum value for personal acceleration coefficient |

$\Delta t$ | Multiplicative factor related with the time to calculate energy |

$B$ | Number of batteries |

$L$ | Number of controllable loads |

$T$ | Number of Periods |

$\rho $ | Penalty value |

${P}_{p,t}^{PV}$ | Photovoltaic production |

$xu{b}^{j}$ | Upper bond for ${\overrightarrow{x}}^{j}$ |

${P}_{t}^{load}$ | Value of load |

Variables | |

${I}_{t}^{gridin}$ | Binary variable for control the flow direction |

${P}_{l,t}^{cut}$ | Cut power of load |

${X}_{l,t}^{cut}$ | Decision binary variable to active the cut of loads |

${P}_{b,t}^{bat}$ | Energy charged or discharged by battery |

$f\left(\overrightarrow{x}\right)$ | Fitness function |

${f}^{\prime}\left(\overrightarrow{x}\right)$ | Fitness function with penalty |

${P}_{t}^{grid}$ | Flow of energy between household and grid |

${P}_{best}^{j}$ | Historical best position |

${w}_{i}^{j}$ | Inertia weight |

$pf\left(\overrightarrow{x}\right)$ | Penalty function |

$c{1}_{i}^{j}$ and $c{2}_{i}^{j}$ | Personal and global acceleration coefficients |

${G}_{best}$ | Population historical best position |

${\overrightarrow{x}}_{i}^{j}$ | Position vector |

${E}_{b,t}^{stor}$ | State of the battery |

$r{1}_{i}^{j}$ and $r{2}_{i}^{j}$ | Uniform distribution random numbers |

${\overrightarrow{v}}_{i}^{j}$ | Velocity vector |

## References

- European Union. The Strategic Energy Technology (SET) Plan; European Union: Brussels, Belgium, 2017. [Google Scholar]
- Parag, Y.; Sovacool, B.K. Electricity market design for the prosumer era. Nat. Energy
**2016**, 1, 16032. [Google Scholar] [CrossRef] [Green Version] - Bhandari, B.; Lee, K.-T.; Lee, G.-Y.; Cho, Y.-M.; Ahn, S.-H. Optimization of hybrid renewable energy power systems: A review. Int. J. Precis. Eng. Manuf. Technol.
**2015**, 2, 99–112. [Google Scholar] [CrossRef] [Green Version] - Roldán-Blay, C.; Escrivá-Escrivá, G.; Roldán-Porta, C. Improving the benefits of demand response participation in facilities with distributed energy resources. Energy
**2019**, 169, 710–718. [Google Scholar] [CrossRef] - Paterakis, N.G.; Erdinç, O.; Catalão, J.P.S. An overview of Demand Response: Key-elements and international experience. Renew. Sustain. Energy Rev.
**2017**, 69, 871–891. [Google Scholar] [CrossRef] - Neves, D.; Silva, C.A. Optimal electricity dispatch on isolated mini-grids using a demand response strategy for thermal storage backup with genetic algorithms. Energy
**2015**, 82, 436–445. [Google Scholar] [CrossRef] - Jordehi, A.R. Optimisation of demand response in electric power systems, a review. Renew. Sustain. Energy Rev.
**2019**, 103, 308–319. [Google Scholar] [CrossRef] - European Commission. Benchmarking Smart Metering Deployment in the EU-27 with a Focus on Electricity; European Commission: Brussels, Belgium, 2014. [Google Scholar]
- Nan, S.; Zhou, M.; Li, G. Optimal residential community demand response scheduling in smart grid. Appl. Energy
**2018**, 210, 1280–1289. [Google Scholar] [CrossRef] - Zhang, D.; Shah, N.; Papageorgiou, L.G. Efficient energy consumption and operation management in a smart building with microgrid. Energy Convers. Manag.
**2013**, 74, 209–222. [Google Scholar] [CrossRef] - Pina, A.; Silva, C.; Ferrão, P. The impact of demand side management strategies in the penetration of renewable electricity. Energy
**2012**, 41, 128–137. [Google Scholar] [CrossRef] - Nwulu, N.I.; Xia, X. Optimal dispatch for a microgrid incorporating renewables and demand response. Renew. Energy
**2017**, 101, 16–28. [Google Scholar] [CrossRef] - Alipour, M.; Zare, K.; Abapour, M. MINLP Probabilistic Scheduling Model for Demand Response Programs Integrated Energy Hubs. IEEE Trans. Ind. Inform.
**2018**, 14, 79–88. [Google Scholar] [CrossRef] - Zhou, X.; Shi, J.; Tang, Y.; Li, Y.; Li, S.; Gong, K. Aggregate Control Strategy for Thermostatically Controlled Loads with Demand Response. Energies
**2019**, 12, 683. [Google Scholar] [CrossRef] - Yao, Y.; Zhang, P.; Chen, S. Aggregating Large-Scale Generalized Energy Storages to Participate in the Energy and Regulation Market. Energies
**2019**, 12, 1024. [Google Scholar] [CrossRef] - Spínola, J.; Faria, P.; Vale, Z. Photovoltaic inverter scheduler with the support of storage unit to minimize electricity bill. Adv. Intell. Syst. Comput.
**2017**, 619, 63–71. [Google Scholar] - Hussain, B.; Khan, A.; Javaid, N.; Hasan, Q.; Malik, S.A.; Ahmad, O.; Dar, A.; Kazmi, A. A Weighted-Sum PSO Algorithm for HEMS: A New Approach for the Design and Diversified Performance Analysis. Electronics
**2019**, 8, 180. [Google Scholar] [CrossRef] - Shen, J.; Jiang, C.; Li, B. Controllable Load Management Approaches in Smart Grids. Energies
**2015**, 8, 11187–11202. [Google Scholar] [CrossRef] [Green Version] - Kong, D.-Y.; Bao, Y.-Q.; Hong, Y.-Y.; Wang, B.-B.; Huang, H.-B.; Liu, L.; Jiang, H.-H. Distributed Control Strategy for Smart Home Appliances Considering the Discrete Response Characteristics of the On/Off Loads. Appl. Sci.
**2019**, 9, 457. [Google Scholar] [CrossRef] - Jordehi, A.R. A review on constraint handling strategies in particle swarm optimisation. Neural Comput. Appl.
**2015**, 26, 1265–1275. [Google Scholar] [CrossRef] - Faria, P.; Vale, Z.; Soares, J.; Ferreira, J. Demand Response Management in Power Systems Using Particle Swarm Optimization. IEEE Intell. Syst.
**2013**, 28, 43–51. [Google Scholar] [CrossRef] [Green Version] - Shehzad Hassan, M.A.; Chen, M.; Lin, H.; Ahmed, M.H.; Khan, M.Z.; Chughtai, G.R. Optimization Modeling for Dynamic Price Based Demand Response in Microgrids. J. Clean. Prod.
**2019**, 222, 231–241. [Google Scholar] [CrossRef] - Aghajani, G.R.; Shayanfar, H.A.; Shayeghi, H. Demand side management in a smart micro-grid in the presence of renewable generation and demand response. Energy
**2017**, 126, 622–637. [Google Scholar] [CrossRef] - Hu, M.; Xiao, F. Price-responsive model-based optimal demand response control of inverter air conditioners using genetic algorithm. Appl. Energy
**2018**, 219, 151–164. [Google Scholar] [CrossRef] - Qian, L.P.; Wu, Y.; Zhang, Y.J.A.; Huang, J. Demand response management via real-time electricity price control in smart grids. Smart Grid Netw. Data Manag. Bus. Model.
**2017**, 169–192. [Google Scholar] - Lezama, F.; Sucar, L.E.; de Cote, E.M.; Soares, J.; Vale, Z. Differential evolution strategies for large-scale energy resource management in smart grids. In Proceedings of the Genetic and Evolutionary Computation Conference Companion on GECCO ’17, Berlin, Germany, 15–19 July 2017; ACM Press: New York, New York, USA, 2017; pp. 1279–1286. [Google Scholar]
- Eberhart, R.; Kennedy, J. A new optimizer using particle swarm theory. In Proceedings of the Sixth International Symposium on Micro Machine and Human Science (MHS’95), Nagoya, Japan, 4–6 October 1995; pp. 39–43. [Google Scholar]
- Faia, R.; Pinto, T.; Vale, Z.; Corchado, J.M. Strategic Particle Swarm Inertia Selection for the Electricity Markets Participation Portfolio Optimization Problem. Appl. Artif. Intell.
**2018**, 32, 1–23. [Google Scholar] [CrossRef] - ERSE Tarifas e Precos Para a Energia Eletrica e Outros Servicos em 2019. Available online: http://www.erse.pt/pt/electricidade/tarifaseprecos/2019/Documents/Diretiva ERSE 13-2018 (Tarifas e Preços EE 2019).pdf (accessed on 6 February 2019).
- Jozi, A.; Pinto, T.; Praca, I.; Vale, Z. Day-ahead forecasting approach for energy consumption of an office building using support vector machines. In Proceedings of the 2018 IEEE Symposium Series on Computational Intelligence (SSCI), Bangalore, India, 18–21 November 2018; pp. 1620–1625. [Google Scholar]
- Jozi, A.; Pinto, T.; Praça, I.; Vale, Z. Decision Support Application for Energy Consumption Forecasting. Appl. Sci.
**2019**, 9, 699. [Google Scholar] [CrossRef]

Parameter | Energy (€/kWh) | Contracted Power (€/Day) | ||
---|---|---|---|---|

Peak | Intermediate | Off-Peak | ||

Buy from grid | 0.2738 | 0.1572 | 0.1038 | 0.5258 |

Periods | 10.30 h–13 h 19.30 h–21 h | 08 h–10.30 h 13 h–19.30 h, 21 h–22 h | 22 h–02 h 02 h–08 h | |

Sell to grid | 0.1659 * | − | ||

DR weight | 0 | 0.2 | 0.4 |

Parameters | Symbol | Value | Units |
---|---|---|---|

Maximum power injected to grid | $-{P}_{t}^{gridmin}$ | −5.1 | kW |

Maximum power required from grid | ${P}_{t}^{gridmax}$ | 1000 | kW |

Maximum power accumulated in battery | ${E}_{b,t}^{stormax}$ | 12 | kW |

Maximum energy of battery discharge | $-{P}_{b,t}^{dchmax}$ | −6/4 | kWh |

Maximum energy of battery charge | ${P}_{b,t}^{chmax}$ | 6/4 | kWh |

Total Periods | $T$ | 96 | − |

Total of controllable loads | $L$ | 3 | − |

Total of batteries | $B$ | 1 | − |

Total of PV units | $P$ | 2 | − |

Adjust parameter | $\Delta t$ | 4 * | − |

Parameters | Symbol | Value |
---|---|---|

Population size | ${j}^{max}$ | 500 |

Maximum numbers of iterations | ${i}^{max}$ | 500 |

Maximum inertia weight | ${w}^{max}$ | 0.4 |

Minimum inertia weight | ${w}^{min}$ | 0.9 |

Maximum cognitive weight | ${c}_{1}^{max}$ | 1.5 |

Minimum cognitive weight | ${c}_{1}^{min}$ | 0.5 |

Maximum global weight | ${c}_{2}^{max}$ | 1.5 |

Minimum global weight | ${c}_{2}^{min}$ | 0.5 |

Number of evaluations | − | 250,000 |

Number of trials | − | 30 |

Resources Combination Scenarios | CPLEX | PSO | |||
---|---|---|---|---|---|

Min | Mean | STD | |||

Values optimized | PV + Bat + DR | 3.1874 | 3.2771 | 3.3381 | 0.0469 |

PV + Bat | 7.8652 | 7.9454 | 8.0595 | 0.1169 | |

PV | 8.8478 | 8.8478 | 8.8478 | 0 | |

Nonoptimized values | PV + Bat | 9.3298 | |||

Without resources | 16.8570 |

Scenario | Method | Equation (1) | Equation (2) | Equation (3) | Daily Costs (€) | Daily Revenues (€) | Monthly Costs (€) |
---|---|---|---|---|---|---|---|

PV + Bat + DR | CPLEX | 3.1874 | 3.1874 | 0 | 6.9380 | 3.7505 | 95.6233 |

PV + Bat + DR | PSO * | 3.2771 | 3.2771 | 0 | 6.0565 | 2.7794 | 98.3140 |

PV + Bat | PSO * | 7.9922 | 7.9922 | 0 | 8.5136 | 0.5683 | 239.7661 |

PV + Bat | Nonoptimized | 9.3298 | 9.3298 | 0 | 9.3298 | 0 | 279.8928 |

© 2019 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Faia, R.; Faria, P.; Vale, Z.; Spinola, J.
Demand Response Optimization Using Particle Swarm Algorithm Considering Optimum Battery Energy Storage Schedule in a Residential House. *Energies* **2019**, *12*, 1645.
https://doi.org/10.3390/en12091645

**AMA Style**

Faia R, Faria P, Vale Z, Spinola J.
Demand Response Optimization Using Particle Swarm Algorithm Considering Optimum Battery Energy Storage Schedule in a Residential House. *Energies*. 2019; 12(9):1645.
https://doi.org/10.3390/en12091645

**Chicago/Turabian Style**

Faia, Ricardo, Pedro Faria, Zita Vale, and João Spinola.
2019. "Demand Response Optimization Using Particle Swarm Algorithm Considering Optimum Battery Energy Storage Schedule in a Residential House" *Energies* 12, no. 9: 1645.
https://doi.org/10.3390/en12091645