## 4 Optimization Results and Discussion
A control system with a heuristic controller  
\begin{table}
\begin{tabular}{c c c c c c c c c c} \hline \hline \multirow{2}{*}{**Scenario**} & \multirow{2}{*}{**System**} & \(COD_{in}\) & \(COD_{out}\) & \(Red.\) & \(N_{tot,in}\) & \(N_{tot,out}\) & \(Red.\) & \(P_{tot,in}\) & \(P_{tot,out}\) [g & \(Red.\) \\  & & [g O\({}_{2}\)/m\({}^{3}\)] & [g O\({}_{2}\)/m\({}^{3}\)] & [\%] & [g N/m\({}^{3}\)] & [g N/m\({}^{3}\)] & [\%] & [g P/m\({}^{3}\)] & [\%] \\ \hline \multirow{achieving the best result in almost all cases failed to reduce phosphorus in the output wastewater for Scenario II, which shows that a system with an optimizer can be a little more consistent in terms of compliance with the limit values for pollution indicators. The objective function that has been used in the optimizer focuses mainly on reducing energy costs for wastewater treatment. For this reason, the output wastewater pollution indicators are not so important and are maintained only at the limits. A hierarchical control system with an optimizer works slightly worse in terms of numerical values than a system with a heuristic controller, but if one looks at binary results (1--maintained limit values, 0--no), there is only one structure that performs all the tasks. Another significant aspect in evaluating the operation of a control system with an optimizer is the amount of energy required to treat wastewater during the full cycle of the SBR plant. Table 2 shows three important indicators: efficiency (E\({}_{\text{f}}\)), energy cost (E\({}_{\text{c}}\)) and energy to perform a single work cycle (E). As can be seen in Table 2, the main objective of the optimizer application has been met. Energy cost is the lowest for both scenarios, as is the energy needed to perform one full cycle work. The worst results in each of the presented indicators are shown by the control system in Swarzewo. This is due to the fact that a simple timer-based control system has been used in the actual treatment plant. A positive aspect of this solution is the guarantee of always treating the same amount of wastewater at a constant known time. The heuristic controller has the best efficiency ratio and, compared to Swarzewo, significantly reduces the amount of energy required for wastewater treatment. This performance efficiency is guaranteed by assumptions of this structure, which included at least two full work cycles in one day. This assumption did not occur in the process of creating an optimizer for the SBR plant. Therefore, the performance in a structure with an optimizer is the most varied. Other factors, such as energy and energy costs in one work cycle, are minimized even more than with the heuristic method. The optimization of these two parameters was the main objective of the proposed optimizer and the implementation of this assumption looks very optimistic. DO are illustrated in Figures 7 and 8. These apply to Scenario II, which usually occurs in Swarzewo WWTP. Figure 7 shows three complete cycles of SBR installations. As it can be seen, the DO values and the number of aerobic phases for each additional portion of wastewater vary significantly. This is because the optimizer initially randomly searches for the best solution, so one can find many combinations of DO, number of sequences and phase lengths that can be optimal for each case. This diversity of optimal solutions is also the result of changes in the biological environment inside the reactor. Figure 8 shows the magnification of the DO and it is, therefore, easier to compare DO with \(DO_{\text{ref}}\). The SBR is a very complex plant and does not allow real DO capacity to deal with the \(DO_{\text{ref}}\) perfectly. Therefore, some overshootings and other imperfections of the DO are acceptable. However, the serious problem of the optimizer is that sometimes it can find solutions that are almost impossible to apply in the simulation and can cause problems in keeping contaminant parameters within their limits. This can be particularly the case if the input wastewater is heavily polluted.