## 2 Materials and Methods  
### Process Model  
The sewage treatment plant considered in this work has an anaerobic-anoxic-aerobic (A\({}^{2}\)O) arrangement. The sewage enters the treatment plant with a flow rate of about 115,000 m\({}^{3}\)/day, and it undergoes a series of physical treatments: mechanical filtration,separation of sand and grease, and the first sedimentation step. Water exits the first clarification step and enters the bioreactor tank. Here, activated sludge technology significantly reduces the concentration of carbon, nitrogen and phosphorus compounds. Three different zones characterize the biodegradation basins. The first one is anaerobic and has a capacity of about 9000 m\({}^{3}\); the second is anoxic and has a volume of around 12,800 m\({}^{3}\); the third is aerobic and comprises a total volume of approximately 33,000 m\({}^{3}\). Biological phosphorus removal is accomplished in the first bioreactor, and the transformation of nitrates and nitrites (NO) produced in the aerobic reactor occurs in the second bioreactor [48]. Physical separation takes place in a secondary clarifier. The clean water is discharged to the emissary river as purified water. A small fraction of 0.5% of the secondary clarifier bottom sludge flow rate is directed to the plant unit for digestion. The bulk is returned to the anaerobic degradation tank as external recycling. A second recycle flow, called internal recycling, recycles nitrate from the aerated bioreactor to the anoxic bioreactor for denitrification [49; 50]. The WWTP model constructed and developed in this study was built on the foundations of BSM1 and ASM1. To comply with the A\({}^{2}\)O configuration, size and operation characteristics of the case study targeted municipal WWTP, the appropriate modifications were made to the original BSM1. Each of the basic structural parts of the WWTP was described by a set of differential and algebraic equations: primary settler [51], anaerobic bioreactor, anoxic bioreactor, the set of 3 aerated bioreactors [51] and secondary settling unit [52]. Design and dry weather operation data were collected and reconciled from municipal WWTP measurements. The plant data were further used to update and calibrate the modified BSM1 model [53]. The model parameters were calibrated using optimization techniques. This previously calibrated model of the municipal sewage treatment plant was used in the current work to carry out the scenarios of simulations for the normal and faulty sensors. The model was implemented in MATLAB version 8.5 (MathWorks, Natick, MA, USA) and Simulink\({}^{\text{TM}}\) version 8.5 software (MathWorks, Natick, MA, USA). In order to speed up the simulation of Simulink S-functions and save computational resources, the mathematical model was written in the C++ programming language and compiled as a MATLAB executable. Automatic control is widely regarded as critical for the efficient and safe operation of the WWTP, and the prevention of pollution spread into freshwater ecosystems [54; 55]. When associated with optimization, control generates a highly valuable synergy [56; 57]. This study employed two typical automatic control structures: one is the dissolved oxygen control loop, and the other one is devoted to the control of nitrates and nitrites concentration. Both control loops used proportional-integral (PI) controllers. The DO concentration in the aerated bioreactor was controlled by the first loop, and the nitrate and nitrite concentrations in the anoxic bioreactor were controlled by the second loop. For the DO concentration control loop, the DO reference of 2 mg O\({}_{2}\)/L was enforced in the aerobic bioreactor in order to prevent excessive aeration [58]. The DO controller manipulates the air control valves to supply the necessary oxygen flow rate into the aerated reactors. In the sequence of three aerobic reactors (No. 3, 4 and 5) of the modified BSM1 plant configuration, the airflow calculated by the oxygen controller was unevenly distributed.