Intelligent multi-agent architecture for a supervisor of a water treatment plant

The rapid development of Information and Communication Technologies (ICT) and high-capacity hardware components make it necessary to achieve a strong integration of automatic systems based on new paradigms on intelligent distributed architectures, where require highly complex supervision and control tasks, due to the generated requirements of the new production systems, the high number of variables to control and the advancement of technologies, especially in industries where continuous processes have been established. In the present work, a distributed hierarchical modular architecture is proposed for a supervision system, based on multi-agent systems (MAS), oriented to the management of processes in the filtration stage of a water purification plant, using a methodology to the implementation of intelligent agents that allow to project, design, verify and validate the system. This methodology is fundamentally based on the use of the Unified Modeling Language (UML) for its projection and Petri nets (PN) for the simulation and validation of properties, which allows to guarantee the modularity, flexibility, and robustness of the proposed system. The architectures of the intelligent agents in the different programmable devices are modeled and simulated to achieve an adequate interaction and collaboration, allowing to reduce the conflicts that may be generated between them. The evaluation of the distributed architecture focuses on the fulfillment of the functional requirements and evaluation metrics, which, through the analysis of the properties of the Petri net, allows to determine the correct operation of the system and its dynamic behavior in the face of unforeseen situations at different levels of automation.


Introduction
At the present time, industrial processes face great challenges to achieve high levels of production with the quality of the product demanded by the market, requiring for this to maintain high levels of safety, reliability and availability of the processes and the systems involved [1,2,3]. The development of new technologies has made possible the integration of industrial process data in a distributed way, leaving behind the classic automation systems based on local information, until reaching applications based on web services that achieve the integration of information and the data distributed at the different levels in the industrial supervision systems of a company [4,5,6]. The need for integration of automation systems (information systems + decision-making systems + decision-making support systems) generates automation that is complex to implement, especially if there are no adequate platforms and control elements, both decision-making and regulatory, which allow the achievement of integrated automation

Analysis for Filtering Thread Automation
Filtration is a water purification sub-process in which the particles and microorganisms that have not been retained in the previous treatment sub-processes are separated, which is why filters are the most important equipment of the water treatment plant and its good Operation is highly dependent on the quality of the water as a final product. During the useful life of the filters, they are subjected to several backwashing or filter washing processes, because as the pores of the filter sand become dirty, an increase in the pressure drop occurs until reaching a value maximum that is given by the height of water above the sand of the filter. The duration of this washing process (known as the filtration run) is the working time of the filter between washing and washing and can range from 12 hours to several days.
Filter washing is the operation by which the filtration process is suspended, and water is injected through the bottom of the filter (drains) with adequate pressure, with the objective that the filter bed expands, the grains are rubbed and all the material that has remained between them in the filtering operation is detached. The water treatment plant that is proposed as a case study in this work has a battery of fast and open filters with six independent filtration cells, as shown in figure 1. To maintain the minimum capacity of the plant, the operation is required. Simultaneous filtering of at least four filter cells.
The arrival of the settled water to the filter bank is carried out through the interconnection tube with the settler from its bifurcation, each filtration unit consists of five valves with different functions, figure  1, water inlet to be filtered (V1), filtered water outlet (V2), backwash water inlet (V3), wastewater outlet (V4) and drain outlet (V5). To enable washing, a level greater than the minimum of 0.2 m in the storage tank will be necessary. For lower values, the filter washing process will be blocked, although the level can be adjusted during the operation of the system.
Next, general aspects are described to develop the automation process of the six filtration cells. In the automation of a water treatment plant, the subsystems corresponding to the control and supervision of the operation of the filters would be integrated with the rest of the subsystems  The main functions and requirements of the filter automation system that have been considered are the following: • Measure the level in the filter.
• Measure the water pressure at the washing inlet on the filter.
• Check the operating states of the filter (filtration, washing, rinsing, or draining).
• Check the level in the filter during the filtration state.
• Check the inlet pressure of the filter washing water.
• Check the water level in the wash tank.
• Check the start / stop sequence of pumps B1 and B2 for filling the wash tank.
• Acquisition and registration of all the variables in the six filtration units, the storage tank, and the washing tank. • Generation of alarms for abnormal states of the variables, establishing priority levels as required. • User interface with restricted access to configure the system, display, or change the desired values of the controlled variables. • Failure diagnosis of all sensors, actuators, and pumps of the six filtration units, the storage tank, and the washing tank. • Fault tolerance functions in the control of the water pumps for the wash tank.
• Production management of the filters to maintain the minimum production capacity required in the plant (keep four filters in a state of filtration, manage the washing process and consider the diagnosis of equipment failures). • Maintenance management based on the diagnosis of all the sensors, actuators, and pumps of the six filtration units, the storage tank, and the washing tank. • Remote access via mobile device, limited only to the supervisor's viewing.
• All signals will be displayed on the supervisor's screen. The representation of the filtration units, the storage tank and the washing tank must guarantee real-time visualization of the operating status of each subsystem. The sequence of filter operations depends on the four possible states, filtration, washing, rinsing, and draining. In addition, the water pressure for washing the filters and the filling process of the washing

Modular structure of automation for the case study
Based on the functional requirements of the industrial automation process under study, a hierarchical architecture illustrated in Figure 2 is proposed. To guarantee distributed intelligence, a modular design of the architecture is necessary, in such a way that the existence of communication networks from the sensor level to the supervision level. The proposal of physical elements with these characteristics constitutes the basis that should allow the two-way exchange of data to process and transform them into useful information that helps in decision-making. To satisfy the requirement for intelligent field instrumentation, the Modbus RTU network [20,27] is proposed, which offers the possibility of transmitting standard data and safety-oriented data over the same cable.
Other research works propose the use of sensors with microcontrollers to manage intelligence in these devices in such a way that a more robust and efficient automation system is achieved [24,25,26,27]. In our research, it is proposed to use SIEMENS SIMATIC S7-1200 series compact design controllers, since they have a high integration scale, great real-time calculation capacity and powerful communication possibilities that include an Ethernet interface. Regarding the supervision system, the use of 7-inch KINCO-brand panels with Human-Machine Interface (HMI) is proposed, which have sufficient features, present a powerful development environment, and have an adequate cost. One of the HMIs will preferably be used to visualize all the variables and the dynamic behavior of the filters and another for the cistern and washing tank subsystem. In the intelligent supervisory system, for the development of advanced automation features such as production and maintenance management, it is proposed to use the SCADA CODESYS HMI SL from a PC with wireless connectivity to the automated system. between intelligent agents are determined, which guarantees the proper functioning of the system. The internal interactions within the agent are called internal conflicts or internal collaborations and the external conflicts or external collaborations [28,29,30].
In general, the advantages offered by SMAs for intelligent integrated automation can be very significant, however, from the perspective of designers there is an increase in the complexity of the design [5,31,32], which constitutes a challenge for developers of design, modeling and simulation tools, as they must also take into account the possibility of new phases during the analysis and design stages of automation projects. An alternative for its solution can be given in the methodology suggested in figure 3 [3].

Figure 3. Stages of a development methodology for SMAs
Considering the architecture proposed in figure 2, the stages that the methodology of figure 3 must meet for the case study are analyzed below.

Design and Analysis
For the design of the intelligent integrated system, the UML language given in [33] and the SMA methodology detailed in [4] are used. Based on these results, the design of an architecture of distributed intelligent agents is proposed that allows evaluating their cooperation and conflict resolution, complying with the local and general requirements of the process with the greatest efficiency. The UML modeling tools, specifically the use case diagrams, allow evaluating the functionalities of each of the components and their interrelation for the fulfillment of the general objectives. For this reason, an initial phase of "definition" is established in Figure 2.

Simulation and Modeling
The structure and operation are simulated in the Simulink software and the hierarchical Petri nets extended in the Matlab and Visual Object Net programs. In the second stage of the proposed design, the modeling, simulation, verification, and validation of the industrial automation models are carried out. integrated. These models are implemented from the use case diagrams using UML diagrams (sequence diagrams, class diagrams and / or state diagrams or models in Petri nets (PN GHENeSys hierarchical extended and / or hybrid). Sequence allows establishing the interrelationships between agents based on a time base. Class diagrams are established for the parts of the system that require programming in superlanguages and a guide for the programs of the local control devices. State machines, allow to establish the fundamental stages that systems fulfill for the fulfillment of their functions, and which are the indicators for state changes. However, any of the UML diagrams represent the behavior of the system statically. For this reason, the translation of state diagrams to Petri nets allows the simulation of the dynamic behavior of the system [34]. Verification of the model properties makes it possible to determine some important characteristics, such as the liveliness or absence of blockages, which makes it possible to guarantee that the application programs created from said models in PN are also absent from unplanned stops. The validation by dynamic simulation of the model makes it possible to guarantee that the programs fulfill the required functions.

Programming and simulation of industrial or service applications
The third stage of the integrated automation system considers the programming of the application by translating the verified and validated models into an application program package. The programming is initially carried out on program design tools that allow validating the applications created, since they are tools that allow simulating the behavior of the programs within the local control devices, the windows and programs of the supervision and the communication networks, using various tools, for example, the CoDeSys software. This helps reduce programming errors before implementation.

Implementation of Integrated Automation
In the last stage of development of the intelligent integrated automation system is the study of the particularities of the technology to be used to adapt the programs and models already validated to a technological architecture of application to the filtering process of the water treatment plant. In this stage, the coordination of activities in real time of each function of the transactional domain is carried out, in which tests are carried out at an experimental level to validate the results with comparison metrics that are internationally recognized.
Next, a procedure is presented with the methodology proposed for the formal description of the SMA proposed in the automation of the filters of the water purification plant.

Method for the formal description of the proposed Multi-agent System
The studies and tests carried out allow the application of the SMA design method proposed in our research, which consists of six stages to achieve the expected results. The stages or steps of the proposed SMA are the formal description of the agents for each of the agents, the use case diagrams of each level of abstraction, the class diagram of each level of abstraction, the sequence diagram of each level. of abstraction, the state diagram of each type of agent and finally the Petri net of each type of agent. For reasons of extension of these activities, only the analysis of the Level Sensor deliberative Subagent is presented, analyzed through the six steps.

Step 1
The architecture or model of agents Beliefs, Desires, and Intentions (BDI) is associated with beliefs, desires, or objectives to be achieved and intentions or plans to act and achieve those desires [35,36]. In formal terms, this logic can be used to describe the components or agents of the SMA. In the practical order, beliefs can be seen as the state of the world. Desires or goals can be associated with a utility value so that desires can be differentiated, as these can be valued using "path formulas" by which all possible paths associated with a desire can be evaluated. Also, in practice, assessment functions can be used to dynamically update goals. On the other hand, the intentions reflect the actions that must be taken to achieve the objectives, so the intentions indicate the actions along a path formula in the decision tree used to calculate the goal values [33].
The BDI architecture analyzes the system as a rational agent with certain mental attitudes present in human beings, emphasizing beliefs, desires and intentions, which represent the information (Beliefs), motivation (Desires) and deliberative (Intentions) states. ) from the people. These attitudes of BDI agents, unlike reactive agents, allow a proactive behavior of the system to try to fulfill its own plans and objectives, which is of vital importance to achieve better performance.
The basic model of the BDI architecture presented in figure 4 proposes the following behavior scheme for the agents [37]: • Perceive changes in the environment in which it operates.
• Review your beliefs about the world based on your perception.
• Reason about your intentions to reconsider them if necessary.
• Select an action, reasoning about your beliefs and your intentions. • Execute the selected action, which produces changes in the environment, and return to step 1 to perceive the changes that have occurred.

Figure 4. Basic BDI Architecture Outline
Next, the table with the beliefs, desires and intention of the Filter Level Sensor Subagent is shown considering the BDI model based on agents sensitive to individual behavior. The Production Planning Agent, Filter Agent, Filtration Controller Subagent, and Actuator Subagent V1 have also been developed, but due to space limitations they have not been included in this work.

Step 2
The UML modeling language is the most widely used standard for specifying and documenting any system precisely [33]. The use of UML as a tool for system modeling is an important aid in describing  [21]. Figure 5 shows the diagram of use cases corresponding to the internal architecture proposed for the Subagent Agent Level Filter Sensor.  Figure 6 shows the diagram of use cases of the intelligent supervision abstraction level, where agents have been included as special actors to obtain an overview of the system, identifying all the functionalities present in the system and the interactions between the agents of this level. This diagram shows the interaction between agent and subagents that represent the levels of supervision, control, and intelligent instrumentation, within the respective subsystems modeled for each use case.

Step 3
The class diagrams of each level of abstraction represented by the use cases analyzed in the previous section are presented to model the static structure of the system, identifying the relationships between the classes, their attributes, and methods, including the characteristics of the SMA [33]. Figure 7 shows the agent class diagram for the smart monitoring level. In it, it can be noted that the Intelligent Supervision Management Agent is a fundamental virtual actor of this level, in fact, through its own subagent interface, the interaction of the SMA with the real actors of the case study takes place.

Step 5
In the set of agents that represent the entire SMA, five types of agents were selected that, due to their functions, tasks, and level of abstraction to which they belong, can be considered representative of the rest; the selected agents were the Production Planning Agent, the Filter Agent, the Filtration Controlling Subagent, the Filter Level Sensor Subagent, and the Actuating Subagent. In correspondence with them, the state diagrams of each type of agent are presented to analyze the behavior of a specific object, containing the rules for each transition. Figure 9 shows the state diagram modeling the Filter Level Sensor Deliberative Subagent.

System modeling and results analysis
After performing the static modeling of the system and its types of agents, a dynamic modeling is carried out using the GHENeSys Petri Network of each type of agent, performing a direct translation of the State Diagrams. Auxiliary places and actions are added to each diagram to provide a non-abstract representation for the most important transitions of the network, allowing the verification of properties of the models (liveliness and reachability), their functional validation and a direct translation for the programs in the IEC61131 [34]. Figure 10 shows the dynamic model in Petri nets that correspond to the state diagram of Figure 9.  For the validation of Petri nets, the most used techniques are the observation and inspection of a model, the execution by a simulator and the animation and generation of code for its subsequent execution [35]. To validate the proposed models, the behavior and functionality of the models is inspected by running the simulation. The P-invariant equations of each of the elements to be studied are also searched to verify the reachability of the states and the liveliness of the network, which allows to verify that from the initial state any state can be reached avoiding closed loops and blockages; The equations are shown in table 2. Furthermore, it was found that they comply with the property of being persistent since with any two transitions activated, the triggering of one of the transitions does not deactivate the other. For a more detailed analysis of the proposed networks, in addition to the validation and verification of functional properties, we proceed to verify some of their structural properties such as the presence of place and transition invariants and controllability. To achieve this objective, it is possible to use several methods, including analysis by reduction or transformation, the reachability tree and the Gauss-Jordan elimination tree [36]. For the analysis, the Gauss-Jordan elimination method is used in which, through the calculation of the ranges of the incidence matrix A, the reduced incidence matrix RedA, the transpose of the incidence matrix AT, and from the reduced transposed incidence matrix RedAT, as well as the number of columns of these matrices m, some of their structural properties can be verified. To carry out the calculations, the Matlab® software was used, which facilitated the process of obtaining the matrices A, RedA, AT, RedAT and the rank of each of them. Figure 11 shows the image of these matrices for each of the agents or subagents under analysis.   Table 3 shows the data of the incidence matrices of the Filter Level Sensor Subagent according to the Gauss-Jordan elimination method, knowing that the network meets the following properties: there are transition invariants, there are place invariants, it is consistent, repetitive, conservative, structurally bounded and not totally controllable.

Conclusions
The development of this research work allowed modeling the supervisory system for the filtering stage of a water purification plant, considering a multi-agent architecture, where UML and Petri nets have been used as design and analysis tools to determine the static and dynamic behavior of the system. In addition, a modular structure of the integrated automation system was defined, describing the functions associated with the blocks proposed for modeling as a discrete event system. The proposed modular design, according to the general architecture, complies with the model defined for each of the main functions implemented in the supervisory system, facilitating integration into the general system, and presenting advantages when making modifications without having to alter or stop fully the process. The analysis of the general characteristics and functions of the system and the hardware architecture and the communications network designed allowed to form an SMA architecture that includes instrumentation, control, and intelligent supervision.
|The usefulness of UML modeling was proven to specify and document the water filtration system accurately, as well as to describe the scope of the same, the functional requirements, the actors or components, the services or use cases and the relationships between the actors or components. The UML modeling carried out facilitates the process of implementing the automation system at an experimental simulation scale. The models built using Petri nets allowed evaluating the dynamic behavior of the system, checking the details of implementation, algorithms, sequence of operation and the verification of the properties of the subsystems of the distributed intelligent architecture model, which guarantees the good formation of the models and then the dynamic validation of the functional requirements by simulation of the Petri nets.