Encrypted extremum seeking for
privacy-preserving PID tuning as-a-Service
Abstract. Wireless communication offers many benefits for control such as substantially reduced deployment costs, higher flexibility, as well as easier data access. It is thus not surprising that smart and wireless sensors and actuators are increasingly used in industry. With these enhanced possibilities, exciting new technologies such as Control-as-a-Service arise, where (for example) controller design or tuning based on input-output-data can be outsourced to a cloud or mobile device. This implies, however, that sensitive plant information may become available to service providers or, possibly, attackers.
Against this background, we focus on privacy-preserving optimal PID tuning as-a-Service here. In particular, we combine homomorphic encryption with extremum seeking in order to provide a purely data-driven and confidential tuning algorithm. The encrypted realization requires several adaptions of established extremum seekers. These encompass relative parameter updates, stochastic gradient approximations, and a normalized objective function. As a result, and as illustrated by various numerical examples, the proposed encrypted extremum seeker is able to tune PID controllers for a wide variety of plants without being too conservative. ††∗This paper is a preprint of a contribution to the 20th European Control Conference 2022.
I. Introduction
Wireless communication is of growing interest in the automation and process industry due to, e.g., cost reduction, high flexibility, and easy data access. It is often viewed as a key enabler of industry 4.0 and plays a vital role in fields like mobile robotics, building automation, and intelligent transportation systems. Clearly, wireless communication also effects control loops, where it becomes possible to make extensive use of input-output-data provided by smart sensors and actuators. This also enables Control-as-a-Service (CaaS), where plant data is processed externally on a cloud or a mobile device in order to realize remote control or remote controller design and tuning. CaaS offers many advantages compared to classical in-house control engineering. For instance, it allows reducing the necessity of expert knowledge and the effort for time-consuming design processes. Moreover, elaborated design methods can be used, yielding high-performance controllers. However, CaaS is not yet widely used since it involves the exchange of and computations on highly sensitive plant data.
In principle, privacy-preserving CaaS can be realized with the help of modern cryptosystems such as homomorphic encryption (HE) (see, e.g., [1, 2, 3, 4]) which enable (simple) computations on encrypted data. Utilizing HE for encrypted control is, however, non-trivial and usually requires tailored controller reformulations (see [5] for an overview). Still, various control schemes have already been successfully (re)implemented in an encrypted fashion (see, e.g., [6, 7, 8]). Nevertheless, a more specific analysis of existing realizations shows that encrypted controller design or tuning has rarely been considered. One exception is the recently proposed HE-based implementation of a data-driven LQR from [9] which builds on the scheme in [10]. In order to strengthen this promising direction of encrypted data-driven control, we aim for secure cloud-based tuning of PID controllers in this paper.
Our focus on PID tuning as-a-Service is motivated by two key observations. First, PID controllers are still widely used in industry. In fact, according to [11], they are the control technology with the highest (perceived) impact. Second, despite their simple structure, a proper PID tuning can be challenging and time-consuming. Consequently, many PID controllers are tuned by hand, by heuristics such as Ziegler and Nichols, or aren’t tuned at all. This results (often) in a performance that is far from optimal. Against this background, our goal is to provide a cloud-based PID tuning that preserves privacy of the exchanged and processed plant data.
Now, there exist a vast amount of PID tuning methods with different scopes, and a competitive cloud-service should probably offer various methods to choose from. However, we aim for a proof of concept here and, hence, we will concentrate on a privacy-preserving implementation of one scheme which can be efficiently implemented with current HE techniques. In fact, model-based approaches such as pole placement, loop-shaping, or internal model control are hard to realize in an encrypted fashion if model identification is part of the cloud-service. At the same time, the lack of a model and the need for ad-hoc controller designs/improvements is what motivates to use CaaS. As a consequence, we focus on purely data-driven tuning methods at the cost of stability guarantees. Nonetheless, the following methods provide a handle on rapid improvements of a PID’s control performance and have been extensively tested on a variety of closed-loops. Possible candidates are, for example, iterative feedback tuning, virtual reference feedback tuning, correlation-based tuning, or extremum seeking (ES) control [12]. A comparison of these schemes reveals that especially the latter combines an encryption-friendly algorithm with an optimization based tuning approach. Thus, the remaining paper will focus on HE-based PID tuning via ES.
Road map. In Section II we introduce ES with the focus on PID controller tuning and shed some light on HE. With this knowledge at hand, we tackle the reformulation of ES tailored for encryption in Section III. Finally, we test our proposed method with numerical examples in Section IV and end the paper with a conclusion and outlook in Section V, respectively.
Notation. We denote the modulo operation . In this context, , , and refer to the floor function, the ceiling function, and rounding to the nearest integer, respectively. Moreover, the Hadamard product, i.e., component-wise multiplication, of two vectors and is denoted by and the vector of ones in suitable dimension is .
II. Preliminaries
We begin with a brief summary on how ES can be used for controller tuning. In general, ES is a model-free online optimization technique. As such, it is often applied if a model is unavailable or unreliable, but also if the optimization criterion is (slowly) changing with time. As we will shortly see, ES is a very simple algorithm that can be easily adapted for controller tuning. This adaptation will be the basis for our privacy-preserving PID tuning in Section III. The corresponding cryptographic foundations will be laid in Section II.B, where we collect some useful insights on HE.
A. Extremum seeking control
ES is used to determine or maintain an extremum value of an objective function with parameters . This is achieved by perturbing at iteration step according to
(1) |
with being a user-defined perturbation. Clearly, this results in an “exploration” of and, hence, allows approximating the gradient (or even higher order derivatives) in the vicinity of . Based on this information, the parameters are updated by, e.g., a gradient descent step of the form
(2) |
where and denotes the step width. By repeating these steps for suitable , the algorithm approaches a local minimum .
Controller tuning. In classical setups, is often a cost function that characterizes an optimal operating point, e.g., for power tracking in photovoltaic systems or for maximizing the output of bioreactors [12]. However, ES is also useful for PID tuning [13]. There, the integrated square error
(3) |
is minimized over a user-defined horizon, where is the control error, i.e., the difference between the reference and the plant output at time , and where reflects the tuning parameters of the PID
(4) |
Remarkably, the extremum seeker has only access to closed-loop information in terms of (3). In fact, additional knowledge about the plant itself is not assumed.
Now, an important difference between classical ES control and ES-based controller tuning is that perturbations of the controller parameters will not (or only insignificantly) excite the closed-loop in steady state. Hence, additional reference steps of the form
(5) |
are considered in [13] throughout the tuning process. However, other reference signals are possible. Yet, it should be noted that depends on by means of (3).
Tuning setup. In principle, we have now collected all crucial components for ES-based PID tuning. However, it remains to detail the choice of the perturbations and the approximation of the gradient . The perturbation signals are in general periodic functions with an amplitude of , zero mean, and non-zero squared average (power), e.g., cosine or square waves. With at hand, the approximation of works as follows. First, the controller parameters are updated by and is then used to excite the closed-loop. This allows to measure over some time frame and to obtain by means of (3). From here on, depending on the choices for , different approaches are possible. For instance, if are cosine wave perturbations, can be estimated by a high-pass filter and a demodulation signal. This, more classic approach, is used in [13]. Square wave perturbations, on the other hand, enable numerical differentiation [14]. Finally, and control the convergence speed and exploration, respectively. Thus, they must be chosen with care such that the closed-loop does not become unstable during (1) or (2) and the convergence speed is acceptable. For different closed-loop dynamics, these often have to be adapted manually. A convergent controller tuning will, however, improve the controller’s performance by .
B. Homomorphic encryption for confidential computations
In a nutshell, HE allows carrying out (simple) mathematical operations on encrypted data (see [15] for an introduction). Over the previous decade, various schemes have been proposed with different functionalities (see, e.g, [1, 2, 3, 4]). Commonly supported homomorphisms are encrypted additions and (or) multiplications. More precisely, let and be two arbitrary numbers in the cryptosystem’s plaintext space and let us denote the encryption by “” and the decryption by “”. Then, the homomorphisms “” and “” allow computing
(6a) | ||||
(6b) |
Some further operations can easily be derived from these fundamental ones. For instance, we will use “” for encrypted subtractions and “” for encrypted multiplications with one public factor or . Obviously, with these homomorphisms at hand, polynomial expressions can be evaluated easily. However, non-polynomial expressions are computationally expensive and typically require “tricks”.
Plaintext space and mapping. The plaintext space of HE cryptosystems is usually some finite set with (for example) the canonical representatives
where is the ciphertext modulus, i.e., the number of elements in the set . Hence, before one can use HE, all quantities must be mapped to or encoded in . An easy way to do this is as follows. For some scalar , we compute
(7) |
where is a scaling factor. In order to reconstruct , one can use
(8) |
where if . For multidimensional quantities, i.e., vectors or matrices, (7) and (8) can be used component-wise. Now, it is possible to investigate ciphertext additions and multiplications by means of plaintext additions and multiplications over due to (6). Then, note that, e.g., is meaningful for as in (7) only if . In other words, summands should share the same scaling and multiplications increase the scaling. Due to the latter, and must be chosen carefully such that overflows, i.e., , are avoided while maintaining sufficient accuracy. Furthermore, for arbitrarily many multiplications with and finite , the plaintext will (almost certainly) overflow , which, e.g., poses a problem for the operating time of a controller [8].
LWE-based cryptosystems. Cryptosystems providing (6) can, e.g., be constructed based on learning with errors (LWE) [16]. These cryptosystems combined with a regular execution of a technique called “bootstrapping” (see [2]) results in a fully homomorphic cryptosystem and resolves the aforementioned problem regarding operating time. Fully HE (theoretically) allows computing any function in terms of boolean or arithmetic circuits. However, bootstrapping is computationally costly (many seconds to minutes up to now in the arithmetic case) such that fully HE is not yet useful for our application. Opposed to fully HE, a leveled HE scheme waives on bootstrapping [but also provides (6)], which results in performance advantages. Consequently, only a finite number of operations111Additionally to the scale factor growth during multiplications, LWE-based cryptosystems inject a small error in the ciphertexts which grows during operations such that additions and multiplications can only be evaluated finitely often. can be supported, i.e., for a predefined , one must a priori select a large enough for the arithmetic circuit to be encrypted. Finally, we point out that among the leveled HE schemes, [4] stands out because multiple optimizations such as constructions over polynomial rings with tailored plaintext encodings, residue number systems, or ciphertext rescaling make it somewhat practical. A detailed explanation of the cryptosystem or these methods is, however, out of this scope of this paper.
III. Robust encrypted extremum seeking
A. Challenges for encrypted extremum seeking
Several challenges have to be overcome in order to realize encrypted ES-based PID tuning as-a-Service. First (and probably most important), we need to carefully select the parameters of the extremum seeker a priori such that it converges for different unknown closed-loop dynamics without being too conservative. Second, for the estimation of in [13] a high-pass filter is necessary which reuses old output values and would require bootstrapping. Thus, a different technique must be used. Similarly, the integrator for can not have unlimited operating time. As specified below, solving these issues will require tailored modifications of the scheme from Section II.A.

B. Robust encryptable extremum seeker for PID tuning
Before we move on, let us briefly note that PID controllers of the form (4) are not practical in many industrial applications because high-frequency measurement noise and step-like changes in can cause very large control inputs due to the derivative part. The standard solution for this issue is to introduce a first order derivative filter with the time constant . These (more general) PID controllers of the form
with will therefore be considered in the following. Due to the general framework provided by ES, this does not entail changes.
Parameter updates. In order to achieve a convergent ES scheme for different a priori unknown plants, a simple building block is as follows. Instead of absolute updates as in (1) and (2), we make use of
(9a) | ||||
(9b) |
where and are relative updates opposed to before. This automatically takes the current size of into account and results in “sensible” updates. Consider, for example, and . Then, and , i.e., a change by , are probably useful updates, whereas will likely have a negligible effect and results in positive feedback, which may destabilize the closed-loop. Furthermore, we move these updates to the controller. Thus, our tuning scheme will provide and .
Gradient estimation. Next, we focus on the estimation of . Here, instead of using a high-pass filter in combination with a demodulation, we focus on square wave perturbation signals for . In combination with the parameter updates, this allows for arbitrarily many tuning steps and circumvents the necessity for bootstrapping. The result of square wave perturbations is a gradient approximation based on finite differences. However, cost function measurements are then necessary in order to approximate which is inefficient. Instead, simultaneous perturbation (see [17]) approximates the (relative) gradient stochastically based on
(10) |
with only two cost function measurements. Here, consists of an amplitude and a random perturbation vector . The entries of are mutually independent zero-mean random variables, e.g., symmetrically Bernoulli distributed around . Now, using (10) results in various benefits. First, the (expected) performance is higher. More precisely, compared to other approximation techniques, simultaneous perturbations requires the least total amount of cost function evaluations until convergence [14]. Moreover, since is a square wave signal, faster convergence compared to other perturbation wave forms [18] can be expected. Second, in comparison to [13], the high-pass and additional perturbation signal parameters are now obsolete. Third, it is well-suited for encryption because there are possible values for which allows precomputing the corresponding multiplicative inverses a priori.
Normalization. In the current form, the magnitude of may be very different for different closed-loops, which may also result in quite different and destabilizing or conservative updates. In this context, it would be useful to replace with the normalization . Then, could be tuned solely by means of . The problem is, however, that depends on . Consequently, a costly and/or unreliable encrypted inversion would be necessary. This is why we proceed differently here. Our goal is to obtain similar magnitudes for regardless of the closed-loop response. Then, by means of (10) with a predefined , also will be similar in magnitude throughout the tuning. To this end, we replace (3) in (10) by a Newton-Cotes formula
(11) |
where denotes the -th discrete time sample of , with , denote the integration weights, and refers to the number of samples. Note that the proposed changes amount to scaling a discrete time version of (3) by , where is the integration time. Thus, optimal parameter values are not affected. Now, the normalized control error contributes to a decoupling of (11) from . Next, in order to capture the full step response, we propose , where is the time step and is the settling time of the closed-loop. Then, if is large enough in (11), the magnitude of becomes insensitive to variations in and , which naturally happen for different closed-loops.
Survivorship bias. Obviously, the presented tuning approach is somewhat naive because closed-loop stability is not guaranteed during the tuning process as in other model-free tuning methods (see, e.g., [13, 19]). However, as a first step towards privacy-preserving controller tuning, our adaptions of ES work surprisingly well, as we will see in Section IV.
C. Encrypted evaluation
With these preparations and by means of the homomorphisms from Section II.B, an encrypted evaluation of our tailored extremum seeker, in which costly computations are deliberately avoided, can be realized as follows. We first note that, once , , and are fixed, all encrypted perturbations and the encrypted multiplicative inverses can be precomputed, where encrypted quantities are scaled in line with (7). Similarly, we precompute , , and , where the latter serves as an initialization for the integration. During operation, is randomly selected from the preencrypted values and used as a perturbation signal. Then, after exciting the closed-loop, the cloud obtains and computes as well as with a step-wise evaluation of (11) for each . For the relative parameter update , is selected based on the selected perturbation signal. This implementation prohibits the cloud from learning input output data or intermediate results and allows for an arbitrary amount of tuning steps.
Our encrypted scheme (with some additional details) is depicted in Figure 1. There, ciphertext rescaling is applied after every homomorphic (and plaintext) multiplication. We briefly mentioned this technique before in Section II.B. Without losing ourselves in technicalities, with ciphertext rescaling one can reduce the scaling factor of an encrypted plaintext (otherwise it would be in and not ) at the cost of also reducing the modulus (see [20, 4] for details). Thus, the overflow problematic is not resolved. However, apart from some advantages, it is also convenient to use and often automatically performed in popular libraries. An implementation according to Figure 1 can, e.g., be realized with the cryptosystems from [20, 4].
Finally, the remaining parameters are specified as follows. We assume that the number of tuning steps , , and are user-defined, where is an estimation of . We further note that, as well as are public, since an attacker can always count the number of and measure the time between and . Consequently, also and for some are public.222In fact, this enables an encrypted estimation of based on comparisons of .
IV. Numerical benchmark
For comparison, we use the examples from [13] and investigate the plants with normalized amplification
where has a time delay, which is replaced with a third order Padé approximant, is a high order model with repeated poles, and is non-minimum phase. Note that we significantly decreased the time constant of in comparison to [13] in order to test our scheme with a greater variety of dynamics. Next, and are used for simulation, where initial controller parameters stem from the Ziegler-Nichols oscillation method. We fix , , and for all tunings and use a trapezoidal rule in (11). For the cryptographic implementation we opted for the leveled homomorphic RNS Variant of CKKS [4] available in the PALISADE library [21] which is executed on an Intel i7-7600U. In this context, with levels, and a ring dimension of provide a parameter-dependent security of approximately bits according to the estimator333https://bitbucket.org/malb/lwe-estimator from [22].
Tuning results. We start with the tuning results of our proposed scheme for , , and in Figure 2.



Here, the control errors in all closed-loops are significantly reduced, in spite of the different dynamics. Furthermore, we present five tunings for each plant to take the stochastic effects of (10) into account. Clearly, all tunings converged with similar speed and result in almost identical performance. Next, the parameters corresponding to Figure 2 can be found in Table I.
– | ||||||
---|---|---|---|---|---|---|
50 | ||||||
– | ||||||
50 | ||||||
– | ||||||
50 | ||||||
- † variance of the measurement noise in of
There, also Gaussian measurement noise is considered. Although a significant amount of noise is used for each plant, we can see that the parameters are very similar compared to the noise-free case and none of the tunings led to an unstable closed-loop, which is a result of the integration (11). Interestingly, more iterations reveal that the convergence is slower in the presence of noise.
Now, let us focus on the effect of and . With a view on (11) it becomes clear that both of these parameters influence by means of . On one hand, could be much larger than necessary, i.e., for many in (11). Then, will be smaller in comparison to the case where is adequately chosen, which reduces the magnitude of and, as a result, the convergence speed. On the other hand, if is much smaller than necessary, might become larger than expected, which can cause a non-stable update for . However, changes of had negligible effects on the tuning outcomes in our studies. For example, unstable behavior occurs the fastest for if is reduced by .
Lastly, the cryptographic performance is as follows. The encryption of and the decryption of as well as take approximately . By means of (11) the homomorphic evaluation depends on . In particular, for an evaluation of requires around . The values for we used in the examples therefore lead to evaluation times of in the order of to . Hence, faster evaluations require smaller values for at the cost of less robustness.
V. Conclusion and Outlook
As a first step towards privacy-preserving controller tuning as-a-Service, we tailored an extremum seeking algorithm for encrypted PID tuning. More precisely, relative parameter updates, a stochastic gradient approximation, and a normalized objective function provided a more “encryption-friendly” reformulation, while contributing to the robustness (and performance) of our algorithm. We tested our encrypted extremum seeker against different plant dynamics, measurement noise, as well as parameter variations. In all cases, the PID parameters were significantly improved, which shows the effectiveness of our approach.
We are well aware of the fact, that the simplicity of the algorithm makes outsourcing it to a cloud questionable. Apart from that also stability during the tuning process is an issue. Therefore, one may view the proposed method as a first step towards CaaS. For future research, the design and encryption of other tuning algorithms will be of interest. With a view on the rapid performance enhancements of HE over the last decade, it may soon be possible to evaluate more complex controller designs in an acceptable time.
VI. Acknowledgment
The authors gratefully acknowledge the support by the German Research Foundation (DFG) under the grant SCHU 2940/4-1.
References
- [1] P. Paillier, “Public-Key Cryptosystems Based on Composite Degree Residuosity Classes,” in Advances in Cryptology - Eurocrypt ’99, ser. Lecture Notes in Computer Science. Springer, 1999, vol. 1592, pp. 223–238.
- [2] C. Gentry, “Computing Arbitrary Functions of Encrypted Data,” Communications of the ACM, vol. 22, no. 11, pp. 612–613, 2010.
- [3] L. Ducas and D. Micciancio, “FHEW: Bootstrapping Homomorphic Encryption in Less Than a Second,” in Annual International Conference on the Theory and Applications of Cryptographic Techniques. Springer, 2015, pp. 617–640.
- [4] J. H. Cheon, A. Kim, M. Kim, and Y. Song, “Homomorphic Encryption for Arithmetic of Approximate Numbers,” in Intl. Conference on the Theory and Application of Cryptology and Information Security. Springer, 2017, pp. 409–437.
- [5] M. Schulze Darup, A. B. Alexandru, D. E. Quevedo, and G. J. Pappas, “Encrypted Control for Networked Systems: An Illustrative Introduction and Current Challenges,” IEEE Control Systems Magazine, vol. 41, no. 3, pp. 58–78, 2021.
- [6] M. Schulze Darup, A. Redder, I. Shames, F. Farokhi, and D. Quevedo, “Towards Encrypted MPC for Linear Constrained Systems,” IEEE Control Systems Letters, vol. 2, no. 2, pp. 195–200, 2018.
- [7] A. B. Alexandru, M. Morari, and G. J. Pappas, “Cloud-based MPC with Encrypted Data,” in Proc. of the 57th IEEE Conference on Decision and Control (CDC). IEEE, 2018, pp. 5014–5019.
- [8] N. Schlüter, M. Neuhaus, and M. Schulze Darup, “Encrypted dynamic control with unlimited operating time via FIR filters,” in Proc. of the 2021 European Control Conference (ECC), 2021, pp. 947–952.
- [9] A. B. Alexandru, A. Tsiamis, and G. J. Pappas, “Towards Private Data-driven Control,” in Proc. of the 59th IEEE Conference on Decision and Control (CDC). IEEE, 2020, pp. 5449–5456.
- [10] J. Coulson, J. Lygeros, and F. Dörfler, “Data-Enabled Predictive Control: In the Shallows of the DeePC,” in Proc. of the 2019 European Control Conference (ECC), 2019, pp. 307–312.
- [11] T. Samad, “A Survey on Industry Impact and Challenges Thereof,” IEEE Control Systems Magazine, vol. 37, no. 1, pp. 17–18, 2017.
- [12] K. B. Ariyur and M. Krstic, Real-Time Optimization by Extremum-Seeking Control. John Wiley & Sons, 2003.
- [13] N. J. Killingsworth and M. Krstic, “PID Tuning Using Extremum Seeking: Online, Model-Free Performance Optimization,” IEEE Control Systems Magazine, vol. 26, no. 1, pp. 70–79, 2006.
- [14] S. Z. Khong, Y. Tan, C. Manzie, and D. Nešić, “Extremum seeking of dynamical systems via gradient descent and stochastic approximation methods,” Automatica, vol. 56, pp. 44–52, 2015.
- [15] J. Kim, H. Shim, and K. Han, “Comprehensive introduction to fully homomorphic encryption for dynamic feedback controller via LWE-based cryptosystem,” in Privacy in Dynamical Systems. Springer, 2020, pp. 209–230.
- [16] O. Regev, “The learning with errors problem,” in Proc. of the 25th Annual Conference on Computational Complexity, 2010, pp. 191–204.
- [17] J. C. Spall et al., “Multivariate Stochastic Approximation Using a Simultaneous Perturbation Gradient Approximation,” IEEE Transactions on Automatic Control, vol. 37, no. 3, pp. 332–341, 1992.
- [18] Y. Tan, D. Nešić, and I. Mareels, “On the choice of dither in extremum seeking systems: A case study,” Automatica, vol. 44, no. 5, pp. 1446–1450, 2008.
- [19] O. Lequin, M. Gevers, M. Mossberg, E. Bosmans, and L. Triest, “Iterative Feedback Tuning of PID parameters: comparison with classical tuning rules,” Control Engineering Practice, vol. 11, no. 9, pp. 1023–1033, 2003.
- [20] Z. Brakerski, C. Gentry, and V. Vaikuntanathan, “(Leveled) Fully Homomorphic Encryption without Bootstrapping,” ACM Transactions on Computation Theory (TOCT), vol. 6, no. 3, pp. 1–36, 2014.
- [21] “PALISADE Lattice Cryptography Library (release 1.7.4),” https://palisade-crypto.org/, Jan. 2020, Polyakov, Y. and Rohloff, K. and Ryan, G. W.
- [22] M. R. Albrecht, R. Player, and S. Scott, “On the concrete hardness of Learning with Errors,” Journal of Mathematical Cryptology, vol. 9, no. 3, pp. 169–203, 2015.