1 Introduction

Electrotaxis is the process by which eukaryotic cells establish a cell polarity and move directionally in the presence of an electric field (Cohen et al. 2014; Allen et al. 2013; Zajdel et al. 2020). Electrotaxis is strongest in cellular collectives due to E-cadherin mediated adhesions (Wolf et al. 2022; Li et al. 2013), and displays striking similarities between different cell types and electric field stimulation patterns. Previous studies have focused on using electrotaxis as a means to achieve particular patterns in collective movement (Cohen et al. 2014; Zajdel et al. 2020). For instance, electric fields can be programmed to give bespoke migration patterns (Zajdel et al. 2020), which are along the field lines in converging and diverging electric fields (Cohen et al. 2014). A common theme in all of these experiments is that the average direction of collective migration can be accurately controlled during electric field stimulation. The ease with which electric fields can establish directed migration in cellular collectives has led electrotaxis to be accepted as a robust method of steering collective migration (Leal et al. 2023). The theoretical interest in modelling collective electrotaxis then lies in the ability to answer the following question: Given a desired spatio-temporal movement pattern, how should the electric field be designed to achieve this?

The adoption of electrotaxis as a predictable driver of collective migration has been stalled by a poor understanding of the temporal dynamics of the collective speed during electric field stimulation. For example, Wolf et al. (2022) found that MDCK collectives display a strong, but transient response to the electric field: while the average speed in the direction of the field increases quickly after the electric field is turned on, the collective starts to slow down after approximately one hour, even though the electric field strength remains constant. In general, the current lack of understanding of how the speed of the cellular collective will evolve during stimulation with an electric field poses difficulties in designing bespoke stimulation strategies that can be used to achieve a predictable migration outcome. This difficulty places the question of predicting collective speed during electrotaxis among the most pressing issues in collective electrotaxis. The problem we seek to address in this work is therefore how the collective speed of MDCK monolayers during stimulation with a given electric field can be predicted, and how this knowledge could be exploited to design a stimulation strategy to produce a desired pattern of collective migration?

Both theoretically and experimentally, the question of how to control the temporal dynamics of the collective velocity has scarcely received attention in the literature, even though the fact that the temporal dynamics of electrotaxis are non-trivial is well-documented. Controlling the temporal dynamics of collective velocity remains challenging, since the subcellular processes governing the evolution of cell polarity and active force production in response to stimulation with an electric field remain poorly understood (Allen et al. 2013; Cohen et al. 2014; Wolf et al. 2022; Zajdel et al. 2020). At the subcellular level, electrophoresis of charged membrane components creates a cell polarity that activates intracellular signalling pathways that are largely shared with those found in chemotaxis (Allen et al. 2013; Song et al. 2021; Gao et al. 2015). Subsequent modelling efforts Ifunanya Nwogbaga et al. (2022) have been able to explain the directional movement of cells during electrotaxis, but the existing literature is not well positioned to explain the temporal dynamics of cell responses.

In this work, we are interested in constructing a deterministic, continuous-time model to predict the average velocity of the centre of mass of a cellular monolayer in response to stimulation with an electric field. We will consider only uniaxial electric fields, i.e., the field can be described solely by its field strength in the positive or negative direction. Under these assumptions, the goal of this work will be to derive a system of ODEs which predict the collective velocity and the active forces in the monolayer. A significant benefit of using ODE models is that there exists a completely developed theory on how to optimally control ODE solutions according to a given optimisation problem Lenhart and Workman (2007). In the context of collective electrotaxis, this means that a well-calibrated and reliable ODE model can be used to solve an optimisation problem, whereby the optimality condition is given by the desired temporal pattern of collective movement and the control is the electric field input.

The current scholarship on collective migration of epithelia provides a convenient starting point for the construction of such an ODE model – see Alert and Trepat (2020) for a review of continuum models of collective epithelial migration. For example, since the internal signaling pathways for collective electrotaxis are largely shared with chemotaxis, one can begin to model the internal cellular response to an electric field with a well-established continuum model for the response to a chemotactic signal. Erban and Othmer proposed an adaptation-excitation model for the chemotactic response of single cells, whereby cells are excited when initially exposed to an external signal, and slowly adapt over time Erban and Othmer (2005). In their work, signal transduction is interpreted as “having two input pathways, an excitatory one that stimulates the [response], and one [...] which, in turn, shuts off the response”. Similar models are frequently proposed to describe chemotaxis. The advantage of such a model is that it is given by a straightforward system of scalar ODEs that describe the effective signal transduced within a cell upon contact with a chemoattractant (Erban and Othmer 2005). In this work, we will assume that similar internal signaling dynamics can be used to model the cellular response to an applied electric field. By letting the strength of the active forces in the monolayer be described using the model of Erban and Othmer (2005), we can derive a closed system of ODEs to describe the monolayer speed. Using experimental data in conjunction with Bayesian inference, we can interrogate the validity and applicability of using such a system of ODEs to model collective electrotaxis in response to stimulation with an electric field. Put together, the model can be used to develop a framework for designing electric fields that lead to desired outcomes in the form of an optimal control experiment.

This work will be structured as follows. In Sect. 2 we present the experimental data of collective electrotaxis that will be used for calibration and validation of the ODE models. Then, in Sect. 3, we derive a simple ODE model that describes the evolution of the tissue velocity. We then use this system of ODEs to predict the optimal control policy when a number of targets are considered, and compare our results to the current standards for electric field stimulation used in the literature. Together, we offer a mathematical modelling framework to describe, understand, and optimise key cellular processes involved in the regulation of collective electrotaxis.

2 Methods and Data

In this section, we present the publicly available experimental data from Wolf et al. (2022). In brief, the experiments of Wolf et al. (2022) involved electrotaxis of 5\(\times \)5 \(\hbox {mm}^2\) MDCK-II epithelial monolayers. In these experiments, a total of nine MDCK epithelial monolayers were grown to confluence and stimulated with an electric field of 3V/cm—see stimulation trace in Fig. 1. In each experimental replicate, 5\(\times 5\hbox {mm}^2\) square tissues were seeded onto 10 cm tissue-culture plastic dishes (CELLTREAT) using stencils of 250\(\upmu \)m-thick silicone elastomer (Bisco HT6240) cut with a hobbyist razor-writer (Silhouette Cricut). Suspensions of MDCK cells were seeded into the stencil patterns at a volume of 10\(\upmu \)L and density of 2.5 (±0.15) x 10\(^6\) cells/mL. Cells were given one hour to adhere before the dish was flooded with media and incubated for 18 h prior to stencil pull and insertion into the electric bioreactor. Tissue culture stencils were pulled approximately 1 h before imaging began. Immediately post-stencil pull, dishes were refilled with fresh culture media followed by direct integration with the bioreactor. The assembled bioreactor is then placed into the microscope, situated within a custom-built cage incubator maintained at 37\(^{\circ }\)C and perfused with fresh media continuously bubbled with 5% \(\hbox {CO}_2\) using a peristaltic pump (Instech Laboratories) at a rate of 2.5 mL/h. Electrotaxis was induced by custom electro-bioreactors developed by the Cohen group at Princeton University, which are based on the SCHEEPDOG platform (Zajdel et al. 2020). These bioreactors provide a continuous flow of media and can be programmed to generate electrical fields with custom electric field densities.

Fig. 1
figure 1

Experimental data of MDCK monolayer electrotaxis with its electric field stimulation protocol. Left panel: phase field image of an MDCK epithelial monolayer indicating direction of the uniaxial electric field and bulk region where the mean velocity is measured. Right panel, top: electric field density during the experiment. Right panel, bottom: bulk velocity corresponding to the electric field trace in the top row

Velocity data from each of the experiments were acquired using particle image velocimetry (PIV) on phase contrast images, where the cell nuclei are used as the fiduciary markers. Local tissue velocities were computed every 10 min. The PIV data provide a velocity field at a spatial resolution of 32\(\times \)32 \(\upmu \) \(\hbox {m}^2\), which corresponds roughly to 3\(\times \)3 cell lengths. For a sample velocity heat map, see Fig. 1. For further details on the PIV data processing and implementation details in FIJI Schindelin et al. (2012) and MATLAB The MathWorks Inc. (2022), we refer the reader to Wolf et al. (2022). Experimental PIV data provides detailed spatiotemporal information on the velocities at a fine spatial resolution. Wolf et al. (2022) previously used this detailed spatial data to characterise the responses in different tissue locations during collective electrotaxis. They found that the edges of the MDCK monolayer have a preferred direction of movement, which is outward of the tissue and is only observed within approximately 200\(\upmu \)m of the tissue boundary. This effect is a hallmark of the collective migration of MDCK cells (Wolf et al. 2022; Tlili et al. 2018; Cohen et al. 2014; Alert and Trepat 2020). Although some attention has been given to understanding how the preferred migratory direction of the edges interferes with electrotaxis in the literature (Wolf et al. 2022), it is not necessary to incorporate detailed mechanisms of edge migration when understanding the average velocity of the centre of mass of the epithelial monolayer. Since the majority of the tissue does not exhibit the preferred direction of migration that the edges show, we restrict our analysis to the tissue bulk, the \(3\times 3\hbox { mm}^2\) region in the centre of the tissue characterised by Wolf et al. (2022)—for a schematic, see Fig. 1. We take a spatial average of the velocity in the bulk, which yields one-dimensional data traces that represent the monolayer velocity in each of the experiments.

3 An Adaptation-Excitation Model of Collective Electrotaxis

We use a known model for cellular excitation and adaptation proposed by Erban and Othmer (2005) to model the internal cellular response to electric field. Since all the experiments we study consider a uniaxial electric field, we describe the migration of the monolayer bulk using the x component of the velocity, v, in the positive direction of the electric field, which is assumed aligned with the x-axis, as shown in Fig. 1. The goal of this section is to connect a model of cellular adaptation and excitation to the temporal evolution of the bulk velocity in response to the electric field and furthermore, to seek to use this model to address the question of how to optimally control the collective migration of MDCK epithelia by varying the field strength.

3.1 Model Derivation

We assume that cells experience a viscous friction force per unit mass which is proportional to their velocity with a friction coefficient, \(\gamma \), such that the friction force per unit mass is given by \(-\gamma v.\) The assumption of linear friction is well-founded for epithelia, since this corresponds to the polymerisation of adhesions on the substrate Alert and Trepat (2020). We assume throughout that there will be a uniaxial electric field in the positive v-direction whose magnitude is given by a scalar signal, \(s = s(t)\). In what follows, we will introduce in detail the Erban and Othmer model Erban and Othmer (2005) to describe how the electric field creates an intracellular effective signal to the cytoskeletal machinery to produce an active force in the direction of the electric field.

The canonical model for excitation-adaptation proposed by Erban and Othmer considers an external stimulus, s(t), an effective signal, \(s_{\text {eff}}\), and an inhibitor, I. The effective signal, \(s_{\text {eff}}\), is a scalar quantity that describes the extent to which an external signal is transduced within the cell. There is therefore a difference between the constant electric field supplied and the resulting internal signal. The inhibitor, in contrast, represents the strength of the internal signalling pathways that try to inhibit this response to the external stimulus. The dynamics are given by

$$\begin{aligned} \dot{s}_{\text {eff}}&= \frac{s(t) - (s_{\text {eff}} + I)}{\tau _e}, \end{aligned}$$
(1)
$$\begin{aligned} \dot{I}&= \frac{s(t) - I}{\tau _a}. \end{aligned}$$
(2)

In this model, one assumes that the excitation timescale, \(\tau _e > 0\), is far shorter than the adaptation timescale, \(\tau _a > 0\). The different timescales in this system create a characteristic response to a constant signal Erban and Othmer (2005): when the external signal, s(t), is a Heaviside function, the solution of Eqs. (1) and (2) is of the form

$$\begin{aligned} s_{\text {eff}} = \frac{\tau _a}{\tau _a - \tau _e}\left( e^{-t/\tau _a} - e^{-t/\tau _e}\right) , \quad I = 1-e^{-t/\tau _a}. \end{aligned}$$
(3)

With other words, as \(t \rightarrow \infty \), the effective signal wanes, i.e., \(s_{\text {eff}} \rightarrow 0\). In particular, since \(\tau _e \ll \tau _a\),

$$\begin{aligned} s_{\text {eff}} \sim \frac{\tau _a}{\tau _a - \tau _e} e^{-t/\tau _a}, \end{aligned}$$
(4)

whenever \(t \gg \tau _e\). This implies that on time scales larger than the excitation time, \(\tau _e\), the field response decays exponentially, so that a constant electric field will not produce an internal signal that leads to sustained migration at timescales much greater than the initial excitation time, \(\tau _e\). In this work, we consider s, \(s_{\text {eff}}\), and I to be unitless, as we rescale the field strength, s, by dividing by the canonical field strength of 3V/cm in the experimental set-up. Finally, we make the assumption that whenever \(s \ge 0\), the effective signal, \(s_{\text {eff}}\), equally satisfies \(s_{\text {eff}} \ge 0\). The reason for making this additional assumption is that Eqs. (1) and (2) allow for \(s_{\text {eff}}\) to become negative when the field is turned off. MDCK epithelial monolayers are not observed to move in the direction opposite to the electric field when the electric field is turned off, and this is not physically realistic. For this reason, going forward, unless explicitly noted, we consider the quantity

$$\begin{aligned} s_{\text {eff}}^+ = \max (s_{\text {eff}}, 0). \end{aligned}$$
(5)

To close the system of equations, we now relate the system of effective signal and inhibitor to the velocity. We assume that the active force per unit mass in the direction of the electric field is proportional to the effective signal. This assumption follows canonical models in the literature for coupling polarity and force magnitude Alert and Trepat (2020), and results in the following expression for the active force per unit mass, \(\tilde{F}_{\text {active}}\),

$$\begin{aligned} \tilde{F}_{\text {active}} = \alpha s_{\text {eff}}^+, \end{aligned}$$
(6)

where \(\alpha > 0\) is a parameter that controls the responsiveness of the bulk to the input signal. Note that, since s is unitless, \(\alpha \) is given in units of \(\upmu \)m/\(\hbox {h}^2\). In this section, \(\alpha \) is assumed to be a constant, but we will explore different functional forms for the field response in the next section. By then assuming that the resultant force on the bulk is given by the sum of the active force per unit mass and the friction force per unit mass, one obtains a single equation for the velocity,

$$\begin{aligned} \dot{v} = -\gamma v + \alpha s_{\text {eff}}^+. \end{aligned}$$
(7)

We assume that the monolayer is stationary at the beginning of stimulation and the electric field is turned off, so that the initial condition is given by

$$\begin{aligned} v(0) = s_{\text {eff}}(0) = I(0) = 0. \end{aligned}$$
(8)

3.2 Linear Stability Analysis

We begin by noting that Eqs. (1), (2), and (7) can be written as a linear system of equations such that

$$\begin{aligned} \frac{\text {d}}{\text {d}t}\begin{pmatrix} v \\ s_{\text {eff}} \\ I\end{pmatrix} = \begin{pmatrix} -\gamma &{} \alpha &{} 0 \\ 0 &{} -\tau _e^{-1} &{} - \tau _e^{-1} \\ 0 &{} 0 &{} -\tau _a^{-1} \end{pmatrix} \begin{pmatrix} v \\ s_{\text {eff}} \\ I\end{pmatrix} + \begin{pmatrix} 0 \\ \tau _e^{-1}s(t) \\ \tau _a^{-1} s(t)\end{pmatrix}, \end{aligned}$$
(9)

subject to the initial conditions in Eq. (8). Note that the eigenvalues of the matrix in the homogeneous part of the right-hand side of Eq. (9) are \(-\gamma , -\tau _e^{-1}, -\tau _a^{-1}\), making the matrix invertible. At steady state, one has that the left-hand side of Eq. (9) is zero, and that the steady state solution, \((v^\star , s_{\text {eff}}^\star , I^\star )\), for a constant field strength, \(s(t) \equiv s\), is given by taking the inverse,

$$\begin{aligned} \begin{pmatrix} v^\star \\ s_{\text {eff}}^\star \\ I^\star \end{pmatrix} = \begin{pmatrix} -\gamma ^{-1} &{} -\frac{\alpha \tau _e}{\gamma } &{} -\frac{\alpha \tau _a}{\gamma } \\ 0 &{} -\tau _e &{} \tau _a\\ 0 &{} 0 &{} -\tau _a \end{pmatrix} \begin{pmatrix} 0 \\ \tau _e^{-1} s \\ \tau _a^{-1} s \end{pmatrix} = \begin{pmatrix} 0 \\ 0 \\ s \end{pmatrix}. \end{aligned}$$
(10)

Therefore, Eq. (9) has a single steady state. Since this steady state is given by zero velocity and zero effective signal, it can be interpreted as corresponding to a tissue that has fully adapted to the electric field and exhibits no response. Moreover, this steady state is stable since all eigenvalues of the matrix on the right-hand side of Eq. (9) are strictly negative. This explains the waning response with constant stimulation, as there is no steady state where a non-zero velocity is attained.

3.3 Bayesian Inference of Model Parameters

Our objective is to calibrate the simple adaptation-excitation model in Eq. (9) to the experimental bulk velocity data of Wolf et al. (2022) by performing Bayesian inference on the unknown model parameters \(\gamma , \alpha , \tau _e, \tau _a\) from the available bulk data.

First, we note that the velocity decay parameter, \(\gamma \), can be estimated directly from the data, since Eq. (7) predicts that, given an initial velocity, \(v_0\), the bulk velocity will decay exponentially in the absence of an electric field. Since the experimental data contain information on the bulk velocity after stimulation with the electric field is turned off, it follows that the observed velocity decay can be used to immediately infer the decay rate, \(\gamma \). From these considerations, we seek to fit an exponential of the form

$$\begin{aligned} v(t) = C e^{-\gamma (t-t_{\text {end}})}, \end{aligned}$$
(11)

to the bulk velocity data in the 2.5 h after stimulation with the electric field is turned off. Here, \(t_{\text {end}}\) is the time at which the electric field is switched off, and C is given by

$$\begin{aligned} C = v(t_{\text {end}}). \end{aligned}$$
(12)

We perform a least-squares fit for the decay rate, \(\gamma \), to give an estimate of \(\gamma = 1.765\) \(\hbox {h}^{-1}\). Figure 2 shows that the fitted exponential decay curve is in excellent agreement with the experimental data after pulse stimulation. This motivates us to take the value of \(\gamma \) as fixed going forward. The benefit of directly estimating \(\gamma \) from data is that it reduces the dimensionality of the parameter space, thus simplifying the inference of the remaining parameters.

Fig. 2
figure 2

Experimental data of bulk velocity decay post-stimulation with an electric field pulse of 3 V/cm (black dots) together with least-squares fit of exponential decay in the form \(C e^{-\gamma t}\) (solid blue line). The least-squares solution gives an excellent fit to the data and can be used to identify the decay rate, \(\gamma \) (color figure online)

We now keep \(\gamma = 1.765\hbox {h}^{-1}\) fixed and perform Bayesian inference of the remaining parameters, \(\alpha \), \(\tau _e\) and \(\tau _a\). We use Markov chain Monte Carlo (MCMC) with a Haario-Bardenet adaptive covariance and four chains under the assumption of a Gaussian error implemented in Python with the PINTS pacakge Clerx et al. (2019). For the distribution of the error, we assume Gaussianity since previous experiments by Wolf et al. demonstrate that the experimental variability around the mean is approximately Gaussian Wolf et al. (2022). The (standard) choice of four MCMC chains reflects the fact that each run of the MCMC algorithm is a random walk, so that the use of several random walks can be used to assess the ability of the algorithm to converge to the region in parameter space with high posterior probability Clerx et al. (2019). As a metric of convergence we use the \(\hat{R}\) statistic Clerx et al. (2019), which is defined as the ratio of the between- and within-chain variances of the chains (Clerx et al. 2019). The \(\hat{R}\) statistic summarises mixing and stationarity of the chains, with a value of \(\hat{R} = 1\) showing perfect mixing and stationarity of the chains. We use the reference value of \(\hat{R} = 1.05\) for four chains (Vehtarh et al. 2021) and set a maximum number of MCMC iterations to \(2\cdot 10^4\). We use as data the velocity profiles from the 3V/cm pulse experiments from Wolf et al. (2022). The MCMC procedure yields a well-identified posterior distribution, with marginal posterior means 149.92 \(\upmu \)m/\(\hbox {h}^2\), 0.260h, and 2.038h, for \(\alpha \), \(\tau _e\) and \(\tau _a\), respectively. These posterior means are in good agreement with previous intuition that the time scale for adaptation is longer than the time scale for excitation, as well as with the data, suggesting that the bulk slows down on a timescale of the same order of magnitude as \(\tau _a\). Plots of the marginal posterior distributions of the model parameters are shown in Fig. 3. These show that the parameters can be confidently identified from the data, given their well-defined posterior distributions.

To assess the predictive capability of the model given the posterior distribution of the model parameters, we compute the posterior predictive intervals of the model, i.e. a 95% confidence interval for the model outputs given the posterior distribution of the model parameters. These posterior predictive intervals are shown in Fig. 3. It can be seen that the posterior predictive intervals are tightly concentrated around the mean, showing little model uncertainty in predicting the experimental data, given the posterior distribution of the model parameters. By overlaying the posterior predictive intervals for the model onto the experimental data, we observe that the model predictions are in good agreement with the experimental data and lie comfortably within the standard deviation of the experimental data. We conclude that the adaptation-excitation model presented in this section, when calibrated to the experimental data, is able to recapitulate the phenomenon of attenuating velocity during electrotaxis to the field when the electric field is held constant.

Fig. 3
figure 3

Bayesian inference on a simple model of adaptation and excitation given by Eq. (9) using experimental data from an electrotaxis experiment. Left: bulk velocity using a constant field of 3V/cm. Posterior mean of the model together with a confidence interval between the 5% and 95% quantiles of the model posterior predictions in cyan, experimental data and their confidence interval in grey. Notice the small width of the posterior predictive intervals. Right panels, from top to bottom: posterior distributions for model parameters, \(\alpha \), \(\tau _e, \tau _a\), respectively (color figure online)

4 Optimal Control

Having established that excitation-adaptation dynamics can be used to describe the velocity of the tissue bulk during electrotaxis, we turn to the question of designing a stimulation protocol that is in some way optimal for the experiment. We previously established that the question of how to design electric field stimulation protocols has received little attention due to the difficulties in predicting tissue response a priori. Instead, experiments have been carefully calibrated through trial and error by the experimental laboratories that have performed them over the past few years. At this point, it is worth noting that these experiments are costly and time-consuming, making a grid search or other brute-force methods to determine optimal temporal stimulation patterns infeasible.

In this section, we will consider the problem of predicting an optimal pattern of stimulation using the adaptation-excitation model, drawing extensively on optimal control theory. For a legible introduction, we refer the reader to Lenhart and Workman (2007). We will consider that the optimal control problem can be cast as an optimization problem of a functional, E, that depends continuously on the velocity as well as the signal,

$$\begin{aligned} E(v,s) = \int _0^T f(v,s) \text {d}t, \end{aligned}$$
(13)

and that there is a fixed start and end time of stimulation, given by 0, T, respectively. We need to penalise for the total amount of electric current administered during the experiment, as applying large currents throughout the cell medium for large amounts of time yields damage to the tissue and the experimental set-up. For now, we will incorporate this by requiring that a proxy of the total amount of charge delivered to the tissue during stimulation remains constant, i.e.

$$\begin{aligned} \int _0^T s(t)^2 \text {d}t= s_{\text {budget}}. \end{aligned}$$
(14)

Later in this section, we will investigate the role of introducing lower and upper bounds on the field strength instead. Note also that in Eq. (14) we have introduced a quadratic to account for the fact that the electric field can be positively or negatively charged, and that fields of both signs will affect the tissue.

Under the condition of Eq. (14), we set up the first optimal control problem to maximise the total distance travelled by the tissue. This is a straightforward question to ask when one is concerned with increasing the controllability of collective migration. We therefore consider the optimization problem

$$\begin{aligned} \max _{s} \int _0^T v(t)\text {d}t. \end{aligned}$$
(15)

This optimisation problem is then subject to the condition in Eq. (14). In optimal control theory, this is known as an isoperimetric problem. In this formulation, we introduce a new variable,

$$\begin{aligned} z(t) = \int _0^t s(t)^2 \text {d}t, \end{aligned}$$
(16)

such that the problem can be described as

$$\begin{aligned} \max _s E&= \int _0^T v \text {d}t, \quad \text {subject to} \end{aligned}$$
(17)
$$\begin{aligned} \dot{z}(t)&= s(t)^2, \end{aligned}$$
(18)
$$\begin{aligned} v(0)&= 0, \end{aligned}$$
(19)
$$\begin{aligned} z(0)&= 0, \quad z(T) = s_{\text {budget}}. \end{aligned}$$
(20)

Recall that the isoperimetric contraint above has been introduced to enforce a physical limit on the amount of charge to which cells in the monolayer are exposed. One might also interpret the isoperimetric constraint as a manner of interrogating how, given a fixed amount of charge, one might optimally distribute the delivery of this charge so that the total distance travelled by the monolayer is optimal. To make direct comparisons with the experiments performed in Wolf et al. (2022), we wish to make the stimulation pattern have the same integrated charge for constant stimulation at 3 V/cm, so we set \(s_{\text {budget}} = 27\) \(\hbox {V}^2\)h/\(\hbox {cm}^2\). For this problem the Hamiltonian is given by

$$\begin{aligned} \begin{aligned} H&= v + \lambda _v(t)\dot{v} + \lambda _{s_{\text {eff}}}(t) \dot{s}_{\text {eff}} + \lambda _I \dot{I} - \mu _z \dot{z}\\&= v + \lambda _v(t) \left[ -\gamma v + \alpha s_{\text {eff}}\right] \\&+ \tau _e^{-1}\lambda _{s_{\text {eff}}}(t)\left[ s - s_{\text {eff}} - I \right] + \tau _a^{-1}\lambda _I(t)\left[ s-I\right] - \mu _z s^2,\\ \end{aligned} \end{aligned}$$
(21)

where \(\partial \lambda _\bullet /\partial t = - \partial H/\partial \bullet \), such that

$$\begin{aligned} \frac{\text {d}\lambda _v}{\text {d}t}&= - \frac{\partial H}{\partial v} = -1 + \gamma \lambda _v, \end{aligned}$$
(22)
$$\begin{aligned} \frac{\text {d}\lambda _{s_{\text {eff}}}}{\text {d}t}&= - \frac{\partial H}{\partial s_{\text {eff}}} = -\alpha \lambda _v + \tau _e^{-1} \lambda _{s_{\text {eff}}}, \end{aligned}$$
(23)
$$\begin{aligned} \frac{\text {d}\lambda _{I}}{\text {d}t}&= - \frac{\partial H}{\partial I} = \tau _e^{-1} \lambda _{s_{\text {eff}}} + \tau _a^{-1} \lambda _I, \end{aligned}$$
(24)
$$\begin{aligned} \frac{\text {d}\mu }{\text {d}t}&= -\frac{\partial H}{\partial z} = 0 , \end{aligned}$$
(25)

subject to the terminal conditions \(\lambda _\bullet (T) = 0\). Additionally, \(\mu = \mu _\star \) is a constant. The optimality condition is given by

$$\begin{aligned} 0 = \frac{\partial H}{\partial S} = \tau _e^{-1} \lambda _{s_{\text {eff}}} + \tau _a^{-1}\lambda _I - 2\mu _\star s. \end{aligned}$$
(26)

The solution to Eq. (26) yields the optimal stimulation pattern, \(s^\star \), which is given by

$$\begin{aligned} s^\star = \frac{1}{2\mu _\star }(\tau _e^{-1} \lambda _{s_{\text {eff}}} + \tau _a^{-1}\lambda _I) = \frac{\tau _e^{-1}}{2\mu _\star }\left( \lambda _{s_{\text {eff}}} + \frac{\tau _e}{\tau _a}\lambda _I\right) = \frac{\tau _e^{-1}}{2\mu _\star }\left( \lambda _{s_{\text {eff}}} + \epsilon \lambda _I\right) , \end{aligned}$$

where \(\epsilon = \tau _e/\tau _a\). To find the optimal stimulation pattern, \(s^\star \), one must seek to solve the linear inhomogeneous system of equations for \(\lambda _\bullet \). Note that Eq. (22), the equation for \(\lambda _v\), decouples from the other adjoint equations, so we can solve directly to find

$$\begin{aligned} \lambda _{v}\left( t\right) = \frac{{\left( \gamma \lambda _{v}\left( 0\right) - 1\right) } e^{\gamma t}}{\gamma } + \frac{1}{\gamma }. \end{aligned}$$

Applying the terminal condition, \(\lambda _v(T) = 0\), yields that \(\lambda _v(0) = -(e^{-\gamma T}-1)/\gamma \), and so we have

$$\begin{aligned} \lambda _{v}\left( t\right) = (e^{\gamma (t-T)}-1)/\gamma . \end{aligned}$$

Direct substitution of the solution for \(\lambda _v\) into Eq. (23), the equation for \(\lambda _{s_{\text {eff}}}\), then yields

$$\begin{aligned} \begin{aligned} \lambda _{s_{\text {eff}}}&= \frac{\alpha }{\gamma (\gamma - \tau _e^{-1})} - \frac{\alpha }{\tau _e^{-1}(\gamma - \tau _e^{-1})} + c_1 e^{\tau _e^{-1}t} - \frac{\alpha e^{\gamma (t-T)}}{\gamma (\gamma - \tau _e^{-1})}\\&= -\frac{\alpha }{\tau _e^{-1}\gamma } + c_1 e^{\tau _e^{-1}t} - \frac{\alpha e^{\gamma (t-T)}}{\gamma (\gamma - \tau _e^{-1})}. \end{aligned} \end{aligned}$$

We can now fit the terminal condition, \(\lambda _{s_{\text {eff}}}(T) = 0\), such that

$$\begin{aligned} 0 = \lambda _{s_{\text {eff}}}(T) = -\frac{\alpha }{\tau _e^{-1}\gamma } + c_1 e^{\tau _e^{-1}T} - \frac{\alpha }{\gamma (\gamma - \tau _e^{-1})}, \end{aligned}$$

which gives

$$\begin{aligned} c_1 = e^{-\tau _e^{-1}T}\left( \frac{\alpha }{\tau _e^{-1}\gamma } + \frac{\alpha }{\gamma (\gamma - \tau _e^{-1})}\right) = \frac{\alpha \gamma }{\tau _e^{-1} (\gamma - \tau _e^{-1})}e^{-\tau _e^{-1}T}. \end{aligned}$$

Therefore,

$$\begin{aligned} \lambda _{s_{\text {eff}}} = \frac{\alpha \gamma }{\tau _e^{-1}(\gamma - \tau _e^{-1})} \left( e^{\tau _e^{-1}(t-T)} - \frac{\tau _e^{-1}}{\gamma ^2}e^{\gamma (t-T)} \right) -\frac{\alpha }{\tau _e^{-1}\gamma }. \end{aligned}$$

We can then find \(\lambda _I\) by solving Eq. (24),

$$\begin{aligned} \lambda _I = e^{-\tau _a^{-1}t}\int _0^t \lambda _{s_{\text {eff}}}(\xi ) e^{\tau _a^{-1}\xi }\text {d}\xi + C_I e^{\tau _a^{-1}t}, \end{aligned}$$

where \(C_I\) is determined by setting the terminal condition, \(\lambda _I(T) = 0\), which gives

$$\begin{aligned} C_I = -e^{-\tau _a^{-1}T}\int _0^T \lambda _{s_{\text {eff}}}(\xi ) e^{\tau _a^{-1}\xi }\text {d}\xi . \end{aligned}$$

Therefore,

$$\begin{aligned} s^\star = \frac{\tau _e^{-1}}{2\mu _\star } \lambda _{s_{\text {eff}}} + \epsilon \frac{\tau _e^{-1}}{2\mu _\star }\left[ e^{-\tau _a^{-1}t}\int _0^t \lambda _{s_{\text {eff}}}(\xi ) e^{\tau _a^{-1}\xi }\text {d}\xi + C_I e^{\tau _a^{-1}t} \right] . \end{aligned}$$
(27)

To determine the solution of the system, it remains to find the constant \(\mu _\star \) such that the optimal solution integrates to \(s_{\text {budget}}\). We use the marginal posterior means for the model parameters \(\alpha , \tau _e, \tau _a\) to first compute \(s^\star \) numerically and use numerical integration to determine the integral during the stimulation window.

Fig. 4
figure 4

Stimulation patterns for optimal control of collective electrotaxis. In all plots, red corresponds to maximum tissue displacement (optimal solution given by Eq. (27)), and yellow corresponds to maximum terminal velocity (optimal solution given by Eq. (32)). Blue curves represent 3V/cm electric field pulse stimulation pattern used experimentally. Left: the different stimulation patterns in normalized units. Middle: corresponding velocity curves using the different stimulation patterns. Right: data from 3V/cm pulse experiment, compared to posterior distribution for optimal solution for distrance travelled and terminal velocity. Parameter values correspond to the posterior means for \(\alpha \), \(\tau _a\), \(\tau _e\), and the pre-computed value for \(\gamma \) (color figure online)

We show a prediction for the optimal stimulation pattern in Fig. 4. Interestingly, the optimal stimulation pattern begins at a nonzero electric field value and increases for the first half of the stimulation window, when it exceeds the constant electric field strength of 3V/cm, before dropping below that field strength in the second half of the stimulation window. The optimal stimulation pattern found in Eq. (27) shows only a modest increase in the distance travelled by the bulk of the monolayer compared to the experimental data, since the integrated numerical solution of the velocity is 2.17% greater than the distance travelled using a constant electric field. This reflects the fact that electrotaxis experiments have been iterated many times experimentally. Strikingly, the optimal stimulation pattern also results in a bulk velocity that still exhibits a slowdown during stimulation. Commonly, studies on collective migration induced by electrotaxis aim to optimise electrotaxis by maximising the velocity at which cells migrate (Wolf et al. 2022; Leal et al. 2023; Cohen et al. 2014). If maximising the speed of collective migration is the goal, optimising collective migration during electrotaxis would be incompatible with allowing a significant slowdown during collective migration. Our findings, however, suggest that the slowdown of the bulk during stimulation does not immediately represent nonoptimality of the stimulation procedure, if maximising the total distance travelled instead is the aim.

We incorporate parameter and prediction uncertainty by computing the posterior distribution over the optimal control solution. We take \(2\cdot 10^3\) samples from the MCMC posterior distribution and for each sample compute the optimal stimulation protocol according to Eq. (27) using that given parameter combination and recomputing the normalising constant, \(\mu _\star \), for each new parameter combination to obtain a normalised density. We again compute the 5% and 95% percentiles of the velocity distribution at each time point and plot them in Fig. 4. We see that the posterior distribution is tight around the posterior mean, which confirms that the above analysis holds true across the entire posterior distribution.

4.1 Optimal Control for the Terminal Velocity

Optimising for the total distance travelled predicts that there is only a very moderate improvement in the optimised outcome compared to stimulation with a constant electric field of 3V/cm. A striking feature of the optimal stimulation curve shown in Fig. 4 is that the velocity curve under the optimal stimulation protocol, like the pulse stimulation protocol, displays a diminishing response to the field at later times. Therefore, we pose the additional question of how to maximise the terminal velocity of the tissue, in other words: How can the stimulation be designed so that the bulk velocity at the terminal time, T, is maximal? A priori, one would expect this to be a different stimulation pattern than the optima found previously. We change the objective function so that we maximise the terminal velocity, v(T),

$$\begin{aligned} E(v) = \int _0^T \dot{v} \text {d}t = \int _0^T [-\gamma v + \alpha s_{\text {eff}}] \text {d}t. \end{aligned}$$
(28)

Note that this change in objective function only changes the equations for \(\text {d}\lambda _v/\text {d}t\) and \(\text {d}\lambda _{s_{\text {eff}}}/\text {d}t\) in the adjoint equations, Equations (22)-(25), since the only additional terms introduced into the Hamiltonian include the velocity, v, and the effective signal, \(s_{\text {eff}}\). We obtain

$$\begin{aligned} \frac{\text {d}\lambda _v}{\text {d}t}&= \gamma + \gamma \lambda _v, \end{aligned}$$
(29)
$$\begin{aligned} \frac{\text {d}\lambda _{s_{\text {eff}}}}{\text {d}t}&= -\alpha \lambda _v + \tau _e^{-1}\lambda _{s_{\text {eff}}}, \end{aligned}$$
(30)

such that, directly fitting the terminal condition, \(\lambda _v(T) = 0\), we have

$$\begin{aligned} \lambda _v = e^{\alpha (t-T)} -1, \end{aligned}$$
(31)

which we substitute into Eq. (23) to find

$$\begin{aligned} \lambda _{s_{\text {eff}}} = \frac{\alpha }{\alpha -\tau _e^{-1}}\left( e^{\tau _e^{-1}(t-T)} - e^{\alpha (t-T)}\right) . \end{aligned}$$
(32)

The same computation as in Eq. (27) now yields predictions of the optimal electric field stimulation protocol, which results in a terminal velocity of 62.9 \(\upmu \)m/h compared to 52.5\(\upmu \)m/h for a constant field. The electric field that optimises the terminal velocity is shown in Fig. 4. Note that the field strength is monotonically increasing to its maximum intensity at the end of stimulation. We obtain a higher terminal velocity than in the other experiments, at the cost of a very high field strength at the end of stimulation, approximately 6 V/cm, which is physiologically and experimentally feasible, albeit not for long periods of time. The fact that the optimal control problem for the terminal velocity yields a ramping pattern suggests that total distance travelled and terminal velocity are two incompatible requirements to fulfill simultaneously, given the model and evidence presented. Finally, to address parameter and prediction uncertainty, we repeat the computation of posterior distributions over the velocities, as done in Sect. 4, which we display in Fig. 4. Again, the posterior distribution of the velocities is tight around the posterior mean.

4.2 Optimal Control for Constant Velocity

The optimal control problems for the maximum distance travelled and the maximum terminal velocity seem to suggest that maximising the distance comes at the cost of a decrease in velocity during stimulation, while optimising the terminal velocity does not maximise the total distance travelled. The finding that the optimal stimulation pattern for total distance travelled does not yield a nondecreasing bulk velocity during the course of stimulation with the electric field runs counter to intuition in the electrotaxis community, as the current opinion in the field tends to view a drop in bulk velocity as a source of nonoptimality in stimulation. From an experimental viewpoint, controlling field strength so that the migratory velocity is constant is attractive, since electric fields are often used for ‘cruise control’. Therefore, we set up a final optimal control problem designed to keep variations in the velocity minimal. We do this by once more modifying the functional so that we seek solutions that minimise

$$\begin{aligned} E(\dot{v}) = \int _0^T \dot{v}^2 \text {d}t = \int _0^T (-\gamma v + \alpha s_{\text {eff}})^2\text {d}t . \end{aligned}$$
(33)

As in the previous section, the only adjoint equations affected are those for \(\lambda _v\) and \(\lambda _{s_{\text {eff}}}\). These become

$$\begin{aligned} \frac{\text {d}\lambda _v}{\text {d}t}&= 2\gamma (- \gamma v + \alpha s_{\text {eff}}) + \gamma \lambda _v, \end{aligned}$$
(34)
$$\begin{aligned} \frac{\text {d}\lambda _{s_{\text {eff}}}}{\text {d}t}&= -2\alpha (-\gamma v + \alpha s_{\text {eff}}) - \alpha \lambda _v + \tau _e^{-1} \lambda _{s_{\text {eff}}}. \end{aligned}$$
(35)

In addition, we impose a terminal condition for the velocity, so that we prescribe a desired velocity at the end of stimulation, i.e., \(v(T) = v^\star \) for some pre-determined constant, \(v^\star \), which can be set by the practitioner in accordance with a practical need. Together with Eqs. (9), (34), (35) and the usual transversality conditions, \(\lambda _\bullet (T) = 0\), the optimisation of the function in Eq. (33) creates a nonlinear first-order boundary value problem (BVP). The complicated coupling between the equations requires a numerical solution to the problem. Here, we set \(v^\star \) so that it is equal to the average bulk velocity during stimulation with a single pulse of 3 V/cm.

For numerical solution of the BVP, we use the bvp4c scheme of Kierzenka et al. implemented in Python through the SciPy package Virtanen et al. (2020). This scheme implements a fourth-order collocation algorithm with control of the residuals and uses a damped Newton method with an affine-invariant criterion function. For the implementation, we set a maximum relative tolerance of \(10^{-3}\), an absolute boundary value tolerance of \(10^{-6}\) and specify a maximum of \(10^6\) nodes for the collocation algorithm.

Fig. 5
figure 5

Solution to optimal control problem for constant bulk speed (optimal solution for the problem in Eq. (33)) during stimulation with an electric field. Left: bulk speed for constant velocity (solid line) plotted alongside experimental data with constant electric field stimulation protocol (dashed line). Middle: numerical solution of the optimal control problem for constant velocity (solid line) plotted against reference normalized electric field strength (dashed line). Right: effective signal, \(s_{\text {eff}}\). Parameter values correspond to the posterior means for \(\alpha \), \(\tau _a\), \(\tau _e\), and the pre-computed value for \(\gamma \)

Figure 5 shows that the electric field profile needed to produce a constant velocity profile is very strong initially and rapidly decays to create a constant effective signal, \(s_{\text {eff}}\). In fact, the field strength predicted here is 75 V/cm, which is not physiologically realistic, as it would lead to toxicity and rapid cell death. This finding suggests that given the physiological constraints of the problem, it is not possible to design an optimal control experiment that creates a constant speed profile with the same average velocity as that arising from pulse stimulation. This large initial peak in electric field strength arises from the requirement that the tissue hits a constant velocity quasi-instantly upon stimulation. This finding invites the question of which constant velocity values are feasible to achieve given that the solution profile needs to be realistic, i.e. given the physical constraints on the electric field strength. To this end, we perform a grid search, whereby we solve the optimal control problem for a range of target velocities, \(v^\star \), ranging from 0 to 40 \(\upmu \)m/h. For each of these terminal velocities, we solve the BVP for the optimal stimulation protocol and compute the resulting bulk velocities and optimal stimulation strategy. We summarise the results in Fig. 6.

Fig. 6
figure 6

Stimulation profiles and electric field strengths for varying terminal velocities in optimal solutions to the problem in Eq. (33)). From left to right. Bulk velocity when using optimal control solution for constant stimulation using different values of terminal velocity (see legend). Optimal stimulation profile corresponding to the different terminal velocities in the left panel. Electric field strength at the start of stimulation. Electric field strength averaged during stimulation. Note the difference in the magnitude of the axes. Parameter values correspond to the posterior means for \(\alpha \), \(\tau _a\), \(\tau _e\), and the pre-computed value for \(\gamma \) (color figure online)

Figure 6 shows that at each of the values for the terminal velocity, \(v^\star \), the model predicts that an optimal stimulation strategy can be designed so that the bulk moves at this constant speed. Each of these stimulation profiles has the same shape, whereby a very large current is applied at the beginning of the experiment, which slowly decreases during the course of the experiment. We investigate the relationship between the desired terminal velocity and the field strength at the onset of stimulation as required by the model. We see that there is a linear increase in the normalised electric field density with \(v^{\star }\) and that the initial electric field strength is prohibitively large for velocities higher than 5 \(\upmu \)m/h. This is surprising and experimentally frustrating given that the mean electric field strength predicted by the model only shows a marginal increase with the desired terminal velocity, whereby all terminal velocities experience a normalised electric field strength that is physiologically tolerable. We conclude, thus, that designing a realistic electric field to maintain the tissue bulk at constant velocity, while keeping the electric field strength within realistic bounds, is not possible.

The source of the unphysically strong electric field at the start of stimulation is the requirement that the field immediately reaches the desired velocity. At the same time, the velocity in the period after the onset of stimulation is constant, with a far smaller field strength than that required at the beginning. Motivated by these two facts, we ask if we can overcome the problem of non-realistic predictions for the initial field strength by setting a maximum field strength allowed for s. We expect this might come at the cost of reaching the target velocity at the beginning of stimulation. We allow for the field to have a field strength of at most 9V/cm, which is around the limit at which electric fields are tolerated in vitro. For the optimal control problem in Eq. (33), we require that the physical optimal solution, \(s^\star _{\text {phys}}\), satisfies

$$\begin{aligned} s_{\text {phys}}^\star = \min \left( s^\star , s_{\max }\right) , \end{aligned}$$
(36)

where \(s_{\max }\) is a parameter we can vary. By considering \(s_{\max }\) across a range between 3 and 9 V/cm, we solve the optimal control problem and show the results in Fig. 7. We set \(v^\star \) as the mean velocity in the 3V/cm pulse experiment and now vary \(s_{\max }\). While the solutions are qualitatively similar and the velocity is constant during most the experiment, the solutions are not identical. A closer inspection of the terminal velocity error shows that solutions with a weaker initial field have a larger error at the end, implying that the large initial pulse is what is necessary to create the terminal velocity, but it is the temporal evolution of the field which is necessary to create a plateau. While this error decreases rapidly for small values of the maximum field strength, \(s_{\max }\), a close agreement with the desired cruise velocity is only achieved, once again, with unfeasibly high electric field strengths.

Fig. 7
figure 7

Optimal stimulation to keep the velocity constant during stimulation. Field strengths are solutions are solutions to the problem in Eq. (33) with maximum field strength defined as in Eq. (36). Left: bulk velocity using different maximum electric field strengths (see legend). Middle: physical electric field profile showing similar stimulation protocols. Right: terminal velocity error decreases when the maximum normalized electric field strength increases. Parameter values correspond to the posterior means for \(\alpha \), \(\tau _a\), \(\tau _e\), and the pre-computed value for \(\gamma \) (color figure online)

4.3 Constant Velocity During a Small Time Interval

When the goal was to optimise to keep the velocity constant, as in the previous section, we observed that the electric field profile had a non-physically high field density at the start of stimulation, making this optimal control strategy infeasible in practise. This comes from requiring that the velocity hits the target velocity, \(v^\star \), quasi-instantly upon the start of stimulation. Here, we ask the question of how solutions change when instead the velocity is only required to be constant on an interval \([t_1, t_2]\) with \(0< t_1< t_2 < T\). Here, we will explore how the optimal electric field profile is affected by this requirement. We will also study how solutions are affected by altering the values for the start and end of stimulation, \(t_1\) and \(t_2\), respectively.

The functional in Eq. (33) needs to be modified to address the optimality condition that the velocity is constant on the interval. This is because minimising the square of acceleration \(\dot{v}^2\) as in Eq. (33) leads to a trivial solution for the velocity: when the velocity is assumed to be zero by the initial conditions and the velocity is continuous, the optimal solution will be zero throughout the stimulation time frame. Therefore, one must consider a functional that directly relates the velocity during the interval \([t_1, t_2]\) to the target velocity. Such a functional can be defined as

$$\begin{aligned} I(v) = \int _0^T \mathbb {I}(t \in [t_1, t_2])\cdot (v-v^\star )^2 \text {d}t, \end{aligned}$$
(37)

where \(\mathbb {I}\) is an indicator function. This indeed restricts the constant velocity requirement to the desired interval, but the integrand is no longer a continuous function of time. To make the optimisation problem admissible, we choose to approximate the indicator function in the integrand by a smooth bump function, \(\Phi \), which we define as

$$\begin{aligned} \Phi (t) = \frac{1}{1 + \exp \left( - \frac{t - t_1}{\epsilon }\right) }\cdot \frac{1}{1 + \exp \left( - \frac{t_2 - t}{\epsilon }\right) }, \end{aligned}$$
(38)

where \(\epsilon \) determines the length scale of the region where the function \(\Phi \) transitions from zero to one. We set \(\epsilon = 50^{-1}\) so that \(\epsilon \ll t_1\) in all of our considered optimisation problems. Now we obtain an admissible optimal control formulation, given by

$$\begin{aligned} E(v) = \int _0^T \Phi (t)\cdot (v-v^\star )^2 \text {d}t, \end{aligned}$$
(39)

which yields a modified version of the adjoint equations for \(\lambda _v\) and \(\lambda _{s_{\text {eff}}}\), which are Eqs. (34) and (35), respectively. These become

$$\begin{aligned} \frac{\text {d}\lambda _v}{\text {d}t}&=\Phi (t)\cdot 2(v - v^\star ) + \gamma \lambda _v, \end{aligned}$$
(40)
$$\begin{aligned} \frac{\text {d}\lambda _{s_{\text {eff}}}}{\text {d}t}&= - \alpha \lambda _v + \tau _e^{-1} \lambda _{s_{\text {eff}}}, \end{aligned}$$
(41)

subject to the terminal conditions \(\lambda _\bullet (T) = 0\). Note that, in contrast to the optimal control problem for constant velocity in the previous subsection, there is no need to set up a terminal condition for the velocity. This means that the zero initial conditions of Eq. (8) can be imposed. As before, we solve this boundary value problem using the bvp4c numerical scheme introduced in Sect. 4.2.

To determine the range of admissible values for the interval \([t_1, t_2]\), we make the assumption that \(t_2 = T-t_1\), i.e. the stimulation interval is symmetric within the interval [0, T]. A priori, \(t_1\) should be chosen sufficiently large that a physically realistic electric field is optimal, but not so large that the field is off at \(t = 0\). To understand how to choose \(t_1\), then, we note that there exist two characteristic times in this optimal control problem. First, since constant stimulation for times longer than the adaptation time scale, \(\tau _a\), results in a waning response from the field, choices for \(t_1\) that result in the stimulation time being too long, i.e., \((T-t_1)/2 \gg \tau _a\), will require a large value of the electric field initially to prevent cellular adaption to the field and will hence provide unphysical solutions that are not realistic stimulation protocols in practice. At the same time, one might expect that there is a time scale that dictates when the field is initially on at \(t=0\)h and when it is off: if the waiting time from the beginning of stimulation, \(t_1\), is shorter than this critical time scale, the electric field should be turned on immediately, since otherwise the monolayer will not reach the target velocity during the optimality time window. Intuitively, this time scale should be of the same order as the time it takes for the velocity to reach its maximum under a constant electric field. We can estimate of this time scale, \(\tau _{\max }\), by maximising the expression in Eq. (3), which yields

$$\begin{aligned} \tau _{\max } = \frac{\log (\tau _a) - \log (\tau _e)}{\tau _e^{-1} - \tau _a^{-1}}. \end{aligned}$$
(42)

For \(t_1 > \tau _{\max }\) one would therefore expect that the optimal electric field density is zero at \(t = 0\), while for \(t_1 < \tau _{\max }\) one would expect that the density is nonzero. Therefore, one would expect that choices of \(t_1\) in the region

$$\begin{aligned} t_1 \in \left[ \frac{T-\tau _a}{2}, \tau _{\max }\right] , \end{aligned}$$
(43)

will yield optimal electric field protocols that are high at the onset of stimulation when \(t_1\) is at the left boundary of the interval, or electric field protocols that slowly ramp up after the onset of stimulation. We also expect values of \(t_1\) smaller than the values in this range to yield physically unrealistic electric field protocols, and solutions for \(t_1\) larger than the values in this range to have a near-zero initial electric field strength. In Fig. 8, we show how the optimal electric field protocol changes when different values for \(t_1, t_2, v^\star \) are used.

Fig. 8
figure 8

Optimal control to keep velocity constant in a small time window (solutions to the optimal control problem in Eq. (39)). Left: bulk velocity traces using different values of \(t_1\) for stimulation. Middle: electric field strengths with different values of \(t_1\). Right: initial electric field strength in the optimal control solution as a function of \(t_1\). Parameter values correspond to the posterior means for \(\alpha \), \(\tau _a\), \(\tau _e\), and the pre-computed value for \(\gamma \) (color figure online)

Figure 8 shows that the optimal electric field protocols change qualitatively as \(t_1\) is varied. For small values of \(t_1\), close to \(\tau _a\), the optimal electric field protocol exhibits a sharp overshoot of the velocity prior to reaching a plateau in the desired interval. This is achieved by the optimal electric field protocols exhibiting a sharp peak initially, bringing the velocity above the target, and then letting the velocity decrease to the target. This overshoot disappears whenever \(t_1 > \tau _{\max }\). In this regime, the field allows the velocity to slowly increase to the desired target velocity. All optimal electric field protocols exhibit a ramp. This effect is clearly visible in the final plot of Fig. 8, which shows that there is a sharp decrease in the initial field strength whenever \(t_1 < \tau _{\max }\). We conclude that a constant velocity can be achieved without having an overshoot when the waiting time, \(t_1\), is sufficiently long. Finally, we note that by performing a grid search across possible values for the target velocity, \(v^\star \), we found that these results do not change qualitatively with the value of \(v^\star \), as the only change is that the maximum magnitude of the optimal electric field protocol scales linearly with \(v^\star \).

4.4 Comparison to Bang–Bang Control

The modest gain in distance travelled by the tissue predicted when the optimal stimulation protocol is used suggests that naive stimulation by keeping the electric field at constant field density might be an effective policy. This is not surprising given that it is the policy converged upon after years of experimental iteration, and that the key variable here is when to switch off the field. This is reminiscent of bang-bang control in linear optimisation theory. Bang-bang control occurs when the Hamiltonian, H, of the optimal control problem is linear in the control variable, so that it disappears from the optimality condition altogether (Lenhart and Workman 2007). In our problem the Hamiltonian is nonlinear due to the \(\mu _zS^2\) term included to enforce the condition that a fixed amount of charge is injected into the system. If one now assumes instead that the field is always positive, the condition could be relaxed so that instead S is bounded by some maximum strength, \(0 \le S \le S_{\max }\). When the isoperimetric constraint is removed, the Hamiltonian becomes

$$\begin{aligned} H = v^2 + \lambda _v(t) \left[ -\gamma v + \alpha s_{\text {eff}}\right] + \tau _e^{-1}\lambda _{s_{\text {eff}}}(t)\left[ s - s_{\text {eff}} - I \right] + \tau _a^{-1}\lambda _I(t)\left[ s-I\right] ,\nonumber \\ \end{aligned}$$
(44)

with optimality condition

$$\begin{aligned} \frac{\partial H}{\partial S} = \tau _e^{-1} \lambda _{s_{\text {eff}}} + \tau _a^{-1}\lambda _I, \end{aligned}$$
(45)

so that the optimal control is given by \(s^\star = s_{\max }\), whenever the right-hand side of Eq. (45) is positive by the Pontryagin optimality criterion. This, we have established in the previous numerical experiments, holds whenever \(t < T\). In sum, we find that naive stimulation with a pulse is the optimal stimulation policy when the condition of total injected charge is relaxed and replaced instead with an upper bound on the electric field strength.

5 Discussion and Outlook

In this work we have developed and calibrated a canonical model for excitation-adaptation to describe the cellular response to collective electrotaxis, and we have identified that the mechanism of excitation and adaption can faithfully describe the temporal dynamics of the bulk response to electric field stimulation. We have used this model to optimise for different experimental outcomes, including maximising the total distance travelled by the tissue bulk, maximising the terminal velocity, and keeping the migration velocity constant.

Our model shows that maximising the distance travelled by the tissue bulk is possible by changing the temporal distribution of electric field strength, but it only produces a marginal increase in performance relative to stimulation with an electric field with constant field strength. In fact, this increase is well within the standard deviation of the experimental data. We related the near-optimal performance of the constant stimulation experiment to the fact that constant stimulation is the solution to a bang-bang control problem. A similar insight arises from controlling the maximum terminal velocity of the tissue, which recovers a ramp, but has an unphysically large field strength at the end of electric field stimulation. Together, this challenges the idea in the electrotaxis community that a bulk velocity that is not constant during stimulation – but rather exhibits a sharp peak and a rapid decrease during stimulation –is not optimal, as this velocity profile is in close agreement with the optimal solution for the maximum distance travelled for the tissue bulk.

Most importantly, our analysis shows that it is not possible to generate a constant velocity profile during electrotaxis when the experimental time exceeds the adaptation time scale, \(\tau _a\). This is reflected in the prediction that an unphysical field strength is necessary to create a constant velocity profile for the duration of the experiment. When we relaxed the constraint to allow the tissue to slowly increase to the desired velocity and then remain constant, such optimal electric field protocols only yielded velocity profiles without an overshoot whenever the stimulation time satisfied certain constraints. Together, these findings show that there exist physical limits to how we can stimulate, both in terms of duration of the experiment, and physiological constraints on electric field strength.

In the context of collective electrotaxis, this work can be extended and applied in several possible ways. Firstly, our framework establishes a reproducible and predictive model for collective cell migration that can be used to develop new experimental approaches. Conversely, experimental data can help validate and develop the optimal control framework proposed in this work. More generally, our modelling approach can be generalised and extended to be used in other contexts where there exists a desired collective migration outcome and one must find an optimal electric field protocol to achieve this pattern of migration. This can be achieved directly in our framework by expressing the desired movement pattern as the optimal solution to a linear control problem and using the optimal control framework put forth in this work. Secondly, in this work we have only considered uniaxial electric fields, while experimental set-ups exist to apply spatially dependent fields (Cohen et al. 2014; Leal et al. 2023; Song et al. 2021). Our framework can be extended to optimise for desired migration outcomes that vary in both time and space. For the optimisation and control of spatially varying fields, one must first develop a spatial model of collective electrotaxis that takes into account the different migratory cues that are present in the different parts of the monolayer. Such a spatially resolved model will enable the design and implementation of physically relevant applications of electrotaxis, such as those used in wound healing or steering collective migration. Finally, this work provides a blueprint for using optimal control theory in conjunction with external inputs that can be modulated in time, to control cellular collectives. Such a tunable external input might, for example, be implemented in the context of chemotaxis, which was the external signal originally modelled by Erban and Othmer (2005). By carefully setting up an optimal control problem corresponding to the maintenance and adaptation of a chemical gradient, one could aid the experimental design of microfluidics or other ways of maintaining chemical gradients to ensure desired outcomes during chemotaxis.