Optimal switching of MPC cost function for changing active constraints

Model predictive control (MPC) allows for dealing with multivariable interactions, known future changes and dynamic satisfaction of constraints. Standard MPC has a cost function that aims at keeping selected controlled variables at constant setpoints. This work considers systems where the steady-state optimal active constraints change during operation. This situation is not handled optimally by standard MPC which uses fixed controlled variables for the unconstrained degrees of freedom. We propose a simple framework that detects the constraint changes and updates the controlled variables accordingly. The unconstrained controlled variables are chosen to be the reduced cost gradients, which when controlled to zero minimizes the steady-state economic cost. In this paper, the nullspace method for self-optimizing control is used to estimate the cost gradient using a static combination of the measurements. This estimated gradient is also used for detecting the current set of active constraints, which in particular allows for giving up constraints that were previously active. The proposed framework, here referred to as ‘‘region-based MPC’’, is shown to be optimal for linear constrained systems with a quadratic economic cost function, and it allows for good economic performance in nonlinear systems in a neighborhood of the considered design points.


Introduction
Model predictive control (MPC) denotes a class of control strategies based on the online optimization of the predicted dynamic trajectory of the system [1].It is a valuable tool for process control, being able to deal with multivariable interactions, future known disturbances and setpoint changes, and constraint satisfaction.In practice, MPC is usually implemented as a supervisory control layer above the plant regulatory layer, where stability is assessed, and is subordinate to a real-time optimization (RTO) layer, which updates the setpoints for the controlled variables (CVs) based on economics, as presented in Fig. 1.It is possible to eliminate the controlled variables by combining the RTO layer, the supervisory control (MPC) layer and the regulatory control (PID) layer into one layer.This alternative, known as Economic MPC (EMPC) [2], is popular in academia but almost never used in industry and is not considered in this paper.
The steady-state economic optimization of the plant, solved at the RTO layer, can be defined as the following constrained optimization problem: where   is the scalar economic cost function,  ∈ R   is the vector of inputs or manipulated variables (MVs),  ∈ R   is the vector of Fig. 1.Typical hierarchical control structure with standard setpoint-tracking MPC in the supervisory layer.The cost function for the RTO layer is   and the cost function for the MPC layer is    .With no RTO layer (and thus constant setpoints   ), this structure is not economically optimal when there are changes in the active constraints.For some applications, the state estimator and RTO estimator may be combined.
problem or through the use of penalty terms.Additionally, most industrial MPC implementations include a target calculation block, which ensures that the setpoint that the MPC tracks is feasible at steady state [1].
In most MPC implementations, the CVs are selected based on process intuition, and not in a systematic manner.In this context, selfoptimizing control (SOC) provides useful tools for systematic selection of CVs, having optimal steady-state operation for changing disturbances as the main goal [3,4].For quadratic problems, this gives for the unconstrained degrees of freedom, the controlled variables [5]: where  denotes the available process measurements (possibly including inputs  and measured disturbances ) and  is a selection or combination matrix.
Most SOC approaches for CV selection assume that the steady-state active constraint set  is constant [4].For example, Graciano et al. [5] implemented MPC using the nominal self-optimizing CVs, that is, with the nominally active constraints.This can reject disturbances in the fast timescales and minimize the economic loss without the intervention of the RTO layer for the nominal set of active constraints.This is relatively simple to implement and also satisfies the constraints under changing operating conditions (disturbances).However, the approach of Graciano et al. [5] is not economically optimal for changing active constraints, because the optimal approach is to use different selfoptimizing CVs for each set of active steady-state constraints [6], that is, to update the matrix  for each set of active constraints.Graciano et al. [5] write that: ''When considering active set changes, there are two fundamental cases that must be handled by every method that attempts to give optimal operation: (1) Detecting when a new constraint becomes active: Here a degree of freedom is consumed for controlling the new constraint, and control of one of the unconstrained self-optimizing controlled variables must be given up.(2) Detecting when a previously active constraint becomes inactive: Here the constraint that was enforced previously must be released, and a new self-optimizing variable must be controlled instead''.To handle case 2, the approach Graciano et al. [5] depends on RTO updates to be optimal.The authors write: ''Our approach does not handle Case 2 in between RTO updates.That is, if a constraint becomes inactive in between RTO runs, it will be kept at its bound until the next RTO execution''.17) and (18).The possible updates from an upper RTO layer ( * ,  *  etc.) are not considered in the present work.Even with no RTO layer (and thus with constant setpoints    in each active constraint region), this structure is potentially economically optimal when there are changes in the active constraints.
This work proposes a solution to this problem by providing a framework for self-optimizing control under changing active constraints (Fig. 2), labeled ''region-based MPC''.Which is optimal in both cases 1 and 2, without needing to rely on a RTO layer.Here, the self-optimizing CVs tracked by MPC are a function of the active constraint set.The detection of when a constraint becomes inactive (case 2) is based on the work of Woodward et al. [7].In three case studies, we show that standard MPC with a single (nominal) set of CVs leads to economic loss when there are changes in active constraints during operation, whereas the proposed region-based MPC framework attains steady-state optimal operation, at least locally where nonlinearity in the model is negligible.
The rest of the paper is organized as follows.In Section 2 we present some basic notions of MPC implementation.In Section 3 we describe the control structure proposed in this work, and the results of its application in some case studies are presented in Section 4. Based on these results and the theoretical aspects of the control structure, we discuss the proposed framework in Section 5, and the paper is then concluded in Section 6.

Standard MPC implementation
We first briefly discuss the standard MPC implementation represented in Fig. 1, which includes a state estimator and an open-loop optimizer (MPC block).For the estimator, consider the following dynamic model used as an internal model for MPC: Here,  ∈ R   represents the vector of dynamic states,  ∈ R   the vector of inputs (MVs),  ∈ R   the vector of measurements and   ∈ R    a vector of model disturbances.
There is usually one   for each controlled variable, which is used to account for uncertainty, for example, related to the ''true'' disturbances , measurement bias, or model parameter changes.Note that   does not need to have a physical interpretation and is used mainly to include integral action in MPC.In other words, to attain offset-free control, the internal model is augmented with the integrating states   : For a linear internal model, the number of additional integrating states must be at least the number of controlled variables, and it need not be greater than the number of measurements [8].The dynamic model considered by the state estimator is therefore of the form: where  ∼  (0,   ) and  ∼  (0,   ) are the random variables present in most state estimation frameworks, and   and   are the corresponding tuning parameters [9].The estimated states x and d are then used to solve a moving-horizon optimization problem, which results in the next control action to be implemented.A simple MPC optimization problem discretized using multiple shooting [10] can be of the form: Here,  are the selected controlled variables,   denotes the state at the th time step, and ( −1 ,  −1 , d ) is the result of the integration of the dynamic model in Eq. ( 2) from  −1 to   =  −1 +  with  =  −1 ,   = d , and the initial condition as the previous state ( −1 ) =  −1 .The objective function    aims to minimize the tracking error  −   while penalizing large input changes   . is the number of prediction steps, and the weight matrices  and  are tuning parameters.
The output, state, and input constraints in Eq. ( 5) can be used to embed the RTO constraint (, ) ≤ 0 from Eq. (1) in the MPC time scale.State constraints are not needed if we assume that the constraints (, ) are measured (or estimated) and included as elements in the measurements vector .Without loss of generality, we will assume that the constraints can be estimated from the dynamic model as: We remark that an MPC in the form of Eq. ( 5) has no stability guarantees, but it can converge if the prediction horizon  is large enough (the reader is referred to Mayne [11] for an in-depth review of MPC formulations).
The focus of the present work is the case where the original setpoints   must be given up due to constraints becoming active at steady state.In theory, the RTO layer may update the setpoints, but in most cases there is no RTO layer, so the setpoints are constant.Standard MPC satisfies the constraints, but it is suboptimal in terms of steadystate economic performance.In the next section, we propose an optimal way of dealing with changing active constraints, without the need for RTO updates.

Region-based MPC framework
The structure of the proposed region-based MPC scheme is summarized in Fig. 2. The state estimator, also present in standard MPC, serves as the feedback element for MPC as well as for the active set detection block, which is the new element of the framework when compared to standard MPC.The detected active set , is sent to the MPC block, which uses a different set of predetermined CVs for each active set .We next describe how the CVs for each active set are determined, and how the set of active constraints can be estimated online.

Controlled variables for region-based MPC
The controlled variables (CVs) in region (or active constraint set)  are: Here,   denotes the active constraints, and   denotes the unconstrained CVs (which we will see are the reduced gradients) for optimal steady-state operation.The dynamic control problem for the proposed region-based MPC is very similar to that of standard MPC in Eq. ( 5), except that the objective function changes for each region : where   and   are tuning parameters that can be chosen independently for each region , and    are setpoints that will be calculated next.
The unconstrained controlled variables   should be selected to minimize the steady-state cost, given that the active constraints   are being controlled.For this purpose, we follow Halvorsen et al. [12] and consider a local QP approximation of the steady-state economic optimization problem: Here,  =  −  ⋆ and  =  −  ⋆ represent the disturbances and inputs as their deviation from their reference values  ⋆ and  ⋆ , respectively, and   ⋆ ,  ⋆  , and   represent respectively the cost function, its gradient, and its Hessian with respect to the inputs, all evaluated at the steady state reference point ⋆ .The linearized expression in Eq. (9b) for the constraints is not used by Halvorsen et al. [12], but it is needed here because we consider changes in active constraints.Additionally, the measurements  are locally approximated by a linear steady-state model of the form: The optimal solution to the problem in Eq. ( 9) can be implemented in a feedback fashion by selecting as unconstrained controlled variables  a static linear combination of the measurements [12]: Assuming that there are enough (  =   +   )1 independent noisefree measurements, we can find an analytical expression for  based on the nullspace method [14,15]: where † denotes the pseudo inverse.The associated controlled variables are: Actually, the expression for  0 is non-unique [14], and the particular formula given in Eq. ( 12) is chosen because it can be used to obtain an optimal first-order estimate of the unconstrained cost gradient   [13,15]: As we shall see, the unconstrained gradient estimate Ĵ is very useful when considering the constrained case.The setpoint   0 =  0  ⋆ − ⋆  , is calculated based on the reference steady state ⋆ .If the reference steady state is an optimal operating point in the fully unconstrained region, then  ⋆  = 0.However, if the reference steady state is not optimal, or (more commonly) if the reference steady state is in a constrained region, then  ⋆  ≠ 0. For the constrained case, we introduce the reduced gradient, defined by: where the projection matrix   is a basis for the nullspace of the active constraints gradient, i.e.: Optimal steady-state operation is achieved when the reduced gradient is zero [6,16], that is, when      = 0. Using the gradient estimate in Eq. ( 14), we then have that the optimal CVs related to the unconstrained degrees of freedom are In summary, the full set of controlled variables for each active constraint region  becomes: with corresponding setpoints: This choice of CVs minimizes the steady-state economic loss around the reference point ( ⋆ ,  ⋆ ).Furthermore, even if the current operating point has a different active set  than that of the reference point, the use of   minimizes the steady-state loss, as long as the approximations in Eqs. ( 9) and (10) hold.However, for non-quadratic/nonlinear problems the reference point matters and there will be a steady-state loss, for example, compare Figs.11 and 13 for case study 2 which are linearized in two different reference points.
We now discuss how to detect the active set using the available measurements, so as to select the correct controlled variables   .

Active constraint set detection
Woodward et al. [7] describes an active set detection algorithm for a feedback optimizing strategy which only depends on the current value of the cost gradient   , the constraints , and the constraints gradient   .In our case, we assume that  is directly measured,   is estimated using Eq. ( 14), and   is a constant, see Eq. (9b).Thus, in our case the algorithm depends directly on the available measurements.
The steady-state cost gradient estimate Ĵ is obtained at the (expected) steady state (denoted   ) that would result when the CVs are driven to their setpoints.This expected steady state can be determined using Eq. ( 2), leading to: Algorithm 1 Active set estimation, adapted from Woodward et al. [7].
  ←  ′ 8: end if from which we obtain   = ℎ(  ,   , d ) and   = ℎ  (  ,   , d ).With these values, we apply the algorithm from Woodward et al. [7] to find the current set of active constraints.
The algorithm is summarized in Algorithm 1.In step 1 we first find the expected steady-state measurements   by solving Eq. ( 19), and then compute Ĵ using Eq. ( 14).In step 2 the constraints predicted to be violated, i.e.    ≥ 0, are added to the estimated active set.With this augmented active set , we solve in step 3 the following optimization problem: The idea is to find the largest projection of the negative of the estimated cost gradient, − Ĵ , onto the feasible directions, i.e. find directions that do not violate      ≤ 0. The solution  * therefore dictates the best feasible descent direction for improving the economic cost function.In step 4, the inactive constraints at the solution (    * < 0) are removed from the active set , as controlling these constraints would hinder economic improvement.If the resulting active set has more than   elements, it is infeasible, because we can at most control   constraints with   inputs.In step 6, one picks a subset which is predicted to be feasible (   ≤ 0 ∀) by evaluating the corresponding expected steady states with Eq. (19).
One may also add a constraint priority list, such that, when operation is infeasible for all candidate active sets, the less important constraint is given up.
The problem given in Eq. ( 20) is an NLP due to the quadratic equality constraint.The work of Woodward et al. [7] solves it using an efficient algorithm tailored to this problem, but here we solve the optimization problem with a general-purpose NLP solver (IPOPT).To prevent premature switching, for example due to noise or estimator dynamics, the estimated constraint set  is only selected as the new set of active constraints (resulting in switching of the CVs) if the estimated new set has remained the same for   time steps.  is a tuning parameter.

Case studies
For the following case studies, consider the mixed continuousdiscrete time objective function for MPC: This mixed formulation is used for convenience, as the integration of the MPC objective function and the internal model are done together using orthogonal collocation.The resulting problem is solved using CasADi/IPOPT [17].

Case study 1 -toy example
We first consider a toy example with a quadratic cost function and linear dynamic and constraint models, for which the proposed region-based MPC is steady-state optimal.On the other hand, standard MPC is expected to result in steady-state losses is some constrained regions.
The system has two dynamic states , three inputs (MVs) , two disturbances , two constraints  and five independent measurements .The first two measurements are the two constraints.Note that   = 3,   = 2 and   = 5 which means that we satisfy the requirement   =   +  needed to apply the nullspace method for estimating the gradient   (for cases with fewer measurements and/or measurement noise we should instead apply the more general exact local method [13]).
The economic objective and constraints are represented by the following steady-state optimization problem: The dynamic states  are affected by the MVs  and the disturbances  according to the following linear dynamic state-space model: with For the vector of measurements , we consider the constraints as direct measurements, figuring in the first two rows of the measurement vector.The remaining measurements are chosen with the goal of satisfying a sufficient number of independent measurements (  =   +   ).We may eliminate the state variables  from the steady-state optimization problem in Eq. ( 22), since from Eq. ( 23) we have at steady state: We may then write the steady-state optimization problem in the standard form: The following static measurements model is assumed: This problem has two inequality constraints and three MVs, so optimal operation will always have between one and three unconstrained degrees of freedom.As the system has only two disturbances, we can graphically illustrate the active constraint regions as in Fig. 3, where we can see all four possible combinations of active constraints.Note that this map is not needed to apply the proposed region-based method; it is only made to visualize the regions.

Table 1
Gradient projection matrices for the four regions for case study 1.For implementing a standard MPC controller, we follow the strategy described by Graciano et al. [5].We design the self-optimizing controlled variables  =  0  in the unconstrained region and from the nullspace method in Eq. ( 12) we obtain: As the reference steady state, we choose the optimal operating point at . The measurements at the optimal operating point are  ⋆ = [−6.17−9.86 2.62 −6.91 −2.56]  , and the resulting setpoints become   =  0  ⋆ = [ 0 0 0 ]  .For the region-based MPC controller, we use the same unconstrained nominal point, resulting in the same  0 =  0 .The projection matrices   for the constrained regions are presented in Table 1.
The tuning parameters for the MPC controllers are given in Table 2, where the standard MPC uses only the tuning parameters for the fully unconstrained region ( = {}).
The closed-loop dynamic responses for both standard and regionbased MPC are shown in Fig. 4. The responses go through eight sets of With standard MPC, the controlled variables  0 =  0  obtained in the unconstrained region ( = {}) are not steady-state optimal when applied to the constrained regions.This is most easily seen by comparing the inputs ( 1 ,  2 ,  3 ) from standard MPC (green) with the steady-state optimal inputs (magenta).On the other hand, the inputs obtained with the proposed region-based MPC (blue) are optimal at steady state in all four regions.In addition, the switching of CVs between regions is seen to be smooth.Both strategies satisfy the constraints at steady state but with some dynamic violations.The ''loss'' in the lower left plot in Fig. 4 is the difference between the current (dynamic) economic cost and the optimal value of the cost at steady state for the corresponding disturbances, and therefore both negative and positive dynamic spikes are possible.
The steady-state economic loss is of more interest.This loss is zero for the proposed region-based MPC.For standard MPC, the steady-state loss is shown in more detail in Fig. 5.As expected, the steady-state loss is strictly positive.It can be seen that the loss is nonzero whenever the system leaves the unconstrained region.Note that the lines delimiting the operating regions (blue) do not coincide with the optimal boundaries (magenta) at the partly constrained regions, because the use of fixed controlled variables is not optimal.Therefore, standard MPC may result in control of constraints which should not be active.
It is worth mentioning that the proposed region-based MPC method does not rely on RTO updates of the setpoints for dealing with changes  in active constraints.Instead, it relies on a switching logic for the CVs which is solely based on measurements.

Case study 2 -Williams-Otto reactor
This case study is based on the process described by Williams and Otto [18], see Fig. 6.It consists of a continuously stirred reactor tank with perfect level control, in which A and B are mixed, generating the main product of interest P, along with the less interesting product E and the undesired byproduct G.The three reactions are: The component balances result in the following system of ODEs:   Here,   represents the mass fraction of component .The model parameters for this case study are summarized in Table 3.The economic optimization problem to be considered is: The available degrees of freedom for the MPC layer are  = [     ]  , which are the mass inflow of pure B and the reactor temperature.Note that the physical degrees of freedom are valve positions, so in practice there will be a lower-layer regulatory (PID) layer, with a flow controller and a temperature controller.However, the regulatory layer is not considered in this paper, that is, we assume perfect regulatory control where the inflow rate and reactor temperature are set directly.As long as we have an acceptable time scale separation (typically, a factor 4 or higher [19]) between the MPC and regulatory layers, this assumption has no effect on the results.
The considered disturbances are  = [     ]  , namely the mass inflow of pure A and the relative variation of the price   .Similar to case study 1, we can optimize the system for various disturbances, and visualize in Fig. 7 the resulting active constraint regions as a function of the two disturbances.
We choose to scale the constraints relative to the maximum optimal constraint value in the disturbance window shown in Fig. 7.This gives the following scaled constraints: The measurements are the two constraints, the fraction of component P and the price of P, that is, For the two MPC controllers, we use a linear approximation of the dynamic model, and estimate disturbances and additional integrating states using a linear Kalman filter that ensures zero offset [20].Similarly, to find the matrix  0 needed to design the controlled variables (CVs) for MPC, we must first obtain, by linearization at the nominal design point ( ⋆ ), the matrices   ,   ,   ,    , and   .The choice of nominal design point is important, especially for the CV selection, as it affects the steady-state losses that we may result when operating away from the nominal point.To understand this better we shall consider two different nominal design points (I and II).
The first set of results are based on linearization in design point I, at the vertex between the regions ( ⋆  = [1.543;−0.089]),where the resulting  0 is given by:  4 and 5, respectively.From the closed-loop dynamic simulations in Fig. 8, we see that in the unconstrained region (until = 4 h), the behavior of standard MPC and region-based MPC is identical (as expected, since  0 , and thus the two CVs, are the same).However, note that the presence of nonlinearity leads to non-optimal steady-state optimal operation, even for the region-based MPC.This is most easily seen by comparing the process inputs  1 and  2 with the steady-state optimal dashed magenta lines.The operation in the subsequent region with constraint  1 active (from  = 4 to  = 8 h) highlights the difference between the two MPC approaches.The region-based MPC framework detects quite accurately the region change and switches to two new CVs (one constraint and one reduced gradient), whereas standard MPC, while using one degree of freedom to control the constraint, attempts to track (one average, with the remaining single degree of freedom) both the two original CVs from the unconstrained region.This is not optimal, as seen most easily from the plot of  2 .For the fully constrained region ({ 1 ,  2 } from  = 8 to  = 12 h), the two MPC schemes behave similarly, attaining zero steady-state loss by taking all the constraints to their limit values.The region-based MPC attains this through direct constraint control, whereas standard MPC relies on its dynamic constraint handling, which has its own issues regarding stability and performance.
In Figs. 9 and 10 we can see in more detail the steady-state loss for the two MPC schemes as a function of the two disturbances.The  difference between the two MPC controllers is not so large because there are losses also with region-based MPC due to nonlinearity in the model.However, in standard MPC, the prioritization of CVs in the constrained regions depends on the cost function weights, and therefore the steady state economic loss depends on the MPC tuning parameters.This fact is illustrated in Fig. 11, where a different standard MPC tuning (different choice of the weight ) led to much larger losses in the constrained regions.For the proposed region-based MPC, this is not an issue because the choice of CVs is consistent with the active constraints, making the steady-state performance independent of the MPC tuning.
We now design the region-based MPC and the standard MPC by linearizing at a different optimal nominal point, namely at  ⋆  = [2.0;+0.2], which lies in the interior of the unconstrained region.Here, the resulting  0 is: ] and the corresponding gradient projections and controller tunings are given in Tables 6 and 7, respectively.For this linearization point, the results are shown in Figs. 12 to 14.In this case, the region-based MPC overall gives much smaller economic losses than standard MPC.Also, the regions obtained in Fig. 13 are shaped similarly to the optimal regions, which does not happen with standard MPC, see Fig. 14.Because the linearization of the system is in the interior of the unconstrained region, the economic loss in that region is smaller when compared to that of Fig. 9, while (somewhat surprisingly) not resulting in a larger loss for the remaining regions for the region-based MPC.{1, 2} -

Table 7
Tuning of controllers and estimator for case study 2 -linearization at  ⋆  = [2.0;+0.2] (omitted parameters are the same as in Table 5).

Case study 3 -Williams-Otto reactor revisited
We now revisit case study 2, and consider a case with three rather than two constraints.The main reason for adding a constraint is because then the standard decentralized selector-based region-based control does not work because   >   [21].The cost function is the same as in case study 2, except that we do not consider price changes.We consider the following constraints (all of which are new): The MVs are the same,  = [     ]  , but to make it easier to plot the results, we only consider one disturbance,  =   , which is in the range 0.5 ≤  ≤ 3.5.The nominal value is  ⋆ = 1, which corresponds to an optimal operating point where constraint  3 is active.We again normalize the constraints, and the normalized steady-state optimization problem is given by:

Table 8
Gradient projections for case study 3.
-Fig. 15 shows the active constraint regions as a function of the disturbance   .It can be seen that all seven feasible combinations of active constraints appear in the considered disturbance range. 2he available measurements are the normalized constraints,  = .We design the unconstrained controlled variables based on the nominal point, for which the resulting  0 is given by:  8 and 9, respectively.Dynamic closed-loop simulations with standard and region-based MPC appear in Fig. 16.The tuning used for standard MPC was done such that it operates acceptably when constraints become active, which reduces the performance in some regions.Because the region-based MPC can be tuned independently for every active constraint region, its dynamic performance is better (although it is not so easy to see from the graphs).
Figs. 17 and 18 shows the steady-state values of the constraints as a function of the disturbance for region-based MPC and standard MPC, respectively.The corresponding steady-state losses in Fig. 19 show large benefits of the proposed region-based MPC.The regionbased MPC is optimal at and around  =  ⋆ = 1.0.But this not the case for standard MPC.The reason is that the nominal operating point is partly constrained (with  3 = 0 being active).While the region-based MPC is able to use the correction  ⋆  in Eq. ( 14), the same correction   applied to the standard MPC does not lead to optimal operation.In addition, standard MPC performs poorly at driving the system to the correct constraints to be controlled, which leads to large steady-state losses for  > 2, approximately.As mentioned, the standard decentralized selector-based regionbased control cannot cover all regions.For example, assume  1 is paired to  1 , and  2 is paired to  2 , then we cannot allow  3 to be active at the same time as any of the other constraints.Thus, we would need to use some sort of adaptive pairing, if decentralized control is to be achieved (see Bernardino et al. [22] for an example).

Exact local method for gradient estimation
The unconstrained gradient   is a key element in the proposed region-based MPC approach, as it used both to determine the unconstrained CVs and to detect switches in active constraints.In this work, see Eq. ( 14), the gradient is estimated using the nullspace method of self-optimizing control, as first suggested by Jäschke and Skogestad [15].The nullspace method is simple, but it assumes that we have a sufficient number of measurements and it does not take into account measurement error.In another paper [13], we propose a more general gradient estimation approach, based on the exact local method of selfoptimizing control [14] which accounts for static measurement error and can be applied with any number of measurements.It is not much more difficult to use than the nullspace methods, but it requires the the magnitude of disturbances and measurement errors.

20.
Comparison of active set detection using the proposed prediction of the new steady state (blue) and using direct measurements (green dashed; not recommended).The simulations are for region-based MPC for case study 3.

Optimal operation under changing active constraints
The region-based MPC proposed in this work depends on a logic element (the active set detection block) that detects the current active constraint set.From this, we obtain the optimal controlled variables (which are the active constraints plus the corresponding reduced gradients, see Eq. ( 17)).The use of simple logic elements for switching control structures is very common in industrial practice, but we lack a good theory of such systems, including stability analysis [19].In general, it is necessary to analyze and possibly simulate the proposed control system for the range of expected disturbances.The proposed system includes a switching strategy, along with a pairing between MVs and CVs.This approach, however, depends on the case study and the engineering insight, and, as mentioned, one may find cases where a decentralized strategy is impossible or at least too complex to be considered for practical use [22].
In addition, even if the disturbance range is such that constraints paired to the same MV are never active at the same time, the control structure should be changed according to which set of constraints is active, because the optimal CVs related to the unconstrained degrees of freedom will change, that is, the reduced gradient will change.In summary, in terms of optimal operation of such systems, there needs to be some centralized logic, as the region-based MPC proposed in this paper.
Alternatively, a general decentralized approach is the primal-dual feedback optimizing control scheme proposed by [23,24].Here, there is a decentralized master constraint controller which controls the constraints on a slow time scale by manipulating the corresponding Lagrange multipliers.The active constraint set is detected by using maxselectors on the Lagrange multiplier.The approach has been further developed by [25] to include override control on the fast time scale for critical constraints.

Estimation of active constraints
To determine the active set during operation, we use the method by Woodward et al. [7], which is proven optimal for measured gradients.In this work, the cost gradient is estimated through a linear combination of the measurements, which is consistent with the CVs being used.
Another approach for detecting changes in the active constraint region is to track the values of the CVs in the neighboring regions [6,26].The CVs determined for each region must be consistent to result in a unique solution to the switching problem.If this is not the case, one may encounter multiple steady-state solutions or lack of convergence where the control structures switch indefinitely.This was observed when applying this approach to the case studies.On the other hand, the solution presented in this work relies on a single model realization, and all CVs obtained from it are consistent.

Use of direct measurements for the constraint switching block
To simplify the active constraint detection block, one may consider using a gradient estimate based directly on the current measurements , instead of solving for the predicted steady-state   as described in Algorithm 1.A simulation with direct measurements for case study 2 is shown in Fig. 20 (dashed green lines), and is compared to the approach proposed in this work (blue lines).However, this is not a good solution, for example, consider the controller activation plots (shown as true/false) for constraints  2 and  3 .Here, we see that the use of direct measurements in some cases delays the detection of an active set change, and in other cases switches unnecessarily.

Region-based MPC tuning
The proposed region-based MPC can be seen as a set of multivariable feedback controllers coordinated by a logic element.This logic element introduces an additional information loop, besides the feedback controller itself, which may cause stability problems.Rapid changes in which of the controllers is active may occur from the interaction between the switching element and the closed-loop dynamics, generating high-frequency, self-sustained switching.This is a wellknown problem in closed-loop systems with selectors or other logical elements, and it may be counteracted by restricting how fast the logical element may change, leading to overall system stability [27].In this work, this is attained by the tuning parameter   .
Additionally, the cost functions in Eq. ( 8) for the region-based MPC must be independently tuned.This is necessary because different CVs usually have different dynamic behaviors.Careful evaluation of the MPC tunings for different regions is therefore advised, so that good dynamic performance is attained in all relevant operating conditions.

Constraint handling with standard MPC
The simulations verify that standard setpoint-tracking MPC is unable to deal optimally with changing steady-state constraints.To satisfy a steady-state constraint which is not in the nominal region, standard MPC gives up on tight control of its CVs.In our simulations of standard MPC, this is done in an average manner, as determined indirectly by the weight  for setpoint tracking.A better way of implementing this, used in most industrial implementations before solving the dynamic MPC problem, is to use a steady-state target calculation block [1], which, based on the predicted disturbances, computes the new steady state and from this feasible setpoints for unconstrained further improvement, used in many industrial MPC implementations, is to solve a sequence of steady-state target calculations, giving up constraints in a predefined order, until one obtains a feasible steady-state solution (satisfying all constraints) [28].
The approach presented in this work could then be used in the target calculation block only, and the dynamic MPC problem remains unchanged for every active constraint region.The main benefit of this would be that the stability properties of the MPC problem would remain the same regardless of the detected active set.This does not completely solve the stability issue, as the estimator and the target calculator blocks must converge, but it would still be an appealing approach.

Addition of RTO layer
The present work has not focused on integrating the proposed tool with RTO, as other works have covered [29].Instead, the region-based MPC was formulated to be independent of the RTO layer, such that it operates near optimally without its updates.Naturally, the proposed tool can be integrated with RTO, by updating the gain matrices and reference values in Fig. 2. Because these updates are associated with the steady-state conditions of optimality, the economic performance of the region-based MPC will be as good as the quality of these updates.

EMPC
We must also note that the proposal of this work is fundamentally different from that of centralized approaches such as economic model predictive control (EMPC).In these approaches, the dynamic and economic problems are solved together, which requires a high level of detail in the available dynamic model [2].In the proposed regionbased MPC, we only require a reasonable dynamic model to ensure closed-loop stability for the tracking of CVs and an accurate economic steady-state problem that will define these CVs.

Conclusion
A framework for optimal switching of the MPC cost function under changing active constraints was presented, see Fig. 2. The two main elements are (1) the active set detection block (see Algorithm 1), and (2) the use of self-optimizing CVs (reduced gradients) in each active constraint region for the unconstrained degrees of freedom; see   =     0  in Eq. ( 17) with corresponding setpoint    in Eq. (18).In this paper, we estimated the measurement combination matrix  0 using the nullspace method from self-optimizing control, but more generally, with measurement error and any number of measurements , it is recommended to obtain  0 using the exact local method [13].We highlight that the switching of control objectives is done without the need for pairing MVs and CVs and without the need for RTO updates of the setpoints, making it applicable to a wide class of problems.

Fig. 2 .
Fig. 2. Proposed region-based MPC structure with active set detection and change in controlled variables, see Eqs. (17) and (18).The possible updates from an upper RTO layer ( * ,  *  etc.) are not considered in the present work.Even with no RTO layer (and thus with constant setpoints    in each active constraint region), this structure is potentially economically optimal when there are changes in the active constraints.

Fig. 3 .
Fig. 3.The four active constraint regions for case study 1 as a function of the two disturbances.The upper green region is unconstrained.

4 .
Dynamic simulation results for case study 1 -comparison between standard MPC (green) and the proposed region-based MPC (blue).disturbances;two inside each region as illustrated by the lower right plot.

Fig. 5 .
Fig. 5. Economic loss of standard MPC for case study 1 as a function of disturbances.Magenta lines delimit optimal active constraint regions, blue lines delimit operating regions of standard MPC.Region-based MPC attains zero loss for all disturbance values.

Fig. 7 .
Fig. 7.The four active constraint regions for case study 2 as a function of the two disturbances.

Fig. 15 .
Fig. 15.Optimal values of the three constraints   for case study 3 as a function of the disturbance .The vertical lines represent region switches.Fully unconstrained operation occurs when  is small.

5 Fig. 16 .
Fig. 16.Dynamic simulation results for case study 3 -comparison between standard MPC (green) and the proposed region-based MPC (blue).

Fig. 17 .
Fig. 17.Steady-state constraint values for standard MPC for case study 3 (optimal values as dashed lines).

Fig. 18 .
Fig. 18.Steady-state constraint values for region-based MPC for case study 3 (optimal values as dashed lines).

Fig. 19 .
Fig. 19.Steady-state loss as a function of the disturbance for case study 3 (the -axis is scaled quadratically for better visualization of low loss values).

Table 2 Tuning
parameters for MPC controllers and estimator for case study 1.The standard MPC uses only the tuning parameters for the fully unconstrained region ( = {}), that is  = diag([1, 1, 100]).

Table 3
Model parameters for case study 2.

Table 4
Gradient projections for case study 2 with linearization at vertex ( ⋆

Table 9
Tuning parameters for MPC controllers and estimator for case study 3.