{'fraction_non_alphanumeric': 0.047233162383475476, 'fraction_numerical': 0.011362026464171365, 'mean_word_length': 4.594230464415914, 'pattern_counts': {'":': 0, '<': 2, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Cautious Bayesian MPC: Regret Analysis and Bounds on the Number of Unsafe Learning Episodes

This paper investigates the combination of model predictive control (MPC) concepts and posterior sampling techniques and proposes a simple constraint tightening technique to introduce cautiousness during explorative learning episodes. The provided theoretical analysis in terms of cumulative regret focuses on previously stated sufficient conditions of the resulting `Cautious Bayesian MPC' algorithm and shows Lipschitz continuity of the future reward function in the case of linear MPC problems. In the case of nonlinear MPC problems, it is shown that commonly required assumptions for nonlinear MPC optimization techniques provide sufficient criteria for model-based RL using posterior sampling. Furthermore, it is shown that the proposed constraint tightening implies a bound on the expected number of unsafe learning episodes in the linear and nonlinear case using a soft-constrained MPC formulation. The efficiency of the method is illustrated using numerical examples.


I. INTRODUCTION
Driven by a constantly increasing research and development effort in the field of autonomous systems, including, e.g., autonomous driving, service robotics, or production processes in chemical or biological industry branches, the number of constrained control problems is growing steadily, which motivates research efforts towards automated and efficient synthesis procedures of high-performance control algorithms. While significant progress in this context has been made in the area of reinforcement learning (RL) comparably few methods address systems with continuous state and input spaces and can take into account system constraints. In addition they often require up to hundreds of thousands of rollouts, see, e.g., [1], [2], prohibiting their direct application to most real-world control engineering applications. In addition to related learning problems for general nonlinear systems, there exist a variety of results for the linear quadratic regulator (LQR) problem, see, e.g., [3] for the case of known stage cost and infinite horizon or [4, Appendix D] for finitetime horizons. While LQR-based techniques can provide an efficient learning procedure, a principled incorporation of state and input constraints can involve a significant amount of manual cost shaping. Learning-based control design for constrained systems has also been approached from a control engineering perspective. Particularly in the case of safety-critical control problems, model predictive control (MPC) techniques [5] have shown significant impact in both, industrial and research-driven applications. Due to its principled controller synthesis procedures and professional software tools [6,Chapter 8], MPC offers an important framework for a variety of learning-based control tasks [7], including larger-scale systems. However, it should be noted that challenging control problems can be difficult to formulate in the form of a learning-based MPC policy, e.g., in the case of sparse or discontinuous dynamics and rewards. Since MPC heavily relies on a sufficiently accurate prediction and reward model of the system, research in learning-based MPC mainly focuses on automatically improving the model quality. To this end, common methods either rely on available system data or include an exploration mechanism similar to RL, see, e.g. [7,Section 3], for an overview. In addition, recent learning strategies include the optimization of model and cost function parameters of an MPC using automatic differentiation [8], sensitivity analysis [9], or Bayesian optimization [10]. While the underlying concepts are promising, their theoretical properties still need to be investigated. A concept for combining the merits of posterior sampling based RL [4] and learning-based MPC [7] has been introduced in a Bayesian MPC scheme [11], enabling practical and scalable RL for industrial applications with state and input constraints. However, the fundamental regularity assumption [4, Section 6.1] required to obtain rigorous regret bounds was not established. Compared with constrained RL techniques [12], [13], the Bayesian MPC approach in [11] is further missing bounds on the number of unsafe learning episodes.
Contributions: In order to complete the Bayesian MPC theory and justify its central assumption [11, Assumption 1] to obtain cumulative regret bounds, Section III-A provides a theoretical analysis based on multiparametric optimization theory in the case of linear system dynamics, convex constraints, and linear or concave quadratic rewards. Then, Section III-B extends the analysis to nonlinear MPC by connecting [11, Assumption 1] with common assumptions from nonlinear MPC and shows that these assumptions are also sufficient for nonlinear Bayesian MPC. The presented cautious Bayesian MPC formulation uses a simple state constraint tightening as introduced in Section II-A that allows to rigorously relate the expected number of unsafe learning episodes to the cumulative performance regret bound in Section III-C, recovering similar bounds on the number of unsafe learning episodes as derived, e.g., in the context of RL [1], [12], [13]. Compared to the original formulation in [11], this guarantees fewer constraint violations as the learning process advances while maintaining the fast practical learning convergence due to the MPC policy parametrization.

A. Preliminaries
Notation: We denote the i-th element of a vector c ∈ R n as c i . A vector with n elements equal to 1 is denoted by 1n and if it is clear from the context we write 1.
We consider dynamical systems that can be modeled as with parameters θ F , σ F -sub-Gaussian zero mean i.i.d. noise F (t), and random initial condition x(0). The system states x(t) are constrained to a desired admissible state constraint set of the form X := {x ∈ R n |gx(x) ≤ 1} and the inputs u(t) are limited to hard constraints of the form U : where R (t) is σ R -sub-Gaussian zero mean i.i.d. noise and θ R parameterizes a mean reward function at time t ∈ N. In case of perfectly known parameters θ F and θ R , the goal is to find a control policy π : N × X → U such that application of u(t) = π(t, x(t)) maximizes the sum of reward signals starting from a given initial condition x(0) over a finite horizon of T time steps: ]. Importantly, maximization of (3) needs to be performed while taking into account state and input constraints, i.e. x(t) ∈ X and u(t) ∈ U for all t = 0, ..., T − 1.

II. CAUTIOUS BAYESIAN MPC
A. Cautious soft-constrained model predictive control In the idealized case of perfect system parameter knowledge, an approximate policy π to maximize (3) can be obtained by repeatedly solving a simplified model predictive control (MPC) problem, initialized at the currently measured state x(t). While MPC formulations vary greatly in their complexity, a simple formulation as originally proposed by [14] provides sufficient practical properties in terms of performance and constraint satisfaction for many applications. Thereby, we optimize over an input sequence {ū k|t } such that the corresponding nominal predicted statesx k|t neglecting additive disturbances satisfy the system constraints. The resulting MPC problem is given by for all k = t, .., T − 2 : for all k = t, .., T − 1 : and can be efficiently solved online based on the current system state x(t) using tailored MPC solvers [6,Chapter 8]. Ideally, the prediction horizon T equals the task length, yielding a shrinking horizon MPC. For long task horizons T , a common approximation in MPC is to select a smaller prediction horizon and to operate in a receding horizon fashion, see, e.g. [7, Section 2.2]. Different from [11], we propose two modifications of the state constraint formulation (4d). First, we use a tightened state constraint common in MPC for uncertain systems to foster practical closed-loop constraint satisfaction, see, e.g. [15], for the case of bounded uncertainties. By optimizing state trajectories subject to a tightened state constraint set, i.e. gx(x) ≤ (1 − δ k−t )1 with non-decreasing 0 < δ k−t ≤ 1 along prediction time steps k at time t, we gain a safety margin to compensate for uncertain model parameters θ F and unknown external disturbances F before state constraint violation occurs at some time step t in the future, i.e. gx(x(t)) 1. As a second modification, we soften the tightened state constraint in (4d) and include the extra negative reward term −I(ρ) on the constraint relaxation in (4a) to ensure recursive feasibility of problem (4) as similarly done in [16]. The penalty ideally realizes a so-called exact penalty function as proposed by [17]. The resulting cautious soft-constraint formulation is given asx k|t ∈X k−t (ρ) := {x ∈ R n |gx(x) ≤ (1 − δ k−t )1 + ρ} with parameters δ k−t ∈ R, δ k−t > 0 defining the degree of cautiousness, slack variable ρ ∈ R nx , ρ ≥ 0, and the constraint violation penalty I(ρ) = c 1 ρ + c 2 ρ ρ with penalty weights Sufficiently large values of c 1 yield an exact penalty, which ensures that (4) recovers the original hard constrained solution in the convex case whenever possible while guaranteeing feasibility of (4) for any x ∈ R n if necessary. Using an imperfect estimateθ = (θ R ,θ F ) of the true system parameters θ := (θ R , θ F ) in the MPC problem (4), we denote the expected closed-loop future reward, including a weighted constraint violation penalty, at time t and state x as conditioned on ( ) defined as and u * (j, x(j);θ) :=ū * j|j (x(j);θ), being the first element of the optimal input sequence of the MPC problem (4) at time step j with parameters θ and ρ(j) the required softening of state constraints.
∈ X ⇒ ρ(j) > 0, and will be the main mechanism to derive a sublinear bound on the expected number of unsafe learning episodes in Section III-C. As it will be shown in Theorem III.4, the linear tightening δ 0 > 0 can be selected arbitrarily small with the limiting case lim δ 0 →0X0 (0) = X. The combined value function (5) can therefore reflect the reward without constraint tightening arbitrarily closely. This concept relates to RL for constrained problems as it ensures the existence of a 'strictly safe baseline policy' [12, Assumption 2.2] or a 'slater point' [13,Assumption 2] if E [ρ(j)] = 0.

B. Reinforcement learning problem
We consider the case of unknown transition and reward distributions that are parametric according to (1), (2). During each learning episode e = 0, 1, .., N − 1 we need to provide a control policy that trades-off information extraction and knowledge exploitation when applied to the system (1) at each time step t = 0, 1, .., T − 1 starting from x(0). We, therefore, assume access to prior information about the system parameterization such as production tolerances, to be given as (θ F , θ R ) ∼ Q θ . Collected data up to N episodes is denoted by Conditioned on collected data (6), the corresponding posterior distribution up to episode e is denoted by θe ∼ Q θ|De . Based on the acquired data over N episodes, the performance of the RL algorithm is measured in terms of the expected Bayesian cumulative regret Algorithm 1: Bayesian MPC algorithm Data: Parametric model f , ; Prior Q θ Initialize D 0 = ∅ for episodes e = 0, 1, .., N − 1 do sample θe ∼ Q θ|De for time steps t = 0, 1, .., T − 1 do apply u(t) =ū * (t, x(t); θe) measure objective and state end extend data set to obtain D e+1 end with episodic regret defined as Using the notation of the expected future reward in (5), the cumulative regret (7) quantifies the expected performance deviation between the MPC-based RL algorithm using episodically updated model parameters θe and the optimal MPC-based policy with access to the true parameters θ of the underlying system.

C. Cautious Bayesian MPC algorithm
Following the concept introduced in [11], we propose to combine model-based RL using posterior sampling investigated by [4] with a cautious model predictive control policy parametrization as described in Section II-A to obtain a new class of model-based RL policies, called Cautious Bayesian MPC, which allows to bound the number of unsafe learning episodes. At the beginning of each learning episode e we sample transition and reward parameters θe according to their posterior distribution that results from the prior distribution Q θ together with observed data De. The sampled parameters yield an MPC problem parametrization (4) that would correspond to a system and reward with true parameters θe. However, since θe = θ, such an MPC policy might be inconsistent with the underlying system to be controlled, in particular if the posterior parameter variance is large. In this case, the sampled policy is likely to cause explorative closedloop behavior, producing information-rich data. Compared to using, e.g., the current maximum a-posteriori estimate of the parameters as done in most learning-based MPC approaches, which we refer to as nominal posterior MPC [7], the algorithm therefore generates explorative behavior in case of large posterior parameter uncertainties. As soon as the task-relevant parameter distributions begin to cumulate around the corresponding true process parameters, the parameter samples will start to cumulate as well, implying convergence of the sampled MPC performance to the MPC performance with perfectly known parameters. We provide a rigorous analysis of this effect in Sections III-A and III-B, which is one of the key ingredients to obtain a regret bound. In addition to performance, if the MPC policy using the true system parameters is capable of ensuring cautious constraint satisfaction in expectation, i.e. if E E [I(ρ(t))] = 0 for δ 0 > 0 under u(j) =ū * (j, x(j), θ) in (5), then we can additionally bound the expected number of unsafe learning episodes, i.e. the number of episodes in which the state constraints are violated. As formalized in Section III-C, this can be achieved through a sufficiently large c 1 in the exact penalty I(.) in (5) together with a bound on the instant regret (8).
Remark II.1. Efficient algorithms for solving the MPC problem (4) already scale to larger-scale industrial problems, see, e.g., [18], which considers 256 states and 32 input dimensions. Furthermore, distributed structures as, e.g., considered in the numerical example in Section IV or in [19], can additionally be exploited to implement the corresponding MPC problem [20], [21] and the posterior computation and sampling in a scalable distributed fashion.

III. ANALYSIS
Since the Bayesian MPC algorithm can conceptually be used to enhance any existing MPC application for a wide variety parametrized transition and reward functions (1) and (5), we briefly recap general sufficient conditions from [11] in this section to obtain finite-time regret bounds that are based on the framework proposed by [4]. Part of the main contribution of this paper compared to [11] is to establish that these conditions hold for the relevant case of linear systems in Section III-A and to provide sufficient conditions for the more general nonlinear case in Section III-B. These results then enable us together with cautious soft constraints from Section II-A to derive a bound on the expected number of unsafe learning episodes under application of the Bayesian MPC algorithm in Section III-C.
We start by reviewing the main steps of model-based RL based on posterior sampling arguments as presented in [4] to reformulate the regret in terms of the expected learning progress of the transition and reward function. By using a regularity assumption on the expected future reward under the sampled MPC controllers this then allows us to bound the cumulative regret using the so-called Eluder dimension, which expresses the learning complexity for different mean and reward function classes. Instead of the instant regret ∆e in (8), which includes the unknown optimal future reward V θ θ,0 (x), we formulate the regret in terms of the sampled MPC controller applied to the corresponding sampled system, for which it is optimal, i.e.
where V θe θe,0 (x) is known based on the sample θe and V θ θe,0 (x) can be observed. It holds E θ,θe,x,De [∆e −∆e] = 0 ⇒ E θ,θe,x,De [∆e] = E θ,θe,x,De [∆e], which allows another reformulation based on the Bellman operator as proposed by [4] for the continuous case to end up with a regret bound of the form |r(t, x(t), u(t); θe) − r(t, x(t), u(t); θ)| , (9) with expectation over θ, θe, x, De, F (t), and R (t). The second term in (9) can be bounded via the conditional posterior through The first term, however, requires a regularity assumption that quantifies how errors in the expected one-step-ahead prediction f (x(t), u(t); θe) − f (x(t), u(t); θ) cause deviations w.r.t. the one-step-ahead expected future reward V θe θe,t+1 (.): Assumption 1. For all θe ∈ R n θ and x + ,x + ∈ R n there exists a constant L V > 0 such that While previous literature only required this assumption, we will theoretically investigate its justification in the case of MPC-based policies in Section III-A and Section III-B.
The relationship between the regret and the mean deviation between the true and sampled reward and transition function as described previously allows us to derive a Bayesian regret bound using statistical measures. The first bound relates to the complexity of the respective mean function also known as the Kolmogorov dimension dim K , see also [22]. In an online learning setup it is additionally necessary to quantify the difficulty of extracting information and accurate predictions based on observed data, which is measured in terms of the Eluder dimension dim E [22]. These measures further require boundedness of the mean reward and transition function as follows. 2 Assumption 2. There exist constants c R and c F such that for all admissible x ∈ R n , u ∈ R m , θ ∈ R n θ , and t = 0, 1, .., T − 1 it holds | (t, x, u; θ R )|≤ c R , and ||f (x, u; θ F )||≤ c F .
Following [4], [11], we can combine these measures to obtain the following regret bound for the Bayesian MPC algorithm as an immediate consequence from Theorem 1 in [4] withÕ neglecting terms that are logarithmic in N .
Theorem III.1. If Assumptions 1 and 2 hold then it follows that Specific bounds for different parametric function classes can be found, e.g., in [22], [4].

A. Regularity of the value function for large-scale linear transitions and concave rewards
Regularity of the future reward as required by Assumption 1 is a central ingredient for the performance analysis and essentially determines the shape of the regret bound in Theorem III.1. While explicit bounds on the Kolmogorov-and Eluder dimensions are available for relevant parametric function classes [22], [4], we provide a bound on L V that holds under application of the Bayesian MPC algorithm. In this section we begin by focusing on the control relevant case of linear time-invariant transitions (1) of the form and reward models (5) that are either affine or quadratic and concave in the states and inputs for each time step t = 0, 1, .., T −1. Furthermore, we restrict our attention to state and input spaces that are polytopic of the form X := {x ∈ R n |Axx ≤ bx} and U := {u ∈ R m |Auu ≤ bu}. Based on these assumptions we establish Lipschitz continuity of the optimizer of the MPC Problem (4).
Theorem III.2. Consider MPC problem (4). If the mean transition (4c) is linear, the state (4d) and input (4e) constraints are polytopic, and the mean reward function (4a) is linear or quadratic and strictly concave for all time steps, then under application of the Bayesian MPC algorithm it follows that Assumption 1 holds.
The proof together with a detailed construction of L V according to Asssumption 1 can be found in Appendix A.
By combining this result with Theorem III.1 and the specific bounds on the Eluder-and Kolmogorov dimensions from [22], [4], we obtain the specific bound with L V according to (18) in Appendix A. 2 Most real-world systems are bounded, e.g., due to finite energy or limited raw materials, justifying Assumption 2 in practice. A modified LQR setting to match Assumption 2 can be found, e.g., in [4, Appendix D].

B. Extension towards nonlinear transitions and rewards
While the linear case as considered in the previous section covers a large portion of control applications, the increasing availability and performance of nonlinear MPC solvers motivates the extension to nonlinear reward and transition models. We therefore extend the analysis from Section III-A to the more general case of transition and reward functions f and that are nonlinear and non-convex as well as more general state and input spaces of the form X := {x ∈ R n |gx(x) ≤ 1} and U := {u ∈ R m |gu(u) ≤ 1}. To this end, we use a similar line of reasoning as in the proof of Theorem III.2 to provide sufficient conditions on the resulting nonlinear MPC problem (4) that ensure Assumption 1. In particular, we utilize results from [23] to analyze local continuity properties of KKT-based solutions of the MPC problem (4), which results in sufficient conditions commonly used in nonlinear optimization algorithms [24], and in the nonlinear MPC literature [6, Chapter 8.6.1].
Theorem III.3. Let Assumption 2 hold and consider the MPC problem (4) with f, , I, gx, and gu continuously differentiable and Lipschitz continuous. If the linear independence (LI) and the strong second-order sufficient condition (SSOSC) according to [23, 3(a) and 3(d)] hold for all admissible x ∈ R n , θ ∈ R n θ , and t = 0, 1, .., T −1, then it follows that Assumption 1 holds.
The main steps of the proof can be found in Appendix B. The linear independence (LI) condition refers to the linear independence of the gradients of the active constraints at an optimum of (4) with respect to the decision variables and ensures necessity of the corresponding KKT conditions. In addition, the strong second-order sufficient condition (SSOSC) guarantees sufficiency of the KKT conditions and uniqueness of local solutions through a local positive definiteness condition of the Hessian of the Lagrangian with respect to the decision variables, also depending on the active constraints at the optimum. Consequently, if these conditions do not hold, situations where small deviations of x cause a 'jumping behavior' between different local optimal solutions of the MPC problem (4) can occur and potentially lead to a non-Lipschitz continuous future reward function. While the imposed assumptions are difficult to verify, note that the LI condition is a common requirement for nonlinear solvers and that the SSOSC is the weakest condition to ensure existence and uniqueness of local solutions of the MPC problem (4) for small perturbations of the initial condition x, see [25]. In addition, recent results connect these assumptions and the resulting Lipschitz continuity property to the actual underlying optimal control problems [26]. Importantly, note that, e.g., a normally distributed F helps to smoothen the future reward through the expectation operator in (10), rendering the conditions for Bayesian MPC less restrictive than common assumptions from the nonlinear MPC literature.

C. Bounding the expected number of unsafe learning episodes
While a tightened MPC formulation using the true parameters θ typically provides state constraint satisfaction in expectation for many practical applications, the parameter samples θe during application of the Bayesian MPC algorithm can vary significantly during initial learning episodes. It can therefore happen that the constraints are violated, even in expectation. In such learning episodes, however, the amount of constraint violation can partially be observed through the regret due to the exact penalty in the future reward function (5). As a consequence, if the MPC using the true system parameters θ provides satisfaction of the tightened constraints in expectation, i.e. x(t) ∈ X k (0), we can use regularity of the expected future reward to show that a converging parameter estimate yields a converging future reward and therefore converging constraint satisfaction. In other words, since the stage cost function is bounded and the constraints are tightened, a sufficiently large soft constraint penalty ensures observability and a bound on state constraint violations, which can be formalized as follows. We first derive an upper bound on the instant regret ∆e as defined in (7) implying constraint satisfaction in Appendix C. By combining this intermediate result with the regret bound from Theorem III.1 we bound the cumulative expected number of unsafe learning episodes in Theorem III.4. To streamline notation we denote the state, input, and slack variable sequence in the expected future reward (5) for a given initial state x as x θ θ (j), u θ θ (j), and ρ θ θ (j) for j = 0, .., T − 1 in the following.
Theorem III.4. Let the conditions of Theorem III.1 hold and consider a weighting factor in the exact penalty term I(.) in (4a) that satisfies with c R from Assumption 2 and some c δ > 0. If E E,x ρ θ θ (j) = 0, then the total number of N unsafe episodes, for which there exists a j ∈ N, 0 ≤ j ≤ T − 1 such that E E,x x θ θe (j) / ∈ X is bounded in terms of the cumulative regret by A sublinear cumulative regret bound therefore ensures a decreasing ratio between the number of episodes with constraint violation and the total number of learning episodes, which vanishes at the rate of c(1/N ) for N → ∞ and some positive constant c.
It should be noted that Theorem III.4 requires that min i (c i ) ≥ 1/δ 0 holds up to linear factors, which implies that a smaller constraint tightening δ 0 results in a larger constraint violation penalty I(ρ) in (5) by the factor 1/δ 0 in case of unsafe episodes. While this does not affect the overall structure of the bound and its dependence on √ N in Theorem III.1, a practical choice of δ 0 in the related MPC literature is typically between 0.005 and 0.1. While the slack penalties in (5) can similarly be found in constrained RL concepts [1], [12], [13], it should be noted that the proposed MPC policy directly minimizes the slacks through the soft constraints (4d) and penalty (4a) and constraint violations only occur due to model uncertainties. In contrast, policy optimization methods [1], [12], [13], e.g., perform primal and dual update steps after each episode, resulting in separated bounds on performance and constraint satisfaction. Note that the upper bound c δ and consequently also the lower bound on the exact penalty scaling could potentially be improved in the corresponding proof (Appendix C) by exploiting the concrete structure of I including quadratic terms.
Furthermore, for practical applications with large initial parametric uncertainties, one could consider the use of a more restrictive constraint tighteningδ 0 > δ 0 during a finite number of initial training episodes to reduce the number of constraint violations within the initial learning phase.

IV. NUMERICAL EXAMPLES
All examples are implemented using the IPOPT solver [24]. The source code of the numerical examples can be found online 3

A. Large scale thermal application
We first consider the task of efficiently controlling a large-scale network with 100 cooling units, e.g. a server farm or production machines in manufacturing plants, that are arranged in a grid structure and have a strong thermal coupling with respect to locally neighboring units, see Figure 2. Inputs u(t) ∈ U ⊂ R 100 describe the applied cooling power to each cooling, which are subject to physical limitations U := {u ∈ R 100 |u ≤ū}. The system state is defined by the temperatures x(t) ∈ R 100 of each unit that needs to be below a given threshold x(t) ∈ X := {x ∈ R 100 |x ≤ 100} for all times. The thermodynamics of the plant are given with linear mean dynamics such that each unit i has unknown dynamics of the form x i (t + 1) = A ii x(t)+B i u i (t)+ j∈N s,i A ij x j (t)+C i + F (t) with neighboring units indexed by j, known Gaussian parameter prior distribution (A, B, C) ∼ Q θ F and Gaussian process noise F (t). Note that the resulting overall dynamics can be stated in the form (12) by extending the state space. The goal is to minimize the overall expected energy consumption i L i u i (t) + R by considering thermal couplings while keeping the temperature of each cooling unit below a specified maximum temperature, starting form a temperature level below 100 degrees. The energy efficiency of each unit is described through parameters L ∈ R 100 that are sampled from a known Gaussian prior distribution l ∼ Q θ R plus additive Gaussian measurement noise R . Based on these assumptions, i.e., the distributed linear structure of the dynamics and reward in combination with Gaussian prior distribution, each unit i can compute its posterior distribution Q θ i |D e,i and corresponding samples independently from other units in closedform [7, Section 3.2.1]. The overall plant consists partly of new cooling units with known efficiency and older cooling units with uncertain efficiency factors that are worse in expectation. Due to these different efficiency levels that are provided through the prior distribution, explorative behavior can be beneficial to exploit more efficient units. The exact numerical values and prior parametrisation can be found in the function server experiment.m in the provided source code for the example. In Figure 1 (Left), we compare the proposed Bayesian MPC algorithm against commonly used nominal posterior MPC, i.e. selecting θe := E [θ|De] [7, Section 3], using 100 different system realizations. While both algorithms show reasonable learning performance and provide constraint satisfaction at all times, Bayesian MPC is able to significantly reduce the cumulative regret by almost 50% compared to nominal posterior MPC.

B. Drone search application
In this example, we consider a generic drone search task falling into the problem class of Section III-B. The goal is to collect information about an a-priori unknown position of interest using a quadrotor drone. While the prior of the 10-dimensional drone dynamics are selected according to [27], we additionally simulate strong winds in different altitudes, which adds strong nonlinear effects to the dynamics. Once the target position is reached, the drone collects information before it returns to the base station for analysis and recharge. The overall goal therefore is to learn the drone dynamics, winds in different altitudes and the most informative search position. The safety-critical constraints are a maximum range of the drone together with a minimum altitude that need to be satisfied under physical actuator limitations. The dynamics are of the form x(t + 1) = Ax(t) + Bu(t) + CΦ(x(t)) + F , where A and B matrices describe the unknown dynamics around the hovering state and and CΦ(x(t)) models strong winds in different altitudes as Φ(x(t)) = [k(x 3 (t),W 1 ), k(x 3 (t),W 2 ), k(x 3 (t),W 3 )] using radial basis functions k(., .) [28] with given hyper-parameters W i and unknown parameters C. The system has a three dimensional input space that allows to control the desired pitch and roll as well as vertical acceleration of the drone. The system constraints are given by physical input constraints and a box constraint on the position states, which describes the minimal altitude and maximum range of the drone. Furthermore, the use of a linear model is only valid around the hovering state, yielding additional absolute pitch and roll constraints of 30 [deg] to the system. The reward signal corresponds to the information gained at the final position at the end of an episode and is modeled as the sum of equally spread radial-basis-functions κ(., .) at positions p i ∈ R 3 , i = 1, .., 9 , i.e.

Unit
Cooling input Thermal couplings

V. CONCLUSION
In this paper, we combined model predictive control with reinforcement learning based on posterior sampling in an episodic setting to efficiently learn an optimal MPC control policy for dynamical systems that are subject to state and input constraints. Using arguments from multi-parametric optimization, we were able to rigorously bound the learning performance of the resulting Bayesian MPC algorithm in the case of linear mean transition functions, concave mean rewards, and polytopic system constraints. For more general systems that can be described through Lipschitz continuous nonlinear functions, we derived sufficient conditions for bounded cumulative learning regret using sensitivity analysis results, providing insights into the general applicability of Bayesian MPC. To account for external disturbances as well as large parametric uncertainties during initial learning episodes, we introduced softened state constraints that are iteratively tightened along the prediction horizon, guaranteeing a sublinear bound on the number of expected unsafe learning episodes with state constraint violations. While the proposed algorithm maintains the online computation load of nominal MPC, the advantage in terms of learning performance was demonstrated in simulation using a largescale thermal control problem together with a highly nonlinear drone application.

A. Proof of Theorem III.2
It is sufficient to show global Lipschitz continuity of V θe θe,t (x) since existence of an L V t > 0 such that implies the desired result. Let˜ (j, x, u) := (j, x, u; θe) − I(ρ(x)) with ρ(x) := min ρ≥0 s.t. s ∈X k (ρ) according to (5), which is Lipschitz continuous in x and u since X and U are polytopic.
To streamline notation we denote the state and input sequence in the expected future reward (5) withθ = θe as x(j, x, E) and u(j, x) for j = 0, .., T − 1 with x(0, x, E) = x and E := [ R (t), .., R (T − 1), F (t), .., F (T − 2)] in the following. We have due to linearity of the expectation operator, Jensen's inequality, the triangle inequality, and global Lipschitz continuity of˜ that there exists L ,j such that (14) holds. It therefore remains to show that x and u are Lipschitz continuous in their second argument. Since u(j, x) is the first element of the optimal input sequence according to (4) and (4) is guaranteed to be feasible due to the soft-constraint reformulation, it follows from [5, Thm. 1.8] for affine˜ and from [5, Thm. 1.12] for strictly concave quadratic˜ for any j and x,x ∈ R n that there exists aK ∈ R + ,K < ∞ such that ||u(j, x) − u(j,x)||≤K||x −x||.
Combining these results yields which completes the proof.

B. Proof outline of Theorem III.3
For any initial state x 0 there exists a corresponding optimal solutionū * t|t to (4) due to the soft-constraint formulation, Lipschitz continuity of the objective, Lipschitz continuity of the constraints in (4), and the compactness of the input constraints. Together with [23,Theorem 3.7] it follows from the given assumptions that there exists a unique function y(t, x) → [ū * t|t ,ū * t+1|t , ...,ū * t+N −1|t ] that is Lipschitz continuous with respect to all initial conditions x ∈ B(x 0 , r) with B(x 0 , r) := {s ∈ R n | ||x − x 0 ||≤ r} and x 0 fulfilling the KKT conditions corresponding to (4). Due to the SSOSC, the KKT conditions imply optimality of y(t, x) and we conclude existence of a local Lipschitz constant Lu(t, x 0 ) > 0 such that for