## 2 Materials and Methods
### WWTP Process and Model Description
#### 2.2.3 WWTP Control Problem  
The control problem formulation is based on the influence of the activated sludge process variables on the general performance of the WWTP. The effluent quality is given by the limits imposed by the environmental regulation over nutrients and organic matter concentration of WWTP discharges. The effluent quality limits considered here are those defined within the BSM1 in [22] and reproduced here in Table 1.  
The violations of the established limits over pollutants concentration in the effluent presented in Table 1 has an impact on economics due to the fines imposed for off-specification discharges. In the periods of lower load, the reduced levels of pollutants facilitate the treatment, and the effluent quality standards can be achieved even with values of dissolved oxygen (DO, also denoted by \(S_{\text{O2}}\)) below the reference. The regulation of the dissolved oxygen concentration (\(S_{\text{O2}}\)) and nitrates (\(S_{\text{NO1}}\)) to reference values that ensure the desired process performance implies the use of energy for aeration and pumping purposes. In this situation, driving these variables to the set point using a conservative control strategy may result in unnecessary energy consumption. On the other hand, during the periods of higher load, it is necessary to increase the biological activity to reduce the excessive amount of pollutants. Then, the attainment of the set points for \(S_{\text{O2}}\) and \(S_{\text{NO1}}\) is decisive to meet the effluent quality specifications or minimize the violations of the imposed limits to avoid economic penalties. The desired levels over COD in Table 1 are easily satisfied. The total nitrogen (TN) includes, among others, the NH\({}_{4}\)\({}^{+}\) + NH\({}_{3}\) compounds. These compounds are more damaging than nitrates in the effluent (\(S_{\text{NO},e}\)). Therefore, in this work, the effluent quality is measured considering only the concentration of NH\({}_{4}\)\({}^{+}\) + NH\({}_{3}\) compounds in the effluent (\(S_{\text{NH},e}\)). A concentration of NH\({}_{4}\)\({}^{+}\) + NH\({}_{3}\) compounds in the effluent below 4 mg/L is desired. A performance index that measures the economic penalty for violations of the \(S_{\text{NH},e}\) as a function of the concentration of ammonium compounds in the ASP (\(S_{\text{NH}}\)) is [21]:  
\[Cost\_{\text{NH}}_{eff}=\left\{ \begin{array}{c}0\ for\ S_{\text{NH},e}<4\\ \frac{8.2}{1000}\int\limits_{t_{0}}^{tf}\left(S_{\text{NH}}(t)-4\right)\cdot Q _{e}(t)\cdot dt\left[\frac{\text{Kg}}{\text{day}}\right]\ for\ S_{\text{NH},e} \geq 4\end{array} \right. \tag{3}\]  
The index \(Cost\_{\text{NH}}_{eff}\) is a measure of the load in excess accumulated in the operating period. In practice, the bound of 4 mg/L is applied over the daily mean concentration of the NH\({}_{4}\)\({}^{+}\) + NH\({}_{3}\) compounds in the effluent (\(S_{\text{NH},e}\)). In addition to the economic penalty for effluent limit violation, operating costs related to energy consumption are also considered. They include the aeration energy and the pumping energy, which are measured using the cost indices proposed in the BSM1 platform [22]. \begin{table}
\begin{tabular}{c c} \hline \hline
**Variable** & **Bound** \\ \hline Total Nitrogen (TN) & \textless{}18 grN/m\({}^{3}\) \\ Chemical Oxygen Demand (COD\({}_{e}\)) & \textless{}100 grCOD/m\({}^{3}\) \\ Ammonium concentration (\(S_{\text{NH},e}\)) & \textless{}4 grN/m\({}^{3}\) \\ Nitrate concentration (\(S_{\text{NO},e}\)) & \textless{}10 grN/m\({}^{3}\) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Effluent quality limits. In this case study, the Pumping Energy (\(PE\)) represents the energy use for the pumping of internal recycle flow (\(Qa\)):  
\[PE=\frac{1}{T}\int\limits_{t_{0}}^{tf}(0.004\cdot Q_{a}(t))dt\ \left[\frac{\text{kWh}}{ \text{day}}\right] \tag{4}\]  
where \(t_{0}\) and \(t_{f}\) are the initial and final times considered for the index evaluation and \(T=t_{f}-t_{0}\).