# AI for Industrial Process Control (Part 2): Model Predictive Control Deep dive

Covering the fundamentals of process control. November 13, 2020 | Thouheed Abdul Gaffoor

Share

So far, we’ve covered the fundamentals of process control. We reviewed how PID controllers work, discussed their limitations and introduced the concept of predictive control. In this article, we’ll explore how MPC controllers work in more detail.

## Model Predictive Control: Recap

Predictive Control operates by performing dynamic, real-time optimization to generate control actions that are adaptive to process disturbances and are compliant with user-specified constraints. Examples of process disturbances include changes in raw material quality, environmental conditions (i.e. precipitation), and upstream operations.

Meanwhile, examples of constraints include regulatory limits or maintenance requirements. MPC allows operators to run their processes more efficiently by operating much closer to constraints than would be possible with conventional reactive controllers in order to save on costs or increase production. This is particularly useful for complex, nonlinear systems such as bioreactors or distillation columns where the impact of tighter controls can yield substantial cost savings. ##### At is Figure 1. Block diagram of an MPC Controller (Image by author)

As previously discussed, the core components of an MPC controller include:

1. a simulation model: a mathematical representation of the process dynamics, i.e. it can predict what the future state of a process will be based on control actions

2. an optimizer: a mathematical solver that can iteratively determine the “optimal” control action based on outputs from the simulation model

3. constraints: specifies the boundary of acceptable future states that the optimizer cannot exceed, i.e. a compliance limit on discharge concentrations

4. objectives: the optimization goal the operator seeks to achieve, i.e. reducing deviations from a target product quality

## Receding Horizon

To understand how all these components fit together, we need to review the concept of a “receding horizon”, as illustrated in Figure 2. ##### (Image by Martin Behrendt on Wikimedia Commons, CC BY-SA 3.0)

The MPC controller starts at present time, denoted as “k” in Figure 2. At this point, the controller has an idea of what the desired target is, denoted as the “reference trajectory” in Figure 2. However, the controller needs to know what control actions to take in future steps, “k+1” to “k + p”, to get there.

1. As a first step, the controller samples the current measured output at present time “k”

2. In order to determine what future control actions are required, the MPC controller runs an optimization algorithm over the prediction horizon (p), from “k+1” to “k + p”.

a. It performs an on-the-fly calculation to determine the impact of a control action at any timestep, let's say “k+1”, on the predicted output of “k+1” and then measures the distance of the predicted            output from the reference trajectory.

b. The optimization goal will be to minimize the distance and time it takes for the predicted output to match up with the reference trajectory over the prediction horizon.

3. Only the first step of the control action sequence, “k+1”, is implemented.

4. Once we move forward in time and are now at “k+1”, the current measured output is sampled again and the calculations are repeated starting from the new current state, yielding a new control and new predicted state path. The prediction horizon keeps being shifted forward and for this reason MPC is also called receding horizon control.

## Model Predictive Control: The Simulation Model

The simulation model is perhaps the single most important component of an MPC controller. It also happens to be the most challenging aspect since most real industrial systems are often complex, highly non-linear and often under observed (lack sensor coverage). The process of discovering a simulation model for a system is known as model identification. ##### Figure 3. Model Identification Process (Image by Author)

As shown in Figure 3, the first step in identifying a model involves wrangling data into a useable format. Industrial data often has many challenges that require correction including but not limited to signal noise, sensor communication failures (i.e. flatlining or gaps) and sensor drift. ##### (a) Anomalous trend in time series signal ##### (b) Highly noisy time series signal ##### Figure 4. Examples of challenges from industrial data (Image by Author)

Apart from the data cleanliness issues described above, data collected from an industrial process is often too limited to build a robust model. This limitation may occur if the data has significant gaps or if the facility operations were largely static, i.e. control inputs were not changed frequently.

The consequence of this is illustrated in Figure 5. The distribution shown on the left panel (a), illustrates a control input variable that has frequent observations between a wide data range. In contrast, the distribution on the right panel (b) has observations tightly coupled around a single value.  ##### Figure 5. (a) Idealized distribution (left), versus (b) poorly distributed data (right) for model fitting.

In the case of panel (b), further manipulation is required to generate a wider distribution of data. This is because we need a simulation model that is responsive to a diverse range of control input changes. One strategy to deal with this limitation is step testing. Step testing involves manipulating control inputs in the real process and studying how the system responds on order to generate new data to build a model.

Once there is enough data to build a model, various modelling strategies can be pursued. These include:

• Physics-driven models: described by ordinary differential equations, only design parameters and rate coefficients need to be calibrated based on data.
• Grey-box/hybrid models: empirical models whereby the structure and selection of inputs are crafted based on domain knowledge, but the model parameters are fit based on available data.
• Empirical models: data-driven statistical models whereby both the model structure and parameters are determined based on the available data

In another series, we’ll compare these different modelling strategies in more detail. Generally, most non-linear industrial systems can be described by the general equation below, whereby ‘f’ represents the non-linear mathematical model of an arbitrary system and is a function of its state variables (Y), control variables (U) and disturbance variables (W).  ## Model Predictive Control: The Objective Function & Optimizer

As mentioned earlier, the objective function is a mathematical description of the optimization goal that the operator seeks to achieve, i.e. reducing deviations from a target product quality. The squared error formulation is the most common form of an objective function that is used in industry.

The equation penalizes deviation of a current measured value (ymeas) from a desired target value (ytarget), by squaring the deviation (thereby amplifying the absolute magnitude of it). The optimizer must then aim to reduce the squared deviation to zero. If an objective can be decoded into the general equation form above, virtually any constraint can be added to the MPC objective function. Multiple constraints can be jointly balanced by introducing weights, “wi”, in order to enable prioritization, whereby larger weights signify greater prioritization.

The last piece of the puzzle is the optimizer. The optimizer is an iterative algorithm that is designed to minimize the objective function using the outputs from the simulation model. Noting that the form of the objective function is quadratic, a quadratic optimization routine can be used.

## Up Next?

Now that we’ve covered the detailed elements of an MPC controller, in Part 3, we’ll do an end to an end walkthrough with an industrial system, benchmarking MPC against a PID controller.

Tags: ### Thouheed Abdul Gaffoor

#### VP, AI

Thouheed is a tech entrepreneur that’s passionate about using AI for social good. That’s what led him to Emagin.ai (acquired by Innovyze), an AI company he cofounded and successfully scaled that helped utilities and manufacturers manage water more efficiently. By trade, Thouheed is a process control/ML specialist and has spent 5+ years developing, commercializing and deploying AI/ML solutions for mission critical systems (heavy industry and manufacturing). Over his career, he has patented novel AI frameworks, raised capital from global VCs, and sold to Fortune 500 companies ranging from public and private utilities (water, sewer and power) to manufacturers (food/beverage, pulp/paper mills and mining).