Real-Time Optimization Tutorial

Williams-Otto reactor system

Problem Description

The Williams-Otto CSTR is a benchmark process for real-time optimization (RTO) systems. It consists in the following reactions:

$ A + B \rightarrow C $ (1)

$ B + C \rightarrow P + E $ (2)

$ C + P \rightarrow G $ (3)

where A and B are raw materials, P is the desired product, E is the byproduct with added sales value, C is the complex intermediate without sale value, and G is the residual material. The reactor is fed by two reactant flow rates (Fa and Fb). The full set of mass balance equations can be found in [1], for example.

Each reaction has its rate $k$ defined as a function of the reactor temperature Tr:

$ k_1 = 1.6599\times10^6\exp(-6666.7/Tr) $

$ k_2 = 7.2177\times10^8\exp(-8333.3/Tr) $

$ k_3 = 2.6745\times10^{12}\exp(-11111/Tr) $

Fa assumes a fixed, therefore Fb and Tr are our manipulated (decision) variables, $u=[Fb, Tr]$. The optimization objective is finding a combination of these variables in order to maximize the profit when the system reaches steady-state operation:

$ \Phi(u) = 1043.38*Xp*(Fa+Fb)+20.92*Xe*(Fa+Fb) - 79.23*Fa - 118.34*Fb$

where $Xp$ and $Xe$ are the amount of P and E in steady-state operation, respectively. Besides steady-state operation, the following operational constraints are enforced:

$Fb \in [3,6]$

$Tr \in [70, 100]$

$Xa < 0.12$

$Xg < 0.08$

In practice, however, it is very unlikely to know the complete model of a given process. It can be in the form of parametrical and/or structural mismatch. Parametrical mismatch means we know the model structure, but its parameters are uncertain. Structural mismatch is the case where we the complete model equations are unknown, which usually happens when trying to model complex processes and have to apply simplifications to some of its behaviors. It is easy to see that if we try to optimize a process based on a uncertain model, we can produce sub-optimal or even unfeasible operating points. This is where RTO systems come to the rescue: they are specifically designed to handle model uncertainty and lead to process optimality under convergence.

For the Williams-Otto CSTR we know all the process equations and parameters. Therefore, to study the real-time optimization capabilities, we will use a simplified version of this model in order to simulate what would happen in real applications. For that, we consider the following model structure:

$ A + 2B \rightarrow P + E $ (1)

$ A + B + P \rightarrow G $ (2)

And the reaction rates are given by:

$ k_1 = 1.655\times10^8\exp(-8077.6/Tr) $

$ k_2 = 2.611\times10^{13}\exp(-12438.5/Tr) $

Analysis

The real process will be called the "plant", while the uncertain one is the "model". First, we create and instance for each one:

Next, let's have a look at the decision surface of our cost function, along with the constraints. This is a way to observe the effects of the plant-model mismatch. First we do a grid search over the input domain, storing the objective and constraint values.

Now, the contour plot is generated for both the plant and model. The feasible region is limited by the red surface.

From this chart we notice these interesting information:

  1. The unconstrained minima of plant and model and very different. Optimizing over the model would definitely result in a sub-optimal operating point.
  2. When constraints are added, the optima are located at their intersection. This could lead to unfeasible operation if optimazing over the model, if not properly evaluated beforehand.

Let's have a deeper look at item (2). In order to do that, we should solve the optimization problem described previously, for both the plant and model. The Differential Evolution algorithm will be used, because of it's nice capabilities for handling restrictions and global convergence.

Although the solution found for both the model and plant are very close, let's see what happens if we apply the input found with the model into the plant. The 'x' represents the model solution, while the "*" the plant optimum.

Notice that although the solution remained inside the feasible region, it is definitely sub-optimal. It is easy to notice that depending on the model parameters, the optimal solution could easily become unfeasible. Thus, one can see that some sort of adaptation of the model is necessary to ensure convergence to the actual plant optimum, while respecting the process constraints.

Real-Time Optimization

RTO systems are capable of iteratively driving the system towards the optimum in spite of plant-model mismatch. The entire system is displayed in the image below:

RTO System

Several approaches exist in the literature, and can be classified based on the adaptation strategy they use. The most relevant are the two-step (TS) and modifier adaptation (MA). TS employs as adaptation strategy the update of the model parameters by solving a data reconciliation problem based on measured plant data. On the other hand, modifier adaptation uses plant data to add the so-called modifiers to the cost and constraint functions of the model-based optimization problem. Each method has its pros and cons, and their usage will depend on the process being optimized. Here I am going to use first the Modifier Adaptation with Gaussian Processes (GP) scheme.

Modifier Adaptation with Gaussian Processes

This is a novel technique that leverages GP regression to represent the plant-model mismatch. It removes the need of calculating plant gradients, a requirement for previous MA schemes. The diagram below display how it works in practice:

MA-GP

The RTO system is run with the following parameters:

Since we know the plant's optimal cost and input signal, we can evalute the system performance based on the relative optimality gap:

$\Delta u\% = \left\|100 \frac{u - u^{opt}}{u^{opt}} \right\|, \quad \Delta \phi \% = 100 \frac{\phi - \phi^{opt}}{\phi^{opt}} $

Before running the RTO system in closed-loop, first we collect some initialization data. After that, we have to build the two main elements of such system:

After that, we pass these objects to the RTO class, which will be responsible for running the system in closed loop, as shown in the previous diagrams. Internally, it runs the following steps:

  1. Run the model-based optimization problem
  2. Filter the calculated optimal input using an exponential filter
  3. Apply the input to the plant and collect the necessary measurements
  4. Execute the adaptation strategy

All the RTO iteration data is stored in a sqlite database. This makes sure we have everything necessary for analyzing its performance as a whole later. This notebook uses a memory datbase, but one can also use a physical one.

Finally, we can run the RTO system. The last sampled initial operating point is used to start the system.

After the system stops after reaching the maximum amount of iterations, we can start analyzin the results. In order to do that, we need could use an instance of the ExperimentAnalyzer class.

Below the results for the cost and input optimality gap are displayed. Notice that, although starting from some random initial points, the RTO system was able to drive the process towards plant optimality (0% gap), even though we use an approximate model and measurements are noisy.

It is also possible to look at the operating points calculated at each RTO iteration. The initial dataset is represented by the pink diamonds, while the closed-loop iterations are in black. Notice that the system rapidly converges to the plant optimum, but some of the constratins were violated duting this process. It could be an effect of the measurement noise, as the system also oscilattes around the optimum on convergence.

Conclusions

This notebook presented an analysis of the process optimization under uncertainty problem using. By using the Williams-Otto CSTR model, we tackle it using a real-time optimization approach called Modifier Adaptation with Gaussian Process to handle the plant-model mismatch. There are many other aspects of this problem that could be also studied, but they will be analyzed in another opportunity.

References

  1. Zhang, Yale, and J. Fraser Forbes. "Extended design cost: a performance criterion for real-time optimization systems." Computers & Chemical Engineering 24, no. 8 (2000): 1829-1841.
  2. de Avila Ferreira, Tafarel, Harsh A. Shukla, Timm Faulwasser, Colin N. Jones, and Dominique Bonvin. "Real-time optimization of uncertain process systems via modifier adaptation and Gaussian processes." In 2018 European Control Conference (ECC), pp. 465-470. IEEE, 2018.