A Retrofit Hierarchical Architecture for Real-Time Optimization and Control Integration

To achieve the optimal operation of chemical processes in the presence of disturbances and uncertainty, a retrofit hierarchical architecture (HA) integrating real-time optimization (RTO) and control was proposed. The proposed architecture features two main components. The first is a fast extremum-seeking control (ESC) approach using transient measurements that is employed in the upper RTO layer. The fast ESC approach can effectively suppress the impact of plant-model mismatch and steady-state wait time. The second is a global self-optimizing control (SOC) scheme that is introduced to integrate the RTO and control layers. The proposed SOC scheme minimizes the global average loss based on the approximation of necessary conditions of optimality (NCO) over the entire operating region. A least-squares regression technique was adopted to select the controlled variables (CVs) as linear combinations of measurements. The proposed method does not require the second order derivative information, therefore, it is numerically more reliable and robust. An exothermic reaction process is presented to illustrate the effectiveness of the proposed method.


Introduction
The effectiveness of optimal operation has been widely recognized, and becomes more important when considering environmental impact and market competition in the chemical industry [1,2]. The hierarchical architecture (HA) of chemical processes includes the real-time optimization (RTO) layer and the control layer, which operate on different time scales and have different tasks, respectively [3,4]. In the RTO layer, daily operation has been optimized based on a steady-state process model. This layer is usually also divided into a site-wide optimization layer and local optimization layer. The control layer is located below the RTO layer and it aims to ensure system stability, reject various disturbances, and maintain the controlled variables (CVs) at the desired set-points. This layer can be further divided into a supervisory control layer and a regulatory control layer. The objective of the supervisory control layer is to satisfy the operational constraints, e.g., those configured within multivariable model predictive controllers (MPC), whereas the objective of the regulatory control layer is to stabilize the actual plant with proportional integral-derivative (PID) controllers. These layers are connected through different set-points, which are passed from the higher layers to the lower layers.
The performance of the chemical processes tends to decay with time under various uncertainties and disturbances (e.g., equipment damage, raw material fluctuation, daily weather fluctuation and market demand change). Once such uncertainties or disturbances exist, the current operating strategy is no longer optimal. Thus, determining how to make better use of resources and energy to achieve optimal operation has become an important issue in the chemical industry. Depending on how this is realized, the approaches for achieving optimal operation of chemical processes can be classified into three categories, namely, the model-free approach, the online model-based approach and the offline model-based approach.
For the model-free approach, several measurement-based methods have been developed that avoid using an explicit process model. Necessary conditions of optimality (NCO) tracking [5], hill-climbing control [6] and extremum-seeking control (ESC) [7] belong in this category. These approaches use the input excitation to estimate the steady-state gradient from the cost measurement without the need for rigorous process models. Consequently, the advantage is that they can handle plant-model mismatch and unexpected disturbances. Nonetheless, these approaches need to wait for the process to settle down and reach a new steady state before estimating the gradient, therefore the convergence rate is slow. The concept of ESC is relatively old and can be traced back almost 100 years [8]. It has recently gained increased attention since the stability problem was proven by Krstic and Wang [9]. In recent years, there has been several advancements in ESC approaches such as the least-square-based ESC [10,11], discrete-time ESC [12], sliding-mode ESC [13], Newton-based ESC [14], etc. A common step included in all of these approaches is to drive the estimated steady-state gradient to zero under some specific control law.
The online model-based approach relies on measurements collected online together with the process model. Depending on the type of optimization problem, the online model-based approach can be further classified as steady-state real-time optimization (SRTO) [15] and dynamic real-time optimization (DRTO) [16] or economic model predictive control (EMPC) [17]. Due to the steady-state wait time for SRTO and computation complexity of DRTO and EMPC, the convergence rate for the online model-based approach is also slow. SRTO requires several preprocessing steps, such as steady-state detection, data reconciliation, parameter estimation and model adaptation before it can be used. A major improvement can be obtained in the data reconciliation step [18]. Recently, DRTO and EMPC have become more attractive due to their better performance in handling input and output constraints in comparison with SRTO. Both DRTO and EMPC use the dynamic model to predict future optimal input trajectories.
Of all of the offline model-based approaches, self-optimizing control (SOC) has been demonstrated to be the most attractive one. The concept of SOC was first proposed by Skogestad [4] to design the control structure. A set of offline selected CVs are said to be self-optimizing if by keeping them at constant set-points through a simple feedback control, the process operation automatically approaches optimum despite disturbances and uncertainties. In the past two decades, various methods of SOC have been reported. Instead of using individual measurements as CVs [19], using linear combinations of measurements as CVs has been proved to result in better performance [20]. Alstad [21] devised a null space method to select the linear combinations of measurements to achieve optimal operation around the nominal point. This method evolved into an extended null space method [22] to reduce the impact of implementation error. Meanwhile, Kariwala proposed an eigenvalue decomposition-based SOC method to minimize the local average loss and the local worst-case loss [23,24]. On this basis, a series of branch and bound-based methods were developed to fast screen the CV candidates [25][26][27][28]. A mixed-integer quadratic programming method was also proposed for measurements subset selection [29]. These methods are all based on linearized models around nominal operating points and thus they are only locally valid. More recently, the local SOC method has been advanced to the global method, which is based on the simulation data over the entire operating space. Some artificial intelligence techniques are also employed for the global SOC method [30,31]. For more detailed information about the SOC method, readers are referred to an overview of the state-of-the-art and open issues in the development of SOC by Jaschke [32].
The hierarchical architecture (HA) incorporating the SOC scheme has been reported in the literature. For example, Jaschke [33] presented a novel control hierarchy to combine the NCO tracking and the local SOC. The NCO tracking approach uses finite difference to periodically update the set-points to reduce the economic loss. Ye [34] developed a controlled variable adaptation-based structure to improve the optimizing performance. A two-layer control architecture integrating the SOC and modifier adaptation (MA) was also provided by Ye [35] to address the plant-model mismatch.
The main contribution of this work is a retrofit hierarchical architecture (HA) for integrating real-time optimization and control. Specifically, a fast extremum-seeking control (ESC) approach using transient measurements is employed in the upper RTO layer and the set-points are updated by driving the estimated steady-state gradient of the cost to zero. The ESC approach can effectively suppress the impact of the plant-model mismatch and steady-state wait time. The lower control layer is configured with a global SOC scheme to select the appropriate CVs and track the set-points delivered from the upper ESC layer. The SOC scheme minimizes the average loss globally and provides a faster reaction to expected disturbances. The proposed methodology inherits the advantages of both the fast ESC approach and the global SOC scheme.
The rest of this paper is arranged as follows: Section 2 introduces a fast extremum-seeking control (ESC) approach using transient measurements. Section 3 presents the concept of a global self-optimizing control (SOC) for CV selection. Section 4 devises a retrofit hierarchal architecture (HA) integrating real-time optimization (RTO) and control. An exothermic reaction process is used to investigate the advantages of the proposed methodologies in Section 5. Finally, the conclusions are summarized in Section 6.

Fast ESC Using Transient Measurements
The objective of the ESC scheme is to estimate the gradient of the cost function and drive it to zero under a specified control law (usually simple integral action). It can handle the plant-model mismatch or any other unexpected disturbances since it is a model-free adaptive control approach. The performance of this approach depends purely on the accuracy of the gradient estimation. Nevertheless, the drawbacks of this approach are that the convergence rate is slow and the cost function value is required. Hence, it fits better in the upper RTO layer.
An excitation signal (e.g., the sinusoidal signal or pseudo-random binary sequence signal) is commonly added to provide sufficient excitation for the gradient estimation in the ESC scheme. However, it requires a clear time scale separation between the process dynamics, excitation signal and convergence to the optimum [9]. Typically, the excitation signal that is chosen is 10 times slower than the plant dynamics such that the plant behaves like a static map. Furthermore, the selected integral gain is usually small enough such that the convergence to the optimum is another 10 times slower than the excitation signal, which means the overall convergence rate is about 100 times slower than the plant dynamics. This is unacceptable and impractical for real-time optimization of most processes. In order to address the steady-state wait time, which is caused by the local linear static map assumption, an alternative solution is to explicitly include the plant dynamics in the ESC approach. In this section, we introduce a fast ESC approach using transient measurements to significantly improve the convergence rate.
A local linear dynamic model, the auto regression exogenous (ARX) model was used as an effective way to include the plant dynamics. In the meantime, incorporating the plant dynamics in the gradient estimation removes the static map assumption, therefore, one does not need the time scale separation between the plant dynamics and the excitation signal. This results in a significantly faster convergence rate compared to the conventional ESC approach, which is also shown in the simulation results in Section 5.
For simplicity of derivation, we considered a nonlinear single input single output process, where the objective is to drive the cost Q to its optimal value by adjusting the input u.
The following assumptions should be met. Assumption 1. The plant cost Q can be measured or calculated.

Assumption 2.
The process can be represented as a combination of a nonlinear time invariant part and a linear stable time invariant dynamic part. Assumption 3. The nonlinear time invariant part is sufficiently smooth and continuously differentiable such that it has a unique optimal solution. Assumption 4. The set of active constraints do not change with disturbances and they are perfectly controlled.
One can use the transient measurements to estimate the gradient from the cost. A sliding window strategy containing the last N samples of data is used to fit the following ARX model: where t denotes the current time, e(t) denotes the white noise signal, and (n a , n b ) denotes the order of the ARX model. The last N transient measurements of data are used to estimate the ARX parameters θ = a 1 , . . . , a n a , b 1 , . . . , b n b T based on the linear least-squares method: where Ψ ∈ R N−n represents the vector of the last (N−n) cost data, which is given by and Φ ∈ R (N−n)×(n a +n b ) represents the characteristic vector, which is given by where n = max(n a , n b ). The analytical solution of problem (2) is given bŷ Introducing the notation, A(q) = 1 + a 1 q −1 + . . . + a n a q −n a and B(q) = b 1 q −1 + . . .
where q −1 denotes the unit shift operator. Once the ARX parameters θ = a 1 , . . . , a n a , b 1 , . . . , b n b T are estimated, a local linear dynamic model can be obtained in the form: The steady-state gradient around the current operating point can then be estimated bŷ where the notation "ˆ" means the estimated value, onceQ u is estimated, a simple integral controller can be used to drive the gradient to zero and update the controlled input. In discrete time, this can be expressed asû where K I ∈ R denotes the integral gain and T s denotes the sample time. It is also necessary to add the perturbation signal ω (e.g., pseudo-random binary sequence signal) to the input for sufficient excitation, which yields u(t + 1) =û(t + 1) + ω. The block diagram of the fast ESC approach is shown in Figure 1. The buffers are used to store the last N transient measurements of data. In this section, a fast ESC approach was proposed using transient measurements, which is based on identifying a local linear ARX model around the current operating point. The steady-state gradient can be estimated from the identified ARX model. By using transient measurements, one can effectively eliminate the time scale separation between the plant dynamics and the excitation signal. This results in a significantly faster convergence rate compared to the classical ESC approach, which is also shown in the simulation results in Section 5. Additionally, the proposed approach can be extended to a multivariable system where each input should have a particular excitation signal to estimate the gradient, and the controller is a simple decentralized integral control framework.

Basic Concept of SOC
The concept of SOC was first proposed to design control structures by selecting the appropriate measurement combination as the CVs. A set of offline selected CVs are said to be self-optimizing if by keeping them at constant set-points through a simple feedback control, the process operation automatically approaches optimum despite disturbances and uncertainties. Usually, the modelbased approach has better convergence than the model-free approach, thus it fits better to integrate the RTO and control layers. Consider the following steady-state optimization problems: where ∈ ℝ denotes the scalar cost function, ∈ ℝ denotes the manipulate variables (MVs), ∈ ℝ denotes the disturbance variables, ∈ ℝ denotes the theoretical measurements, which are calculated from the steady-state measurement model : ℝ × ℝ → ℝ , ∈ ℝ denotes the constraints corresponding to the operating limits and product qualities (e.g., temperature limit, flow limit and product concentrations, etc.).
For the SOC method, the controlled variables (CVs) ∈ ℝ are selected as where ∈ ℝ (with = ) are the selected CVs, ∈ ℝ × represents the selection matrix and ∈ ℝ denotes the available measurements, which are corrupted by the measurement noise ∈ In this section, a fast ESC approach was proposed using transient measurements, which is based on identifying a local linear ARX model around the current operating point. The steady-state gradient can be estimated from the identified ARX model. By using transient measurements, one can effectively eliminate the time scale separation between the plant dynamics and the excitation signal. This results in a significantly faster convergence rate compared to the classical ESC approach, which is also shown in the simulation results in Section 5. Additionally, the proposed approach can be extended to a multivariable system where each input should have a particular excitation signal to estimate the gradient, and the controller is a simple decentralized integral control framework.

Basic Concept of SOC
The concept of SOC was first proposed to design control structures by selecting the appropriate measurement combination as the CVs. A set of offline selected CVs are said to be self-optimizing if by keeping them at constant set-points through a simple feedback control, the process operation automatically approaches optimum despite disturbances and uncertainties. Usually, the model-based approach has better convergence than the model-free approach, thus it fits better to integrate the RTO and control layers. Consider the following steady-state optimization problems: where J ∈ R denotes the scalar cost function, u ∈ R n u denotes the manipulate variables (MVs), d ∈ R n d denotes the disturbance variables, y ∈ R n y denotes the theoretical measurements, which are calculated from the steady-state measurement model f : R n u × R n d → R n y , g ∈ R n g denotes the constraints corresponding to the operating limits and product qualities (e.g., temperature limit, flow limit and product concentrations, etc.).
For the SOC method, the controlled variables (CVs) c ∈ R n c are selected as c = Hy m , y m = y + n. (10) where c ∈ R n c (with n c = n u ) are the selected CVs, H ∈ R n c ×n y represents the selection matrix and y m ∈ R n y denotes the available measurements, which are corrupted by the measurement noise n ∈ R n y . The steady-state measurement model is linearized around the nominal point as follows: where G u ∈ R n y ×n u denotes the steady-state gain matrix of y with respect to u and G d ∈ R n y ×n d denotes the steady-state gain matrix of y with respect to d. Then, the loss function L(u, d) is defined as where J(u opt (d), d) and u opt (d) denote the optimal cost function value and the optimal manipulated variables for a given disturbance d, respectively. The ultimate goal is to keep the CVs at their desired set-points c s delivered from the upper layer by adjusting MVs u. Meanwhile, the loss function L for the expected disturbance d and measurement noise n is minimized.
For the SOC method [21,29], the CVs selection problem can be converted to minimize the average loss L avg in the form of selection matrix H as where Y = FW d W n is the augmented matrix and * F denotes the Frobenius norm, W d and W n represent the diagonal matrices with the expected magnitudes of the disturbance and the measurement noise, respectively. F represents the optimal sensitive matrix, J uu denotes the Hessian matrix of J with respect to u.
The analytical solution to problem (13) can be derived: It should be noted that the above results are derived on the basis of linearization around the nominal optimal point, therefore this method is only locally valid around the nominal optimal point. It may lead to large steady-state loss if the process moves far away from the nominal condition in the presence of various disturbances and uncertainties. Over time, the increase in the steady-state loss may no longer be acceptable and re-optimization is required to get the new optimal set-points. The aforementioned method belongs in the local SOC category [20][21][22]. To overcome the drawbacks of the local SOC method, in the next section, a new SOC method is developed based on the approximation of the necessary conditions of optimality (NCO) over the entire operating region, such that it is globally sound. We call it the global SOC method.

Global SOC
A global SOC method was developed to circumvent the drawbacks of the local method by using the simulation data over the entire operating space. Reconsidering the steady-state optimization  (9), the first order NCO, which is also known as the Karush−Kuhn−Tucker (KKT) conditions should hold: where µ k denotes the Lagrange multipliers, the constraints g k with equality hold are the active constraints, which is denoted as g a , and it can be separated from the above equations, then the NCO can be reformulated as two parts [7]: where ∇ p J ∈ R n u denotes the projected gradient, it can be further compressed as n u − n a dimensions using singular value decomposition [30] as where ∇ cp J ∈ R n u −n a denotes the compressed projected gradient, and V 2 is the right singular vector of According to Equation (17), the compressed NCO will change depending on which constraints are active, this means the CVs will change when the constraints transform from inactive and active. For the proposed SOC, to focus on the main contribution, we must assume that the set of active constraints do not change with disturbances and they are perfectly controlled at zero, which consumes the same number of degrees of freedom. In order to address the issue of changes in the active set, several approaches, e.g., split range control [36] and constraint handling approach [37] have been proposed recently. How to handle the changes in the active set is a topic worthy of investigation in our future work.
In the meantime, if the CVs, c are perfectly controlled at the desired setpoint c s , we can redefine the CVs as c = c − c s with zero value. It should be noted that with all active constraints implemented, the compressed gradient ∇ cp J with respect to the remaining degrees of freedom is in the unconstrained subspace and their value will always be zero under optimal conditions. On this basis, the controlled variables should be selected as close to ∇ cp J as possible. The approximation to the compressed projected gradient should be over the entire operating region such that the method is globally valid. Naturally, the CVs can be selected as an approximation of ∇ cp J using the least-squares regression technique. At the current sampling time t, the jth approximated NCO,ẑ t,j can be represented as the linear form: where y t denotes the current measurements vector, θ j denotes the parameters to be estimated, and N denotes the total number of samples over the entire operating region. Define where z j denotes the real value of jth compressed NCO calculated from the process simulation model offline. The regression parameters θ j can be determined by solving the least-squares regression problem: The analytical solution of problem (20) is given bŷ The block diagram of the global SOC method is shown in Figure 2. In this section, a global SOC method was proposed for the selection of CVs that is based on the approximation of necessary conditions of optimality (NCO) over the entire operating region. The selected CVs are globally valid compared to the local SOC method. Additionally, the proposed method does not require the second order derivative information, therefore it is numerically more reliable and robust. In the next section, a retrofit hierarchical architecture (HA) combining the fast ESC and global SOC is proposed and elaborated.

A Retrofit HA Integrating RTO and Control
Considering the differences between ESC and SOC, in general, the former is a model-free scheme that requires the cost measurements to estimate the gradient information based on the local linear least-squares method. In contrast, SOC is a CVs selection scheme that needs no cost measurement, but rather the process simulation model offline to minimize economic loss compared to optimal operation. Furthermore, the SOC scheme can quickly reject the expected disturbances since it works in a feedback fashion, whereas the ESC scheme can handle plant-model mismatch or other unexpected disturbances.
To include both merits from the ESC and SOC schemes, a retrofit HA for RTO and control integration is proposed in this section. Since the time scale in the RTO layer and control layer is different, the ESC scheme fits better in the slower RTO layer to improve the economic performance, while the SOC scheme fits better to integrate the RTO and control layers at a higher frequency. The proposed HA is shown in Figure 3.  In this section, a global SOC method was proposed for the selection of CVs that is based on the approximation of necessary conditions of optimality (NCO) over the entire operating region. The selected CVs are globally valid compared to the local SOC method. Additionally, the proposed method does not require the second order derivative information, therefore it is numerically more reliable and robust. In the next section, a retrofit hierarchical architecture (HA) combining the fast ESC and global SOC is proposed and elaborated.

A Retrofit HA Integrating RTO and Control
Considering the differences between ESC and SOC, in general, the former is a model-free scheme that requires the cost measurements to estimate the gradient information based on the local linear least-squares method. In contrast, SOC is a CVs selection scheme that needs no cost measurement, but rather the process simulation model offline to minimize economic loss compared to optimal operation. Furthermore, the SOC scheme can quickly reject the expected disturbances since it works in a feedback fashion, whereas the ESC scheme can handle plant-model mismatch or other unexpected disturbances.
To include both merits from the ESC and SOC schemes, a retrofit HA for RTO and control integration is proposed in this section. Since the time scale in the RTO layer and control layer is different, the ESC scheme fits better in the slower RTO layer to improve the economic performance, while the SOC scheme fits better to integrate the RTO and control layers at a higher frequency. The proposed HA is shown in Figure 3. To include both merits from the ESC and SOC schemes, a retrofit HA for RTO and control integration is proposed in this section. Since the time scale in the RTO layer and control layer is different, the ESC scheme fits better in the slower RTO layer to improve the economic performance, while the SOC scheme fits better to integrate the RTO and control layers at a higher frequency. The proposed HA is shown in Figure 3. The proposed HA contains the following features: (1) An ESC scheme is employed in the upper layer as an alternative to online model-based real-time optimization techniques. The computational burden is reduced since it is a data-driven approach based on the local linear least-squares method. In addition, incorporating the plant dynamics during the gradient estimation removes the time scale separation between the plant dynamics and the excitation signal, which leads to a faster convergence compared to the classical ESC approach. More importantly, the ESC layer can handle the plant-model mismatch and reduce the steady-state loss by adjusting the set-points. (2) A SOC scheme is configured with the lower control layer, which can significantly benefit the ESC layer. It should be noted that there are some inherent shortcomings in the ESC scheme. Any a priori information about the process is ignored and the convergence rate is slow in the presence of expected disturbances. The proposed hierarchical architecture combining the ESC and SOC circumvent the above shortcomings of ESC. More precisely, when the expected disturbances occur, the SOC scheme can make a fast adjustment such that the loss is under an acceptable level, whereas in the case where the plant-model mismatch or other unexpected disturbances enter into the process, the action is mainly attributed to the upper ESC layer and the true optimum will be achieved. (3) Convergence (stability) analysis is another important issue. In this part, we discuss the convergence issue. As mentioned in Section 2, although the fast ESC scheme effectively eliminates the time scale separation between the plant dynamics and the excitation signal, the integral adaptation gain of the ESC scheme must be selected as small to ensure a clear time scale separation between the dither and convergence to the optimum. To this end, there are two time scales in the ESC layer, namely, fast (plant dynamics and dither) and slow (convergence to the optimum). In the proposed retrofit HA, the SOC scheme configured with the lower control layer belongs to the fast time scale [9]. The convergence (stability) results from the least-squares based ESC [10] require a smooth control action parameterized by a performance parameter, which is used by the ESC controller. In the proposed HA, the smooth control action is given by the SOC scheme and the performance parameter is the set-points passed from the ESC layer. In conclusion, the existing convergence results from reference [10] can be applied to the proposed HA under two conditions: (a) the control layer configured with SOC is closed-loop stable; (b) the product of integral adaptation gain and the length of the moving window K I N must be small enough. It is intuitive that a small value of the product K I N guarantees the measurements used for gradient estimation is in the small neighborhood of the current operating point. The gradient estimation error can be bounded if the selected moving window length N is sufficiently small, which allows the chosen integral gain K I to be large (since only the product should be small), leading to arbitrary, fast convergence. However, in the general case, the adaptation gain should be chosen small such that the performance remains close to the steady state when seen from the upper ESC layer. The detailed convergence (stability) proof which relies on the Lyapunov-Razumikhin theorem can be found in reference [10].
In summary, the SOC scheme not only stabilizes the process, but also drives the process to a near optimal region with an acceptable steady-state loss, whereas when the loss becomes unacceptable or plant-model mismatch occurs, the ESC layer will take actions by adjusting the set-points to reduce them. The major properties show that the model-free ESC and the model-based SOC concepts are complementary rather than competitive.
The procedures for the implementation of a retrofit HA are summarized as follows: 1.
Collect the last N transient measurements of cost data and input data (also known as the set-points to the lower control layer).

2.
Estimate the steady-state gradient around the current operating point based on Equations (5) and (7).

3.
Keep the steady-state gradient at the zero value under an integral control action and update the set-points to the lower control layer.

4.
Determine and sample the entire operating space using independently generated inputs, disturbances and random noises.

5.
Calculate the compressed NCO, z j and matrix Y from a process simulation model offline.

6.
Fit the CVs and calculate the regression parameters by linear least-squares Formula (21). 7.
Keep the selected CVs at the zero value under a simple feedback control law and update the MVs to the lower plant layer as the process input.

Process Description
The continuous stirred tank reactor (CSTR) with a reversible exothermic reaction A B has been extensively investigated [30,33]. A schematic diagram of the CSTR is shown in Figure 4. 4. Determine and sample the entire operating space using independently generated inputs, disturbances and random noises. 5. Calculate the compressed NCO, and matrix from a process simulation model offline. 6. Fit the CVs and calculate the regression parameters by linear least-squares formula (21). 7. Keep the selected CVs at the zero value under a simple feedback control law and update the MVs to the lower plant layer as the process input.

Process Description
The continuous stirred tank reactor (CSTR) with a reversible exothermic reaction ⇌ has been extensively investigated [30,33]. A schematic diagram of the CSTR is shown in Figure 4. According to the law of conservation of mass and energy, the following ordinary differential equations can be obtained to model the dynamic behavior of the system [30]: where Ai , Bi , denote the inlet A concentration, inlet B concentration and inlet stream temperature, respectively, and Ao , Bo , denote the outlet A concentration, outlet B concentration and outlet Figure 4. A schematic diagram of the continuous stirred tank reactor.
According to the law of conservation of mass and energy, the following ordinary differential equations can be obtained to model the dynamic behavior of the system [30]: where C Ai , C Bi , T i denote the inlet A concentration, inlet B concentration and inlet stream temperature, respectively, and C Ao , C Bo , T o denote the outlet A concentration, outlet B concentration and outlet stream temperature, respectively, τ is the residence time. r represents the reaction rate, which is defined as The manipulated variables u, disturbance variables d and measurement variables y of the exothermic reaction process are The measurement noise is ±0.01 (mol·L −1 ) for concentrations C Ao and C Bo , and ±0.1 K for temperatures T o and T i . The state-input constraints are The objective is to minimize the cost function J, which is defined as where the first term of J represents the cost of heating the input stream and the second term is the negative profit of the desired product B.
The nominal values for the exothermic reaction process are listed in Table 1. Table 1. Nominal values for the exothermic reaction process.

Variable Nominal Value Unit
To illustrate the effectiveness of the proposed method, first, we applied the fast ESC scheme alone to control the exothermic reaction process and compared it with the classical ESC scheme [9], with a special focus on the convergence time to the optimum. Then, we adopted the global SOC scheme alone to control the process and compared it with the local SOC scheme [20], with a special focus on the average loss over the entire operating space. Finally, we used a retrofit HA combining the fast ESC and global SOC to control the process and compared it with the ESC scheme alone, the SOC scheme alone, simultaneously under the same disturbance conditions, which demonstrates the superiority of the proposed methodology.

Fast ESC Scheme
In this subsection, the fast ESC scheme proposed in Section 2 is compared with a classical ESC scheme [9] to control the exothermic reaction process. An additional sinusoidal signal with an amplitude of 0.5 K and a time period of 40 s is added to the classical ESC scheme, and an additional pseudo-random binary sequence signal with an amplitude of 0.5 K is added to the fast ESC scheme, the measurements are assumed to be available with the sample time of 10 s, the adaptation gains of K I are 0.3 and 2 for the classical ESC and the proposed fast ESC, respectively. The total simulation time is 5000 s with disturbances C Ai from 1 (mol·L −1 ) to 0.6 (mol·L −1 ) and C Bi from 0 (mol·L −1 ) to 0.4 (mol·L −1 ) at time t = 2000 s. The comparison of the input variables using both schemes is shown in Figure 5. It can be clearly seen that both ESC schemes converge to the same steady-state input value, which is 398.53 K, however, the classical ESC scheme has a significantly slower convergence compared to the proposed fast ESC scheme due to the steady-state wait time. The proposed ESC scheme converges to the optimum within 200 s, whereas the classical ESC scheme takes more than 2000 s to converge. This example clearly shows the effectiveness of the proposed fast ESC over classical ESC.

Global SOC Scheme
In this subsection, the global SOC scheme proposed in Section 3.2 is compared with a local SOC scheme [20]. In this case, there is only one degree of freedom, such that only one CV needs to be selected. All four measurements are included in the CV function. In the local SOC scheme, the process model is used offline to calculate the optimal sensitive matrix .
The matrices and are evaluated at the nominal point, which is shown as The analytical solution of the selection matrix for the local SOC scheme is It can be clearly seen that both ESC schemes converge to the same steady-state input value, which is 398.53 K, however, the classical ESC scheme has a significantly slower convergence compared to the proposed fast ESC scheme due to the steady-state wait time. The proposed ESC scheme converges to the optimum within 200 s, whereas the classical ESC scheme takes more than 2000 s to converge. This example clearly shows the effectiveness of the proposed fast ESC over classical ESC.

Global SOC Scheme
In this subsection, the global SOC scheme proposed in Section 3.2 is compared with a local SOC scheme [20]. In this case, there is only one degree of freedom, such that only one CV needs to be selected. All four measurements are included in the CV function. In the local SOC scheme, the process model is used offline to calculate the optimal sensitive matrix F.
The matrices G u and J uu are evaluated at the nominal point, which is shown as Processes 2020, 8, 181 13 of 17 The diagonal matrices with the expected magnitudes of the disturbance W d = diag 1 0.5 and the measurement noise W n = diag 0.01 0.01 0.1 0.1 , which yields, The analytical solution of the selection matrix for the local SOC scheme is H 1 = −13.1173 15.0102 −1.1384 1.3478 with the average loss L 1 = 10.0355. We also investigated the condition without measurement noises, the result is H 1 = −0.4351 −0.5224 −0.7289 0.9674 with the average loss L 1 = 8.6377.
In the global SOC scheme, the input variables are divided equally into 10 parts and the total sample number is N = 11 3 = 1331. From the offline calculation, the matrix Y ∈ R 1331×5 , z j ∈ R 1331×1 in Equation (19) can be obtained, but the result is not given due to the space limitation. The selection matrix for the global SOC scheme can be calculated by Formula (21) Table 2. From the above results, we can clearly see that compared to the local SOC scheme, the average loss, maximum loss and standard deviation for the global SOC scheme has been significantly reduced, e.g., the average losses are reduced by 87.6% with measurement noise and 86.3% without measurement noise, respectively. It should also be noted that the losses and standard deviations with measurement noise are larger than that without noise. This example clearly shows the superiority of the proposed global SOC over the local SOC in the sense that the selected CVs are globally valid.

A Retrofit HA Combining the Fast ESC and Global SOC
In this subsection, a retrofit HA combining the fast ESC and global SOC is considered. An additional pseudo-random binary sequence signal with an amplitude of 0.5 K is added to the input signal, the measurements are assumed to be available with a sample time of 25 s, the adaptation gains are 0.12 and 3 for the fast ESC scheme and the global SOC scheme, respectively. The expected disturbance scenarios are designed as after 1000 s at the nominal value with a step change of 0.4 (mol·L −1 ) that occurs in the inlet A concentration. At t = 2000 s, a step change of −0.8 (mol·L −1 ) occurs in the inlet A concentration and a step change of 0.2 (mol·L −1 ) occurs in the inlet B concentration. At t = 3000 s, a step change of 0.4 (mol·L −1 ) occurs in the inlet A concentration. At t = 4000 s, a step change of 0.2 (mol·L −1 ) occurs in the inlet B concentration as shown in Figure 6. are 0.12 and 3 for the fast ESC scheme and the global SOC scheme, respectively. The expected disturbance scenarios are designed as after 1000 s at the nominal value with a step change of 0.4 (mol•L −1 ) that occurs in the inlet A concentration. At t = 2000 s, a step change of −0.8 (mol•L −1 ) occurs in the inlet A concentration and a step change of 0.2 (mol•L −1 ) occurs in the inlet B concentration. At t = 3000 s, a step change of 0.4 (mol•L −1 ) occurs in the inlet A concentration. At t = 4000 s, a step change of 0.2 (mol•L −1 ) occurs in the inlet B concentration as shown in Figure 6.  A comparison of the input variables using the fast ESC scheme alone (at the same conditions as in Section 5.2), the global scheme alone (at the same conditions as in Section 5.3) and the proposed combined method is shown in Figure 7.  It can be clearly seen that both the ESC scheme and combined method converge to the same steady-state value, which is 424.29 k for 0~1000 s, 426.27 k for 1000~2000 s, 408.2 k for 2000~3000 k, 417.17 k for 3000~4000 k and 410.67 k for 4000~5000 k, respectively. However, steady-state losses differ between the SOC scheme and the other two schemes. The steady-state losses for the SOC scheme are 0.11 k for 0~1000 s, 0.68 k for 1000~2000 s, 2.54 k for 2000~3000 k, 1.47 k for 3000~4000 k and 4.68 k for 4000~5000 k. It was also clearly shown that for 2000-3000 s and 3000-4000 s, the convergence rate of the combined method is faster than the other two schemes.
In addition, it is also necessary to compare the profits among the three methods in the presence of plant-model mismatch (structural uncertainty). Considering the plant-model mismatch, more specifically, a step change of 3% in the activation energy E1 (structural mismatch) occurs at time 2400 s, a comparison of the profits (negative cost − ) of these methods is shown in Figure 8. It can be clearly seen that both the ESC scheme and combined method converge to the same steady-state value, which is 424.29 k for 0~1000 s, 426.27 k for 1000~2000 s, 408.2 k for 2000~3000 k, 417.17 k for 3000~4000 k and 410.67 k for 4000~5000 k, respectively. However, steady-state losses differ between the SOC scheme and the other two schemes. The steady-state losses for the SOC scheme are 0.11 k for 0~1000 s, 0.68 k for 1000~2000 s, 2.54 k for 2000~3000 k, 1.47 k for 3000~4000 k and 4.68 k for 4000~5000 k. It was also clearly shown that for 2000-3000 s and 3000-4000 s, the convergence rate of the combined method is faster than the other two schemes.
In addition, it is also necessary to compare the profits among the three methods in the presence of plant-model mismatch (structural uncertainty). Considering the plant-model mismatch, more specifically, a step change of 3% in the activation energy E 1 (structural mismatch) occurs at time 2400 s, a comparison of the profits (negative cost −J) of these methods is shown in Figure 8.
It was shown that the plant-model mismatch reduces the desired profit value from 0.4237 to 0.3022 at time 2400 s. The reason is that the structural uncertainty reduces the reaction rate for the exothermic process. Nonetheless, the combined method and the ESC scheme alone performed similarly in terms of the profit and both outperform the SOC scheme alone, which was anticipated since they both inherit the good features of the model-free approach, and more importantly, as we see from Figure 7, the combined method provides moderate and smoother input usage than the ESC scheme alone. The above results demonstrate the superiority of the proposed methodology.
It can be clearly seen that both the ESC scheme and combined method converge to the same steady-state value, which is 424.29 k for 0~1000 s, 426.27 k for 1000~2000 s, 408.2 k for 2000~3000 k, 417.17 k for 3000~4000 k and 410.67 k for 4000~5000 k, respectively. However, steady-state losses differ between the SOC scheme and the other two schemes. The steady-state losses for the SOC scheme are 0.11 k for 0~1000 s, 0.68 k for 1000~2000 s, 2.54 k for 2000~3000 k, 1.47 k for 3000~4000 k and 4.68 k for 4000~5000 k. It was also clearly shown that for 2000-3000 s and 3000-4000 s, the convergence rate of the combined method is faster than the other two schemes.
In addition, it is also necessary to compare the profits among the three methods in the presence of plant-model mismatch (structural uncertainty). Considering the plant-model mismatch, more specifically, a step change of 3% in the activation energy E1 (structural mismatch) occurs at time 2400 s, a comparison of the profits (negative cost − ) of these methods is shown in Figure 8.

Conclusions
The main contribution of this work is a retrofit HA for real-time optimization and control integration, which demonstrates that ESC and SOC are complementary rather than competitive. The features of the proposed HA can be summarized as follows. (1) A fast ESC scheme using transient measurements that is employed in the upper RTO layer, which can effectively suppress the impact of plant-model mismatch and steady-state wait time. The time scale separation between the plant dynamics and the excitation signal was removed by using transient measurements during the gradient estimation. (2) A global SOC scheme is configured with the control layer to select the appropriate CVs, which provide a moderate reaction to expected disturbances and maintain the process in a near optimal region. The selected CVs are globally valid compared to the local SOC method since it is based on the approximation of NCO over the entire operating space. (3) A linear least-squares regression technique is adopted in both the ESC and SOC schemes, which does not require the second order derivative information, therefore it is numerically more reliable and robust.
An exothermic reaction process was investigated to illustrate the effectiveness of the proposed methodology. The results show that the proposed method inherits the advantages of each individual method, i.e., quickly rejecting disturbances whose characteristics are known, and converging to the optimal operating point in the presence of unknown disturbances. Future work may consider more sophisticated and realistic cases such as the issue of the calculation of the ARX model with measurement noise in the process industry, and how to deal with the changes in the active set is also worthy of further investigation.