An Augmented Lagrangian Neural Network for the Fixed-Time Solution of Linear Programming

Dayanna T. Toro and Jose´ M. Lozano Juan Diego Sanchez-Torres´ Department of Electrical Engineering Research Laboratory on Optimal Design, Universidad de Guanajuato Devices and Advanced Materials -OPTIMA- Carretera Salamanca - Valle de Santiago, km 3.5 + 1.8 ITESO University Comunidad de Palo Blanco. P.C. 36885, Salamanca, Mexico.´ Tlaquepaque, Mexico´ Email: [email protected], [email protected] [email protected]

Abstract—In this paper, a recurrent neural network is of a linear problem, obtaining the optimal solution of a system proposed using the augmented Lagrangian method for solving in finite time. linear programming problems. The design of this neural In the same way, investigations have also been carried out in network is based on the Karush-Kuhn-Tucker (KKT) optimality conditions and on a that guarantees fixed-time nonlinear systems with discontinuous activation function [10], convergence. With this aim, the use of slack variables allows [11]. Similarly, in later studies a neural network was proposed transforming the initial linear programming problem into that solved problems where the objective function may or may an equivalent one which only contains equality constraints. not be continuously differentiable [12] and a neural network Posteriorly, the activation functions of the neural network are capable of solving non-convex problems [13] was successfully designed as fixed time controllers to meet KKT optimality conditions. Simulations results in an academic example and an proposed, which expanded the universe of systems that can be application example show the effectiveness of the neural network. solved. Other studies have used the augmented Lagrangian method for solving optimization problems, achieving better I.INTRODUCTION numerical stability [14]. For this reason, the aim of this Linear programming is an important field of optimization, paper is to develop a recurrent neural network based on since many applications can be formulated and solved through Lagrangian augmented and slack variables to solve linear a linear representation, which has generated major research programming problems, thus illustrating its operation in a within this area. Over the years, for many applications, a classic optimization problem. variety of numerical have been developed, being The remainder of this paper is organized as follows: in Pyne one of the first to introduce the use of dynamic systems Section II, the preliminaries related to the development of the to solve optimization problems. The main advantage of this neural network are presented. Section III describes the model technique is that the system constantly seeks new solutions as of the recurrent neural network and its performance through an the parameters of the problems are varied [1]. academic example. In Section IV an application is presented Since then, many extensions of these systems have been were the energy that is delivered by the different generation developed in which recurrent neural networks have received units of a microgrid are maximized. Finally, conclusions are substantial attention. In 1986, Tank and Hopfield proposed the given in Section V. first recurrent neural network for solving linear programming problems [2], which inspired the development of numerous II.MATHEMATICAL PRELIMINARIES neural networks in the area of optimization. In 1988, Kennedy and Chua [3] proposed a neural network with a finite penalty In this section, the important concepts for the development parameter for , with the disadvantage of the network structure are presented. that the penalty parameter had to grow infinitely to achieve convergence. To avoid using the penalty parameter, others A. Slack Variables methods such as Lagrange multiplier were introduced [4]. Proposition 1. If a and b are two real numbers, then a ≤ b In this sense, Wang [5] proposed a recurrent neural if and only if a + y2 = b for some number y [15]. network with a time-varying threshold vector to solve linear programming problems, with the disadvantage that the proposed network is asymptotically stable. Similarly, it was A classical optimization problem usually has both equality shown [6] that the use of differential algebra, in conjunction and constraints that, when combined, often interact with KKT conditions, has a faster convergence than other in complex ways, so that slack variables can be used to methods used in linear programming; other investigators [7]– transform the original problem into a problem that only has [9] also use recurrent neural networks to study the convergence equality restrictions. Now, consider the general programming problem multipliers and the , since it consists of adding an additional term to the Lagrangian. min cT x Given σ = Mz − d and parting from problem (3), the s.t. Ax = b (1) augmented Lagrangian is defined as l ≤ x ≤ h Z σ L (x, z, λ) = cT x + λT σ + ψ(σ)dz (6) n ρ where x ∈ is the vector of decision variables, c, l, 0 n m m×n h ∈ R , b ∈ R and A ∈ R is a full row-rank T where λ = [λ1, ... , λk] represents the vector of the (rank(A) = m, m ≤ n). R σ Lagrange multipliers and 0 ψ(σ)dz is the penalty function. The general problem (1) can be transformed into a problem ρ 2 Usually, the penalty term most commonly used is 2 k σ k , of equality constraints by well-knows techniques such as but in this work, a different function is used to illustrate its adding slack variables. For this to occur, first the inequality behavior. is converted into independent inequalities, as follows III.STRUCTUREOFTHE NETWORK min cT x A. Recurrent Neural Network Design s.a. Ax − b = 0 (2) Starting from (6) and according to the KKT conditions [16], −x ≤ −l (x*, λ*, z*) is an optimal solution if x ≤ h * * * ∇xLρ(x , z , λ ) = 0 Note that problem (2) is equivalent to problem (1); once this ∇ L (x*, z*, λ*) = 0 form is obtained, the slack variables are introduced in order y ρ * * * to eliminate the inequality ∇λLρ(x , z , λ ) = 0 min cT x Subsequently, the following conditions must be fulfilled ∂z ∂σ ∂z ∂σ s.t. Ax − b = 0 c + λ + ψ(σ) = 0 (7) −x + s + l = 0 ∂x ∂z ∂x ∂z 1 ∂z ∂σ ∂z ∂σ λ + ψ(σ) = 0 (8) x + s2 − h = 0 ∂y ∂z ∂y ∂z  2 2   2 2  σ = where s1 = y1, ... , yn and s2 = yn+1, ... , y2n are the 0 (9) vectors that contain the slack variables. T k where y = [0 ...0 y1 y2 ... y2n] ∈ R and x = When a problem has equality constraints, it can be written T k [x1 x2 ... xn 0 ... 0] ∈ R ; this is done so they are of the in vectorial form as shown below ∂z ∂z same dimensions as z, such that ∂y y ∂x are square matrices min cT x k × k, of the form (3) s.a. Mz − d = 0  ∂z1 ∂z2 ... ∂zk  ∂y1 ∂y1 ∂y1  ∂z1 ∂z2 ... ∂zk  where ∂z  ∂y2 ∂y2 ∂y2  =  . . .   AO O   b  ∂y  . . .  m×n m×n  ......  ∂z ∂z ∂z M =  In×n In×n On×n  , d =  h  (4) 1 2 ... k ∂yk ∂yk ∂yk −In×n On×n In×n −l   ∂z1 ∂z2 ... ∂zk ∂x1 ∂x1 ∂x1 T = x , ... , x , y2, ... , y2  (5)  ∂z1 ∂z2 ... ∂zk  z 1 n 1 2n ∂z  ∂x2 ∂x2 ∂x2  =  . . .  . ∂x  . . .  A is the matrix containing the equality constraints, Om×n is  ......  a matrix of zeros of dimension m×n, O is another matrix ∂z1 ∂z2 ... ∂zk n×n ∂xk ∂xk ∂xk of zeros of dimension n × n, I is an identity matrix of n×n The KKT conditions (7)-(9) are used to propose the dimension n × n, z is the vector containing both the decision following recurrent neural network in order to solve the linear variables (x) and the slack variables (y2), which represent the i program given in (3) additional value that needs to be added to satisfy the equality;  ∂z ∂σ ∂z ∂σ  each slack variables is elevated to the square to ensure that it x˙ = −γ c + ψ(σ) + λ (10) is positive. ∂x ∂z ∂x ∂z  ∂z ∂σ ∂z ∂σ  B. Augmented Lagrangian y˙ = −γ ψ(σ) + λ (11) ∂x ∂z ∂x ∂z The augmented Lagrangian method is a technique used to λ˙ = γασ (12) solve optimization problems by transforming those problems into unconstrained equivalent ones. This method can where γ is a positive scaling constant, α is a nonnegative gain be considered a hybrid between the method of the Lagrange and ψ(σ) is the derivative of the penalty function. ∂z ∂z Given that σ = Mz − d, then σ˙ = M ∂x x˙ + M ∂y y˙. Hence, B. An Academic Example from (10) and (11), it results Consider the linear programming problem [18] " # ! ∂z  ∂z 2  ∂z 2 ∂σ σ˙ = − γ M c − M + λ ∂x ∂x ∂y ∂z min 4x1 + x2 + 2x3 " # ! (13)  ∂z 2  ∂z 2 ∂σ s.t. x1 − 2x2 + x3 = 2 − γ M + ψ(σ) . ∂x ∂y ∂z − x1 + 2x2 + x3 = 1 − 5 ≤ x1, x2, x3 ≤ 5 Selecting ψ(σ) in (13) as " # !−1 The proposed neural network (10)-(12) with the design  ∂z 2  ∂z 2 ∂σ ψ(σ) = − γM + function (14) and (20) is tested, with k1 = 8, k2 = 3, k3 = 3, ∂x ∂y ∂z α = 1, ρ = 1, γ = 105 and initial conditions are randomly " " # ! # ∂z  ∂z 2  ∂z 2 ∂σ selected within a range from −10 to 10. Results are shown in γ M c + M + λ − φ(σ) Fig.1 and Fig.2. ∂x ∂x ∂y ∂z (14) 10 the dynamics of σ in (13) reduces to σ˙ = −φ(σ). 8 In addition, when (14) is substituted in (7)-(9) is obtained: 6 x3 ( " # )−1 4 ∂z ∂σ  ∂z 2  ∂z 2 ∂σ c+ M + φ(σ)− 2 ∂x ∂z ∂x ∂y ∂z 0 x2 −1 (15) Decision Variables " # -2 ∂z  ∂z 2  ∂z 2 ∂z x1 + c = 0 -4 ∂x ∂x ∂y ∂x -6 ( " 2  2# )−1 ∂z ∂σ ∂z ∂z ∂σ -8 M + φ(σ)− ∂y ∂z ∂x ∂y ∂z -10 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 (16) ×10-5 " #−1 Time [s] ∂z  ∂z 2  ∂z 2 ∂z + c = 0 ∂y ∂x ∂y ∂x Fig. 1. Transient States of the Neural Network σ = 0. (17)

Since 12 z4 −1 " 2  2# 10 ∂z ∂z ∂z ∂z z + = I (18) 5 ∂x ∂x ∂y ∂x 8 z9 " #−1 ∂z  ∂z 2  ∂z 2 ∂z + = 0 (19) 6 ∂y ∂x ∂y ∂x Slack Variables z6 4 and φ(0) = 0 it follows that the KKT conditions (15)-(16) are z8 fulfilled when σ = 0. 2 If φ(σ) is defined as z7 0 σ 1/2 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 φ(σ) = k1 + k2σ + k3σ k σ k (20) Time [s] ×10-5 k σ k1/2 Fig. 2. Transient States of the Slack Variables with k1, k2 and k3 positive gains, then the dynamics of σ in (13) is given by σ Hence, it can be observed that the network converges σ˙ = −k − k σ − k σ k σ k1/2 . (21) ∗ ∗ 1 k σ k1/2 2 3 to the optimal solution x = [−5, −2.75, 1.5] with z = [−5, −2.75, 1.510, 7.75, 3.5, 0, 2.25, 6.5]. Note that the first Finally, from (21), σ = 0 in fixed time [17]. Therefore, positions of the vector correspond to the decision variables from the KKT conditions (15)-(17), the linear programming x. Fig. 3 shows the dynamics of σ which becomes zero in problem (3) is solved in fixed time. fixed time and satisfies the constraint. 2 the available energy in an electrical microgrid prototype that was available at the time. 0 For this reason, PW min = 0 and PW max = 240 Watts

d -2 were selected for the aero-generator. In the case of the photo- − voltaic panel, its minimum energy is equal to 0 Watts, while Mz

= -4 the maximum that the module is able to deliver is 1.2 Watts. σ On the other hand, the values of the battery were chosen to

-6 increase its lifespan as much as possible, reason for which Pmin is set to 10% of its load and PBmax to 60%. Therefore, -8 the main system is like an infinite bus, but in this work its maximum and minimum energy are respectively considered

-10 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 as 250 and 0 Watts. -5 Time [s] ×10 To solve this problem, the proposed neural network (10)- Fig. 3. Dynamics of σ (12) is used with k1 = 8, k2 = 3, k3 = 3, α = 1, 4 ρ = 1, γ = 10 , PL = 350 Watts and the initial IV. APPLICATION EXAMPLE conditions are randomly selected within a range from 0 to 255 Watts. In Fig. 4 it can be seen how the decision variables An optimization problem is presented where the energy converge to the optimal solution x∗ = [36.8, 240, 1.2, 72] delivered by a non-autonomous microgrid (connected to the in fixed time. Fig. 5 shows the transient states of the main system) must be minimized. The energy availability of slack variables until they reach stabilization in z∗ = each of the generation and storage units is considered, given [36.8, 240, 1.2, 72, 213.2, 0, 0, 0, 36.8, 240, 1.2, 60]. that the demand required by the load is satisfied. A general case of study considers both a wind and a solar power system as generation units, and also acknowledges a 300 battery bank system as a storage unit, all connected to the main P 250 W electrical system. This optimization problem can be expressed as follows: 200

min PG − PW − PS − PB 150 s.t. PG + PW + PS + PB = PL

100 PGmin ≤ PG ≤ PGmax Power [Watt] PB PW min ≤ PW ≤ PW max 50 PG PSmin ≤ PS ≤ PSmax PS PBmin ≤ PB ≤ PBmax 0

where x = [PG PW PS PB], c = [1 − 1 − 1 − 1], -50 0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0.04 0.045 0.05 A = [1 1 1 1], b = PL, l = [PGmin PW min PSmin PBmin] Time [s] and h = [PGmax PW max PSmax PBmax]. Fig. 4. Transient States of the Decision Variables In order to use the neural network (10)-(12), it is necessary to transform the problem into form (3):

min PG − PW − PS − PB 300

s.t. PG + PW + PS + PB = PL 250 z10 2 −PG + y1 = PGmin z5

2 200 PG + y2 = PGmax −P + y2 = P W 3 W min 150 2 PW + y4 = PW max 100 2 Power [Watt] −PS + y5 = PSmin 2 z12 PS + y = PSmax 50 6 z9 2 z −PB + y7 = PBmin z6 z7 z8 11 2 0 PB + y8 = PBmax

-50 Once expressed in this way, the matrix M and the vectors z 0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0.04 0.045 0.05 and d can be formed, as shown in (4) and (5). The maximum Time [s] and minimum values defined in [18] are taken according to Fig. 5. Transient States of the Slack Variables Subsequently, a variable load profile is used, as shown in grid when a variable load profile was used. This shows that Fig. 6, so the behavior of the proposed neural network can be the proposed recurrent neural network operates successfully observed when there are changes in the demand of the load. If in real applications that can be defined as linear programming the same characteristics mentioned above are used, the result problems. obtained is presented in Fig. 7. ACKNOWLEDGMENT 600 Dayanna Toro acknowledges CONACyT, Mexico´ for the

550 MSc scholarship number 718729.

500 REFERENCES

450 [1] I. B. Pyne, “Linear programming on an electronic analogue computer,” American Institute of Electrical Engineers, Part I: Communication and

400 Electronics, Transactions of the, vol. 75, no. 2, pp. 139–143, 1956. Power [Watt] [2] D. Tank and J. Hopfield, “Simple ’neural’ optimization networks: An 350 A/D converter, signal decision circuit, and a linear programming circuit,” IEEE Transactions on Circuits and Systems, vol. 33, no. 5, pp. 533–541, 300 1986. [3] M. P. Kennedy and L. O. Chua, “Neural networks for nonlinear 250 programming,” IEEE Transactions on Circuits and Systems, vol. 35, no. 5, pp. 554–562, 1988. 200 0 5 10 15 20 25 30 35 40 45 50 [4] S. Zhang and A. G. Constantinides, “Lagrange programming neural Time [s] networks,” IEEE Transactions on Circuits and Systems II: Analog and Fig. 6. Load Profile Digital Signal Processing, vol. 39, no. 7, pp. 441–452, Jul 1992. [5] J. Wang, “Analysis and design of a recurrent neural network for linear programming,” IEEE Transactions on Circuits and Systems I: Fundamental Theory and Applications, vol. 40, no. 9, pp. 613–618, 250 1993. [6] M. Xiong, J. Wang, and P. Wang, “Differential-algebraic approach 200 to linear programming,” Journal of Optimization Theory and Applications, vol. 114, no. 2, pp. 443–470, 2002. [Online]. Available: http://dx.doi.org/10.1023/A:1016095904048 150 [7] L. V. Ferreira, E. Kaszkurewicz, and A. Bhaya, “Synthesis of a k- winners-take-all neural network using linear programming with bounded 100 Power [Watt] variables,” in Proceedings of the International Joint Conference on Neural Networks, 2003., vol. 3, July 2003, pp. 2360–2365 vol.3. [8] Y. Zhang and K. Chen, “Global exponential convergence and stability 50 of wang neural network for solving online linear equations,” Electronics Letters, vol. 44, no. 2, pp. 145–146, January 2008. 0 [9] Q. Liu and J. Wang, A One-Layer Dual Recurrent Neural Network with a Heaviside Step Activation Function for Linear Programming with Its P P P P g w b s Linear Assignment Application. Berlin, Heidelberg: Springer Berlin -50 0 5 10 15 20 25 30 35 40 45 50 Heidelberg, 2011, pp. 253–260. Time [s] [10] V. Utkin, Sliding Modes in Control and Optimization. Springer Verlag, Fig. 7. DER’s Power 1992. [11] S. K. Korovin and V. I. Utkin, “Using sliding modes in static When the load demand is low, the energy delivered by the optimization and nonlinear programming,” Automatica, vol. 10, no. 5, pp. 525 – 532, 1974. main system is practically zero, since the energy supplied by [12] Q. Liu and J. Wang, A One-Layer Recurrent Neural Network for Non- the microgrid is sufficient to satisfy the demand. However, smooth Subject to Linear Equality Constraints. when the demand increases, the microgrid cannot provide Berlin, Heidelberg: Springer Berlin Heidelberg, 2009, pp. 1003–1010. [13] A. Bhaya and E. Kaskurewicz, “A control-theoretic approach to the enough energy, reason for which it takes what is additionally design of zero finding numerical methods,” IEEE Trans Autom Control, needed from the main system. At 30s, the demand of the load vol. 52, no. 6, pp. 1014–1026, June 2007. becomes so large that the system has to provide its maximum [14] B. W. Wah and T. Wang, “Efficient and adaptive lagrange-multiplier methods for nonlinear continuous ,” Journal of energy so that together with the microgrid, its load can be Global Optimization, vol. 14, no. 1, pp. 1–25, 1999. [Online]. Available: satisfied. http://dx.doi.org/10.1023/A:1008203422124 [15] X.-S. Zhang, Neural Networks in Optimization. Springer, 2010. V. CONCLUSION [16] H. W. Kuhn and A. W. Tucker, “Nonlinear programming,” in Proc. Second Berkeley Symp. on Math. Statist. and Prob. (Univ. of Calif. In this paper, a recurrent neural network for solving linear Press), 1951. programming problems was proposed based on the augmented [17] A. Polyakov, “Nonlinear feedback design for fixed-time stabilization Lagrangian method and slack variables. The penalty function of linear control systems,” IEEE Transactions on Automatic Control, vol. 57, no. 8, pp. 2106–2110, 2012. used was selected because of its capacity to provide fixed time [18] J. D. Sanchez-Torres,´ M. J. Loza-Lopez, R. Ruiz-Cruz, E. N. Sanchez, convergence. Simulations results were presented to illustrate and A. G. Loukianov, “A simple recurrent neural network for solution of linear programming: Application to a microgrid,” in 2014 IEEE its performance on an academic example and on an application Symposium on Computational Intelligence Applications in Smart Grid to distribute energy in an electrical microgrid. In the microgrid (CIASG), Dec 2014, pp. 1–7. example, its power distribution maximized the use of the alternative power sources by minimizing the use of the main