# Introduction n mathematics and computing, the Levenberg-Marquardt Algorithm (LMA), also known as the damped least-squares (DLS) method, is used to solve non-linear least squares problems. These minimization problems arise especially in least squares curve fitting. The LMA interpolates between the Gauss-Newton Algorithm (GNA) and the method of gradient descent. The LMA is more robust than the GNA, which means that in many cases it finds a solution even if it starts very far off the final minimum. For well-behaved functions and reasonable starting parameters, the LMA tends to be a bit slower than the GNA. LMA can also be viewed as Gauss-Newton using a trust region approach. The LMA is a very popular curve-fitting algorithm used in many software applications for solving generic curve-fitting problems. However, as for many fitting algorithms, the LMA finds only a local minimum, which is not necessarily the global minimum [1]. The primary application of the Levenberg-Marquardt algorithm is in the least squares curve fitting problem: given a set of ?? empirical datum pairs of independent and dependent variables, (????, ????) optimize the parameters ?? of the model curve ð??"ð??"(??, ??) so that the sum of the squares of the deviations becomes minimal. ??(??) = ?[?? ?? ? ð??"ð??"(?? ?? , ??)] 2 ?? ??=1 The Levenberg-Marquardt (LM) algorithm is an iterative technique that locates the minimum of a multivariate function that is expressed as the sum of squares of non-linear real-valued functions [4,6]. In the other hand, a common problem in control system design is establishing the appropriate value of controller gains. In general a low value of gain produces a slow system response, while high gain values can cause an excessively-oscillatory response with the possibility of instability. Somewhere between these extremes is a value of gain that produces the best system response. The essential function of a feedback control system is to reduce the error, ??(??) between any variable and its demanded value to zero as quickly as possible. Therefore, any criterion used to measure the quality of system response must take into account the variation of the error over the whole range of time. Four basic criteria are in common use: Integral of absolute error (IAE) = ? |??(??)|???? ? 0 Integral of squared error (ISE) = ? {??(??)} 2 ? 0 ???? Integral of time multiplied by absolute error (ITAE) = ? ?? ? 0 |??(??)|???? Integral of time multiplied by squared error (ISE) = ? ?? ? 0 {??(??)} 2 ???? For any of the possible criteria, the best response corresponds to the minimum value of the chosen criterion. Note that in all cases it is either the absolute error or the squared error which is involved, straightforward integration of the error would produce zero result, even if the system response was a constant amplitude oscillation. IAE is often used where digital simulation of a system is being employed, but it is inapplicable for analytical work, because the absolute value of an error function is not generally analytic in form. This problem is overcome by the ISE criterion. The ITAE and ITSE have an additional time multiplier of the error function, which emphasizes long-duration errors, and therefore these criteria are most often applied in systems requiring a fast settling time [3,5]. # C In this paper, the shape of the complete closed loop response, from time ?? = 0, until steady state has been reached, could be used for the formulation of a dynamic performance criterion. The simple criteria of this category are based on the entire response of the process and the integral of the Square Error (ISE) criterion used here, where ?????? = ? ?? 2 (??) ? 0 ???? = ? ?Y sp (t)-Y(t)? 2 ? 0 ???? (1) Where ??(??) = ?? ???? (??) -??(??) is the deviation (error) of the response from the desired set point. The ideal continuous time domain PID controller for a SISO process is expressed in the Laplace domain as follows: ??(??) = ?? ?? + ?? ?? ?? + ?? ?? ??(2) With K p = proportional gain, K i = integral time constant and K d = derivative time constant. # II. # Mathematical Model of ph Neutralization Process Consider a pH neutralization process as shown in Fig. 1. The flow rates of acid, buffer, base and effluent streams are denoted by ?? 1 , ?? 2 , ?? 3 , and ?? 4 , respectively. Output of the process is the pH value of the effluent stream, and the flow rate of base stream, ?? 3 is the control input. A dynamic model is derived using the conservation laws and reactions equilibrium. The modeling assumptions include perfect mixing, constant volume of the neutralization tank ( V ), and complete solubility of the ions involved. The chemical reactions in the system are as follows [8]: The equilibrium constants for these reactions are: ???? 1 = [?????? 3 ? ][?? + ] [?? 2 ???? 3 ] ???? 2 = [???? 3 2? ][?? + ] [?????? 3 ? ] ???? = [?? + ] + [???? ? ] + [???? 3 2? ] The chemical equilibrium equations are modeled using the reaction invariant concept. For this system, concentrations of reaction invariants are defined as: ?? 1 = [???? 3 ? ] ?? 2 = [???? + ] ?? 3 = [?? 2 ???? 3 ] + [?????? 3 ? ] + [???? 3 2? ] Denoting, ?? = ???? the ions neutrality balance in the tank results the following static equation: ?(??, ??) = ??? 1 + ?? 2 + ?? 3 ?? ??3 + 10 ??? ? 10 ??????? ?? = 0 (3) ?? ??3 = 2 + 10 ???? 2 ??? 1 + 10 ???? 2 ??? + 10 ???? 1 +???? 2 ?2?? ???? 1 = ? log 10 ???? 1 ???? 2 = ? log 10 ???? 2 The dynamic equations are given by: ?????1 ???? = ?? 1 ?? (?? 11 ? ?? 1 ) + ?? 2 ?? (?? 21 ? ?? 1 ) + ?? 3 ?? (? 1 ? ?? 1 ) (4) ?????2 ???? = ?? 1 ?? (?? 12 ? ?? 2 ) + ?? 2 ?? (?? 22 ? ?? 2 ) + ?? 3 ?? (? 2 ? ?? 2 ) (5) ?????3 ???? = ?? 1 ?? (?? 13 ? ?? 3 ) + ?? 2 ?? (?? 23 ? ?? 3 ) + ?? 3 ?? (? 3 ? ?? 3 ) (6) Where: © # Simulation Results The closed loop control system was solved using Levenberg-Marquardt's optimization approach with sampling time of 0.001 s. The simulation method combines SIMULINK module for pH neutralization model and M-file for LMA approach. A list of M-file programs used in the paper is provided in Appendix 1 and 2. Figure (1 and 2) show the responses of the pH neutralization obtained with change in pH set point. The optimal gains of PID controller are calculated to minimize the error function which described in equation (2). Also the values of gains of PID controller are plotted. The response of pH value tends to set point value with minimum steady state error and the values of gains tend to minimum values once the error reaches to zero value. Figure (3) show the change in set point from pH = 6 to 7, noticed that the spike value of manipulated variable (q 3 ) and the values of gains (Kp and Ki) tend to increasing while the gain (Kd) tends to decreasing. In other hand, figure (4) show the change in set point from 7 to 6, the value of manipulated variable (q 3 ) and the value of gains (Kp, Ki and Kd) tend to decreasing. # Conclusion The paper presents an application of the Levenberg-Marquardt Algorithm (LMA) to optimization of parameters (Kp, Ki, Kd) of the PID controller structure according to minimum of integral square error. The simulated results were obtained of parameters by means of computer program implemented in Matlab software. As an example, the optimization of parameters of PID controllers with reference to a ph Neutralization process was presented. 12![Fig. 1 : pH neutralization process](image-2.png "Fig. 1 : 2 ?") ![2015 Global Journals Inc. (US) 's Algorithm used for PID Controller Parameters Optimization ??: Volume of the mixing tank, ml ????: Dissociation constant of water, 10 ?14 ???? ?? : ith dissociation constant of acid ?? ?? : Concentration of the ith species in the process stream, mol/l ?? 1?? : Concentration of the ith species in the acid stream, mol/l ?? 2?? : Concentration of the ith species in the buffer stream, mol/l ?? ?? : Flow rate of acid, buffer and base stream in simulation, ml/s ? ?? : Concentration of the ith species in the titrating stream, mol/l ?? ?? : Reaction invariant of ith species, mol/l ??: Process variable, pH ??: Flow rate of the titrating stream, ml/min or ml/s III.](image-3.png "") Appendix (1) %Determination of PID controller prameters using "Levenberg-Marquardt %Algorithm" %Step 1: Write an M-file tracklsq.m. function [Kp,Ki,Kd] = phpidL2015k ph2015 % Load the simulink model plot(t,y1,'r',t,y2,'-.b','LineWidth',2); title('levenberg-marquardt') legend({'pH','pH setpoint'},'Location','SE','FontSize',8') xlabel('Time (min)','FontSize',12') ylabel('pH','FontSize',12) grid on subplot(2,1,2),plot(t,y3,'r','LineWidth',2); xlabel('Time (min)','FontSize',12') ylabel('q3 (ml/s)','FontSize',12') Appendix (2) % Read Mat. Files of PID gains % ki(First number, second number)first number points to raw number % second number points to col. number % load ki.mat; %# assume this contains a matrix called ki load kp.mat load kd.mat for i=1:1:51 %# numbers of columns x(i) = ki(1,i); %# numbers from all rows, column 1, into X x1 * Fuzzy-neural predictive control using Levenberg-Marquardt optimization approach * PID Parameters Optimization Using Genetic Algorithm Technique for Electrohydraulic Servo Control System AAyman Aly Intelligent Control and Automation 2 2011 * PID Controllers: Recent Tuning Methods and Design to Specification PCominos NMunro IEE Pro-ceedings Control Theory & Applications 149 I January 2002 * Survey of Advanced PID Parameter Tuning Methods WWang JTZhang TY AChai Acta Auto-matica 26 3 2000 * PID Parameter Optimization of an UAV Longitudinal Flight Control System KamranTurkoglu UgurOzdemir MelikeNikbay ElbrousMJafarov World Academy of Science, Engineering and Technology 21 2008 * Robust PID Controller Design for an UAV Flight Control System BKada YGhazzawi WCECS 2011. October 19-21, 2011 * Learning Generalized Weighted Relevance Aggregation Operators Using Levenberg-Marquardt B S UMendis .T DGedeon .LKóczy Proc. of the Sixth IEEE International Conference on Hybrid Intelligent Systems of the Sixth IEEE International Conference on Hybrid Intelligent Systems 2006 * Fast Genetic Algorithms Used for PID Parameter Optimization XMeng Song Proceedings of IEEE International Conference on Automatic and Logistic IEEE International Conference on Automatic and Logistic 2007