Optimal Control Applied to an Irrigation Planning Problem

We propose a mathematical model to study the water usage for the irrigation of given farmland to guarantee that the field crop is kept in a good state of preservation. This problem is formulated as an optimal control problem. The lack of analytic solution leads us to turn to numerical methods to solve the problem numerically. We then apply necessary conditions of optimality to validate the numerical solution. To deal with the high degree of unpredictability of water inflow due to weather, we further propose a replan strategy and we implement it.


Introduction
The climate system and the ecosystems are under accelerated change while human cultures, economic activities, and national interactions are undergoing dramatic and sometimes exponential changes [1].The world population is increasing and according to some estimates it will pass 8 billion by 2030.At the same time an increasing number of people are becoming more prosperous and need more water, in the form of the liquid itself and through the use of other products, virtual water.
According to [2], the water flow needs that typically occur every year in the spring/summer period, with a marked intensity in Southern Europe, namely, Portugal, limit strongly the agriculture production.Consequently, it is appropriate to discuss the use of water in these conditions, trying to find the best technical solutions making it possible to improve the efficiency of water use, in response to the environmental concerns.Agriculture exerts pressure on the environment, especially on water, in terms of quantity and quality.An appropriate water management throughout the irrigation processes is the right way to go.
In this paper, we propose a simple mathematical model that will help to plan the water used in a field of potatoes in the Lisbon area.This model is based on a dynamic equation that can translate the hydrological balance equation.
We assume that the soil is homogeneous and that the soil has one cubic meter of volume.A first model is used as a prototype to qualitatively validate irrigation of a farm field.In the literature, there are some examples for irrigation of potatoes farm fields in the Lisbon area.Using their inputs, we are able to qualitatively reproduce the literature outputs.The next step is to calibrate and test our model in a real farm [3].
In order to characterize the solution to our problem, we guarantee the existence of solution via Clarke's theorem [4].Next we characterize the solution using the necessary conditions of optimality in the normal form and then we use such information to validate the numerical solution.
Although preliminary results on this subjects are presented in [5][6][7][8][9], here we improve them and discuss them in detail.Additionally, here we propose the implementation of the replan methodology.Due to weather unpredictability, rainfall might be difficult to estimate accurately.To account for this fact, we propose the recalculation of the optimal strategy every time we obtain new data: a replanning or receding horizon strategy.

Characterization of the Solution of the Irrigation Problem
Our problem consists in optimizing the planning of the water used in the irrigation of farm fields by means of the optimal control, where the trajectory () is the water in the soil and the control () is the flow of water introduced in the soil via its irrigation system.The formulation is as follows: OCP is as follows: min where  is the hydrologic balance function,  min is the hydrological need of the crop (according to [3]),  0 is an initial state,  is a given time, and  is the maximum flow of water that comes from tap.The dynamic function that represents the hydrologic balance is given by (, , ) =  + () − , where () is the rainfall minus the evapotranspiration and  is the percentage of losses of water due to the runoff and deep infiltration [10].Without loss of generality, we assume that  is a continuous function.This optimal control problem has inequality state constraints that can be written in the form ℎ(()) ≤ 0, where ℎ(()) = −() +  min .
Since our optimal control problem has inequality constraints, applying the Maximum Principle to this problem does not allow us to get the explicit analytical solution to the problem.
To guarantee that our problem is meaningful we first prove the existence of the solution.Next, we apply necessary conditions to get some characterization of the optimal solution.

Existence of Solution and
Normality.Here, we discuss the existence of an admissible solution, the existence of an optimal solution, and normality of the optimality conditions.The existence of solution asserts the meaningfulness of our problem.The information extracted from necessary conditions will be of use to validate the numerical results.In order to guarantee that there exists an admissible solution, we have to guarantee that we start at a feasible state and that the maximum flow of incoming water is sufficient to satisfy the needs of the crop throughout the year.We show that, in these conditions, we can also guarantee the existence of an optimal solution to the OCP and that the necessary optimality conditions for this problem can be written in a normal form.
Existence of solution was introduced by Tonelli [11] when he proposed the first theorem of existence of solution for calculus of variations problems.Even today, Tonelli's theorem remains the central existence theorem for dynamic problems, although the hypotheses of the theorem can be relaxed: see, for example, [12].In this section, we apply theorem 23.10 in [4] to guarantee the existence of solution for our OCP.Moreover, we also verify that our problem satisfies the constraint qualification that allows writing the Maximum Principle (MP) in the normal form: the multiplier associated with the objective function  is not zero (see [13,14] for discussion of normal forms of the MP for optimal control problems with state constraints).
Normal forms of the Maximum Principle can be established if the problem satisfies suitable constraint qualification [13][14][15].In this section, we verify that constraint qualification in [14] is satisfied for our problem.
Let function  represent the unmaximized Hamiltonian function: where  and  are multipliers.We note that the function  is mensurable.
Existence of an Optimal Solution.Let us verify the conditions of theorem 23.10 in [4]; see Theorem A.1 (in Appendix).
Let us verify the conditions of theorem 23.10 to OCP  : (i) The dynamic function ( + () − , ) is continuous with respect to the states and control variable and measurable in .
The assumptions of theorem 23.10 in [4] are verified; therefore there exists one admissible (, ) for OCP with a finite value on the cost functional; then there is a solution to OCP.
The Maximum Principle Can Be Written with  = 1.In Rampazzo and Vinter [14], the MP can be written with  = 1, if there exists continuous feedback  = (, ) such that for some positive   , whenever (, ) is close to the graph of the optimal trajectory, (⋅), and  is near to the state constraint boundary.There should exist a control (flow of water provided by the irrigation systems) pulling the state variable away from the state constraint boundary (this guarantees that the crop survives).
In our problem ℎ() =  min −  and, from (8), we write where Δ(, ) = () − .For  on a neighbourhood of , we can always choose  sufficiently large so that ( 9) is satisfied, as long as  > () − (), a condition we can impose with loss of generality.Thus the inward pointing condition ( 9) is satisfied and normality follows.

Necessary Conditions.
In this section, we apply the MP in the normal form.
Proposition 2 (necessary conditions).If the pair (, ) is a minimizer for the OCP, then there exists an absolutely continuous function  and  ∈  * (0, 1) such that where () is defined as follows: Proof.A known form of the normal MP for smooth problems with state constraints [1,3,15] is as follows.
Let (, ) be a minimizer for OCP.Then there exists an absolutely continuous function  and  ∈  * (0, 1) such that If  = , we have that, for all () ∈ [0, ], ( () − 1) In the remaining case (i.e.,  ∈ ]0, [), we have We will use all the above information to validate the numerical solution (already presented in [7]) of our problem.In order to obtain this numerical solution, we consider next a discretized version of our problem.

Numerical Model for the Irrigation Problem
In this section, we obtain the numerical solution to our problem using sequence of finite dimensional nonlinear programming problems.From now on, we consider the following corresponding discrete-time model: where  is the trajectory,  is the control,  is balance water function,  min is the hydrological need of the crop,  is an initial state,  is the time step discretization, and  = 12/.The dynamic equation implements the water balance in the soil: where the evapotranspiration is the evaporation of the soil and the transpiration of the crop and the losses are the losses of water due to the runoff and deep infiltration.The rainfall, evapotranspiration, and losses models are described next, as presented in [10].

Rainfall Models.
To estimate rainfall, we use the monthly rainfall data from Instituto Português do Mar e da Atmosfera (http://www.meteo.pt/), in the Lisbon area.We defined average (using the 10-year data) rainfall for each month of the year; the rain monthly average is as follows: To create the possibility of different weather scenarios, the rain monthly average is multiplied by a precipitation factor.That means rainfall 1 (  ) = precipitation factor × rain monthly average (  ) , where the precipitation factor allows us to consider a typical year if this factor is 1, a drought year if it is less than 1, and a rainy year if it is above 1.This model is based on rain monthly average, so it is interesting if we are solving the yearly problem, for instance, if we want to design a reservoir [6] that can provide the necessary amount of water to our culture.

Evapotranspiration
Model.We used the Pennman-Monteith methodology [16] to calculate evapotranspiration of our culture along the year.In order to do so, we use the following formulation: where   = 0.825 is the culture coefficient for the evapotranspiration (in our case potatoes) and  0 is the tabulated reference value of evapotranspiration that we consulted in [3] for the Lisbon region.The evapotranspiration of our culture in Lisbon is given by the following table: where (  ,   ) =   +rainfall(  )−evapotranspiration(  ).Note that we have a first-order linear ordinary differential equation with integrating factor equal to   .From ( 19) and ( 24), one may say that losses(  ) = (  ), where  depends on the type of soil.
To obtain the numerical solution for the optimal control problem we have approximated the problem by a sequence of finite dimensional nonlinear programming problems (see [18]).
To implement this optimization problem, we use fmincon function of MatLab with the algorithm "active set," by default, and the parameter "Tolfun" is considered 1 − 6.The numerical solution and the expected multipliers are plotted in Figure 1.
Note that the green line represents the hydrological need of the crop.
It can be seen that the value of the optimal amount of water in the soil stays at the minimum allowed value from June till September.The irrigation should start in May; the maximum value is in June and stops in September.The water needs are 0.4612 m 3 /year.The code produces results that are according to what is expected for this region [3].
We can observe that and since  is never equal to 1,  is never greater than 1, as expected from Section 3.3.From here, we can say that although the analytical explicit solution was not obtained, the numerical solution fulfils the necessary optimality conditions.
Our numerical findings suggest that the trajectory has a "boundary interval" [ in ,  out ], with  in > 0 and  out < 12 (i.e., () =  min for all  ∈ [ in ,  out ] and () ̸ =  min for  ∉ [ in ,  out ]) and that  is absolutely continuous function excepted at  out where it exhibits a jump.Taking these information into account we now get an analytical characterization of the solution and  multiplier.

Briefly,
In Figure 2, we plot the numerical and analytical solution obtained.We confirm that the numerical solution agrees with the results shown in Section 3. The analytical and estimated results of trajectory, control, and multipliers coincide.
3.5.Replan.In the previous section, we have computed optimal yearly planning for the needs of water.However, such planning is open-loop, meaning that the input used the prediction for the rainfall along the year as known in the beginning of the year.As we advance through the year, knowledge of the effective past rainfall and a better prediction of the rainfall for the coming months is available.In this section we propose to use this newly available knowledge by resolving the optimal control problem at each month using the new rainfall information, in a receding horizon framework.
In fact, due to the unpredictability of weather conditions, the numerical model presented in the previous section may not provide the real needs of water for the crop.If we have an atypical year, values obtained by the rainfall model may be a lot different from reality, meaning that there is a high probability that the results obtained may not properly describe the reality (if we use as input in our previous model the effective rainfall in each month, the estimated irrigation needs may be higher than if we use as input the rainfall model proposed in Section 3.1).
In Figure 3 we show the results for the years 2004 and 2005 which were severe drought years in Portugal.
For the year 2004, if we look at real data, one can see that the irrigation should start in the mid-April.Using the rainfall as input, the irrigation should start in May.The total amount of water used estimated using the rainfall model is 0.4612 m 3 /year and the real amount of water needed would be 0.5124 m 3 /year.
For the year 2005 if we look at real data, one can see that the irrigation should start in the beginning of March.Using the rainfall model as input, the irrigation should start in May.The real amount of water needed would be 0.6814 m 3 /year.This is due to the unpredictability of the weather.The rainfall was much different from the expected, and, as a consequence, in such a scenario the proposed model would fail.
To overcome this drawback, we propose replan strategy: see Figure 4. To replan the systems we use model predictive control techniques.The predictive control technique generates a feedback strategy by solving a sequence of openloop optimal control problems.In terms of the problem, this means that the irrigation strategy is frequently recomputed (replan) every time taking into account the measured system variable (previous pluviosity).In our case, we determine the optimal solution based on the OCPN and then at every time step we recalculate a new dynamic based on real data for rainfall.
We test the replan model for the last ten years and we observe that state constraint is violated in the years 2003, 2005, 2007, 2008, and 2009.For data of year 2005, the result obtained is described in Figure 5.
To avoid violation of the state constraint (because of use of real data) an improved model had to be considered.In this new model, we use soft state constraints instead of hard state constraint.Therefore, we consider an optimal control problem with penalization in the cost function: In this case where V  =   −  min   .Note that the condition  0 =  is reused at each time step considering the real value of rainfall at that time step.Note that   represents a safety margin that will guarantee that if weather conditions are very severe, the plant survives.In our case we consider = 1.3  meaning that the amount of water necessary is 30% above the plants' needs.However, should time step be smaller, this safety margin may be reduced.
Results for the improved replan strategy can be seen in Figure 6.
Figure 6 shows that for the year 2005 the state constraint is not violated and the result is very close to the optimal solution obtained knowing the rainfall a priori.The water flow needs obtained knowing the rainfall a priori were 0.6803 m 3 /year.The water flow needs estimation using the replan strategy

Conclusion
Our problem consists in optimizing the use of water in irrigation of a farm field by means of optimal control with inequality constraints.We proposed minimizing the irrigation (control) so that the flow of water introduced in the soil (trajectory) fulfils the cultivation water requirements.The corresponding discrete problem was then formulated and the numerical solution obtained.In order to validate the numerical results, we characterized the solution analytically.We proved the existence of solution and we characterized the solution applying the necessary conditions of optimality in the form of the Maximum Principle.We conclude that the multiplier () ≤ 1 when  <  and () = 1 when  > 0.
From the numerical solution, we determined  in and  out where the state constraints were active.With  in and  out we calculated the analytical solution.We observed that analytical and numerical results were very similar.
Due to the weather unpredictability, rainfall estimation may be far from reality.In such a case, the results obtained may not be the best.In order to overcome this difficulty we implemented a replan strategy, considering soft state constraints.Even for a severe drought year like 2005, this new strategy produced good results.

3. 4 .
Results and Validation.We consider a field of potatoes in the region of Lisbon, Portugal.We assume that

Figure 3 :
Figure 3: Solutions obtained for the years 2004 and 2005.

Figure 5 :
Figure 5: Results for the replan strategy for the year 2005 considering hard state constraints.