## 4 Optimization Results and Discussion  
The main goal of implementing the described control system with an optimizer is to improve the efficiency of WWTP and to minimize the incurred costs over one cycle at the same time. This leads to an overall enhancement of the whole system, including higher amount and quality of treated effluent alongside with the cost reduction. The aeration system of the plant and the control system with an optimizer were designed and implemented in Matlab software with the additional SIMBA package, which allows to simulate the work of wastewater treatment plants. The reference control algorithm, with fixed time limits (like the one in Swarzewo WWTP), was prepared in order to compare the obtained results with the described system. Slight change--replacement of the existing PI controller (DO) for the cascade system--had to be done to provide the common basis for the comparison. The optimization tests were conducted for two different scenarios with fixed inflow (5000 m\({}^{3}\)/d) and various contamination levels of effluent, which are: \(COD\) = 535 g O\({}_{2}\)/m\({}^{3}\), \(N_{tot}\) = 55 g N/m\({}^{3}\) and \(P_{tot}\) = 7.38 g P/m\({}^{3}\) for the 1 st one and \(COD\) = 1070 g O\({}_{2}\)/m\({}^{3}\), \(N_{tot}\) = 110 g N/m\({}^{3}\) and \(P_{tot}\) = 14.75 g P/m\({}^{3}\) for the second one. The maximum acceptable pollutant concentrations of effluent, according to the water-law permit for Swarzewo WWTP, are listed in Section 2 of this paper. In the course of the conducted tests, three different types of control systems were compared: new control system with optimizer (symbol OP), reference control system mentioned above (symbol CU) and the heuristic system with supervisory controller [29] (symbol HE). The amount of energy consumed by a single SBR operating cycle is as follows:  
\[E(t)=\frac{s}{3600}\cdot\int\limits_{0}^{t_{s}}p(\tau)\cdot Q_{air}(\tau)d\tau \tag{10}\]  
where: \(E\)--energy related to the work of blowers [kWh], \(s\)--inverse of the blowers efficiency coefficient, \(t_{s}\)--simulation time [s], \(p(t)\)--fleeting value of pressure in the aeration system [kPa] and \(Q_{air}(t)\) --fleeting value of the air flow volume [m\({}^{3}\)/d]. Energy cost, defined as the amount of energy consumed to treat 1 m\({}^{3}\) of wastewater, is the ratio of overall energy consumption and the amount of treated wastewater per cycle. The level of active volume during tests was set to 971 m\({}^{3}\). The results obtained for each of the control systems are compared one to another in the further part of this section. Formula (12) is used to calculate the level (percentage) of improvement:  
\[Z=\frac{x-y}{|x|}\cdot 100\% \tag{11}\]  
where: \(Z\)--the value of calculated comparison criteria [%], \(x\)--base data/point and \(y\)--compared data/point. Table 1 presents the values of important pollution indexes (COD, \(N_{tot}\), \(P_{tot}\)) as well as the efficiency and energy cost indexes which are the main reasons to optimize the work of the SBR plant. Taking into account the contamination rates of the SBR plant production, the best results have a structure with a heuristic control system, and the worst is the reference system from Swarzewo. As shown in Table 1, the original SBR plant control system works well with nitrogen purification but does not work at all in terms of phosphorus use.