## 3 Hierarchical Control System
### Optimization Process
#### 3.3.1 Optimization Details  
A two-step optimization application (Figure 5 explains operating principles) is proposed which determines the aeration trajectory for each refill of the SBR tank and adjusts the settings of the control system to meet the established goal, minimization of operational cost of the WWTP, with SBR. It means that whenever the SBR is being refilled (see Figure 4), the designed optimizer runs and calculates the solution of the problem. Figure 4 shows only the overall operational principles without a detailed explanation of how the optimizer calculates the specific values. The principle of the optimizer's operation is based on two algorithms. In the first place, a non-deterministic algorithm (\"Artificial Bee Colony Algorithm\" block) is initiated after the filling phase. Inputs for this block are decision-making variables with random values in the range of given constraints. This block determines the best values of decision-making variables according to constraints in such a way that the value of the target function is as low as possible. Then calculated values of individual variables are sent to the deterministic algorithm (\"Direct Search Algorithm\" block), as starting conditions. Both algorithms use a simplified model of the SBR (\"Simplified ASM2d model\" block), which makes the calculation time shorter, but decreases the precision of the found solution. Next, the results of both of the algorithms are compared (\"Better solution?\" block), as a solution with the lower value of the objective function is sent to the control system with a more accurate SBR model (\"SIMBA Model ASM2d\" block) to simulate the work of the plant. Figure 6 shows the course of exemplary trajectory of \(DO_{ref}\) set by the optimizer described in this section. With each refill of the SBR tank, the designed supervisory controller with optimizer calculates  
Figure 5: Scheme of the optimization process. the optimal solution of the objective function. The \(DO_{\textit{ref}}\) trajectory is being adapted to the existing biological conditions, thus it may look different after each refill. Proper control of an SBR plant is a difficult and demanding task from both economical and performance point of view. The most significant step in the decision-making process is to formulate the optimization problem. Due to the significant complexity of the SBR wastewater treatment plant model together with the aeration system model, it was decided to use the partial nitrification approach. It guarantees relatively easy implementation and the possibility of effective de-pollution. However, this approach necessitates the use of different types of decision-making variables. Finding proper decision-making variables is a very complicated process and demands extensive knowledge about the technology of SBR plants and biological processes inside the plant. The efficiency of wastewater treatment in the active sludge technology is dependent on several key factors: aeration profile, temperature, sludge age and the quality of wastewater and its concentration. Aeration is the factor that has the biggest impact on the economic aspects of wastewater treatment, due to generating the highest cost. The number of decision-making variables has a direct impact on the complexity of the whole optimization process. The following decision-making variables occur in the optimization task: \(x_{1}\)--the order of phases (aerobic--1, or anaerobic--0, binary) [-], \(x_{2}\)--phase length in day (floating point) [d], \(x_{3}\)--amount of the sequences (integer) [-] and \(x_{4}\)--value of \(DO_{\textit{ref}}\) (floating point) [g O\({}_{2}\)/m\({}^{3}\)]. It has to be noted that variables \(x_{2}\) and \(x_{3}\) relate to the pair of anaerobic and aerobic phases. It means that if the given optimizing application computes the solution which consists of two anaerobic phases 0.2-day length each, the amount and length of the aerobic phases will be exactly the same. Considering the given information, the total length of the reaction phase will remain at 0.8 day.