Enhancing the Performance of a Simulated WWTP: Comparative Analysis of Control Strategies for the BSM2 Model

: This study aimed to improve the performance of a wastewater treatment plant (WWTP) simulated with Benchmark Model No. 2 (BSM2). To achieve this objective, three control strategies were implemented and tested. The first control strategy aimed to maintain the concentration of nitrate and nitrite nitrogen (S NO ) by controlling the external carbon flowrate (strategy A 1 ), and the second control strategy aimed to maintain the ammonia and ammonium nitrogen (S NH ) at a desired level with the use of a cascade controller (strategy A 2 ). The third strategy was applied to control the total suspended solids (TSS) (strategy A 3 ). Combinations of these strategies were considered (B 1 , B 2 , and B 3 strategies), as well as the use of all three together (strategy C 1 ). The control strategies presented in this paper were compared to the default control strategy of BSM2 to validate and identify the one that provided the best performance. The results revealed that the B 1 strategy was the most environmentally friendly, while C 1 obtained the highest overall performance. Several Monte Carlo simulations were performed for the validated control strategies, to identify the optimal setpoint values. For the C 1 strategy, a second method of optimization regarding polynomial interpolation was considered. The applied optimization methods provided the optimal reference values for the PI (proportional integral) controllers.

in the case of water body contamination with wastewater, regulated monitoring of the physicochemical quality indices is important to determine the level of pollution.
To increase the performance of a WWTP, various control strategies need to be tested and evaluated, to select the one that provides the best results. Testing such control strategies on pilot WWTPs is not ideal, taking into account the possible environmental risks and the additional operational costs. A solution to this problem is the use of benchmark models, such as Benchmark Simulation Model No. 2 (BSM2) [9]. This model is widely used in the field of wastewater treatment, being highly appreciated and used by the scientific community.
BSM2 promotes the idea of implementing and testing user-made control strategies. In the literature, there are various examples of configurations that aim to improve the performance of this simulated WWTP. Such control strategies can be found by consulting the specialized literature in the field.
In the study in [10], a fuzzy controller was used to reduce nitrous oxide emissions by minimizing oxygen levels. Another study [11] proposed the use of a fuzzy logic controller, to avoid violation of the BSM2 effluent quality limits for nitrogen and ammonia concentrations.
In the paper in [12], the default control strategy of BSM2 was optimized using the iterative relaxation method. The use of such iterative methods has proven to be useful when the known PI controller's setpoint value must be fine-tuned.
In the study in [13], two hierarchical control loops were proposed, one with a combination of proportional integral-model predictive control (PI-MPC) controllers for the lower level of control, and an MPC-Fuzzy combination for the higher level, with the purpose of enhancing the performance and reducing the operational cost of the plant.
The influent represents the wastewater that enters the WWTP. The influent can be described by its flow rate and load at the entrance to the WWTP. Usually, these influent characteristics are hard to predict, which is the reason why most WWTPs are designed with risk prevention control strategies, usually with bypass systems that are used in case the influent flow rate and load surpass the treatment capacity of the plant. The study in [14] proposed an extension for BSM2 including a sewer network. By implementing a sewer network model in BSM2, multiple options for generating the influent for the simulated WWTP become available; thus, urban WWTP operators can test different realistic scenarios regarding the flow rate and load of the influent.
In the study in [15], a control strategy based on fuzzy logic was implemented in a modified version of BSM2, called BSM2-PSFe [16], which is capable of describing the compound transformations and connections between phosphorus, sulfur, and iron cycles. Different combinations of PI and fuzzy logic controllers were able to successfully improve the effluent quality and the operational cost of the simulated WWTP. The efficiency index proposed in the previously mentioned work is computed as the ratio between the removed nitrogen during denitrification and the energy required for nitrogen removal.
The overall performance of WWTP can be improved by applying simple control loops governed by PID (proportional integral derivative) controllers. In BSM2, the most important control parameter in the aerated section of the bioreactor is dissolved oxygen. Manipulation of this parameter was proposed in [17], where a PID control loop was proposed to minimize the difference between the efficiency index and the desired value.
The optimization of the nitrification and denitrification processes is crucial in wastewater treatment. By conducting an optimized treatment process, the best results are usually obtained. The objective of achieving an optimized wastewater treatment process is discussed in the study in [18], where different fuzzy controllers and MPC were used to create control strategies that aimed to increase the performance of the nitrification and denitrification processes of the bioreactor. The study also proposed a method for detecting the best control strategy, using artificial neural networks to analyze effluent violations.
One of the key elements in optimizing wastewater treatment processes using PI controllers is to find the optimal setpoint value for such controllers. There are different ways to identify or compute the setpoint of the PI controller proposed in the specialized literature. The setpoint of the PI controller is usually considered constant, but it can also be dynamically computed, especially in the case of more complex control strategies. The study in [19] proposed a method of computing a dynamic reference value for a PI controller by predicting the aeration energy consumption with an artificial neural network.
The operation of WWTPs is marked by uncertainty regarding the influent flow rate and component load. Often, WWTP operators are defenseless against different scenarios where both the capacity and the treatment capability of the plant are passed, caused by an unexpected event such as torrential rain. In such situations, the operators are caught off guard and often a large portion of the influent must be bypassed, being discharged directly into the collecting body of water. In reality, every violation of effluent quality parameters may be fined by the responsible authorities, thus affecting the cost-efficiency of the plant. The effluent limit violations of different wastewater quality parameters are also included in BSM2; in the specialized literature, they are usually considered as a secondary performance criterion to evaluate the user-made control strategies. The work in [20] proposed a solution to such situations, using artificial neural networks to detect possible concentration violations of nitrogen and ammonia from the effluent. A similar idea was proposed in the paper [21], where the effluent concentrations were predicted using an alarm generation system based on artificial neural networks.
In the paper in [22], Monte Carlo simulations were performed with the open-loop and closed-loop versions of BSM2. The study proposed two control strategies for the bioreactor. The first strategy uses an oxygen controller, while the second strategy uses a cascade controller, where an ammonium controller regulates the setpoint for the oxygen controller. Monte Carlo simulations were used to generate different values for different plant parameters, such as the internal recirculation flow rate, bioreactor tank volumes, oxygen coefficient ratio, and setpoint of DO (dissolved oxygen) for one of the controllers. The parameters that had less influence over the evaluation criteria were identified and discarded via sensitivity analysis. Moreover, different plant parameters will provide different outcomes in terms of performance and cost efficiency. Thus, various scenarios and plant configurations were tested. By applying this uncertainty analysis method, the optimal version of the control strategies was identified.
In the study in [23], a global sensitivity analysis was performed by combining Monte Carlo simulations with standardized regression coefficients, which were applied to classify parameters by their influence over the BSM2 influent. A similar approach was utilized in the paper in [24], where instead of Monte Carlo simulations, a global sensitivity analysis was performed using polynomial chaos expansion, Gaussian process regression, and artificial neural networks.
The purpose of the present study was to obtain an enhanced performance for a simulated WWTP through implementing, testing, optimizing, and evaluating three control strategies within the framework of BSM2. All control strategies were implemented individually and in a combined manner, and this comparative method was chosen for strategy validation.

Benchmark Simulation Model No. 2
BSM2 was used in this study, and this model represents an important software tool for evaluating the performance of a simulated WWTP with activated sludge. The model was developed by the International Water Association (IWA) Task Group on Benchmarking of Control Strategies for WWTPs [9]. BSM2 is capable of simulating a WWTP with two stages of treatment. The first stage represents wastewater treatment, focused on removing the organic substances and nutrients (nitrogen), to obtain a high-quality effluent. Activated Sludge Model No. 1 (ASM1) [25] was included in the framework of BSM2 to describe the biological and chemical processes that occur in the bioreactor. This makes BSM2 capable of simulating important wastewater treatment processes such as nitrification and denitrification.
In the case of BSM2, the second treatment stage refers to sludge treatment, recirculation, and removal.
The sludge forms through the sedimentation of suspended solids in the primary and secondary clarifier, being further distributed across different treatment installations. The first sludge treatment installation is the thickener. In reality, at this point, the sludge is compressed using various mechanical processes (gravitational sedimentation, rotary drum thickeners, etc.) [26]. This is a process in which the volume of the sludge is reduced and it is prepared to be used in the next treatment installations.
In the next step, the sludge is pumped into the anaerobic digester. Anaerobic Digestion Model No.1 (ADM1) [27,28] was also implemented within the framework of BSM2, to describe the biochemical and physicochemical reactions that occur inside the anaerobic digestor. One key element of this process is the production of biogas, which is further used to sustain the energetic autonomy of the plant.
Lastly, the sludge is pumped into the dewatering unit, whose purpose is to remove any remaining water from the sludge. In reality, this process is carried out using various methods [29]: natural dewatering, drying bed, press filter, belt press filter, press filter with screw, rotary press, solid bowl centrifuge, electro-dewatering, liquid sludge, etc.
The active sludge is recirculated during the wastewater treatment stage to maintain a constant concentration in the bioreactor; in this way, the concentration of the microorganisms is maintained without being flushed out of the system, and thus the nitrification and denitrification processes are controlled.
The basic structure of BSM2 is presented in Figure 1 and includes the following treatment units: 1. Primary clarifier-based on the models developed by [30,31], which describe a biologically inert clarifier. Within this unit, the first separation of sludge and water takes place before the influent enters the bioreactor. The considered volume capacity for the clarifier is 900 m 3 ; 2. Activated sludge bioreactor for nitrogen removal, whose activity is described by the ASM1 model. The bioreactor consists of 5 compartments, with compartments 1-2 operating in anoxic conditions and compartments 3, 4, and 5 operating in aerobic conditions, where specific nitrification and denitrification processes occur. The volume considered for the bioreactor is 12,000 m 3 ; 3. Secondary clarifier-where excess activated sludge is separated from the water, based on the dynamic settling and thickening model developed by [32]. The volume capacity of this unit is 6000 m 3 . The model does not describe any biological processes. 4. Sludge thickening station-capable of achieving a solid removal efficiency of 98% [33]. This unit is modeled as being biologically inert. 5. Anaerobic digestion station (ADM1); 6. Sludge drying station-the final stage before removing the sludge from the system, this unit is modeled as a biologically inert installation. 7. Storage station-the physically-based model describes the process of collecting water obtained during the drying process. The station has a volume capacity of 160 m 3 .
A dynamic influent was considered for 609 days. The period between day 0 to day 245 represents the period of plant stabilization, while the period from day 245 to day 609 represents the observation time. The performance evaluation of the implemented control strategies was conducted using BSM2′s evaluation tools, using mathematical equations that represent the quality of the influent-IQI (influent quality index), the effluent-EQI (effluent quality index), and the operational cost of the treatment plant-OCI (overall cost index), while taking into account only the observation period.
IQI is expressed in kg pollution unit/day, and it is used to indicate the pollution load of the influent. The difference between the IQI and EQI shows the treated pollution load using the simulated WWTP.
where tobs is the observation time, TSS (total suspended solids), COD (chemical oxygen demand), NKj (Kjeldahl nitrogen concentration), NO (nitrite and nitrate concentration), and BOD5 (biochemical oxygen demand), Bi represents the weighting factors, and Qi is the influent flow rate. The EQI (measured in kg pollution unit/day) is the average value of the sum of the weighted effluent loads of the primary wastewater compounds that have a major influence on the quality of the receiving water, calculated over the observation period of one year (364 days). Additionally, when user-implemented control strategies are employed, the EQI can offer valuable insights into the impact of these strategies on the treatment performance of the plant.
EQI is computed using the following mathematical expression: where Qe is the effluent flow rate. The weighting factors for specific influent and effluent parameters have the following values: BTSS = 2, BCOD = 1, BNKJ = 30, BNO = 10, and BBOD5 = 2. The applied values indicate that NKJ has the strongest impact on IQI and EQI.
The purpose of the OCI can be interpreted in two ways. First, it serves to provide information regarding the operating costs of the entire plant. Second, it provides valuable insights into the energetic performance of the control strategies used. OCI analysis can provide a comprehensive understanding of the financial implications and efficiency of the control measures implemented within plant operations.
The simulated WWTP effluent is described by the following mathematical relation: where Qsc,e is the overflow rate from the secondary clarifier and Qbypass is the bypassed flow rate of raw wastewater. OCI is described using the following mathematical relation: where AE is the energy consumed for aeration, PE is the energy consumed by the pumping system, SP is sludge production, EC is external carbon consumption, ME is mixing energy, METprod is the production of biogas, and HEnet is the energy consumed for heating. During the performance analysis stage, the BSM2 model utilizes threshold values for the concentrations of key quality parameters in the effluent. These threshold values can be modified based on user preferences. In this case, the maximum allowable values used were the standard values specified in the BSM2 model, as presented in Table 1.

Parameter Limits
Ntot is total nitrogen, CODtot is total chemical oxygen demand, and SNH is ammonia and ammonium nitrogen.
The effluent Ntot is computed with the following mathematical formula: The effluent CODtot is computed with the following mathematical formula: COD ,e = S S,e + S I,e + X S,e + X I,e + X B,H,e + X B,A,e + X P,e .
The effluent SNKj,e is computed with the following mathematical formula: S NKj,e = S NH,e + S ND,e + X ND,e + i XB (X B,H,e + X B,A,e ) + i XP (X P,e + X i,e ).
The effluent TSS is computed with the following mathematical formula: TSS e = 0.75 • (X S,e + X I,e + X B,H,e + X B,A,e + X P,e ).
The effluent BOD5 is computed with the following mathematical formula: BSM2 introduces a basic control strategy that is depicted schematically in Figure 2 and hereinafter referred to in this article as DefCL. This strategy represents a starting point for new BSM2 users for how they can build and implement their custom control strategies.
The DefCL strategy comprises two control loops to optimize the nitrification and denitrification processes in the bioreactor. The first control loop aims to maintain the dissolved oxygen (DO) level in bioreactor tank no. 5 at a predefined value of 2 g (-COD)/m 3 . This is achieved by manipulating the oxygen transfer coefficient KLa4 in bioreactor tank no. 4 to ensure compliance with the following relationships: where KLa3 is the oxygen transfer coefficient for tank no. 3 of the bioreactor, and KLa5 is the oxygen transfer coefficient for tank no. 5 of the bioreactor. Within the DefCL strategy, the addition of carbon from external sources into the first tank of the anoxic zone in the bioreactor, at a constant flow rate of 2 m 3 /day (Qcrab1), is considered. The purpose of this action is to enhance the potential of the denitrification process. This is achieved through the manipulation of the actuator that controls the carbon flow rate, Qcarb1.
The results obtained with the DefCL strategy can be used as a reference for comparing the outcomes with other user-created control strategies. Where Qpo represents the influent flow rate, Zpo is the influent concentrations, C means constant value, PI is the proportional integral controller, SO4,ref is the setpoint for the PI controller, SO4 is the dissolved oxygen (DO) value measured by a type A sensor, Qint is internal recycle flow rate, Qr is the external recycle flow rate, Qf is the flow rate of the water that exits the bioreactor towards the secondary clarifier, Qsc,u is the underflow rate of the secondary clarifier, Qsc,e is the overflow rate from the secondary clarifier, Qw is the wastage flow rate, zm is equal to 1 m and represents the height of each of the 10 levels of the secondary clarifier.
In addition to the manipulable execution elements, the model also includes a PI-type controller and sensors classified into six categories, based on the measured parameters and response time (A, B0, B1, C0, C1, and D).

Implemented Control Strategies
In this study, the BSM2 model was employed. Three control strategies, presented for the first time in the study [34], were evaluated to identify the strategy that provided the best performance for further optimizations. The control strategies were tested in an individual (strategy A1, A2, A3), combined (strategy B1, B2, B3), and comprehensive manner (strategy C1). The strategies A1, A2, and A3 correspond with the WL-A2, WL-A4, and SL-A1 control strategies from the paper [34].
The purpose of this paper was to compare the results obtained with the proposed control strategies, to identify the best control strategy, and with an attempt to optimize the PI controllers' reference values. A more detailed description of each control loop can be found in the paper in [34].
The first control strategy implemented, represented in Figure 3 and hereafter referred to as A1, includes the following control elements: a PI controller, a B0-type sensor, and an actuator (valve). The B0 type is used to measure the concentration of SNO from the second anoxic tank of the bioreactor. The PI controller computes the optimal value of the external carbon flow rate (Qcarb1) based on the measured value of SNO and the setpoint value for external carbon addition (Qcarb,ref). The considered value for Qcarb,ref is 1 m 3 /day. The objective of this control strategy is to support the DefCL, by converting the constant flow rate of external carbon addition into a closed loop. In this way, it was considered that the denitrification process would be optimized, resulting in a better overall performance. The second control strategy, hereafter referred to as A2 and presented in Figure 4, acts as a support for the DefCL by involving a cascade controller (PI-PI), which involves a higher-level PI controller. The higher-level control loop contains a PI controller and an Atype sensor. The sensor is used to measure the SNH from the fifth aerated tank of the bioreactor. The purpose of the higher-level controller is to compute a dynamic setpoint for the second PI controller, based on the measured values of SNH and the reference value of 1g N/m 3 represented by SNH,ref. The third control strategy, hereafter referred to as A3 presented in Figure 5, does not have a direct connection with DefCL. The A3 components include a PI controller, an A-type sensor, and an actuator. The sensor has the purpose of measuring the TSS concentration in the fifth tank of the biological reactor. The measured information is used by the PI alongside the considered reference value of 4000 g SS/m 3 (TSSref) to compute an optimal value for Qw. Strategy B1, presented in Figure 6a, represents a combination of strategy A1 and A2. The strategy involves a newly implemented control loop and a cascade controller to maintain the SNO and SNH concentration in the first and the last tank of the bioreactor at a desired value.
Strategy B2, presented in Figure 6b, is formed by the simultaneous implementation of strategies A1 and A3. Thus, two control loops were considered: one designed to maintain the SNO at a desired value in the first anoxic tank, and the other, with the same purpose, for the TSS from the fifth tank of the biological reactor.
Strategy B3, presented in Figure 6c consists of strategies A2 and A3, which were implemented together, to control the concentration of SNH and TSS in the last aerated tank of the bioreactor.
The most complex strategy used in this paper is strategy C1, presented in Figure 6d. This strategy represents the simultaneous implementation of the A1, A2, and A3 strategies. The purpose of this strategy was to control the concentration of SNO in the first anoxic tank and the SNH and TSS in the last aerated tank.

Additional Evaluation Criterion
An overall performance criterion (OPC) was proposed to summarize the performance and the operational cost of the control strategies. The OEC takes into account the equal importance of the EQI and OCI for classifying the control strategies using their final results.
The OPC has the following mathematical formula: where EQI ̅̅̅̅̅ and OCI ̅̅̅̅̅ represent the normalized values of EQI and OCI.
Taking into account that EQI and OCI reflect the real performance of the simulated WTTP, a secondary tiebreaker criterion was considered to identify the strategy that is the most environmentally friendly. Thus, an environmentally friendly criterion (EFC) was formulated as:

Evaluation of the Considered Control Strategies
The intermediate results represent the performance of the control strategies regarding their environmental and legal impact and are presented in Figure 7. In practice, exceeding the limit values for all effluent quality parameters may result in penalties imposed on the operator of the WWTP. In the case of BSM2, this idea is not implemented but it is reflected by the EQI.
We must take into account that the control strategy that obtained the shortest violation time for a specific effluent quality parameter represents the best performance regarding the environmental impact.
The violation time for Ntot is presented in Figure 7a. The shortest violation time was obtained by the B2 strategy (0.177 days), followed by C1 (0.468 days).
For CODtot, the intermediate results are presented in Figure 7b. Control strategies DefCL, A1, and B1, obtained the best performance, the recorded violation time for all three strategies was 0.283 days.
In the case of SNH, presented in Figure 7c, the shortest violation time was obtained with the B3 control strategy, representing 0.5417 days. Figure 7d, presents the violation time for TSS. The best performance was obtained with the DefCL strategy, followed by the results obtained with the A2 and B1 strategies.
Finally, the results, presented in Figure 7e indicate that the shortest violation time for BOD5 was recorded with the DefCL, A2, and B1 control strategies. All the results were compared regarding the DefCL control strategy as a reference point. The results shown in Figure 8 indicate that the strategy with the smallest negative impact on the environment was B1. The second place was taken by strategy A2. The other control strategies obtained performances that were above the reference. The most important evaluation within BSM2 is represented by the EQI and OCI indexes. The overall performance of the plant can be approximated by consulting the values of these important evaluation factors.
The results regarding the EQI values, presented in Figure 9a, indicate that the best performance was obtained using the C1 strategy, recording 5.039433478034807 × 10 3 kg poll. units/day. If we analyze the results presented in Figure 9b, we can observe that strategy C1 also obtained the best result compared to all other control strategies regarding the operational cost of the plant. The data presented in Figure 10 was used for strategy validation, regarding the effluent quality and the operational cost, which was obtained by applying Equation (12). The best results were obtained by using strategy C1 (0.869), the second place was taken by the B1 strategy with 0.912, and the third place was taken by strategy B3 with 0.923. Monte Carlo simulations are used as part of uncertainty analysis, with the scope of exploring a wide range of possible input combinations by using random sampling from input parameter distributions. In our case, the considered input parameters that were randomized were the reference values for the PI controllers (Qcarb,ref, SNH,ref, and TSSref). To randomize the sampling from input parameter distributions, the following mathematical relation was formulated: where Xn represents the parameter for which the random values are being generated. (X1 = Qcarb,ref, X2 = SNH,ref, X3 = TSSref) that follow a normal distribution N(μ, σ 2 ) and are constrained within the range Z describing the range [minval, maxval]; μ is considered as the mean value of the considered parameter; σ is the standard deviation used in the normal distribution. The algorithm used to generate the random numbers with a normal distribution follows the steps mentioned below: Step 1: Generate a standard normal random variable Z ~ N(0, 1); Step 2: Scale Z to fit within the desired range [minval, maxval]; Step 3: Ensure that X is truncated to be within the desired range [minval, maxval]. For each input parameter, the [minval, maxval] range condition was determined as the minimum and maximum detected value for nitrate and nitrite nitrogen, ammonia and ammonium nitrogen, during the simulation with DefCL. For TSSref, the generated data were truncated between 3997 and 4004 g SS/m 3 . The data regarding the considered range values are provided in Table 2. In the case of strategy B1, the generated and applied values for Qcarb,ref, are presented in Figure 11a. The data indicate that the lowest recorded value for Qcarb,ref was 0.01631 m 3 /day, while the highest was 3.286 m 3 /day. The mean value for the Qcarb,ref dataset was 1.273 m 3 /day, with a standard deviation of 0.6972 m 3 /day. Figure 11b shows the arranged data in the form of a histogram with seven categories. The category for values between 1 and 1.  The obtained data for EFC is presented in Figure 13a,b. By analyzing the data shown in Figure 13a, the lowest and best value for EFC was recorded during simulation nr. 33, representing 0.75, while the worst result was recorded during simulation nr. 51, with a value of 7.17. The histogram presented in Figure 13b  The Monte Carlo simulation data analysis, for strategy B1 showed that the lowest obtained value for EFC was 0.75, which was recorded during simulation nr. 34, with the corresponding reference values Qcarb,ref = 2.20 m 3 /day and SNH,ref = 0.82 g N/m 3 . The analyzed data show that the environmental impact of the WWTP can be reduced using the optimized version of the B1 strategy (B1,optim1). The data showed that the EFC value for strategy B1,optim1 was better at 4.36% than B1.
In the case of the C1 control strategy, 220 Monte Carlo simulations were performed to identify a better OPC performance regarding the variation of Qcarb,ref, SNH,ref, and TSSref. A higher number of simulations were performed compared to the case of the B1 control strategy, due to the higher importance accorded to the OPC criterion, which summarizes the treatment performance and the cost efficiency of the simulated WWTP.
The generated and applied values of Qcarb,ref are presented in Figure 14a,b. The lowest value generated for Qcarb,ref was 0.0165 m 3 /day, while the highest was 3.705 m 3 /day, the average value for the data was 1.263 m 3 /day, with a corresponding standard deviation of 0.8219 m 3 /day. The histogram presented in Figure 14b  The data regarding the generated and applied values of SNH,ref during the simulations with the C1 control strategy is presented in Figure 15a,b. The data show that the lowest generated value for SNH,ref was 0.1226 g N/m 3 , and the highest value was 3.734 g N/m 3 . The average value of the dataset was 1.259 g N/m 3 , with a standard deviation of 0.7502 g N/m 3 . The histogram presented in Figure 15b contains eight classes. Most of the generated values fit in the class associated with the 1-1.5 g N/m 3 range, including a total of 49 values. The categories with the lowest value counts are the ones representing the 3-3.5 and 3.5-4 g N/m 3 range.  The obtained data for OPC are presented in Figure 17a,b. The analysis of the provided data showed that the lowest value for OPC was 0.8062, while the highest value recorded was 1.27. The average value for the data set was below the reference value of 1 (0.9264), with a standard deviation of 0.1093. The histogram presented in Figure 17b  The analysis of the database obtained with Monte Carlo simulations for strategy C1 showed that the lowest recorded value for OPC was 0.806, obtained during simulation nr. 185, with the corresponding reference values Qcarb,ref = 3.217 m 3 /day, SNH,ref =1.367 g N/m 3 , and TSSref = 4.0008 g SS/m 3 . The results obtained with the Monte Carlo simulations indicate that by using the above-provided reference values, a better overall performance of the WWTP can be obtained with the optimized version of the C1 control strategy, hereinafter referred to as C1,optim1, regarding the effluent quality and operational cost. The data analysis showed that the recorded OPC value for the C1,optim1 strategy was 7.27% better than C1.
The required time for running a single BSM2 simulation with the implemented control strategies on the MATLAB-Simulink version R2021 (The MathWorks, Inc., Natick, MA, USA) [35] software platform and on the hardware platform (PC), described in Table  3, was 3 h. For this study, a total of 329 simulations were performed; this means that the total average time required to perform all the simulations was 987 h or 41.125 days. A secondary optimization method was applied to fine-tune the results obtained with the Monte Carlo simulations. In this process, all the data obtained during the 220 Monte Carlo simulations with the C1 control strategy were considered.
We wanted to use these parameters in the control of the reactor and as an output parameter, and we considered the OPC computed by Equation (12). Thus, an algorithm was built, as well as an application in MAPLE [36] to obtain the interpolation in the polynomial form that allowed identifying the minimum points of the OPC. A total of 220 simulations were used with the considered parameters, with reference values generated by the Monte Carlo simulations.
The algorithm used in MAPLE was as follows: Step 1: enter the obtained input data; Step 2: enter the result data-the values for the OPC; Step 3: a polynomial interpolation function with mixed terms is considered to eliminate Runge-type oscillations: Step 4: the quadratic sum of the errors is considered an optimization criterion: Step 5: choose an order for the polynomial of the variable X = Qcarb,ref-i.e., N1, order for the polynomial of the variable Y = SNH,ref-i.e., N2, order for the polynomial of the variable Z = TSSref-i.e., N3, order for the mixed polynomial in the X and Y variables-i.e., M1, order for the mixed polynomial in the variables Y and Z-i.e., M2, order for the mixed polynomial in the variables Y and Z-i.e., M3f). The expression (9) is constructed, and the unknown parameters are identified{ } =1, 1 , Step 6: the minimum equations for the SS function are obtained through the Lagrange criterion: Step 7: the system of Equation (17) is obtained Step 8: solve and obtain the OPC function (15) Step 9: the global extreme point is obtained using the gradient method:  The final results regarding the OPC are presented in Figure 19. The analysis of the data shows that C1,optim1 version obtained the best results compared with the unoptimized C1 strategy and with the C1,optim2 version. This indicates that both the applied optimization methods provided an improvement for the C1 strategy, while taking into account the wastewater treatment performance and the cost efficiency of the WWTP. Figure 19. Final results of OPC for the C1, C1,optim1, and C1,optim2 control strategies.

Conclusions
This study proposed evaluating seven control strategies (A1, A2, A3, B1, B2, B3, and C1), which were implemented and tested within the BSM2 framework. The evaluation of these strategies was performed by directly comparing the final results with the results obtained with the DefCL strategy. Thus, both the performance and operating cost, represented by the EQI and OCI, as well as the violation time for specific effluent quality parameters, representing the legal aspect regarding environmental impact, were taken into consideration. Significant importance was given to the influent treatment performance and operating cost, since these indexes are commonly used in the specialized literature.
The implemented control strategies were tested both independently and in combined variants, to identify the strategy that provided the best performance. Strategies A1 and A2 were developed as supporting strategies for DefCL, which remained active during all simulations. Therefore, the BSM2 structure for closed-loop simulations was not excessively affected by the applied strategies. This allowed for a direct comparison with the DefCL strategy, as the strategies could have both a positive and negative impact on EQI and OCI.
The analysis of the results regarding the EFC criterion indicated that the B1 strategy had the lowest negative impact on the environment. However, this does not imply that this strategy was the best in terms of performance and operating cost, as indicated by the OPC criterion, where this strategy ranked in second place.
This paper proposes two new evaluation criteria (EFC and OPC), which proved to be extremely precise and useful when comparing the results of user-made control strategies and the default strategy of BSM2. EFC and OPC were used to simplify and clarify the difference between the reference and the compared results. While OPC was used to summarize the treatment performance and the economic aspect of the simulated WWTP operation, the EFC criteria were used to identify the control strategy that proved to have the smallest negative impact on the environment.
The most important results are indicated by the OPC criterion. Although the EFC criterion suggests that the B1 strategy was the most environmentally friendly, when considering the overall treatment performance and operating costs, this strategy obtained second place. Thus, the strategy with the most significant results was considered to be strategy C1, as indicated by the lowest pollutant loading of the effluent and the lowest operating cost, as confirmed by the values of the additional OPC.
In the attempt to identify the optimal setpoints for the PI controllers, 100 Monte Carlo simulations were performed for strategy B1 and 220 simulations for C1 strategy. The database obtained was analyzed to identify if there were any better results than the one detected during the validation of the best control strategy. The uncertainty analysis of the data obtained with the Monte Carlo simulations indicated that there was a better EFC value recorded for strategy B1 and a better OPC value for strategy C1.
Interestingly, the applied method proved to be useful for identifying the optimal reference values, and this supports the theory that the higher number of Monte Carlo simulations performed, the better the result. Our applied method could also be useful for identifying the main reference values for PI controllers in cases where these values are completely unknown or uncertain.
A secondary optimization method was applied to the Monte Carlo simulation database. The studied system accepts interpolation functions of odd order, an aspect that is relatively easy to understand. This aspect allows the identification of some truthful solutions regarding the optimization of the setpoints of the involved PI controllers.
The obtained results regarding the optimized versions of the B1 and, especially, C1 control strategies proved that these optimization methods could be successfully applied to identify and fine-tune the reference values for PI controllers.