## 3 Expert Model Predictive Controller Design  
The block diagram of the designed Expert MPC is depicted in Figure 4. Since the dynamic parameters of the RO desalination plants vary due to membrane fouling, this controller has a plant identification block that on-line calculates the parameters of the prediction model. Based on the information available, the Expert System can develop different on-line decision-making strategies to achieve the control objective, and the prediction error \(\mathbf{e}(k+j)\) approaches zero. Figure 3: Validation results of the mathematical model obtained, where: (**a**) \(G_{11}(s)\); (**b**) \(G_{12}(s)\); (**c**) \(G_{21}(s)\); (**d**) \(G_{22}(s)\). The architecture of the developed Expert System is shown in Figure 5. The components of this Expert System are: the Data Base, the Knowledge Base, the Inference Engine, and the Explanation Module. The Data Base contains the information of all the signals of the control system (a set of facts). The Knowledge Base includes the available symbolic knowledge about the control system represented by a set of rules (the Rule Base). The Rule Base contains rules in the \"IF (case) THEN (action)\" format, which deals with conditions involving changing in the control system. The Inference Engine comprises the methods for applying the general knowledge of the control system (mechanism to match the left and sides of the rules in order to succeed the goals or sub-goals), i.e. to emulate the control expert's decision-making process in reasoning about what input to generate for the plant. The explanation module informs the users on how and why the conclusions are obtained. The CLIPS commercial expert system shell was used because of its flexibility, expandability and low cost [79]. The shell refers to the software package containing a generic inference engine, a user interface, and a structured skeleton of a knowledge base in its empty state with the appropriate knowledge representation facilities that enable users to develop and use expert systems [63]. The Rules Base contains more than 50 rules. The rules were generated based on the knowledge of expert operators on the dynamic behaviour of these plants, as well as on the optimization and safety of their operation. Some rules of the Rule Base are the following:  
Rule 1: IF \(e(k)>e_{n}\), where \(e_{n}\) is a threshold error value, THEN update the parameters of the prediction model with the estimation of the plant identification block;  
Rule 2: IF \(e(k)<=e_{n}\), THEN maintain the current parameters of the prediction model;  
Rule 3: IF \(e(k+j)>0\), THEN continue with the calculation of the new control signal \(u(k)\);  
Rule 4: IF \(e(k+j)<0\), THEN increase the current values of the weighting matrix for control moves (\(Q\));  
Figure 4: Block diagram of the designed Expert Model Predictive Controller. Figure 5: Architecture of the Expert System. * IF \(\tau==0\), where \(\tau\) is the plant time delay, THEN maintain the current value of the minimum prediction horizon (\(N_{1}\));
* Rule 6: IF \(\tau>=0\), where \(\tau\) is the plant time delay, THEN equalize the minimum value of the minimum prediction horizon with the current value of the time delay (\(N_{1}==\tau\));
* Rule 7: IF \(\hat{y}(k+j)>w(k+j)\), where \(w(k+j)\) is the external reference, THEN decrease the current values of the weighting matrix for predicted errors (\(R\));
* Rule 8: IF \(u(k)\) is very aggressive, THEN increase the current values of the weighting matrix for control moves (\(Q\));
* Rule 9: IF \(u(k)\) is very aggressive, THEN increase the current value of the maximum prediction horizon (\(N_{2}\));
* Rule 10: IF \(e(k)==\pm m\), where \(m\) is the steady state error, THEN increase the current values of the weighting matrix for predicted errors (\(R\)). The Rule Base was tested by verifying that it is consistent, that it has no errors, and that it complies with the specifications and established objectives.