Optimization along families of periodic and quasiperiodic orbits in dynamical systems with delay

This paper generalizes a previously conceived, continuation-based optimization technique for scalar objective functions on constraint manifolds to cases of periodic and quasiperiodic solutions of delay-differential equations. A Lagrange formalism is used to construct adjoint conditions that are linear and homogenous in the unknown Lagrange multipliers. As a consequence, it is shown how critical points on the constraint manifold can be found through several stages of continuation along a sequence of connected one-dimensional manifolds of solutions to increasing subsets of the necessary optimality conditions. Due to the presence of delayed and advanced arguments in the original and adjoint differential equations, care must be taken to determine the degree of smoothness of the Lagrange multipliers with respect to time. Such considerations naturally lead to a formulation in terms of multi-segment boundary-value problems (BVPs), including the possibility that the number of segments may change, or that their order may permute, during continuation. The methodology is illustrated using the software package coco on periodic orbits of both linear and nonlinear delay-differential equations, keeping in mind that closed-form solutions are not typically available even in the linear case. Finally, we demonstrate optimization on a family of quasiperiodic invariant tori in an example unfolding of a Hopf bifurcation with delay and parametric forcing. The quasiperiodic case is a further original contribution to the literature on optimization constrained by partial differential BVPs.


Introduction
The optimization of time-delay systems has been the subject of intensive research for many years. Such systems arise naturally in control applications where unmodeled actuator dynamics results in delays between input signals and actuator responses [19], car following models that account for driver reaction times [15], and machine tool dynamics due to the regenerative effect [20]. The wide range of applications has motivated the development of novel techniques for their optimization. For example, Göllmann et al. [4] used a formulation based on the Pontryagin minimum principle to derive necessary optimality conditions for optimal control problems with delays in state and control variables. The obtained equations were discretized and transformed into a large-scale nonlinear programming model, which was then solved using off-the-shelf solvers. In another investigation, Yusoff and Sims [22] combined the semi-discretization method [10] for time-periodic delay equations with differential evolution to optimize a variable helix/pitch tool geometry for regenerative chatter mitigation. Their results were also validated experimentally, confirming the predicted significant improvements arXiv:1901.09121v1 [math.DS] 26 Jan 2019 in chatter stability. This problem of optimal selection of parameters for subtractive manufacturing was also reported in [8,9,21]. Liao et al. [13] developed an optimization technique for periodic solutions of delay differential equations using the harmonic balance method and continuation techniques. They posed an amplitude optimization problem subject to the algebraic constraints obtained by substitution of a truncated Fourier representation in the governing equation along with the stability conditions. The sensitivity expressions were analytically derived, and the optimization problem was then solved for the unknown Fourier coefficients and the unknown parameters. The delayed Duffing oscillator was used to validate the methodology.
The calculus of variations serves as a useful tool for constrained optimization problems. Here, a Lagrangian functional is constructed by combining the objective function with the imposed constraints using Lagrange multipliers (adjoint variables) as coefficients. The vanishing of the variations of the Lagrangian with respect to the design variables and the Lagrange multipliers then yields the necessary optimality conditions for a stationary point. In general, these equations cannot be solved directly. Instead, nonlinear solvers may be applied to various finite-dimensional discretizations. A major challenge with this approach is the selection of a good initial guess which converges to the desired solution. A resolution built on principles of parameter continuation was originally proposed in the work of Kernévez and Doedel [11]. There, a sequence of properly initialized stages of continuation along one-dimensional manifolds of solutions to a subset of the necessary optimality conditions was used to connect the local extremum to an initial solution guess with vanishing Lagrange multipliers. This methodology was recently revisited by Li and Dankowicz [12] and there cast in terms of partial Lagrangians relevant to the general context of constrained optimization of integro-differential boundary-value problems without delay. Importantly, this work showed how the Lagrangian structure was consistent with a staged construction paradigm implemented in the software package COCO. In this work, we generalize the successive continuation approach of Kernévez and Doedel to optimization along families of periodic and quasiperiodic orbits in dynamical systems with delay. We derive the necessary optimality conditions from a suitably constructed Lagrangian without first discretizing the governing equations and unknowns. This approach is in contrast to other studies [16], in which the discretization of the governing equations is first carried out and then the Lagrangian is constructed based on the discretized equations.
In our formulation, the Lagrange multipliers satisfy coupled, piecewise-defined, boundary-value problems with both delayed and advanced arguments. Depending on the imposed constraints, the Lagrange multipliers may be discontinuous or nonsmooth at the interval boundary points, naturally resulting in a multi-segment problem [1].
We first motivate our interest and approach with the problem of optimization of the response amplitude of a harmonically-forced, scalar, linear, delay-differential equation in Sect. 2. The general framework for problems with single delays is then considered in Sect. 3, first for periodic orbits and subsequently for families of two-dimensional quasiperiodic invariant tori. As discussed in detail, the latter optimization problem falls into the category of constrained optimization for partial differential equations (PDEs) [5,6,14], for which the necessary optimality conditions take the form of coupled, piecewise-defined PDEs with non-local coupling, as well as associated boundary and interval conditions representing periodicity in one dimension and rotation in the other. Subsections of Sect. 3 consider example applications to the search for a saddle of the response amplitude of a harmonically-forced Duffing oscillator subject to delayed feedback control and a geometric fold along a family of quasiperiodic trajectories for constant rotation number. Analysis using the COCO software package validates the successive continuation approach, as well as the simultaneous discretization of the dynamic constraints and adjoint equations. A number of additional considerations and opportunities for future work are considered in the concluding section.

Motivating Example
We illustrate the general framework for optimization along families of solutions to delay-differential equations (DDEs) by first considering periodic responses z(t) of frequency ω for a harmonically-forced, scalar, linear, delay-differential equatioṅ where we omit (here, and throughout the paper) functional arguments when they are obvious from the context. It follows from the method of undetermined coefficients that such responses are of the harmonic form where r(ω) = 2 + ω 2 − 2ω sin ω + 2 cos ω and Let us consider the optimization problem of finding the forcing frequency ω for which such a periodic response has maximum amplitude. It follows from (3) that the maximum amplitude r crit . = r(ω crit ) ≈ 0.89 is achieved for ω crit ≈ 1.72 (cf. Fig. 1), and that z(t crit ) = r crit at time t crit . = θ (ω crit )/ω crit ≈ 2.24 (up to multiples of the period T crit . = 2π/ω crit ≈ 3.65). Hence, for this simple optimization problem all components of the solution are known exactly, enabling a comparison with the results of numerical algorithms.  Fig. 1: Frequency-response diagram for the steady-state periodic solutions of the harmonically-forced, scalar, linear delaydifferential equation (1). The maximum value of the amplitude is r crit ≈ 0.8911 which occurs for ω = ω crit ≈ 1.7207 (T = T crit ≈ 3.6516).

Formulation as a constrained optimization problem
We transform the above optimization problem into a format suitable for a general numerical solver by introducing the excitation period T = 2π/ω as an unknown (T replaces ω) and rescaling time (calling the new time τ) such that x(τ) . = z(T τ + T φ /2π). Here, the free phase φ is to be chosen so as to shift the time on the interval [0, 1] when the periodic solution x has a critical point to τ = 0. Thus, we are seeking a solution to the constrained optimization problem with respect to a continuous function x on [0, 1], as well as the variables T and φ , subject to the equality constraints for τ ∈ (0, 1/T ), for τ ∈ (1/T, 1), Here, the constraints (6) and (7) impose the original delaydifferential equation on the interval (0, 1). They rely on periodicity to wrap the delayed argument back into this interval assuming that T > 1. The constraints (8) and (9) are boundary conditions. Constraint (8) imposes periodicity also on the interval boundary, while (9) is a phase condition that ensures that x (0) = 0, consistent with x having a critical point at τ = 0 and justifying the maximization of x(0) as a substitute for the amplitude. By continuity of x on [0, 1] and (8) it follows that x is, in fact, a smooth function on [0, 1]. Indeed, from the explicit solution in the previous section, it follows that x(τ) = r(2π/T ) cos 2πτ and φ = θ (2π/T ) and, in particular, that optimality is obtained for x(τ) = x crit (τ) . = r crit cos 2πτ and φ = φ crit . = θ (2π/T crit ) for T = T crit . The constrained optimization problem (5)- (9) gives rise to the Lagrangian where the Lagrange multipliers are λ 1 (τ) (a function on [0, 1]) for the DDE constraints (6) and (7), λ 2 and λ 3 for the boundary conditions (8) and (9), and η A for the relationship between the fitness µ A and x(0) in (5).
In (10), the integral for the pairing between λ 1 and the DDE constraints has been split into 4 parts, one for each of the intervals (0, 1/T ), (1/T, 1 − 2/T ), (1 − 2/T, 1 − 1/T ), and (1 − 1/T, 1), reflecting different functional forms of the differential equations (6) and (7) for x on (0, 1/T ) and (1/T, 1), respectively, and anticipating possible discontinuities in λ 1 and λ 1 . For example, the split at τ = 1 − 1/T is in anticipation of a potential discontinuity of the Lagrange multiplier λ 1 at this instant caused by the imposition of a constraint on x evaluated at this time in (9). This discontinuity implies a potential discontinuity of λ 1 at τ = 1 − 2/T . For the same reason, the appearances of x(0) in (5) and (9) suggest that λ 1 (0) = λ 1 (1) resulting in a potential discontinuity of λ 1 at τ = 1 − 1/T . All functions are assumed to be continuously differentiable on the partition implied by the integrals in (10). The ordering of the discontinuity points assumes that T > 3 ( Fig. 1 shows that the optimal T is in this range).
Imposing vanishing variations of the Lagrangian L with respect to variations in all its arguments recovers the original constraints (5)-(9) and the following adjoint system determining the Lagrange multipliers. Specfically, vanishing variations with respect to x imply −λ 1 + T λ 1 + T λ 1 (τ + 1/T ) = 0 (11) for τ ∈ (0, 1/T ) ∪ (1/T, 1 − 2/T ) ∪ (1 − 2/T, 1 − 1/T ) and for τ ∈ (1 − 1/T, 1). Boundary and interface conditions for these equations are obtained by considering variations with respect to x(0), x(1/T ), x(1 − 2/T ), x(1 − 1/T ), and x(1), corresponding in that order to using the convention that λ 1 (τ * ) ± . = lim τ→τ * ± λ 1 (τ) and recalling that x(τ) is continuous on [0, 1]. Vanishing variations with respect to φ and T imply the integral constraints and respectively. Finally, vanishing variation with respect to µ A implies that In summary, the system of original contraints (5)-(9) and adjoint equations (11)-(20) is a nonlinear integro-differential boundary-value problem (BVP) defining the critical points of the Lagrangian L and the constrained optimization problem (5)- (9). In this example, the dimension of the manifold on which the constrained optimization problem is posed equals 1, corresponding to the numbers of degrees of freedom of the nonlinear subsystem (5)-(9) (with variables x, T and φ ). In contrast, the full system (5)-(9), (11)- (20) has no such degrees of freedom and, consequently, generically has only isolated solutions. Several properties put it beyond the reach of "offthe-shelf" BVP solvers: 1. It consists of differential equations on multiple intervals (thus, the problem is called a multi-segment BVP) with differential functional forms and continuous "righthand sides". The number and length of these intervals is strongly problem dependent, and may even change during the optimization process. 2. The differential equations evaluate their right-hand sides at times deviating from τ (delayed or advanced arguments).
3. The second point leads to nonlocal coupling across segments that is not restricted to coupling at the boundaries of the intervals. For example, (11) couples the values of On the other hand, the system (5)-(9), (11)- (20) has some additional structure that aids both in its construction and solution: 1. The equations are only forward coupled in that a solution to the original constraints (5) (20)) are linear and homogeneous in the Lagrange multipliers λ j ( j = 1, 2, 3) and η A . A trivial solution of this subset of the adjoint system is therefore given by vanishing Lagrange multipliers for any x, T , and φ . 3. The adjoint equation (20) is trivial both in construction and solution. Imposing its solution (η A = 1) on the remaining adjoint system, however, renders the latter nonhomogeneous.
This structure will also be present for more general cases than the example and can be exploited in the search for solutions, as well as to generate the adjoint equations (11)- (19) automatically during a staged construction of the optimization problem similar to [12].
In this example, a few facts about the Lagrange multipliers may be deduced directly from the adjoint equations. It follows immediately from (14) and (15) that λ 1 is continuous at τ = 1/T and τ = 1 − 2/T , and from (11) that λ 1 is continuous at τ = 1/T . Moreover, using the explicitly known solution for x, it follows that the Lagrange multiplier λ 3 must equal 0 at a local extremum. Indeed, substitution of the modified phase condition in lieu of (9) implies that where φ is implicitly determined by for δ ≈ 0. Implicit differentiation of both conditions with respect to the residual δ shows that the rate of change of µ A with respect to δ equals 0 at δ = 0. This, in turn, implies that that λ 3 = 0 at an extremum, i.e., that λ 1 is, in fact, continuous also at τ = 1 − 1/T and, consequently, continuously differentiable also at τ = 1 − 2/T . In contrast, λ 1 experiences a discontinuity at

Simple continuation
According to the properties enumerated above, a solution to (5)-(9), (11)-(20) may be sought using a method of successive continuation [11,12] with an embedded multi-segment boundary-value problem implementation that permits evaluation of the right-hand side at arguments shifted by arbitrary times. Specifically, this method overcomes the problem of initializing a nonlinear solver for the full system by defining a sequence of continuation problems with one-dimensional solution manifolds that connect an initial solution guess with Lagrange multipliers all equal to 0 with the sought critical point for which η A must equal 1.
To this end, we consider the system given by the relationship between µ A and x(0) in (5), the boundary-value problem constraints (6)- (9), and the adjoint integral-differential boundary-value problem (11)- (19), but purposely omit the algebraic constraint (20). Although we anticipate that λ 3 will equal 0 throughout the analysis, we keep λ 3 as an unknown and monitor its value during continuation. By linearity and homogeneity of the adjoint subsystem in the Lagrange multipliers λ j and η A , it follows that solutions to the full system lie on either of two one-dimensional manifolds. The first of these consists of functions x(τ) = r(2π/T ) cos 2πτ with corresponding T , φ , and µ A = x(0) = r(2π/T ), and with vanishing Lagrange multipliers. The second manifold consists of the periodic solution x crit (τ) = r crit cos 2πτ with corresponding T = T crit , φ = φ crit , and µ A = r crit , and with varying Lagrange multipliers proportional to η A . The two manifolds clearly intersect at the local extremum of µ A along the first manifold. The sought solution to the complete set of equations (5)-(9), (11)- (20) corresponds to the point along the second manifold where η A = 1.
In this example, the solutions along the first manifold are known explicitly. In other cases, an initial periodic response may be approximately obtained from the dynamically stable solution by direct simulation. Given such an initial solution guess for x, T , and φ , a nonlinear solver may be employed to converge to a point on the manifold. A numerical continuation algorithm (e.g., pseudo-arclength continuation) may then be used to generate a sequence of points along the manifold, meanwhile monitoring for local extrema of µ A and singular points for the system Jacobian (corresponding to branch points on the manifold). As shown above, and true also in the general case, these coincide. Using standard techniques, numerical continuation may proceed from such a branch point along the secondary manifold with the help of a candidate direction of continuation, for example, one that is i) transversal to the tangent direction to the original solution manifold and ii) in the plane spanned by the tangent directions to the two manifolds at the branch point.
Continuation using such an implementation in the COCO software package [18] approximately locates an extremum (in the form of a fold point in µ A along the solution manifold) at T ≈ 3.6515 as shown in Fig. 2. Branch switching from the nearby branch point (exact coincidence is lost due to discretization) and continuation until η A = 1 yields the graphs of x(τ) and λ 1 (τ) shown in Fig. 3. As seen in the bottom panel, λ 1 (τ) is approximately continuous at 1 − 1/T ≈ 0.73, albeit with discontinuous derivative at this point, since λ 1 (0) − λ 1 (1) = 1.

General Optimization Framework
In this section, we discuss the general methodology for optimization on periodic and quasiperiodic solutions z(t) ∈ R n of delay-differential equations with a single delay of the forṁ where f : R 1 × R n × R n × R q → R n is periodic in its first argument with period T . Here, α and p denote the time delay and the problem parameters (excluding T ), respectively.
As the motivating example in the previous section illustrates, the problem Lagrangian and, by implication, the adjoint equations are linear in the Lagrange multipliers. The adjoint equations may therefore be constructed term-by-term by successively deriving the contributions from disjoint collections of constraints from the corresponding partial Lagrangians associated with a subset of the Lagrange multipliers. Until the full set of constraints has been considered, the adjoint equations are not completely known. The following subsections discuss the partial Lagrangians and the implied contributions to the adjoint equations resulting from the DDE constraints and boundary conditions associated with periodic and quasiperiodic orbits. For particular examples, we indicate the additional contributions associated with problem-specific constraints that complete the construction of the adjoint equations. In all cases, the contribution from the objective function to the Lagrangian implies the algebraic adjoint condition that the corresponding Lagrange multiplier (η A in the previous section) must equal 1 at a stationary point.

Periodic orbits
Suppose first that T > α and consider the problem of optimizing a scalar-valued objective functional on a family of continuous solutions x(τ) to the differential equations for τ ∈ (α/T, 1), (26) and the boundary conditions By a rescaling of the independent variable by T , such solutions correspond to periodic solutions of (24) with period T . By continuity and periodicity, such solutions must be continuously differentiable to all orders. Suppose, in fact, that T > 3α and that the objective functional and any additional constraints depend on pointwise values of x(τ) only at τ = 0, τ = 1, and τ = β for some β = β (α, T ) such that 2α/T < β < 1 − α/T.
As we show below, such dependence results in an additional adjoint equation associated with variations with respect to x(β ). Other pointwise dependencies of the objective functional would be treated similarly, while dependence on an integral over the entire interval [0, 1] of a function of x would not result in additional adjoint equations. We may formulate a corresponding partial Lagrangian Here, λ f (τ) and λ bc are the Lagrange multipliers associated with the imposition of the differential equations and boundary conditions, respectively, and each integrand is assumed to be continuously differentiable on the corresponding interval. The splitting of the integral is here motivated by an anticipated discontinuity of λ f at τ = β and, consequently, of λ f at τ = β − α/T , the different functional forms of the original DDEs on the intervals (0, α/T ) and (α/T, 1), and an anticipated discontinuity in λ f also at τ = 1 − α/T . By the stated assumptions on the objective function and any additional constraints, it is easy to show that, at a stationary point of the total Lagrangian, λ f (τ) must be continuous at τ = α/T , τ = β − α/T , and τ = 1 − α/T . Using the notation for j = 0, 1 and q = α, T (∂ k f is the partial derivative of f with respect to its kth argument, d/dq is the total derivative of an expression with respect to q), the contributions to the necessary adjoint conditions for a stationary point of the total Lagrangian are given by for variations with respect to x(τ) on τ ∈ (0, α/T ); for variations with respect to x(τ) for variations with respect to x(τ) on τ ∈ (1 − α/T, 1); for variations with respect to x(0), x(β ), and x(1), respectively; for variations with respect to α; (37) for variations with respect to T ; and for variations with respect to p. The terms f j,T and f j,α in (36) and (37) both contain time derivatives x with delayed or advanced arguments, since T and α both appear in the evaluation of x in the third arguments of f 0 and f 1 .
As previously anticipated, the explicit dependence of the Lagrangian on the internal state point x(β ) results in a potential discontinuity of the Lagrange multiplier λ f (τ) at τ = β . Continuous differentiability of x(τ) on [0, 1] and of λ f (τ) on (0, β − α/T ), (β − α/T, β ), (β , 1 − α/T ), and (1 − α/T, 1) implies that the necessary conditions for an extremum are in the form of a multi-segment boundary-value problem in a single trajectory segment for x(τ) and four coupled trajectory segments for λ f (τ). A similar result is obtained, for example, in the limiting case when β = 1 − α/T . This case specializes to the example discussed in the previous section, since there α = 1, β = 1 − 1/T , and T > 3. In contrast, when β is either 0 or 1, i.e., when there is no dependence of the objective function or any additional constraints on an internal point, then we obtain a single trajectory segment for x(τ) and three coupled trajectory segments for λ f (τ) with both variables continuous throughout the interval [0, 1].

A Duffing oscillator with delayed PD control
As an application of the general methodology when β = 0, consider the harmonically-forced Duffing oscillator with delayed state (proportional and derivative; PD) feedback given by the DDË Inspired by [7], for fixed ζ , µ, a, b, and γ, we seek a delay α that minimizes the maximum amplitude of oscillation along a family of periodic responses of this system under variations in the excitation period T . Since the optimization problem involves minimizing a maximum, it corresponds to the search for a saddle point in the value of the oscillation amplitude on the two-dimensional constraint manifold. Following Section 2.1, let x 1 (τ) . = z(T τ + T φ /2π) and x 2 (τ) . =ż(T τ + T φ /2π) represent the displacement and velocity, respectively, on the rescaled time interval [0, 1]. The phase φ is again to be chosen so as to shift the time on this interval when the oscillator reaches its maximum displacement to τ = 0. It follows that the objective functional is given by for solutions of (25)-(27) subject to the phase condition and corresponding to the vector field where p = φ . The partial Lagrangian for the objective functional and phase condition is where λ ph and η A are additional Lagrange multipliers. This partial Lagrangian adds the term (η A , λ ph ) T to the variation with respect to x(0) in (35) (first term) and results in the algebraic adjoint constraint assuming no additional dependence of the problem Lagrangian on µ A . Since neither the objective functional nor the additional phase condition depend on x evaluated at an interior point of the interval [0, 1], it follows that λ f is continuous on the entire interval. This simplifies the partial Lagrangian L BVP in (29) as the two integrals with boundary β can be combined, and the resulting adjoint DDE contribution (33) can be applied on the combined interval (α/T, 1 − α/T ), such that λ f (τ) is in fact continuously differentiable on (0, 1−α/T ). Correspondingly, the middle adjoint condition in (35) can be omitted. Moreover, like in the motivating example in Section 2.1, it is easy to see that the rate of change of µ A = x 1 (0) with respect to δ = x 2 (0) vanishes at δ = 0. We conclude that λ ph = 0 at a stationary point of the Lagrangian. This implies that λ f ,2 (1) = λ f ,2 (0) and, by inspection of (33) and (34), that both components of λ f are actually continuously differentiable throughout the interval [0, 1].
Since the dimension n opt of the optimization manifold equals 2, the successive continuation approach proposed by Kernévez and Doedel [11] requires multiple stages (in contrast to the motivating example in Section 2.1, where n opt = 1): one initially optimizes only with respect to one variable, following a curve in the optimization manifold, keeping n opt − 1 variables fixed. At each successive stage of continuation one releases one further optimization variable, until all variables are free. In this analysis, we propose to keep α fixed during the initial stage of continuation, corresponding to the imposition of a constraint on the set of unknowns. To this end, we consider the additional partial Lagrangian This partial Lagrangian adds the constraint and the algebraic adjoint equation (for vanishing variation with respect to µ α ) and adds η α to the adjoint variations with respect to α in (36). The total problem Lagrangian is now given by L x(·), α, T, p, µ A , µ α , λ f (·), λ bc , λ ph , η A , η α = L BVP x(·), α, T, p, λ f (·), λ bc The necessary conditions for an extremum of the total Lagrangian are then given by (i) the original differential equations and boundary conditions, (25)-(27), (40), (41), and (46), and (ii) the various adjoint equations, including (44) and (47), assembled in stages as constraints and variables are added, setting the sums of all resulting contributions equal to 0. Although we anticipate that λ ph will equal 0 throughout the analysis, we keep λ ph as an unknown and monitor its value during continuation. As in the previous section, we may locate an extremum of L by several successive stages of continuation, in each stage omitting one or both of the adjoint conditions (44) and (47). In particular, by holding µ α fixed and letting η A vary freely, we may arrive at a solution with η A = 1 in two stages of continuation: first, by continuing along a one-dimensional manifold with vanishing Lagrange multipliers, and next by branch-switching at a local extremum of µ A to a secondary branch along which only the Lagrange multipliers vary and, in fact, do so proportionally to η A . A final stage of continuation then proceeds from the point on this second manifold where η A = 1, but this time with η A fixed at 1 and µ α free to vary. A sought extremum is obtained when η α = 0.
An example of such an analysis for the case when ζ = 0.05, µ = 0.05, a = 0.05, b = −0.05, and γ = 0.5 is shown in Fig. 4 (projected into the (α, 2π/T, µ A ) space). Here, the full integro-differential boundary-value problem is discretized and analyzed using the COCO [18] package following the methodology discussed in [2] in terms of continuous, piecewise-polynomial approximants on a uniform partition of every solution segment into N = 10 mesh intervals, resulting in a large system of nonlinear algebraic equations. The successive continuation approach then proceeds along the following stages: -Initial guess. An initial solution guess for x(τ) near the first manifold is first constructed using direct simulation with α = 0.1 and T = 2π, after which φ is adjusted such that the maximum of x 1 occurs at τ ≈ 0. We finally let µ A = x 1 (0) and µ α = α. -Stage 1: Continuation along manifold with vanishing Lagrange multipliers. The delay α is held constant by fixing µ α at its initial value. Continuation proceeds along the blue curve in Fig. 4, monitoring for branch points (coincident with extrema in µ A up to discretization errors). firms to be a saddle point). We may compare the resulting optimal delay with the prediction from a first-order multiplescales perturbation analysis for the weakly nonlinear (small µ), weakly damped (small ζ ), and weakly forced (small γ) case, which predicts a maximal (with respect to T ) response amplitude (independent of µ, see the appendix for intermediate steps and [7,17]). The computed optimal delay α ≈ 0.7824 is in close agreement with the predicted optimal delay π/4 ≈ 0.7854 obtained from (49) for the case that b = −a. The optimal displacement profile x 1 (τ) and the components of λ f (τ) are shown in Fig. 5. The top panel shows close agreement between the results obtained using continuation and the harmonic response obtained from the perturbation analysis, at the computed optimal values of α, T , and φ . Panel (b) of Fig. 5 shows the functional Lagrange multipliers λ f , confirming that they are approximately smooth in this example (since the objective does not depend on β ∈ (0, 1)) but with λ f ,1 (1) = λ f ,1 (0) and λ f ,2 (1) ≈ λ f ,2 (0) (since the objective functional and the phase constraint depend on x(0) and λ ph ≈ 0).  Fig. 4. The upper panel shows a comparison between the numerical solutions obtained using continuation at the computed optimal value of α, with a first-order multiple-scales perturbation analysis at the predicted optimal value of α.
Further comparisons between the results obtained using the successive continuation approach and those predicted by the perturbation analysis are shown in Figs. 6 and 7 for the case when the oscillator is only subjected to displacement feedback, i.e., when b = 0, with weak (µ = 0.05) and strong (µ = 1) nonlinearity, respectively. In each case, the perturbation analysis predicts a saddle in the response amplitude for α = π/2 ≈ 1.5708, while the computational results are α ≈ 1.4712 and 0.8712, respectively. For the case of weak nonlinearity depicted in Fig. 6, there is still close agreement between the optimal time histories for x 1 (τ), while this is no longer true for the case of strong nonlinearity shown in Fig. 7. The frequency-response curves shown in the lower panels of Figs. 6 and 7 were obtained using numerical continuation for the computed and predicted critical values of α. In the case of the weak nonlinearity, we note a weak dependence on the location and magnitude of the peak on the value of the delay, while the differences are stark in the case of the strong nonlinearity. In the latter case, the optimal delay predicted by the perturbation analysis produces a peak amplitude more than 50% larger than that obtained using the numerical method.

Quasiperiodic Orbits
We proceed to consider the problem of optimizing a scalarvalued objective functional on a family of quasiperiodic solutions of (24), for which there exists an irrational rotation number ρ and a smooth function Z : S × S → R n (here, S denotes the unit circle) such that z(t) = Z (θ 1 (t), θ 2 (t)) ,θ 1 = ρΩ , andθ 2 = Ω . = 2π/T (50) in terms of the period T of the vector field f in its first argument. Let subscripts θ 1 and θ 2 denote partial derivatives with respect to the corresponding arguments. Substitution into the governing equation then yields the partial differential equation (PDE) on the two-dimensional torus S × S. We decompose this PDE along its characteristics. To this end, consider the continuous function V : S × [0, 1] → R n given by such that τ = t/T , θ 1 (0) = ϕ, and without loss of generality θ 2 (0) = 0. Shifting and wrapping of arguments between and for τ − a + j ∈ [0, 1] and all ϕ ∈ S. It follows by periodicity that for τ − a + j ∈ [0, 1] and all ϕ ∈ S. Differentiation and use of (51) then implies that along with the boundary conditions Equations (55)-(57) are a family of coupled DDE BVPs in time τ, parametrized by the continuous periodic angle ϕ. A family of orbit segments S × [0, 1] (ϕ, τ) → V (ϕ, τ) ∈ R n solving this family of BVPs then spans the sought quasiperiodic invariant torus. Such a family is unique only up to a shift of its argument ϕ ∈ S. We isolate a locally unique solution by introducing the integral phase condition in terms of a given continuously-differentiable reference function V * : S → R n that is either fixed throughout the analysis or updated as appropriate. For fixed values of the problem delay α, excitation period T , and problem parameters p, the resultant integro-differential BVP (55)-(58) defining the quasiperiodic response is over-determined (recall that the rotation number ρ is fixed) such that one has to leave at least one system parameter free to vary to obtain isolated solutions. For example, for fixed α, we thus expect to obtain a one-dimensional manifold of quasiperiodic invariant tori under simultaneous variations in T and a single element of p. We now apply the construction of the Lagrangian and adjoint equations to this family of DDE BVPs to formulate optimization problems with constraints of the form (55)-(58), following the procedure from section 3.1. We assume that neither the objective functional nor any additional constraints depend on V evaluated for τ on the interior of the interval [0, 1], and that they only depend on V on the boundaries τ = 0 and τ = 1 through integrals over ϕ. In this case, the Lagrange multipliers λ f for the DDE constraint (55) will be continuous on the domain S × [0, 1] (including periodicity in their first argument ϕ). The partial Lagrangian for the constraints (55)-(58) is then given by L BVP (V (·, ·), α, T, p, λ f (·, ·), λ rot (·), λ ph ) = = µ ω + η ω (ω − µ ω ) + L BVP V (·, ·), 1, T, p, λ f (·, ·), λ rot (·), λ ph , where L BVP is given in (59) and η ω is the additional Lagrange multiplier. The necessary conditions for an extremum of the total Lagrangian are then given by (i) the original differential equations and boundary conditions (55)-(58); (ii) the adjoint conditions (excluding (67)) obtained by appending η ω to the variation with respect to p (69) and setting all the resulting contributions equal to 0; and (iii) the condition that η ω = 1.
As in previous examples, we immediately note that λ ph must equal 0 at a stationary point of the Lagrangian, since the objective function is clearly independent of the particular choice of family (ϕ, τ) → V (ϕ, τ) selected by the phase condition. The adjoint boundary conditions (65) and (66) then imply that Moreover, direct computation using (70) and the boundary condition (57) shows that It follows from (63) and (64) that i.e., that λ f is continuously differentiable in τ on the entire interval [0, 1]. We proceed to locate an extremum by applying the successive continuation technique to the set of equations obtained by omitting the trivial adjoint condition that η ω = 1. To this end, we approximate V (ϕ, τ), λ f (ϕ, τ), and λ rot (ϕ) by truncated Fourier series in ϕ with τ-dependent Fourier coefficient functions, as appropriate, approximated by continuous piecewisepolynomial interpolants on the interval [0, 1]. Although we anticipate that λ ph will equal 0 throughout continuation, we keep λ ph as an unknown and monitor its value during continuation. We first continue along a one-dimensional manifold along which the Lagrange multipliers always equal 0, and then branch switch at a local maximum of µ ω to a secondary branch along which the family V remains unchanged, while the Lagrange multipliers vary linearly in η ω . The solution to the necessary conditions for a local stationary point is then obtained once η ω = 1 along the secondary branch.
The results of such an analysis using COCO is shown in Figs. 8 and 9 for the case that ρ ≈ 0.6618. Here, dependence on ϕ is approximated using a Fourier series truncated at the fifth harmonic corresponding to 11 trajectory segments on the torus based at ϕ = (i−1)/11, i = 1, . . . , 11. Each τ dependent Fourier coefficient is discretized using polynomials of degree 4 on a uniform mesh with 10 intervals. The one-dimensional family of quasiperiodic orbits in Fig. 8 along the first manifold with vanishing Lagrange multipliers indicates the existence of a local maximum in µ ω ≈ 0.43685 for T ≈ 5.3153. Branch switching from the nearby branch point (as before, exact coincidence is lost due to discretization) and continuing until η ω = 1 yields the approximate torus and the corresponding Lagrange multipliers λ f and λ rot shown in Fig. 9. As an aside, direct numerical simulation using initial conditions predicted by the continuation analysis suggest that quasiperiodic tori found on the lower half of the onedimensional family shown in Fig. 8 are stable to sufficiently small perturbations, while the tori found on the upper half are unstable, with a critical loss of stability coincident with the peak value of µ ω .

Conclusions
The various examples in previous sections illustrate the successful application to the case with single time delays of the general methodology to optimization along implicitly defined solutions to integro-differential boundary-value problems first proposed by Kernevez and Doedel [11] for ordinary differential equations. Here, the partial Lagrangian approach introduced in [12] was used to derive adjoint conditions that were linear and homogeneous in the unknown Lagrange multipliers. This allowed a search for local extrema to proceed along a connected sequence of one-dimensional manifolds of solutions to the necessary conditions for such extrema minus the trivial algebraic adjoint conditions on a subset of the Lagrange multipliers: first, along a branch with vanishing Lagrange multipliers, then switching to a branch with linearly varying Lagrange multipliers, and then along additional branches until all the previously omitted trivial algebraic adjoint conditions were satisfied.
In contrast to the case of ordinary differential equations, the presence of time delays introduces potential discontinuities that must be accounted for in any numerical solution strategy. By the properties of differential equations with timeshifted arguments, such discontinuities propagate across time, gaining an order of continuity for each iteration. Here, we have only accounted for zeroth-or first-order discontinuities in the formulation of the governing boundary-value problems. On each segment along which a function was shown to be continuously differentiable, we have approximated such a function by a continuous piecewise-polynomial function of degree 4 in each mesh interval, ignoring continuity in the first derivative across mesh boundaries or discontinuities of order two or higher within each mesh interval. The piecewisepolynomial approximants have been used to impose a discretization of the governing differential equations at a set of collocation nodes within each interval and to evaluate functions with time-shifted arguments on the same or other intervals. Such a collocation strategy is consistent with the approach in [3], and there compared to an alternative mesh strategy that depends on the delay. We have not undertaken a detailed analysis of the sensitivity of the results to the numerical mesh or polynomial degree. Notably, while we rely in this paper invariably on uniform meshes, it is common to consider adaptive meshes for which the number of intervals and their relative size may change during continuation. We leave such an implementation for future work.
In all the examples, a Lagrange multiplier associated with a phase condition was found to equal 0 on a local extremum of the corresponding Lagrangian. As stated previously, we nevertheless retained this Lagrange multiplier as an unknown and monitored its value during continuation. Experiments with the number of mesh intervals were used to determine whether this value was effectively 0 also in the computational analysis. An alternative would have been to eliminate this variable from the set of adjoint equations while simultaneously eliminating one of the adjoint conditions. In a single instance, this may indeed be useful, but when relying on a generalpurpose implementation as envisioned in a planned future implementation of COCO, it is better to retain the variable and use its numerical value as an indicator of the accuracy of the solution.
There are a number of directions to go in future work. These include consideration of circumstances in which the ratio α/T violates one or several of the inequalities assumed in the previous sections during continuation. Such violations may necessitate a piecewise definition of the Lagrangian across parameter space with different segmentations of the governing differential equations in each region. Problems with multiple delays, as well as problems with state-or timedependent delays could also be explored as motivated by particular applications.