# Numerical Methods for Optimization Problems Arising in Energetic Districts

• Elisa Riccietti
• Stefania Bellavia
• Stefano Sello
Conference paper
Part of the Mathematics in Industry book series (MATHINDUSTRY, volume 26)

## Abstract

This paper deals with the optimization of energy resources management of industrial districts, with the aim of minimizing the customer energy bill. Taking into account real time information on energy needs and production and on energy market prices, a cost function is built that should be minimized. Here we focus on the solution of the arising nonlinear constrained optimization problem. We describe the two solvers that have been employed for its solution: a Sequential Linear Programming and a Particle Swarm Optimization.

## 1 Introduction

This paper is realized in collaboration with the research centre ‘Enel Ingegneria e Innovazione - Ricerca’ in Pisa, Italy and it is related to an Enel project devoted to the realization of a software tool for the numerical solution of optimization problems arising in energetic districts, [4]. An energetic district is a complex that comprises machines able to generate, absorb or accumulate energy and that is interlaced with the electrical grid with which it can exchange energy. Different machines can be part of a district: generators (electrical, photovoltaic), accumulators, electrical or thermal loads.

Enel research centre aim is to develop a software tool able to find the best asset of the machines in a district, i.e. the one that guarantees the lowest expenses for the district management. The software tool builds the district model, an objective function that measures the costs related to the district management, and functions modelling the physical constraints on the machines. A nonlinear minimization problem with nonlinear constraints arises from this modelling. In this paper we focus on the solution of this optimization problem.

In finding the optimal solution a compromise between two needs should be found. On one hand one aims at finding the machine asset corresponding to the lowest possible value of the objective function. On the other hand the optimization process should be as quick as possible, as it needs to be performed several times in a day, when the needs of the district or the weather conditions affecting the renewable resources change.

For this reason two different solvers were employed and compared: a Sequential Linear Programming (SLP) and a Particle Swarm Optimization (PSO).

SLP is an iterative solver that generates a sequence of linear approximations of the original nonlinear problem. It is supported by theoretical results and it is ensured to converge to a local minimum. With this method it is not guaranteed to find the global minimum, actually the generated sequence usually converges to the local minimum nearer to the starting guess.

PSO is an heuristic research algorithm designed to find a global minimum of the problem. It is a derivative free algorithm that requires just function values. For this reason it is characterized by a slower convergence than SLP that is a first order method.

PSO solver is then expected to find a better solution than SLP, but the optimization process is expected to be longer. To investigate on this, the solvers were tested on many different realistic examples of energetic districts, and on a real energetic district provided by Enel.

## 2 Optimization Problem

The variables that need to be optimized are the physical parameters of the machine that affect their functioning (such as the electrical power produced by generators, that stored by batteries, the thermal power provided by boilers). The aim of the optimization process is to build a plan of the machines parameters for the following day to minimize the expenses related to the district management. The objective function f represents the overall daily cost of energy obtained as a result of the difference between purchase costs (fuel and electric energy) and incomings (incentives and sales revenues).

If n is the problem dimension, $$f:\mathbb {R}^n\rightarrow \mathbb {R}$$ is a nonlinear function. The optimization problems is a constrained problem, with both nonlinear constraints and bound constraints. The first ones represent physical constraints on the machines and are modelled by a nonlinear function $$g:\mathbb {R}^n\rightarrow \mathbb {R}^p$$. Bound constraints arise from the fact that the variables are normalized in the interval [0, 1] or [−1, 1].

The resulting optimization problem is the following nonlinear constrained problem:
\displaystyle \begin{aligned} \begin{array}{rcl} &\displaystyle &\displaystyle \min_x \; f(x) {} \end{array} \end{aligned}
(1)
\displaystyle \begin{aligned} \begin{array}{rcl} &\displaystyle &\displaystyle x_{\min} \leq x \leq x_{\max} , {} \end{array} \end{aligned}
(2)
\displaystyle \begin{aligned} \begin{array}{rcl} &\displaystyle &\displaystyle g(x) \leq 0,{} \end{array} \end{aligned}
(3)
where $$x \in \mathbb {R}^{n}$$ is the parameters vector, $$x_{\min } \in \mathbb {R}^{n}$$ and $$x_{\max }\in \mathbb {R}^{n}$$ denote the related bound constraints.

## 3 Sequential Linear Programming (SLP)

Sequential Linear Programming (SLP) is an iterative method to find local minima of nonlinear constrained optimization problems [1], by solving a sequence of linear programming problems. In our approach first a penalty function is built treating the constraints as a penalty term, i.e. a new term is added to function f that is positive if the constraints are not satisfied, and is zero otherwise. The resulting function is used as the new objective function. Following [1, 5] the l1 penalty function was chosen:
\displaystyle \begin{aligned} \varPhi(x,\nu)=f(x)+\nu \sum\limits_{i=1}^{p}\max(0,-g_i(x)), \end{aligned}
where ν > 0 is the penalty parameter. Then, at each iteration k, linear models of function f and of the constraints are computed, approximating them in a neighbourhood of the current solution approximation x k with first order Taylor series:
\displaystyle \begin{aligned} m_k(d)=f(x_k)+\nabla f(x_k)^Td, & & g_i(x_k)+\nabla g_i(x_k)^Td \qquad i=1,\dots,p, \end{aligned}
where d = x − x k is the step. To obtain a globally convergent method, SLP approach is usually coupled with a trust-region strategy, [2]. Then, a new constraint is added to the bound constraints, that consists of a bound on the step-length:
\displaystyle \begin{aligned} \| d \|{}_\infty\leq \varDelta_k, \end{aligned}
where Δ k is called the trust-region radius. The linearized functions replace the nonlinear ones in the penalty function and the following linear minimization problem is solved:
\displaystyle \begin{aligned} \begin{array}{rcl} &\displaystyle &\displaystyle \min_d f(x_k)+\nabla f(x_k)^Td+\nu \sum\limits_{i=1}^{p}\max(0,-g_i(x_k)-\nabla g_i(x_k)^Td){} \end{array} \end{aligned}
(4)
\displaystyle \begin{aligned} \begin{array}{rcl} &\displaystyle &\displaystyle \max((x_{\min}-x_k)_j,-\varDelta_k)\leq d_j\leq \min((x_{\max}-x_k)_j,\varDelta_k),{} \qquad j=1,\dots,n. \end{array} \end{aligned}
(5)

At each iteration the computed solution d k is used as a step to define the new solution approximation: xk+1 = x k  + d k and the trust-region radius is updated. The step is accepted if a sufficient decrease in the objective function f is obtained, and in this case the trust-region radius is possibly enlarged, otherwise the step is rejected, the trust-region radius is reduced and the subproblem is solved again.

Following [5], for this approach we proved the following important theoretical results:
1. 1.

global convergence of sequence {x k } generated by the algorithm to a KKT point of Φ(x, ν) (if ν is big enough a minimizer of Φ is a solution of (1)–(3)),

2. 2.

convergence of the Lagrange multipliers estimates of problem (4)–(5) to the multipliers of problem (1)–(3).

This second theoretical results allows us to implement a reliable stopping criterion, as it provides a measure of the distance of the solution approximation found to a KKT point of the original system.

## 4 Particle Swarm Optimization (PSO)

Particle Swarm Optimization (PSO) is a stochastic evolutionary method designed to converge to global minimum, [3]. It is inspired to the behaviour of bird swarms. Following the natural metaphor, PSO evolves a population of individuals, referred to as particles, within the search space, that behave according to simple rules but interact to produce a collective behaviour to pursuit a common aim, in this case the localization of a global minimum. The swarm is composed of s particles, each of them represents a solution of the optimization problem and it is represented by a vector $$x\in \mathbb {R}^n$$. To each particle it is associated a velocity vector v too. The method is based on an iterative algorithm and at each step k vectors x and v are updated:
\displaystyle \begin{aligned} \begin{array}{rcl} v^i_{k+1}&\displaystyle =&\displaystyle wv^i_k+c_1r_1(p^i_{best,k}-x^i_k)+c_2r_2(p^g_{best,k}-x^i_k),\\ x^i_{k+1}&\displaystyle =&\displaystyle x^i_k+v^i_{k+1}, \end{array} \end{aligned}
where $$x^i_k$$ and $$v^i_k$$ are the position and velocity vector of the i-th particle, i = 1, …, s, at the k-th iteration, $$p^i_{best,k}$$ and $$p^g_{best,k}$$ are respectively the best position reached by the i-th particle so far and the best position reached by the whole swarm (the best position is the one that corresponds to the lowest value of the objective function), c1, c2 and w are positive weights, r1 and r2 are random variables with uniform distribution in [0, 1].

The process is stopped as soon as a maximum number of iterations is reached or when the objective function is not sufficiently decreased within a fixed number of iterations. The computed approximate solution is $$p^g_{best,k*}$$ where k is the last iteration index.

Bound constraints are handled bringing back on the nearest boundary a particle x that has left the search space and changing the sign of the particle velocity, to avoid a new violation on the next iteration.

Originally PSO methods were developed to deal with problems with just bound constraints, and later they were employed to solve also constrained problems [6]. Usually a penalty function approach is used. We employed a quadratic penalty function:
\displaystyle \begin{aligned} \varPhi(x,\tau_k)=f(x)+\frac{1}{2\tau_k}\sum\limits_{i=1}^{p}g_i(x)^2, \end{aligned}
with τ k penalty parameter that is decreased at each iteration to penalize with increasing severity constraints violations.

The main advantage of PSO methods is that they do not require neither regularity assumptions on the objective function nor to compute the first derivatives and are so suitable when few information on the objective function are available. Clearly the fact that few information on f are used, leads to a really slow method that requires many iterations to converge. Furthermore these methods are heuristic and there are not theoretical results that ensure convergence of the method.

## 5 Numerical Tests

The software tool equipped with the two solvers was tested on 13 different models of synthetic energetic districts and on an existing district in Pisa, provided by Enel.

The numerical experimentation has been carried out on a PC equipped with a AMD Phenom(tm)II X4 965 Processor 3.40 GHz, 8.00 GB RAM, Windows 7 Professional 64 bit and using Matlab R2012a.

Results shown in the following tables are the average of those obtained over 10 runs, varying the starting point for SLP solver. In the headings of the following tables f and k are the arithmetic mean of the function values and the number of iterations, σ f , σ k are the standard deviations, $$\min \mathbf {f}$$, $$\max \mathbf {f}$$ are the minimum and maximum function values obtained, time/it(s) is the time for an iteration in seconds, time(m) is the total time in minutes.

As an example we report in Table 1 the detailed results of the optimization process provided by the two algorithms in one of the 13 tests. The model of energetic district includes an accumulator, a boiler, a CHP, a wind generator, a photovoltaic generator, 5 loads. The optimization problem has 398 variables subject to 213 process constraints and 796 bound constraints.
Table 1

Comparison of solvers on an example of energetic district

Solver

f

σ f

$$\max \mathbf {f}$$

$$\min \mathbf {f}$$

k

σ k

time/it(s)

time(m)

PSO

27.2

0.2

27.6

26.9

1004

881

0.5

9

SLP

26.9

0.3

27.5

26.6

51

12

1.4

1.2

From this test it is possible to deduce the following remarks.

The convergence rate of SLP algorithm is really higher than that of PSO, as it employs first order informations on f. PSO method requires a very high number of iterations to find the minimum and so the computational time is higher. As expected SLP is more suitable for real time optimization.

The capability of PSO method to find a global minimum does not clearly emerge in these tests, actually in many tests the solution found by SLP is better, as it is highlighted in Fig. 1 (left), in which we report for all the tests the comparison of the objective function values obtained by the two solvers at the end of the optimization process. On the other hand, in unconstrained tests on strongly nonlinear problems taken from the literature, PSO performance results to be much higher than SLP one, as it manages to find the global minimum, while the sequence generated by SLP approaches the local minimum nearer to the starting guess. We can notice that the energetic district test cases are characterized by a high number of nonlinear constraints. On one hand we can think that the PSO constraints handling strategy could be improved, on the other hand the standard deviation on function values is really low, so it is possible that the problem does not have many local minima, and the use of PSO algorithm is not worth it.

On the other hand in the test performed on the real example of energetic district, that is much less constrained, PSO gains better performance than SLP.

This is a real district in Pisa that comprises: a CHP characterized by rated power 25 kWe and rated thermal power 75 kWt, a gas boiler with rated thermal power 35 kWt, a tank for the storage of hot water with capacity 9400 kJ/ C, a photovoltaic generator with rated power 14 kWe, a wind farm with rated power 3 kWe, 2 loads. The arising optimization problem has 288 variables, 576 bound constraints and 1 physical constraint.

For this district we have at our disposal data referring to the actual management of local resources, so that we can evaluate savings arising from the optimized management provided by our procedures, as it is depicted in Fig. 1 (right) . In fact in Table 2, that shows the results of the optimization of Pisa district provided by the two methods, we report also the value of the unoptimized objective function f0, that is computed using those data and represents the cost of the actual management.
Table 2

Results of the optimization of the energetic district of Pisa, f 0 is the cost function for the actual management (without optimization by our procedures)

Solver

f 0

f

σ f

$$\max \mathbf {f}$$

$$\min \mathbf {f}$$

k

σ k

time/it(s)

time(m)

PSO

89.3

73.5

0.08

73.6

73.4

377

34

0.4

2.7

SLP

89.3

74.9

2.8

80.6

73.4

23

9

2.6

1

In this case PSO algorithm performs better than SLP algorithm, providing a lower value of the objective function and also a really smaller standard deviation. In this case there is just one mild nonlinear constraint so the constraint handling strategy does not have a strong impact on the search process and the capability of the evolutionary algorithm to search for the global minimum appears as in an unconstrained test case. We can also notice that in this case the execution time is reasonable also for PSO algorithm.

Comparing the unoptimized management of local resources to the optimized one, we can see that the employment of the software tool guarantees considerable savings in the energy bill, about 18% daily saving.

## Notes

### Acknowledgements

Work partially supported by INdAM-GNCS.

## References

1. 1.
Byrd, R.H., Gould, N.I.M., Nocedal, J., Waltz, R.A.: An algorithm for nonlinear optimization using linear programming and equality constrained subproblems. Math. Program. 100, 27–48 (2003)Google Scholar
2. 2.
Conn, A.R., Gould, N.I.M., Toint, P.L.: Trust-Region Methods., SMPS/SIAM Series on Optimization, SIAM, Philadelphia (2000)Google Scholar
3. 3.
Eberhart, R.C., Kennedy, J.: Particle swarm optimization. In: Proceedings of the IEEE International Conference on Neural Networks, pp. 1942–1948 (1995)Google Scholar
4. 4.
Ferrara, W., Riccardi, J., Sello, S.: Enel customer optimization service expert system development, Technical Report, Enel Ingegneria e Ricerca, Pisa (2014)Google Scholar
5. 5.
Fletcher, R., Sainz de la Maza, E.: Nonlinear programming and nonsmooth optimization by successive linear programming. Math. Program. 43, 235–256 (1989)Google Scholar
6. 6.
Parsopoulos K.E., Vrahatis, M.N.: Particle swarm optimization method for constrained optimization problems. In: Intelligent Technologies - Theory and Applications: New Trends in Intelligent Technologies, pp. 214–220. IOS Press, Amsterdam (2002)Google Scholar

© Springer International Publishing AG, part of Springer Nature 2017

## Authors and Affiliations

• Elisa Riccietti
• 1
• Stefania Bellavia
• 2
• Stefano Sello
• 3
1. 1.Dipartimento di Matematica e Informatica “Ulisse Dini”Università di FirenzeFirenzeItaly
2. 2.Dipartimento di Ingegneria IndustrialeUniversità di FirenzeFirenzeItaly
3. 3.Enel Ingegneria e Innovazione - RicercaPisaItaly