# Real-Time Optimization and Control of Nonlinear Processes Using Machine Learning

^{1}

^{2}

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Neural Network Model and Application

#### 2.1. Neural Network Model

#### 2.2. Application of Neural Network Models in RTO and MPC

#### 2.2.1. RTO with the Neural Network Model

#### 2.2.2. MPC with Neural Network Models

**Remark**

**1.**

**Remark**

**2.**

**Remark**

**3.**

**Remark**

**4.**

## 3. Application to a Chemical Reactor Example

#### 3.1. Process Description and Simulation

#### 3.2. Neural Network Model

^{−7}. Data were first normalized and then fed to the MATLAB Deep Learning toolbox to train the model. The neural network model had one hidden layer with 10 neurons. The parameters were trained using Levenberg–Marquardt optimization algorithm. In terms of the accuracy of the neural network model, the coefficient of determination ${R}^{2}$ was 1, and the error histogram of Figure 3 demonstrates that the neural network represented the reaction rate with a high accuracy, as can be seen from the error distribution (we note that error metrics used in classification problems like the confusion matrix, precision, recall, and f1-score were not applicable to the regression problems considered in this work). In the process model of Equation (8), the first-principles reaction rate term ${k}_{A}{e}^{\frac{-{E}_{A}}{RT}}{C}_{A}-{k}_{B}{e}^{\frac{-{E}_{B}}{RT}}{C}_{B}$ was replaced with the obtained neural network ${F}_{NN}({C}_{A},{C}_{B},T)$. The integration of the first-principles model and the neural network model that was used in RTO and MPC will be discussed in the following sections.

**Remark**

**5.**

^{−7}.

#### 3.3. RTO and Controller Design

#### 3.3.1. RTO Design

^{5}] are the desired operating conditions. At the initial steady-state, the heat price is 7 × 10

^{−7}, and the CSTR operates at T = 426.7 K, C

_{A}= 0.4977 mol/L and Q = 40,386 cal/s. The performance is not compromised too much since C

_{A}= 0.4977 mol/L is close to the optimum value C

_{A}= 0.4912 mol/L, while the energy saving is considerable when Q = 40,386 cal/s is compared to the optimum value Q = 59,983 cal/s. In the presence of variation in process variables or heat price, RTO recalculates the optimal operating condition, given that the variation is measurable every RTO period. The RTO of Equation (10) is solved every RTO period, and then sends steady-state values to controllers as the optimal set-points for the next 1000 s. Since the CSTR process has a relatively fast dynamics, a small RTO period of 1000 s is chosen to illustrate the performance of RTO.

#### 3.3.2. Controller Design

#### 3.4. Simulation Results

## 4. Application to a Distillation Column

#### 4.1. Process Description, Simulation, and Model

#### 4.1.1. Process Description

^{7}W and reboiler heat duty 2.61 × 10

^{7}W. The pressure at the top and bottom is 16.8 atm and 17 atm. Both the top and bottom products are followed by a pump and a control valve. All the parameters are summarized in Table 2.

#### 4.1.2. Process Model

#### 4.2. Neural Network Model

^{−7}. It is demonstrated in Figure 10 that the neural network model fits the data from the Aspen property library very well, where the blue solid curve is the neural network model prediction and the red curve denotes the Aspen model. Additionally, we calculated the accumulated relative error (i.e., $E=\frac{{\int}_{y=0}^{y=1}|{T}_{f}-{T}_{h}|dy}{{\int}_{y=0}^{y=1}{T}_{f}dy}$) between the temperature curves (Figure 10) under the Aspen model (i.e., ${T}_{f}$) and under the neural network model (i.e., ${T}_{h}$) and $E=2.32\times {10}^{-6}$; the result was similar for the liquid mole fraction curves. This sufficiently small error implies that the neural network model successfully approximated the nonlinear behavior of the thermodynamic properties. Additionally, the coefficient of determination ${R}^{2}$ was 1, and the error histogram of Figure 11 demonstrated that the neural network model represented the thermodynamic properties with great accuracy.

#### 4.3. RTO and Controller Design

#### 4.3.1. RTO Design

#### 4.3.2. Controller Design

#### 4.4. Simulation Results

## 5. Conclusions

## Author Contributions

## Acknowledgments

## Conflicts of Interest

## References

- Bhutani, N.; Rangaiah, G.; Ray, A. First-principles, data-based, and hybrid modeling and optimization of an industrial hydrocracking unit. Ind. Eng. Chem. Res.
**2006**, 45, 7807–7816. [Google Scholar] [CrossRef] - Pantelides, C.C.; Renfro, J. The online use of first-principles models in process operations: Review, current status and future needs. Comput. Chem. Eng.
**2013**, 51, 136–148. [Google Scholar] [CrossRef] - Quelhas, A.D.; de Jesus, N.J.C.; Pinto, J.C. Common vulnerabilities of RTO implementations in real chemical processes. Can. J. Chem. Eng.
**2013**, 91, 652–668. [Google Scholar] [CrossRef] - Wu, Z.; Tran, A.; Rincon, D.; Christofides, P.D. Machine Learning-Based Predictive Control of Nonlinear Processes. Part I: Theory. AIChE J.
**2019**, 65, e16729. [Google Scholar] [CrossRef] - Wu, Z.; Tran, A.; Rincon, D.; Christofides, P.D. Machine Learning-Based Predictive Control of Nonlinear Processes. Part II: Computational Implementation. AIChE J.
**2019**, 65, e16734. [Google Scholar] [CrossRef] - Lee, M.; Park, S. A new scheme combining neural feedforward control with model-predictive control. AIChE J.
**1992**, 38, 193–200. [Google Scholar] [CrossRef] - Venkatasubramanian, V. The promise of artificial intelligence in chemical engineering: Is it here, finally? AIChE J.
**2019**, 65, 466–478. [Google Scholar] [CrossRef] - Himmelblau, D. Applications of artificial neural networks in chemical engineering. Korean J. Chem. Eng.
**2000**, 17, 373–392. [Google Scholar] [CrossRef] - Chouai, A.; Laugier, S.; Richon, D. Modeling of thermodynamic properties using neural networks: Application to refrigerants. Fluid Phase Equilib.
**2002**, 199, 53–62. [Google Scholar] [CrossRef] - Galván, I.M.; Zaldívar, J.M.; Hernandez, H.; Molga, E. The use of neural networks for fitting complex kinetic data. Comput. Chem. Eng.
**1996**, 20, 1451–1465. [Google Scholar] [CrossRef] [Green Version] - Faúndez, C.A.; Quiero, F.A.; Valderrama, J. Phase equilibrium modeling in ethanol+ congener mixtures using an artificial neural network. Fluid Phase Equilib.
**2010**, 292, 29–35. [Google Scholar] [CrossRef] - Fu, K.; Chen, G.; Sema, T.; Zhang, X.; Liang, Z.; Idem, R.; Tontiwachwuthikul, P. Experimental study on mass transfer and prediction using artificial neural network for CO
_{2}absorption into aqueous DETA. Chem. Eng. Sci.**2013**, 100, 195–202. [Google Scholar] [CrossRef] - Bakshi, B.; Koulouris, A.; Stephanopoulos, G. Wave-Nets: Novel learning techniques, and the induction of physically interpretable models. In Wavelet Applications; International Society for Optics and Photonics: Orlando, FL, USA, 1994; Volume 2242, pp. 637–648. [Google Scholar]
- Lu, Y.; Rajora, M.; Zou, P.; Liang, S. Physics-embedded machine learning: Case study with electrochemical micro-machining. Machines
**2017**, 5, 4. [Google Scholar] [CrossRef] - Psichogios, D.C.; Ungar, L.H. A hybrid neural network-first principles approach to process modeling. AIChE J.
**1992**, 38, 1499–1511. [Google Scholar] [CrossRef] - Oliveira, R. Combining first principles modelling and artificial neural networks: A general framework. Comput. Chem. Eng.
**2004**, 28, 755–766. [Google Scholar] [CrossRef] - Chen, L.; Bernard, O.; Bastin, G.; Angelov, P. Hybrid modelling of biotechnological processes using neural networks. Control Eng. Pract.
**2000**, 8, 821–827. [Google Scholar] [CrossRef] - Georgieva, P.; Meireles, M.; de Azevedo, S. Knowledge-based hybrid modelling of a batch crystallisation when accounting for nucleation, growth and agglomeration phenomena. Chem. Eng. Sci.
**2003**, 58, 3699–3713. [Google Scholar] [CrossRef] - Schuppert, A.; Mrziglod, T. Hybrid Model Identification and Discrimination with Practical Examples from the Chemical Industry. In Hybrid Modeling in Process Industries; CRC Press: Boca Raton, FL, USA, 2018; pp. 63–88. [Google Scholar]
- Qin, S.; Badgwell, T. A survey of industrial model predictive control technology. Control Eng. Pract.
**2003**, 11, 733–764. [Google Scholar] [CrossRef] - Câmara, M.; Quelhas, A.; Pinto, J. Performance evaluation of real industrial RTO systems. Processes
**2016**, 4, 44–64. [Google Scholar] [CrossRef] - Lee, W.J.; Na, J.; Kim, K.; Lee, C.; Lee, Y.; Lee, J.M. NARX modeling for real-time optimization of air and gas compression systems in chemical processes. Comput. Chem. Eng.
**2018**, 115, 262–274. [Google Scholar] [CrossRef] - Agbi, C.; Song, Z.; Krogh, B. Parameter identifiability for multi-zone building models. In Proceedings of the 2012 IEEE 51st IEEE Conference on Decision and Control (CDC), Maui, HI, USA, 10–13 December 2012; pp. 6951–6956. [Google Scholar]
- Yen-Di Tsen, A.; Jang, S.S.; Wong, D.S.H.; Joseph, B. Predictive control of quality in batch polymerization using hybrid ANN models. AIChE J.
**1996**, 42, 455–465. [Google Scholar] [CrossRef] - Klimasauskas, C.C. Hybrid modeling for robust nonlinear multivariable control. ISA Trans.
**1998**, 37, 291–297. [Google Scholar] [CrossRef] - Chang, J.; Lu, S.; Chiu, Y. Dynamic modeling of batch polymerization reactors via the hybrid neural-network rate-function approach. Chem. Eng. J.
**2007**, 130, 19–28. [Google Scholar] [CrossRef] - Noor, R.M.; Ahmad, Z.; Don, M.M.; Uzir, M.H. Modelling and control of different types of polymerization processes using neural networks technique: A review. Can. J. Chem. Eng.
**2010**, 88, 1065–1084. [Google Scholar] [CrossRef] - Wang, J.; Cao, L.L.; Wu, H.Y.; Li, X.G.; Jin, Q.B. Dynamic modeling and optimal control of batch reactors, based on structure approaching hybrid neural networks. Ind. Eng. Chem. Res.
**2011**, 50, 6174–6186. [Google Scholar] [CrossRef] - Chaffart, D.; Ricardez-Sandoval, L.A. Optimization and control of a thin film growth process: A hybrid first principles/artificial neural network based multiscale modelling approach. Comput. Chem. Eng.
**2018**, 119, 465–479. [Google Scholar] [CrossRef] - Schweidtmann, A.M.; Mitsos, A. Deterministic global optimization with artificial neural networks embedded. J. Opt. Theory Appl.
**2019**, 180, 925–948. [Google Scholar] [CrossRef] - Wu, Z.; Christofides, P.D. Economic Machine-Learning-Based Predictive Control of Nonlinear Systems. Mathematics
**2019**, 7, 494. [Google Scholar] [CrossRef] - Goodfellow, I.; Bengio, Y.; Courville, A. Deep Learning; MIT Press: Cambridge, MA, USA, 2016. [Google Scholar]
- Bishop, C. Pattern Recognition and Machine Learning; Springer: New York, NY, USA, 2006. [Google Scholar]
- Haykin, S. Neural Networks: A Comprehensive Foundation; Prentice Hall PTR: Upper Saddle River, NJ, USA, 1994. [Google Scholar]
- Naysmith, M.; Douglas, P. Review of real time optimization in the chemical process industries. Dev. Chem. Eng. Miner. Process.
**1995**, 3, 67–87. [Google Scholar] [CrossRef] - Rawlings, J.; Amrit, R. Optimizing process economic performance using model predictive control. In Nonlinear Model Predictive Control; Springer: Berlin, Germany, 2009; pp. 19–138. [Google Scholar]
- Ellis, M.; Durand, H.; Christofides, P. A tutorial review of economic model predictive control methods. J. Process Control
**2014**, 24, 1156–1178. [Google Scholar] [CrossRef] - Rawlings, J.B.; Bonné, D.; Jørgensen, J.B.; Venkat, A.N.; Jørgensen, S.B. Unreachable setpoints in model predictive control. IEEE Transa. Autom. Control
**2008**, 53, 2209–2215. [Google Scholar] [CrossRef] - Mhaskar, P.; El-Farra, N.H.; Christofides, P.D. Stabilization of nonlinear systems with state and control constraints using Lyapunov-based predictive control. Syst. Control Lett.
**2006**, 55, 650–659. [Google Scholar] [CrossRef] - Wang, L. Continuous time model predictive control design using orthonormal functions. Int. J. Control
**2001**, 74, 1588–1600. [Google Scholar] [CrossRef] - Hosseinzadeh, M.; Cotorruelo, A.; Limon, D.; Garone, E. Constrained Control of Linear Systems Subject to Combinations of Intersections and Unions of Concave Constraints. IEEE Control Syst. Lett.
**2019**, 3, 571–576. [Google Scholar] [CrossRef] - Daoutidis, P.; Kravaris, C. Dynamic output feedback control of minimum-phase multivariable nonlinear processes. Chem. Eng. Sci.
**1994**, 49, 433–447. [Google Scholar] [CrossRef] [Green Version] - Economou, C.; Morari, M.; Palsson, B. Internal model control: Extension to nonlinear system. Ind. Eng. Chem. Process Des. Dev.
**1986**, 25, 403–411. [Google Scholar] [CrossRef] - Lin, Y.; Sontag, E. A universal formula for stabilization with bounded controls. Syst. Control Lett.
**1991**, 16, 393–397. [Google Scholar] [CrossRef] - Luyben, W.L. Distillation Design and Control Using Aspen Simulation; John Wiley & Sons: Hoboken, NJ, USA, 2013. [Google Scholar]
- Al-Malah, K.I. Aspen Plus: Chemical Engineering Applications; John Wiley & Sons: Hoboken, NJ, USA, 2016. [Google Scholar]
- Aspen Technology, Inc. Aspen Plus User Guide; Aspen Technology, Inc.: Cambridge, MA, USA, 2003. [Google Scholar]

**Figure 1.**A feed-forward neural network with input ${x}_{1},\dots ,{x}_{n}$, hidden neurons ${h}_{1},{h}_{2},\dots ,{h}_{p}$, and outputs ${y}_{1},{y}_{2},\dots ,{y}_{m}$. Each weight ${w}_{ji}^{\left(k\right)}$ is marked on the structure. Neuron “1” is used to represent the biases.

**Figure 2.**Steady-state profiles (${C}_{A}$ and T) for the CSTR of Equation (8) under varying heat input rate Q, where the minimum of ${C}_{A}$ is achieved at Q = 59,983 cal/s.

**Figure 4.**Heat price profile during the simulation, where the heat price first increases and then decreases to simulate heat rate price changing.

**Figure 5.**Evolution of the concentration of A and B for the CSTR case study under the proposed real-time optimization (RTO) and MPC.

**Figure 6.**Evolution of the reactor temperature T for the CSTR case study under the proposed RTO and MPC scheme.

**Figure 7.**Evolution of the manipulated input, the heating rate Q, for the CSTR example under the proposed RTO and MPC scheme.

**Figure 8.**Comparison of the total operation cost for the CSTR example for simulations with and without RTO adapting to the heat rate price changing.

**Figure 12.**A schematic diagram of the control structure implemented in the distillation column. Flow rate controller $FC$, pressure controller $PC$, and both level controllers $L{C}_{1}$ and $L{C}_{2}$ have fixed set-points, and concentration controller $CC$ and temperature controller $TC$ receive set-points from the RTO.

**Figure 13.**The feed concentration profile of the distillation column, which is changing with respect to time.

**Figure 14.**Controlled output ${x}_{D}$ and manipulated input $reflux\phantom{\rule{3.33333pt}{0ex}}flow$ for the concentration controller $CC$ in the distillation process under the proposed RTO scheme.

**Figure 15.**Controlled output ${T}_{7}$ and manipulated input $reboiler\phantom{\rule{3.33333pt}{0ex}}heat$ for the temperature controller $TC$ in the distillation process under the proposed RTO scheme.

**Figure 16.**Comparison of the operation profit for the distillation process for closed-loop simulations with and without RTO adapting for change in the feed concentration.

**Table 1.**Parameter values and steady-state values for the continuous stirred tank reactor (CSTR) case study.

${\mathit{T}}_{0}=400$ K | $\mathit{\tau}=60$ s |

${k}_{A}=5000$ /s | ${k}_{B}={10}^{6}$ /s |

${E}_{A}=1\times {10}^{4}$ cal/mol | ${E}_{B}=1.5\times {10}^{4}$ cal/mol |

$R=1.987$ cal/(mol K) | $\mathsf{\Delta}H=-5000$ cal/mol |

$\rho =1$ kg/L | ${C}_{P}=1000$ cal/(kg K) |

${C}_{{A}_{0}}=1$ mol/L | $V=100$ L |

${C}_{{A}_{s}}=0.4977$ mol/L | ${C}_{{B}_{s}}=0.5023$ mol/L |

${T}_{{A}_{s}}=426.743$ K | ${Q}_{s}=\mathrm{40,386}$ cal/s |

F = 1 kmol | ${\mathit{x}}_{\mathit{F}}$ = 0.4 |

${T}_{F}=322$ K | ${P}_{F}=20$ atm |

q = 1.24 | ${N}_{F}$ = 14 |

${N}_{T}$ = 30 | $Diamete{r}_{reboiler}=5.08$ m |

$Lengt{h}_{reboiler}=10.16$ m | $Diamete{r}_{reflux\phantom{\rule{3.33333pt}{0ex}}drum}=4.08$ m |

$Lengt{h}_{reflux\phantom{\rule{3.33333pt}{0ex}}drum}=8.16$ m | |

steady-state condition: | R = 3.33 |

${x}_{B}=0.019$ | ${x}_{D}=0.98$ |

${P}_{bottom}=17$ atm | ${P}_{top}=16.8$ atm |

B = 0.61 kmol/L | D = 0.39 kmol/L |

${Q}_{top}=-2.17\times {10}^{7}$ W | ${Q}_{bottom}=2.61\times {10}^{7}$ W |

**Table 3.**Proportional gain and integral time constant of all the PI controllers in the distillation case study.

K_{C} | τ_{I}/min | |
---|---|---|

FC | 0.5 | 0.3 |

PC | 15 | 12 |

LC_{1} | 2 | 150 |

LC_{2} | 4 | 150 |

CC | 0.1 | 20 |

TC | 0.6 | 8 |

© 2019 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Zhang, Z.; Wu, Z.; Rincon, D.; Christofides, P.D.
Real-Time Optimization and Control of Nonlinear Processes Using Machine Learning. *Mathematics* **2019**, *7*, 890.
https://doi.org/10.3390/math7100890

**AMA Style**

Zhang Z, Wu Z, Rincon D, Christofides PD.
Real-Time Optimization and Control of Nonlinear Processes Using Machine Learning. *Mathematics*. 2019; 7(10):890.
https://doi.org/10.3390/math7100890

**Chicago/Turabian Style**

Zhang, Zhihao, Zhe Wu, David Rincon, and Panagiotis D. Christofides.
2019. "Real-Time Optimization and Control of Nonlinear Processes Using Machine Learning" *Mathematics* 7, no. 10: 890.
https://doi.org/10.3390/math7100890