Optimal Control of a Multi-field Irrigation Problem: validation of a numerical solution by the optimality conditions Optimal Control of a Multi-field Irrigation Problem: validation of a numerical solution by the optimality conditions S.O. Lopesa, F.A.C.C. Fontesb aCMAT and Departamento de Matemática e Aplicações, Universidade do Minho, Portugal bSystec-ISR, Faculdade de Engenharia, Universidade do Porto, Portugal sofialopes@math.uminho.pt, faf@fe.up.pt Abstract—In this paper, we address the problem of minimizing the total water consumption over the period of a year used to supply different fields with different types of crops. We start by recalling a previous study, where the authors developed an optimal control model for this problem by minimizing the water flowing into a reservoir and where the water from the precipitation can be collected. The numerical solution obtained using such model is analyzed. The main results in this paper are the theoretical validation of the numerical solution via a verifications that such solution satisfies the necessary conditions of optimality in the form of a Maximum Principle. This way, we are giving further evidence of the optimality of the numerical solution found. Keywords: Irrigation, Optimality conditions, Optimal Control, Maximum Principle. I. INTRODUCTION Climate change is a reality. Recent findings from NASA [17] report ”Globally-averaged temperatures in 2016 were 1.78 degrees Fahrenheit (0.99 degrees Celsius) warmer than the mid-20th century mean. This makes 2016 the third year in a row to set a new record for global average surface temperatures. (...) NOAA scientists concur with the finding that 2016 was the warmest year on record based on separate, independent analyses of the data.”, On the other hand, although our planet is blue, only 2.5% of it is freshwater. From this 2.5% of freshwater, 70% is used in agriculture. According to [9], in 165 countries and 2 territories: • the irrigation water requirement is 1500, 464 km3/yr • the irrigation water total withdrawal is 2672, 640 km3/yr. So, in this huge volume of a scarce resource, there is a waste of 43.8% of water in the current irrigation systems. Consequently, there is much that can be done to save water, and it is of utmost important to our planet. Naturally, the problem of minimizing water consumption in irrigation systems has been the subject of several researcher works, namely [1], [4] to mention a few using optimization models. Using specifically optimal control techniques, that take advantage of managing the storage of rainwater to save water consunption, we mention the works [5], [20]. Fig. 1. The planet’s long-term warming trend is seen in this chart of every year’s annual temperature cycle from 1880 to the present, compared to the average temperature from 1880 to 2015. Record warm years are listed in the column on the right. Credit: NASA/Earth Observatory.Joshua Stevens. The authors have been studying the irrigation problem as an optimal control problem. In a previous work [11], the authors develop a model to minimize the water flowing into a reservoir that supplies fields with different crops. In such work, only the numerical solution was obtained, . Here, it is proved that the numerical solution satisfies the necessary conditions of optimality in the form of a Maximum Principle. Therefore, in this paper the authors validate the numerical solution, adding evidence of optimality to such solution. The paper is organized as follows. Section 2 describes formally the problem and the model used. Section 3 presents the numerical results obtained for the problem. In Section 4 the numerical solution is validated. Concluding remarks are drawn in Section 5. II. PROBLEM SETTING In this section, we describe the problem of minimizing the total water consumed in irrigation over a long period of time (one year is considered here) to supply various cultivation fields with different types of crops. The problem is modeled as an optimal control problem, based on the recent work reported in [13], being able to capture adequately not only the dynamics of the evolution along time of the variables used, but also i-ETC: ISEL Academic Journal of Electronics, Telecommunications and Computers CETC2016 Issue, Vol. 3, n. 1 (2017) ID-9 http://journals.isel.pt the constraints that represent physical restrictions as well as constraints that guarantee the needs of heathy crops. We start by defining the variables used in the model. The controls are: v total water flow coming from the tap and uj water flow introduced in field j via its irrigation system. The states are: xj water in the soil of field j and y total of amount of water stored in reservoir. The aim is to minimize the total of water flow coming from the tap to a reservoir, min ∫ T 0 v(t)dt, where v(t) denotes the total water flow coming from the tap at time t. The reservoir supplies the multiple cultivated fields where each field can have different areas and different cultures. The water from the precipitation also can be collected into the reservoir. Therefore, the variation of water in reservoir is given by ẏ(t) = v(t) − P∑ j=1 Ajuj(t) + Cg(t), where y represents total of amount of water stored in the reservoir, Aj represents the area of each field j, Cg(t) represents collected water in a certain area C coming from the precipitation g in the time t, and uj is the water flow introduced in field j via its irrigation system. The variation of water in the soil is given by the hydro- logical balance equation, that is, the variation of water in the soil is equal to what enters (water via irrigation systems and precipitation) minus the loss (evapotranspiration of each crop hj and loss by deep percolation βxj(t), a percentage of water that is in the soil). So, ẋj(t) = uj + g(t) −hj(t) −βxj(t), ∀j = 1, . . . ,P where xj water in the soil of field j. We assume that each field has only one crop. In order to ensure that the crop is in good state of conservation, the water in the each field has to be sufficient to satisfy the hydric needs of each crop (xmin), that is: xj(t) ≥ xminj. The physical limitations of the amount of water that comes from a tap, the amount of water that comes from the irrigation systems, and the reservoir are given, respectively, by: y(t) ∈ [0,ymax] uj(t) ∈ [0,Mj] v(t) ∈ [0, ∑ j AjMj] where ymax is the maximum quantity of water in the reservoir and Mj is the maximum water flow coming from the tap in each field. We assume that at the initial time the humidity in the soil of each field and the water in the reservoir are given. Also, the water in the reservoir at the initial time and to the final time are imposed to be equal. So, we assume that xj(0) = x0j y(0) = y(T) = y0 A. The model In summary, the optimal control formulation for our prob- lem (OCP) with P fields and final time T is min ∫ T 0 v(t)dt subject to: ẋj(t) = −βxj(t) + uj + g(t) −hj(t) a.e. t ∈ [0,T], ∀j = 1, . . . ,P ẏ(t) = v(t) − ∑P j=1 Ajuj(t) + Cg(t), a.e. t ∈ [0,T], xj(t) ≥ xminj, ∀t ∈ [0,T], ∀j = 1, . . . ,P y(t) ∈ [0,ymax], ∀t ∈ [0,T] uj(t) ∈ [0,Mj], a.e. , ∀j = 1, . . . ,P v(t) ∈ [0, ∑ j AjMj], a.e. xj(0) = x0j, ∀j = 1, . . . ,P y(0) = y(T) = y0. III. NUMERICAL RESULTS We use a direct method discretization to obtain the numer- ical results for the optimal control problem by transcribing it as a mathematical programming problem. For that, we start by considering a finite time grid i = 1, . . . ,N + 1 xi = x(ti) ui = u(ti) where ti = (i− 1)h and h = T/N. Using the Euler-type discretization, the differential equation ẋ = f(t,x,u) is approximated by xi = xi−1 + hf(ti−1,xi−1,ui−1). To implement this optimization problem, the fmincon func- tion of Matlab is used with the algorithm “active set”, by default and the parameter “Tolfun” is considered 1E − 6. The rainfall is estimated using an average of 10 years data of rainfall for each month of the year, the dates are collected from Instituto Português do Mar e da Atmosfera ([10]). The Pennman - Monteith methodology [22] is used to cal- culate evapotranspiration of culture along the year, according the following formulation: ET(ti) = KcET0(ti), where Kc is the culture coefficient for the evapotranspiration and ET0 is the tabulated reference value of evapotranspiration from [19] for the Lisbon region. To simulate the problem, we assume that: P = 3 T = 12 Mj = 10 m3/month for each fieldj y0 = 0.01 ×At ymax = 0.05 ×At β = 15% S.O. Lopes et al. | i-ETC - CETC2016 Issue, Vol. 3, n. 1 (2017) ID-9 i-ETC: ISEL Academic Journal of Electronics, Telecommunications and Computers where At is the total area, (for more details see [12]). Here, we also consider three crops: wheat in 1000 m2, sugar cane in 750 m2 and olive in 1250 m2. The precipitation water is collected in an area of 200 m2. For these three crops, we consider: xmin = [0.033 0.021 0.032] Kc = [0.825 0.95 0.5] x0 = 5xmin The results obtained are reported in Fig. 2 and 3, (see also [12]): As expected, the crops need incoming water between May and September. The months when the water consumption is higher are June, July. The crop that needs less water is olive with the largest area 1250 m2. Note that we are imposing the constraint that the water volume in the reservoir at the initial time is equal to the water at the final time. It can be seen that until April the water from the precipitation is saved in the reservoir and until this month the tap is not opened. The tap is closed in September. June and July are the months when the irrigation takes the highest value, and also when the water in the reservoir decreases. IV. VALIDATION OF THE SOLUTION Since the problem has inequality constraints that are active for some period of time, it is not easy to get a complete analytical solution. However, we can verify that the numerical solution for the mathematical programming problem satisfies the necessary condition of optimality in the normal form of Maximum Principle (MP). By normal form, we mean that the scalar multiplier associated with the objective function — here called λ — is nonzero. The normal forms of the MP are guaranteed to supply non-trivial information, in the sense that they guarantee that the objective function is taken into account when selecting candidates to optimal processes. There has been a growing interest and literature on strength- ened forms of NCO for Optimal Control Problems (OCP). The normality results reported in literature require different degrees of regularity on the problem data [6], [18], [16], [3], [2], [7], [8], [14], [15]. In Rampazzo and Vinter [18], the MP can be written with λ = 1, if there exists a continuous feedback u = η(t,ξ) such that dh(ξ(t)) dt = ht(t,ξ) + hx(t,ξ) ·f(t,ξ,η(t,ξ)) < −γ′ (1) for some positive γ′, whenever (t,ξ) is close to the graph of the optimal trajectory, x̄(·), and ξ is near to the state constraint boundary. There should exist a control pulling the state variable away from the state constraint boundary. In the problem, we can find three inequality constraints, where the respective function are: h1(x) = xmin −x h2(y) = −y h3(y) = y −ymax. Observing the numerical solution in Fig. 3, we note that the trajectory y never touches the upper limit. So, the inequality constraint y(t) ≤ ymax is not active for any time in [0,T]. In this case, it is not necessary verify the constraint qualification to ensure normality. From (1), we write h1xj(ξ1j(t)) ·f(t,ξ1j,η1j(t,ξ1j)) = −(η1j(t,ξ1j) + 4j(t,ξ1j)) ≤−γ1, (2) where 4j(t,ξ1j) = g(t)−βξ1j . For a ξ1j on a neighbourhood of x̄j , we can always choose η1j sufficiently large so that the equation (2) is satisfied, as long as Mj > βx̄j(t) − g(t), a condition we can impose with loss of generality. Again, from (1), we have h2y(ξ2(t)) ·g(t,ξ2,η2(t,ξ2)) = −(η2(t,ξ2) − ∑P j=1 Ajuj(t) + Cg(t)) ≤−γ2, (3) As long as condition ymax > ∑P j=1 Ajūj(t)−Cg(t) holds, equation (3) is satisfied. This condition can be made to hold but adequately dimensioning the reservoir capacity. Thus, the inward pointing condition (1) is satisfied and normality follows. The problem data is sufficiently regular and the standard hypotheses under which the Maximum Principle holds are satisfied. Since the normality is ensured, we can apply the Maximum Principle with λ = 1, (for example from [21]). Define Hamiltonian function: H(t, (x,y), (p,r), (u,v),λ) = (p,r) · (−βx + u + g(t) − h(t),v + A · u + Cg(t)) −λv Assuming that ((x̄, ȳ), (ū, v̄)) is a minimizer for (OCP), then ∃(p,r) ∈ W1,1([0, 1] : RnP × R) and (µj,νL,νU ) ∈ C∗(0, 1): S.O. Lopes et al. | i-ETC - CETC2016 Issue, Vol. 3, n. 1 (2017) ID-9 i-ETC: ISEL Academic Journal of Electronics, Telecommunications and Computers Fig. 2. Crops need. Fig. 3. Reservoir −(ṗ(t), ṙ(t)) = H(x,y)(t, (x̄, ȳ), (q(t),w(t)), (ū, v̄), 1) H(t, (x̄, ȳ), (q(t),w(t)), (ū, v̄), 1) = max(u,v)∈[0,M]×[0,R] H(t, (x̄, ȳ), (q(t),w(t)), (u,v), 1) a.e.; supp{µj}⊂{t ∈ [0,T] : xj(t) = xminj} supp{νL}⊂{t ∈ [0,T] : y(t) = 0} supp{νU}⊂{t ∈ [0,T] : y(t) = ymax} (q(0),−w(0),−q(T),−w(T)) ∈ + NC (x̄(0), ȳ(0), x̄(T), ȳ(T)) (4) where: q(t) =   p(t) − ∫ [0,t) µ(ds), t ∈ [0,T) p(T) − ∫ [0,T ] µ(ds), t = T, w(t) =   r(t) − ∫ [0,t) νL(ds) + ∫ [0,t) νU (ds), t ∈ [0,T) r(T) − ∫ [0,T ] νL(ds) + ∫ [0,T ] νU (ds), t = T. and C = {x0}×{y0}×RnP ×{y0} From the Adjoint Equation, we obtain  ṗ(t) = βq(t) ṙ(t) = 0 (5) From the Weierstrass Condition, we get: (q(t) − A) · (u − ū) + (w(t) − 1)(v(t) − v̄(t)) ≤ 0 (6) Since the endpoints are fixed, except for the final endpoint of x that is free, the Transversality Condition is simplified to q(T) = 0. Therefore, in this problem, the Maximum Principle can be written as follows. If ((x̄, ȳ), (ū, v̄)) is a minimizer for (OCP), S.O. Lopes et al. | i-ETC - CETC2016 Issue, Vol. 3, n. 1 (2017) ID-9 i-ETC: ISEL Academic Journal of Electronics, Telecommunications and Computers then ∃(p,r) ∈ W1,1([0, 1] : RnP × R) and (µj,νL,νU ) ∈ C∗(0, 1):  ṗ(t) = βq(t) ṙ(t) = 0 (q(t) − A) · (u − ū) + (w(t) − 1)(v(t) − v̄(t)) ≤ 0 q(T) = 0 Furthermore, in the case where (ū, v̄) ∈]0, M[×]0,R[, the Weierstrass Condition can be written as:{ q(t) = A(t) w(t) = 1. (7) From Fig. 4, we can conclude that (ū, v̄) ∈]0, M[×]0,R[ in June, July and August, and therefore we can apply the Weierstrass Condition equation in the form of (7) in these months. We can observe the multiplier associated with the crops state are equal to the area of the fields of the corresponding crops in the months mentioned above: wheat multiplier := 1000 sugar canne multiplier := 750 olive multiplier := 1250. We also observe in Fig, 5, that the tranversality condition is satisfied: q(T) = 0. We also can see that in June, July and August the multiplier associated with the reservoir state is equal to 1. We conclude that for (ū, v̄) ∈]0, M[×]0,R[ the numerical solution fulfills the Weierstrass and remaining conditions of the Maximum Principle in the normal form. In summary, we conclude that: • the constraint qualification is verified, consequently we can ensure normality; • for (ū, v̄) ∈]0, M[×]0,R[ the numerical solution satisfies the Weierstrass Condition of the Maximum Principle in the normal form. • the numerical solution satisfies the transversality condi- tion. • the numerical solution satisfies the adjoint equation. V. CONCLUSION We have addressed an irrigation planning problem of mini- mizing the water used to supply different fields with different types of crops, sharing a common reservoir, which not only serves as storage, but also is from where the rain fall water is collected. We have used an optimal control model, which is ca- pable of adequately representing the dynamics of the humidity of the soil taking into account irrigation, evapotranspirations and infiltration, as well as taking into account the physical and problem requirement constraints. We have carried out a detailed analysis of the results ob- tained numerically, namely by establishing for the problem the necessary conditions of optimality in the form of a maximum principle and verifying that the numerical solution fulfills all the necessary conditions. In the absence of additional candidates for optimality (ex- tremals satisfying the necessary conditions) in the neighbor- hood of the solution analysed, we may conclude that such solution is in fact locally optimal. Acknowledgments. This work was partially supported by NORTE Regional Operational Program through Project NORTE–45–2015–02 STRIDE – Smart Cyberphysical, Mathematical, Computa- tional and Power Engineering Research for Disruptive In- novation in Production, Mobility, Health, and Ocean Sys- tems and Technologies, as well as projects POCI–01- 0145-FEDER-006933 -SYSTEC–Research Center for Sys- tems and Technologies - Institute of Systems and Robotics, Universidade do Porto, UID/MAT/00013/2013 - CMAT - Centro de Matemática da Universidade do Minho, and PTDC/EEI-AUT/2933/2014, POCI-01-0145-FEDER-016858 TOCCATTA, funded by FEDER funds through COM- PETE2020 - Programa Operacional Competitividade e Internacionalização (POCI) and by national funds through FCT - Fundação para a Ciência e a Tecnologia. REFERENCES [1] Surface Irrigation Optimization Models. Journal of Irrigation and Drainage Engineering, 112(1), 1061. [2] P. Bettiol and H. Frankowska. Normality of the maximum principle for nonconvex constrained bolza problems. Journal of Differential Equations, 243:256–269, 2007. [3] A. Cernea and H. Frankowska. A connection between the maximum principle and dynamic programming for constrained control problems. SIAM Journal of Control and Optimization, 44:673–703, 2005. [4] D. J. Bernardo, N. K. Whittlesey, K. E. Saxton, and D. L. Bassett. Irrigation Optimization Under Limited Water Supply. Transactions of the ASAE, 31(3):0712–0719, 1988. [5] HE Fawal, D Georges, and G Bornard. Optimal control of complex irrigation systems via decomposition-coordination and the use of aug- mented lagrangian. In Systems, Man, and Cybernetics, 1998. 1998 IEEE International Conference on, volume 4, pages 3874–3879. IEEE, 1998. [6] M. M. A. Ferreira and R. B. Vinter. When is the maximum principle for state constrained problems nondegenerate? Journal of Mathematical Analysis and Applications, 187(2):438–467, 1994. [7] F. A. C. C. Fontes and S. O. Lopes. Normal forms of necessary conditions for dynamic optimization problems with pathwise inequality constraints. Journal of Mathematical Analysis and Applications, 399:27– 37, 2013. [8] Fernando A.C.C. Fontes and Helene Frankowska. Normality and non- degeneracy for optimal control problems with state constraints. Journal of Optimization Theory and Application, 2015. [9] Karen Frenken and Virginie Gillete. Irrigation water requirement and water withdrawal by country. FAO AQUASTAT, 2012. [10] IPMA. https://www.ipma.pt/pt/. Accessed: 2017-01-20. [11] S.O. Lopes, F. A.C.C. Fontes, Rui M.S. Pereira, MdR de Pinho, and C. Ribeiro. Optimal control for an irrigation planning problem: Characterization of solution and validation of the numerical results. Lecture Notes in Electrical Engineering, 321:157–167, 2015. [12] S.O. Lopes and F.A.C.C. Fontes. Optimal control for an irrigation problem with several fields and common reservoir. Lecture Notes in Electrical Engineering, pages 179–188, 2016. [13] Sofia O. Lopes, F. A.C.C. Fontes, Rui M.S. Pereira, MdR de Pinho, and M. Gonçalves. Optimal control applied to an irrigation planning problem. Mathematical Problems in Engineering, 17:10, 2016. S.O. Lopes et al. | i-ETC - CETC2016 Issue, Vol. 3, n. 1 (2017) ID-9 i-ETC: ISEL Academic Journal of Electronics, Telecommunications and Computers Fig. 4. Controls an their boundaries Fig. 5. Multipliers associated to the crops Fig. 6. Multipliers associated to the water in the reservoir [14] Sofia O Lopes, FACC Fontes, and MdR de Pinho. On constraint qualifi- cations for nondegenerate necessary conditions of optimality applied to optimal control problems. Discrete and Continuous Dynamical System- A, 29(2), 2011. [15] Sofia O Lopes, Fernando ACC Fontes, and MDR de Pinho. An integral-type constraint qualification to guarantee nondegeneracy of the maximum principle for optimal control problems with state constraints. Systems and Control Letters, 62(8):686–692, 2013. [16] K. Malanowski. On normality of lagrange multipliers for state con- strained optimal control problems. Optimization, 52(1):75–91, 2003. [17] NASA. http://climate.nasa.gov/news/2537/nasa-noaa-data-show-2016- warmest-year-on-record-globally. Accessed: 2017-01-20. [18] F. Rampazzo and R. B. Vinter. A theorem on the existence of neighbouring feasible trajectories with aplication to optimal control. IMA Journal of Mathematical Control and Information, 16:335–351, 1999. [19] J. R. Raposo. A REGA — dos primitivos regadios as modernas técnicas de rega. Fundação Calouste Gulbenkian, 1996. [20] J Mohan Reddy. Local optimal control of irrigation canals. Journal of Irrigation and Drainage Engineering, 116(5):616–631, 1990. [21] R. Vinter. Optimal control. Birkhauser, Boston, 2000. [22] I. A. Walter, R. G. Allen, R. Elliott, D. Itenfisu, and et.al. The ASCE standardized reference evapotranspiration equation. Rep. Task Com. on Standardized Reference Evapotranspiration, 2002. S.O. Lopes et al. | i-ETC - CETC2016 Issue, Vol. 3, n. 1 (2017) ID-9 i-ETC: ISEL Academic Journal of Electronics, Telecommunications and Computers