{'fraction_non_alphanumeric': 0.02671173135630179, 'fraction_numerical': 0.00719581334496293, 'mean_word_length': 4.567988668555241, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 2, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
An Implicit and Explicit Dual Model Predictive Control Formulation for a Steel Recycling Process

We present a formulation for both implicit and explicit dual model predictive control for a steel recycling process. The process consists in the production of new steel by choosing a combination of several different steel scraps with unknown pollutant content. The pollutant content can only be measured after a scrap combination is molten, allowing for inference on the pollutants in the different scrap heaps. The production cost should be minimized while ensuring high quality of the product through constraining the maximum amount of pollutant. The dual control formulation allows to achieve the optimal explore-exploit trade-off between uncertainty reduction and cost minimization for the examined problem. Specifically, the dual effect is obtained by considering the dependence of the future pollutant uncertainties on the scrap selection in the predictions. The implicit formulation promotes uncertainty reduction indirectly via the impact of active constraints on the objective, while the explicit formulation adds a heuristic cost on uncertainty to encourage active exploration. We compare the formulations by numerical simulations of a simplified but representative industrial steel recycling process. The results demonstrate the superiority of the two dual formulations with respect to a robustified but non-dual formulation.


I. INTRODUCTION
Model-based control approaches such as model predictive control (MPC) [1] use a model of the controlled system to compute appropriate control inputs. By operating in a closed-loop framework they are able to react to uncertainties and model-plant mismatch. However, standard, i.e., nominal MPC has no model of the uncertainty. Feedback is applied based on the current state estimate independent of its quality. Further, in the absence of additional measures, it will often plan trajectories right on the boundary of the feasible set, such that a slight perturbation can lead to constraint violation. Approaches such as stochastic or robust MPC (SMPC resp. RMPC) try to solve this problem by explicitly taking into account the uncertainty of the model predictions [1]- [4]. However, typically this model of uncertainty is static in the sense that they are not aware how uncertainty can be reduced by learning about the system. The field of dual control [5] considers that controls can be used to achieve two competing aims, in what is often referred to as explore-exploit trade-off: exploiting the already available information to (greedily) advance the original control objective, or exploring the system by exciting it in such a way that new information is efficiently obtained. Model-based approaches can be made aware of this possibility of uncertainty reduction by including an estimator model and planning over the corresponding closedloop policies [6]. As this problem is generally intractable, only approximations can be solved. If the approximation maintains the relevant dual control aspects it is considered implicit dual control. Otherwise additional measures need to be taken, such as a heuristic cost term on uncertainty or random control perturbations ensuring sufficient excitation, in what is considered explicit dual control [7]. An excellent survey on dual MPC can be found in [8].
Steel is mainly produced using one of two methods: Blast Furnace (BF) or Electric Arc Furnace (EAF). The former uses iron ore and cooked coal as raw materials, while the latter melts steel scrap with electrical current. Steel manufacturing accounts for around 25% of industrial greenhouse gas emissions [9], and steelmaking from scrap in an EAF generates one-third of the emissions associated with steelmaking in a BF [10]. Therefore, further reliance on steel scrap recycling and green electric energy is fundamental to achieve a sustainable steel production. Nonetheless steelmaking via EAF presents challenges. In fact when steel scraps are molten, we obtain low concentrations of residual elements which are not intentionally added during the steel production cycle and are difficult to remove. These residual elements may harm the steel properties. As showed in [11], steel production from scrap will become even more difficult in the future, as the content of residual elements is likely to increase if less steel is produced from iron ore. In this work we limit our concern to copper which is a residual element widely spread in mechanical and electrical waste and is known to cause surface defects during hot rolling processes [12], thus limiting the applicability of recycled steel. For all these reasons having a method that monitors the residual elements and selects the scrap to melt according to the steel to be produced has paramount importance.
We consider a scrapyard where the scrap is divided into heaps according to their provenience such as automotive or rail industry and their characteristics such as stainless steel, high or low alloy steel scrap. The aim is to produce steel, which has a maximum content of copper allowed, with the cheapest scrap mix so as to minimize the cost associated with raw materials. However, given the dimension of the heaps and heterogeneity of the scrap it is not possible to know exactly the copper content in each heap. Therefore, we assume to have statistical knowledge of each heap and can refine this knowledge during the production process. Indeed, once it is decided how much scrap is picked from each heap, the scraps are molten and a measurement of the copper content in the product can be taken. The explore-exploit trade-off arises in this scrap selection problem because on the one hand we would like to exploit the current knowledge to achieve the cheapest possible scrap combination, favoring a repetition of previously tried successful selections. On the other hand changing the scrap mix allows us to improve our knowledge via exploration and possibly leads to a more economical selection in the long run.
Related work: A similar (non-square root based) MPC formulation is proposed in [13], but for a deterministic linear system and with the constraint affected by a state-and control-dependent linear random process. The dual MPC formulations proposed in [14] and [15] deal with discrete and time-invariant linear systems with deterministic state but output parametrized by an uncertain parameter. Although our model can be rewritten in their framework, they consider output tracking problems and explicitly account for the parameter uncertainty in the cost function. In Beliefspace planning [16] an estimator model is used to predict future estimation uncertainty but without considering uncertain constraints. In [17] the authors introduce a formulation for perception-aware MPC of a quadcopter, but without modelling uncertainty explicitly and instead using cost terms and constraints to keep the nominal state in regions with good observability.
Contribution: In this paper we introduce an implicit and explicit dual MPC formulation for a steel recycling process. The advantages of the proposed formulations against nondual approaches are demonstrated in numerical experiments. The simulation is based on fictitious numbers and reduced in dimension for clarity of exposition, but otherwise realistic to how it could be used on a real plant. The process is modelled as an autonomous linear system where the state is estimated with a Kalman filter. System control and dual effect occur when the augmented state formed by the state estimate and its covariance is predicted, since the covariance is directly affected by the scrap selection. A QR-factorization based square-root Kalman filter update improves the numerical stability and ensures positive-semidefinitness of the predicted covariance matrices as compared to a standard Kalman filter.
Outline: In Sec. II we introduce the model of the problem together with the nominal and robustified formulation. In Sec. III we present the dual formulations and, eventually, in Sec. IV we compare the formulations by numerical simulations of a simplified steel recycling process.

II. NOMINAL AND ROBUST FORMULATION
We model the steelmaking process as an autonomous discrete time linear system where time index t = 0, . . . , T denotes the casts' sequence. The model is given by where the state x t ∈ R nx represents the copper content in each heap of scrap, the output y t ∈ R ny contains the measured copper content in the produced steel. The output is a linear combination of the state weighted by the controlled variable u t ∈ R nx which corresponds to the amount of scrap picked from each heap. State and output are corrupted by normally distributed and i.i.d. disturbances w t ∼ N (0, Q) and v t ∼ N (0, R) respectively, where N (µ, Σ) denotes the normal distribution with mean µ and covariance Σ.
In the considered set-up the system state x t is not accessible, therefore a state observer is needed to compute a state estimatex t , we assume that the initial state x 0 is normally distributed N (x 0 , P 0 ) with covariance P 0 0. Despite the linear system in itself is autonomous, when we consider the estimated statex t augmented by its covariance P t , the control variable u t directly affects P t via the estimator update, therefore obtaining a controlled system.

A. Optimal scrap selection problem -Nominal formulation
We assume that every scrap has a certain price p i , i = 1, . . . , n x and the concentration of copper, i.e., the pollutant, in the final steel y t is upper bounded by a value y max . Therefore we aim to minimize the cost of the steel produced in the cast t by selecting the cheapest mix of scraps u t which fulfills the limitation on y t .
A first simple formulation of the scrap selection problem is given by wherex 0 is the state estimate at the current time instant t obtained from a Kalman filter. Note that this formulation is not accounting for uncertainty on the state. Thus, ifx 0 is a wrong guess of x 0 , constraint (2b) might be violated by the real state x 0 . As in this formulation the state is not affected by the controls, there is no reason to have a prediction horizon. Finally, note that the dynamics (1) plays a role only in closed-loop control. Indeed, we apply the optimal u 0 to the process and measure the corresponding y 0 . Then, we feed these two quantities to a Kalman filter and update our estimate ofx 0 . We will discuss the closed-loop scheme at the end of Section III.

B. Robust formulation
Considering the covariance P of the state estimatex, we can take into account its level of uncertainty. Thus, we can require constraint (2b) to hold with at least a certain probability, resulting in the chance constraint with > 0 being the maximal allowed probability of constraint violation. Since x is normally distributed, the nonnoisy output u x follows a normal distribution as well with u x ∼ N (u x, u P u). Therefore, we can write the chance constraint as where the coefficient γ( ) = Φ −1 (1 − ) controls the safety backoff from the constraint and can be computed from the inverse cumulative distribution function Φ −1 of the standard normal distribution such that the amount of backoff corresponds to the specified probability 1 − . In the following, we drop the explicit dependency of γ on . We also refer to this constraint as robustified because for a fixed value of γ it corresponds to a robust constraint where a bounded distribution of the state is assumed, with support given by the ellipsoidal level line of the normal distribution corresponding to the chosen value of γ. The resulting robustified scrap selection problem can be formulated as a Second Order Cone Program (SOCP) [18]: As in the nominal case, there is no prediction horizon, since the influence of the scrap selection on future uncertainty is not modelled.

III. DUAL FORMULATIONS
In this section we illustrate the dependency of the state estimate covariance on the scrap selection and how the dual effect is obtained from the covariance predictions.

A. Implicit dual formulation
Consider the Kalman filter propagation of the state estimate covariance, the future covariance is directly affected by u t , then we can manipulate future uncertainty. Hence, it is meaningful to consider a prediction horizon k = 0, . . . , N for the optimal scrap selection problem where the propagation of the state estimate covariance anticipate feedback for u. Since the chance constraint needs to hold when taking the measurement, i.e., without taking into account the new information, the predicted covariance P k := P k|k−1 is the relevant one. The resulting optimization problem is given by where K k are the Kalman gains and function ψ denotes the covariance propagation Recall that Q and R are the covariance of the state and output noise respectively. Note that the chance-constraint (6d) is enforced with respect tox 0 since due to the model the expectation of the state remains constant throughout the horizon. Since the propagation of P k+1 depends on u k , the optimization problem (6) can act on the backoff term in constraint (6d). Therefore, the incentive to reduce the uncertainty depends exclusively on the reduction of the backoff and the exploration incentive increases with the horizon length as a longer horizon allows for more exploitation. Intuitively, if the horizon has length N = 1, there is no chance to explore because the optimization problem can only exploit the available information for selecting the scrap. On the other hand, if the prediction horizon is sufficiently long, it can be worthwhile to take non-greedy actions that reduce the future uncertainty. Thus, the formulation (6) is not only statically uncertainty-aware but it is also able to deliberately reduce future uncertainty. It is a strongly nonlinear and nonconvex optimization problem that can be solved with a NLP solver. Even though in (7) we update the covariance matrix according to the Joseph form, which retains positive definiteness and symmetry of the covariance matrix [19], this is not guaranteed during the optimization solver iterations, resulting in possible numerical difficulties. It is possible to overcome this issue by considering the propagation of the square root factors of the covariance matrix, as shown in the following.

B. Square root covariance propagation
Following the square root covariance filtering algorithm introduced in [20] it is possible to propagate the covariance matrix just using the corresponding square root matrices. Given a positive definite matrix A 0, a square-root factor will be defined as any matrix, A r , such that A = A r A r . In general, square root factors are not unique. They can be made unique by imposing specific properties such as symmetry or triangular structure. In our case the latter is preferred, therefore in the following any A r denotes the upper triangular factor.
Denote the upper triangular decomposition of the matrices P 0 , Q, R as P r 0 , Q r , R r . Then for k = 0, . . . , N − 1 we can propagate P r k by a QR decomposition [20] as follows    where Q F k is an orthogonal matrix and S r k denotes the square root factor of the observer innovation covariance S k = u k P k u k + R = S r k S r k . Then, (8) defines a function ψ QR such that Moreover, it is possible to operate only with the square root factors of the covariance matrix to preserve their condition number throughout the prediction horizon of problem (6). Therefore, the term u k P k u k in constraint (6d) is restated as Finally, the optimal scrap selection problem (6) can be equivalently stated as P IMPL : whereP r 0 corresponds to the Cholesky decomposition of P 0 , u = (u 0 , . . . , u N ) andP r k+1 (u) = ψ QR (P r k (u), u k ), k = 0, . . . , N − 1. In contrast to the formulation (6), here the covariance propagation is not expressed as constraints but is computed externally as function of the controls u.

C. Explicit dual formulation
By adding a heuristic cost on uncertainty it is possible to encourage exploration even more than via the implicit incentive provided by the backoffs in (11b). This new term is weighted in the cost function by a hyperparameter α that regulates the explore-exploit trade-off. Therefore, the explicit dual formulation P EXPL share the same constraints of formulation (11) but its cost function is given by N k=0 p u k + αTr(P r k (u) P r k (u)), where α ≥ 0 is the hyperparameter that tunes the exploration incentive. Adding the trace of the covariance matrix to the cost function allows us to evenly minimize uncertainty along all directions. Note that for α = 0 we recover the cost function (11a) of the implicit dual MPC problem.

D. Closed-loop scheme
We are interested in solving the optimal scrap selection problems (2), (5), (11) and (11) with cost function (12) for every cast t = 0, . . . , T − 1. We apply to the plant only the first element of solution vector u t := u 0 following the receding horizon principle. Once the cast t is completed we can measure the copper concentration y t and feed both u t and y t to the Kalman filter routine. In this way, we update the latest predictions ofx t+1 , P t+1 , needed to solve the optimization problem at the next time step t + 1. A block scheme for the closed-loop simulation is depicted in Fig. 1.

IV. NUMERICAL EXAMPLES
In this section, we compare the closed-loop trajectories of the problem formulations stated in Sec. II-III. First, we show an example for each formulation and then, since we have an uncertain system, we assess the general closed-loop behavior by sampling many different uncertainty realizations.
The four formulations share the same parameters and initialization, which are collected in Table I. The true initial state of the system x 0 is always the same, but we assume imperfect knowledge of it. In consequence the initial state estimatex 0 varies, e.g., because of a different history, and is sampled asx 0 ∼ N (x 0 , P 0 ). The choice of the scrap prices p is motivated by the fact that the first scrap has higher cost since its copper content is lower in terms of mean value and uncertainty compared to the other two. Moreover, we suppose that each heap can supply an infinite amount of scrap, so that we will not run out of a scrap during the closed-loop simulation. The choice of the exploration hyperparameter α will be discussed at the end of the Section. The simulations are carried out using Python, the optimization problems are formulated using CasADi [21] and solved via IPOPT [22].
The letters A, B, C encode the name of the scrap, therefore Specifically, the first one depicts the state, i.e., the copper content of each heap as percentage by weight, the dashed lines are the true state while the solid lines are the estimated state. The shaded area corresponds to the 1σ standard deviation ofx. The second plot represents the control, i.e., the selected mass fraction of each scrap. The third plot pictures the constraint on the maximum copper allowed in the final steel. This plot shows the possible constraint violations and, for the uncertainty-aware formulations, the magnitude of the backoff. Fig. 2 shows the resulting closed-loop trajectory obtained with the nominal formulation. One can notice that at t = 1, the state estimatex C has recovered the true value x C . At this step,x C is greater thanx B , thus the scrap selection picks only scrap A and B. This scrap combination strongly excites the Kalman filter block in closed loop, leading to very accurate prediction of the states at time t = 2. The accurate estimate ofx B leads to increased use of scrap B and reduced use of scrap A to achieve the minimal cost. This formulation achieves the lowest cost among the ones presented, namely 23.86, but ignores constraint violations, as can be seen in the third plot of Fig. 2 where the constraint on the maximum copper content allowed is exceeded. Fig. 3 is obtained adopting the robust formulation to solve the scrap selection problem. Despite being an uncertaintyaware formulation, it does not know how to actively reduce uncertainty, since there is no explicit dependence of the scrap selection on the state estimate covariance. From t = 2 the scrap mix is kept constant for the rest of the simulation. This does not bring new information to the Kalman filter block, resulting in a state estimatex far from the true value x and large uncertainty onx B andx C . In the end, this leads to a greater cost of the closed-loop trajectory. Yet, from the third plot, one can notice that a backoff is always kept from y max which avoids constraint violations. Fig. 4 depicts the closed-loop trajectory attained with the implicit dual formulation. One can see that until t = 4, scrap B is barely selected. Also, u C is greater than u B until the mean of the estimatex C is smaller thanx B . However, a small u B is picked which is enough to excite the Kalman filter in closed loop such that at t = 5 we have the opposite situation,x B smaller thanx C . At this time step, a greater u B is selected because this formulation embeds the notion that the scrap selection can reduce the uncertainty on the future estimates leading to lower cost. The greater use of u B has further distinguishedx B andx C and reduced the uncertainty on the former. The scrap selection at steps t = 6, 7, 8 further increases the mass u B while reducing u A and eliminating u C . From t = 8 the scrap mix is the same until the end of the simulation. Eventually, the exploration embedded in the problem formulation improves the closed-loop performance compared to the robust formulation. This form of exploration is cautious since the realized y is always below the prescribed limit y max , and it involves exclusively the directions where reducing uncertainty leads to lower cost. The first plot of Fig. 4 shows the main drawback of this approach. In fact exploration is triggered only whenx B gets smaller thanx C and dependent on the Kalman filter block in closed loop. This happens because the formulation only plans an openloop control trajectory instead of a policy. In consequence, it does not know that the scrap selection will be adapted after new knowledge is acquired. Instead, with respect to the cost, it only plans with the currently estimated mean. Note that if the initial state estimates are further apart, we may need too many casts to meet the condition that triggers exploration, leading to high-cost trajectories similar to the ones obtained with the robust formulation.
Finally, Fig. 5 shows the results achieved by the explicit dual formulation, where exploration is promoted by the additional minimization term in the cost function (12). This formulation reduces the uncertainty in every direction earlier than the previous approach, because it provides scrap combinations which excite more the Kalman filter. Indeed, already in the scrap mix of step t = 0, this formulation chooses a bigger u B than the implicit dual formulation. Moreover, once uncertainties onx are reduced, the second term of cost function (12) becomes negligible compared to the first one. Thus, the explicit dual formulation doesn't perform any other exploration actions which may increase the cost of the closed-loop trajectories. This leads to the minimum cost among the uncertainty aware formulations without any constraint violation with a value of 24.92, followed by the implicit dual formulation with 25.42 and the robust one with 29.03.

B. Extensive comparison
Since the performance of each formulation depends on the disturbance and initial state realizations, we run N s = 1000 different simulations, where the adopted parameters are the same as described at the beginning of this section. The closed-loop trajectories, obtained by applying the four different formulations, share the same disturbance and initial state realization.
First, we focus on the share of constraint violations obtained with the four formulations. This metric is computed by considering each point of each simulation independently. Therefore, the share of constraint violations is computed as: where I >0 denotes the indicator function that takes value 1 if its argument is positive and 0 otherwise. Results are collected in Table II. The nominal formulation is not aware about uncertainty and places the mean estimateŷ always exactly on the constraint. Thus it is violated in about 50% of the cases. Instead, for the other formulations, violations happen on average 2.2 − 2.4% of the time, corresponding to the chosen allowed constraint violation probability of 2.55%. Secondly, we take into account the cost of the closedloop trajectories obtained with the different formulations. In Table II, we report the empirical mean of the cost distribution. One can see that the nominal formulation leads to minimum cost, the robust formulation to the highest cost and the two dual formulations have similar cost which are in between the other two. In Fig. 6 we plot for each formulation the empirical PDF overlapped by a portion of the total realizations, specifically 15% of the points. The nominal and implicit dual formulations share a similar PDF where a cloud of points is far from the mean. These realizations correspond to the scenarios where the scrap selection u cannot drive the state estimatex close to the true state x, leading to bad performance. However, these scenarios are few compared to the ones realized using the robust formulation. The latter has very scattered realizations leading to unreliable performance in terms of cost. Finally, the explicit dual formulation is outperforming the others in terms of reliability. In fact the cost PDF does not have long tails resulting in very consistent behavior.
Finally, we want to motivate why the hyperparameter in  the explicit dual formulation is set to α = 100. We compare five different values of α ∈ {0, 1, 10, 100, 1000}. The share of constraint violation and the corresponding distributions are very similar and therefore we focus on the cost. The results are collected in Table III. We can see that the mean of the empirical PDF obtained with α = 100 achieves the minimum value and allows a more compact distribution of the cost with 99% of the points below 25.53 as shown in the second column. Also note that once the weight is set sufficiently large, i.e., α = 10, the results are very insensitive to the choice of α.
In this work we have focused only on copper, but it is straightforward to extend the approach to multiple residual elements.

V. CONCLUSIONS
In this paper we have presented a formulation for both implicit and explicit dual model predictive control for a steel recycling process. The process model allows for exact predictions of the state estimate uncertainty with a Kalman filter, leading to an uncertainty-aware and dual formulation. The implicit formulation indirectly tackles the explore-exploit trade-off while in the explicit formulation one should balance the trade-off by tuning one hyperparameter. The numerical simulations of the steel recycling process show that dual formulations outperform the uncertainty aware robust formulation in terms of cost of the closed-loop trajectories while achieving the same prescribed probability of constraint satisfaction. Specifically, the explicit dual formulation provides a more consistent closed-loop behavior than the implicit dual formulation, and proves to be insensitive to the choice of the hyperparameter once it is set large enough.