## 3. Matherial and Methods
### Development of the System
#### 3.7.1 Physical System Development  
This section explains, with a mathematical algorithm, the operation of the physical system (Figure 9a) with its digital variables, \(DI_{PS_{k}}\) and \(DO_{PS_{k}}\), and analog variables, \(AI_{PS_{k}}\) and \(AO_{PS_{k}}\). The operation of Algorithm 1, for the physical system, assigns values to the digital and analog input vectors (Equations (9) and (13)) as well as to the output vectors (Equations (11) and (14)). If there is a change of state \(St_{PS_{k}}\) in the physical system, the inputs and outputs are measured and assigned correspondingly to the digital input-output and analog input-output vectors. Within the digital analysis, the difference between the current state and the previous state is calculated with Equation (9) for digital inputs \(DI_{PS_{k}}\) and Equation (11) for digital outputs \(DO_{PS_{k}}\). The input and output differences are stored in their respective memory equations, \(DI_{mPS_{k}}\) (Equation (10)) or \(DO_{mPS_{k}}\) (Equation (12)). Regarding the analog analysis, it consists of filtering \((1-\alpha)\) the input and output currents and storing their values in an analog input memory, \(AIm_{PS_{k}}\), given by (Equation (13)), and an analog output memory, \(AOm_{PS_{k}}\), according to (Equation (14)), respectively. ```
Data:\(DI_{PS_{k}},DO_{PS_{k}},AI_{PS_{k}},AO_{PS_{k}}\) Result:\(DI_{mPS_{k}},DO_{mPS_{k}},AI_{mPS_{k}},AO_{PS_{k}}\) if\((St_{PS_{k}}\
eq St_{PS_{k-1}})\)then (Digital Physical System): \[DI_{PS_{k}}=\left|DI_{PS_{k}}-DI_{PS_{k-1}}\right|\] (9) \[DI_{mPS_{k}}=DI_{mPS_{k-1}}+DI_{PS_{k}}\] (10) \[DO_{PS_{k}}=\left|DO_{PS_{k}}-DO_{PS_{k-1}}\right|\] (11) \[DO_{mPS_{k}}=DO_{mPS_{k-1}}+DO_{mPS_{k}}\] (12) (Analog Physical System): \[AI_{mPS_{k}}=\alpha AI_{mPS_{k-1}}-(1-\alpha)AI_{PS_{k}}\] (13) \[AOm_{PS_{k}}=\alpha AOm_{PS_{k-1}}-(1-\alpha)AO_{PS_{k}}\] (14)

Figure 9: (a) Physical System Controller; (b) Virtual System Controller; (c) Supervisory Controller. #### 3.7.2 Virtual System Development

This section explains, with a mathematical algorithm, the operation of the virtual system, with its digital variables \(DI_{V_{S_{k}}}\) and \(DO_{V_{S_{k}}}\), and analog variables \(AI_{V_{S_{k}}}\) and \(AO_{V_{S_{k}}}\) representing the function (Figure 9b) in the following:

Algorithm 2, for the virtual system, is similar to the algorithm of the physical system, except that, in this case, the ideal numerical simulation of the system is carried out, which will help to corroborate the optimal functioning of the physical system. Values are assigned to the vectors of the digital virtual input and digital virtual output \(DI_{V_{S_{k}}}\) and \(DO_{V_{S_{k}}}\). In turn, the virtual input and analog virtual output vectors are assigned \(AI_{V_{S_{k}}}\) and \(AO_{V_{S_{k}}}\). Unlike Algorithm 1, the signal that was activated in the physical system is expected to start the ideal virtual model, by \(ST_{P_{S_{k}}}\), to replicate the event in the virtual system, based on the virtual hybrid automaton (Figure 4). The virtual digital and analog values from inputs and outputs are added. An analysis of the previous virtual state and the current digital virtual state is performed with Equation (15) for \(DI_{V_{S_{k}}}\) and Equation (17) for \(D{O}{d}_{V_{S_{k}}}\). These input and output differences are assigned to \(D{I}{m}VS{k}\) by (16) and \(D{O}{m}VS{k}\) by (18), respectively. The analogous ideal simulation produces the input and output vectors \(AI_{V_{S_{k}}}\) and \(AO_{V_{S_{k}}}\), which are filtered by \(\alpha\) and \((1-\alpha)\) to produce mean values stored in (19) and (20), respectively, for the analysis of the supervisory controller.