\subsection{How to Perform "Predict Water Need"}

\par This is refer to Prediction Water function mentioned in figure \ref{fig:ffbd-control-irrigration} which is part of Control irrigation. There are popular ways to define how water is measured in the field such as utilizing capacitive sensors, Plant-related data (leaf wetness, stem diameter, canopy temperature) and Evapotranspiration (ET) calculations. With the telemetry sensors data provided in the previous function, method of Evapotranspiration calculation can be used to establish a metric. Due to timeseries nature of our data, we can apply simple machine learning model to predict the water amount based on sensors data.  With the output of of predictor, we can generate a another linear model that can help to optimize water usage amount. In antoher word, ET output would become a variable for next formula.

\subsection{Water Pump Optimization Model Using Weather Sensors and Linear Regression}

To estimate crop water demand more accurately, we adopt the FAO Penman-Monteith equation. This model computes the evapotranspiration ($ET_0$) by using temperature, humidity, wind speed, and radiation data:

\begin{equation}
ET_0 = \frac{0.408 \cdot \Delta \cdot (R_n - G) + \gamma \cdot \frac{900}{T + 273} \cdot u_2 \cdot (e_s - e_a)}
{\Delta + \gamma \cdot (1 + 0.34 \cdot u_2)}
\end{equation}

Where:
\begin{itemize}
    \item $ET_0$ = Reference evapotranspiration (mm/day)
    \item $\Delta$ = Slope of the saturation vapor pressure curve (kPa/°C) — computed from temperature
    \item $R_n$ = Net radiation at the crop surface (MJ/m$^2$/day) — from radiation sensors
    \item $G$ = Soil heat flux density (MJ/m$^2$/day) — often negligible for daily steps
    \item $\gamma$ = Psychrometric constant (kPa/°C) — depends on atmospheric pressure
    \item $T$ = Mean daily air temperature (°C) — from temperature sensors
    \item $u_2$ = Wind speed at 2 meters height (m/s) — from anemometers
    \item $e_s$ = Saturation vapor pressure (kPa) — derived from temperature
    \item $e_a$ = Actual vapor pressure (kPa) — from humidity sensors
\end{itemize}



\paragraph{Sensor Mapping for ET Variables}
\begin{table}[h]
\centering
\begin{tabularx}{\textwidth}{l X}
\toprule
\textbf{ET Variable} & \textbf{Typical Sensor Input} \\
\midrule
Air Temperature ($T$) & Temperature sensors (°C) \\
Relative Humidity (to compute $e_s$, $e_a$) & Humidity sensors (\%) \\
Wind Speed ($u_2$) & Anemometers (m/s) \\
Solar Radiation ($R_s$, to compute $R_n$) & Pyranometers (W/m$^2$ or MJ/m$^2$/day) \\
Net Radiation ($R_n$) & Derived or measured via radiation balance \\
\bottomrule
\end{tabularx}
\caption{Sensor Mapping to Penman-Monteith Variables}
\label{tab:et_sensor_mapping}
\end{table}

\subsubsection{Step 2: Linear Regression-Based Prediction Model}

We define a linear regression model to estimate the irrigation amount needed based on sensor data:

\begin{align}
\text{Irrigation Amount} =\; & \beta_0 + \beta_1 \times \text{Soil Moisture} 
+ \beta_2 \times \text{ET} \nonumber \\
& + \beta_3 \times \text{Plant Water Need} 
+ \beta_4 \times \text{Historical Irrigation} \nonumber \\
& + \beta_5 \times \text{Weather Forecast} + \varepsilon
\end{align}

\paragraph{Variable Definitions:}
\begin{itemize}
    \item $\text{Irrigation Amount}$: Predicted water application (Liters or mm)
    \item $\beta_i$: Regression coefficients determined via OLS (Ordinary Least Squares)
    \item $\varepsilon$: Residual error term
    \item \textbf{Weather Forecast (categorical)}:
    \begin{itemize}
        \item 0 = No Rain, 1 = Light Rain, 2 = Heavy Rain
    \end{itemize}
\end{itemize}

\subsubsection{Step 3: Optimization Formulation}

To avoid over- or under-irrigation, we introduce an optimization model that minimizes a cost function:

\begin{equation}
\min \; J = \alpha \cdot (\text{Soil Moisture}_{t+1} - \text{Optimal Moisture})^2 + \beta \cdot (\text{Irrigation Amount})^2
\end{equation}

Where:
\begin{itemize}
    \item $\alpha$: Weight for soil moisture deviation penalty
    \item $\beta$: Weight for irrigation cost penalty
    \item $\text{Soil Moisture}_{t+1}$: Predicted soil moisture after irrigation
    \item $\text{Optimal Moisture}$: Target soil moisture for optimal crop growth
\end{itemize}

\subsubsection{Step 4: Soil Moisture Dynamics}

To estimate future soil moisture, we model water balance as:

\begin{equation}
\text{Soil Moisture}_{t+1} = \text{Soil Moisture}_t + k \cdot \text{Irrigation Amount} - ET
\end{equation}

Where $k$ is a field-calibrated coefficient that relates irrigation to soil moisture increase.

\subsubsection{Step 5: Optimization Constraints}

\begin{align}
\text{Irrigation Amount}_{\text{min}} &\leq \text{Irrigation Amount} \leq \text{Irrigation Amount}_{\text{max}} \\
\text{Soil Moisture}_{t+1} &\leq \text{Field Capacity} \\
\text{Irrigation Amount} &\geq 0
\end{align}

\subsubsection{Step 6: Measurement Techniques for Irrigation Amount}

\begin{itemize}
    \item \textbf{Flow Meters:} Measure irrigation volume in real time (e.g., L/s or m$^3$/h)
    \item \textbf{Rain Gauges:} Capture rainfall to adjust irrigation schedule
    \item \textbf{Timers \& Flow Rate:} Volume is estimated as:
    \begin{equation}
        \text{Volume} = \text{Flow Rate} \times \text{Duration}
    \end{equation}
\end{itemize}

