Papers
Topics
Authors
Recent
Search
2000 character limit reached

Direct-Switch: High-Order Discretization Method

Updated 10 July 2026
  • Direct-Switch is a computational framework that reformulates nonsmooth differential equations as a dynamic complementarity system with exact switch detection.
  • It integrates variable step Runge–Kutta schemes with cross-complementarity and step equilibration to force switching events onto mesh boundaries and recover high-order accuracy.
  • The method streamlines nonsmooth optimal control by transcribing the problem into a single MPCC, eliminating the need for pre-guessing switching sequences and improving sensitivity analysis.

Direct-Switch, also described as Finite Elements with Switch Detection (FESD), is a direct-optimal-control and numerical discretization methodology for nonsmooth differential equations in which switching events are detected exactly by making the integrator step sizes degrees of freedom and by adding complementarity conditions that force every switch onto a mesh boundary. In the formulation developed for piecewise-smooth ODEs and later extended to systems with set-valued step functions, the original nonsmooth dynamics are first rewritten as a dynamic complementarity system (DCS), then discretized by a Runge–Kutta scheme whose step sizes are allowed to vary, and finally transcribed into a single Mathematical Program with Complementarity Constraints (MPCC). The central purpose of the method is to recover the high-order accuracy and sensitivity information that standard fixed-step Runge–Kutta methods lose on nonsmooth trajectories (Nurkanović et al., 2022, Nurkanović et al., 2023).

1. Problem class and motivating setting

Direct-Switch addresses nonsmooth dynamical systems whose right-hand side changes across regions of the state space. In the piecewise-smooth setting, the initial-value problem is written as

x˙(t)=fi(x(t),u(t))if  x(t)Ri,  i{1,,nf},\dot x(t)=f_i\bigl(x(t),u(t)\bigr)\quad \text{if}\; x(t)\in R_i,\; i\in\{1,\dots,n_f\},

where the regions RiRnxR_i\subset\mathbb R^{n_x} are disjoint open regions with smooth boundaries, and each fif_i is smooth on a neighborhood of Ri\overline{R_i}. Filippov’s construction replaces the discontinuous right-hand side by a set-valued map and yields a convexified dynamics

x˙=i=1nfθifi(x,u),\dot x=\sum_{i=1}^{n_f}\theta_i\,f_i(x,u),

with measurable Filippov multipliers θi0\theta_i\ge 0, iθi=1\sum_i \theta_i=1, and θi=0\theta_i=0 whenever xRix\notin \overline{R_i} (Nurkanović et al., 2022).

The 2023 extension generalizes the same program to optimal control problems with set-valued step functions. On a horizon [0,T][0,T], the dynamics are posed as

RiRnxR_i\subset\mathbb R^{n_x}0

with switching functions RiRnxR_i\subset\mathbb R^{n_x}1 and

RiRnxR_i\subset\mathbb R^{n_x}2

The paper states that such differential inclusions subsume Filippov systems, piecewise-smooth ODEs, and many hybrid-logic expressions (Nurkanović et al., 2023).

A recurring motivation is that naive discretization is structurally inadequate. The 2022 paper states that if standard time-stepping Runge–Kutta methods are naively applied to a nonsmooth ODE, the accuracy is at best of order one, and the 2023 extension makes the same point for DCS models with set-valued step functions, where only RiRnxR_i\subset\mathbb R^{n_x}3 global order is observed regardless of the base Runge–Kutta order (Nurkanović et al., 2022, Nurkanović et al., 2023). This is the methodological gap Direct-Switch is designed to close.

2. Complementarity reformulation of switching logic

A defining feature of Direct-Switch is that it does not work directly with a discontinuous right-hand side. Instead, it rewrites switching logic as algebraic complementarity constraints.

For piecewise-smooth ODEs, the formulation follows Stewart’s dynamic-complementarity system. With RiRnxR_i\subset\mathbb R^{n_x}4, smooth indicator functions RiRnxR_i\subset\mathbb R^{n_x}5, and auxiliary variables RiRnxR_i\subset\mathbb R^{n_x}6, the DCS is

RiRnxR_i\subset\mathbb R^{n_x}7

The paper presents this as the KKT reformulation of the linear program

RiRnxR_i\subset\mathbb R^{n_x}8

which encodes the active region selection in complementarity form (Nurkanović et al., 2022).

For set-valued step functions, the reformulation is different in detail but identical in spirit. Each step variable RiRnxR_i\subset\mathbb R^{n_x}9 is written as the solution of a small LP,

fif_i0

whose KKT conditions introduce dual variables fif_i1: fif_i2 The paper states explicitly that this reproduces the set-valued step-function exactly: if fif_i3 then fif_i4, if fif_i5 then fif_i6, and if fif_i7 then fif_i8 (Nurkanović et al., 2023).

When the nonsmooth ODE can be expressed as a convex combination over sign-defined regions,

fif_i9

the extension constructs Filippov multipliers

Ri\overline{R_i}0

with Ri\overline{R_i}1 encoding the sign patterns. This yields a DCS in which Ri\overline{R_i}2 are algebraic complementarity variables that encode exactly the switching logic of the original set-valued step (Nurkanović et al., 2023).

3. FESD discretization and exact switch detection

The distinctive step of Direct-Switch is the FESD discretization itself. Standard Ri\overline{R_i}3-stage Runge–Kutta discretization with fixed step sizes Ri\overline{R_i}4 does not detect the exact switch time unless it happens to coincide with a mesh point. FESD therefore promotes each Ri\overline{R_i}5 to a decision variable and imposes

Ri\overline{R_i}6

This introduces new degrees of freedom, which are then pinned down by two additional families of conditions: cross-complementarity and step equilibration (Nurkanović et al., 2022).

In the original formulation, the stage variables on Ri\overline{R_i}7 are Ri\overline{R_i}8, together with Ri\overline{R_i}9. The paper’s key algebraic condition is

x˙=i=1nfθifi(x,u),\dot x=\sum_{i=1}^{n_f}\theta_i\,f_i(x,u),0

including boundary stages. Compacted over an interval, this becomes x˙=i=1nfθifi(x,u),\dot x=\sum_{i=1}^{n_f}\theta_i\,f_i(x,u),1. Lemma 3.1 shows that these pairwise products force a single invariant active set on each interval, so an active-set change cannot occur in the interior of a finite element. Any switch is therefore forced onto a mesh boundary (Nurkanović et al., 2022).

The 2023 step-function extension uses an analogous mechanism. Because the LP multipliers x˙=i=1nfθifi(x,u),\dot x=\sum_{i=1}^{n_f}\theta_i\,f_i(x,u),2 are continuous in continuous time and both must vanish at a zero crossing of x˙=i=1nfθifi(x,u),\dot x=\sum_{i=1}^{n_f}\theta_i\,f_i(x,u),3, it imposes for each interval and every pair of distinct stage indices x˙=i=1nfθifi(x,u),\dot x=\sum_{i=1}^{n_f}\theta_i\,f_i(x,u),4 the cross-complementarity conditions

x˙=i=1nfθifi(x,u),\dot x=\sum_{i=1}^{n_f}\theta_i\,f_i(x,u),5

The paper states that this prevents an active-set change from hiding between Runge–Kutta stages and forces the designer to align that switch exactly with a mesh point (Nurkanović et al., 2023).

Cross-complementarity alone is insufficient, because if no switch occurs on x˙=i=1nfθifi(x,u),\dot x=\sum_{i=1}^{n_f}\theta_i\,f_i(x,u),6, then the free variables x˙=i=1nfθifi(x,u),\dot x=\sum_{i=1}^{n_f}\theta_i\,f_i(x,u),7 would remain underdetermined. Step equilibration removes this spurious freedom. In the 2022 formulation, one defines an indicator x˙=i=1nfθifi(x,u),\dot x=\sum_{i=1}^{n_f}\theta_i\,f_i(x,u),8 such that x˙=i=1nfθifi(x,u),\dot x=\sum_{i=1}^{n_f}\theta_i\,f_i(x,u),9 if and only if no switch occurs at θi0\theta_i\ge 00, and imposes

θi0\theta_i\ge 01

Hence θi0\theta_i\ge 02 whenever no switch occurs, while the condition becomes vacuous at a true switch (Nurkanović et al., 2022). The 2023 extension gives the same principle in the form

θi0\theta_i\ge 03

with θi0\theta_i\ge 04 if and only if no switch occurs on θi0\theta_i\ge 05 (Nurkanović et al., 2023).

A common misconception is that high-order Runge–Kutta formulas alone suffice for nonsmooth systems. The Direct-Switch construction is explicitly built on the opposite conclusion: without exact switch detection, one loses high-order accuracy; with free step sizes, cross-complementarity, and step equilibration, the scheme recovers it (Nurkanović et al., 2022, Nurkanović et al., 2023).

4. Direct transcription into an MPCC

Once discretized, Direct-Switch transcribes the entire nonsmooth optimal-control problem into one large MPCC rather than into a sequence of event-detection subproblems.

For the step-function extension, the finite-element Runge–Kutta equations on one interval are written with stage variables θi0\theta_i\ge 06: θi0\theta_i\ge 07 together with the DCS constraints at each stage. Collecting all state and algebraic variables over all finite elements plus the vector of step sizes yields a single large system consisting of state updates, stage equations, complementarity conditions, cross-complementarity conditions, step-equilibration conditions, and the horizon constraint θi0\theta_i\ge 08. The paper identifies this explicitly as an MPCC (Nurkanović et al., 2023).

The direct transcription of the optimal-control problem proceeds by dividing θi0\theta_i\ge 09 into iθi=1\sum_i \theta_i=10 control intervals with piecewise-constant controls iθi=1\sum_i \theta_i=11, applying FESD with iθi=1\sum_i \theta_i=12 finite elements on each interval, and minimizing a discrete objective

iθi=1\sum_i \theta_i=13

subject to the FESD-discretized DCS equations, path constraints, terminal constraints, and sum-of-steps constraints (Nurkanović et al., 2023).

The 2022 paper gives the same overall architecture in the piecewise-smooth setting and emphasizes that the framework is a direct-optimal-control method that no longer needs pre-guessing or enumeration of switching sequences (Nurkanović et al., 2022). The 2023 extension adds implementation details: in NOSNOC, each complementarity iθi=1\sum_i \theta_i=14 is replaced by a smooth C-function such as Fischer–Burmeister, a decreasing sequence of smoothing parameters drives the solution toward the true MPCC, and the underlying smooth NLPs are solved by IPOPT via CasADi (Nurkanović et al., 2023).

5. Accuracy, convergence, and numerical sensitivities

The formal analysis of Direct-Switch is one of its central features. Under assumptions including invertibility of certain matrices off-switch, strict complementarity, strong stability of the switching LCP, and a convergent Runge–Kutta method of order iθi=1\sum_i \theta_i=15, the 2022 paper proves that the FESD-discrete system has locally isolated solutions for each fixed switching pattern and that FESD trajectories converge to a true Filippov solution with order iθi=1\sum_i \theta_i=16 away from switches and order iθi=1\sum_i \theta_i=17 at switches (Nurkanović et al., 2022).

The quoted error bounds include both event time and state accuracy: iθi=1\sum_i \theta_i=18 at every mesh point, including those that coincide with switching times. The same paper also states that the discrete-time sensitivities iθi=1\sum_i \theta_i=19 converge to the correct Filippov sensitivity jumps with order θi=0\theta_i=00, often θi=0\theta_i=01 for stiffly accurate Runge–Kutta methods (Nurkanović et al., 2022).

The extension to set-valued step functions frames the same numerical issue in sharper terms. If a standard θi=0\theta_i=02-stage Runge–Kutta method with fixed step sizes is applied directly to the DCS, only θi=0\theta_i=03 global order is observed, no matter how high the Runge–Kutta order. By contrast, the paper reports that FESD with an underlying Radau IIA method of order θi=0\theta_i=04 recovers global θi=0\theta_i=05 in a planar oscillator example with one crossing at θi=0\theta_i=06 (Nurkanović et al., 2023).

The corresponding methodological significance is precise: Direct-Switch does not merely refine the mesh near nonsmoothness; it enforces an exact alignment of switches with finite-element boundaries, and the recovery of high-order accuracy follows from that alignment together with the underlying Runge–Kutta order (Nurkanović et al., 2022, Nurkanović et al., 2023).

6. Benchmarks, software realization, and scope

The published benchmarks emphasize both solution quality and computational behavior. In the 2022 optimal-control benchmark

θi=0\theta_i=07

standard fixed-step Gauss–Legendre or Radau discretization yields an objective curve θi=0\theta_i=08 with spurious local minima and incorrect gradients, whereas FESD recovers the exact objective curve, correct derivatives, and a single global minimum. In a switched-oscillator–MPC benchmark, FESD achieves five orders of magnitude smaller terminal error versus CPU time than the standard fixed-step approach, and the abstract summarizes this as up to five orders of magnitude more accurate solutions for the same computational time (Nurkanović et al., 2022).

The 2023 paper reports complementary evidence in a different model class. For a planar oscillator, classical Runge–Kutta time stepping of the DCS remains first-order, while FESD with Radau IIA recovers the base order. For an optimal control problem of a hopping robot, where leg-tip impact and frictional-sliding logic are expressed as three step-functions in normal and tangential velocity, a Radau-IIA(3)-based FESD directly discretizes the task of making five jumps in five seconds. In CPU-timing studies over increasing numbers of control intervals, FESD via the step-LP reformulation is up to 50% faster per NLP iteration than the earlier Stewart-based DCS reformulation because it uses fewer auxiliary variables and sparser complementarity (Nurkanović et al., 2023).

NOSNOC is the software package explicitly associated with the method in the step-function extension, and all methods and examples in that paper are implemented there (Nurkanović et al., 2023). A plausible implication is that Direct-Switch has evolved from a numerical discretization strategy into a software-supported direct-transcription framework for nonsmooth optimal control.

Within its documented scope, Direct-Switch is characterized by four recurring properties: it rewrites switching logic as complementarity constraints, lets mesh steps float, enforces exact switch detection through cross-complementarity, and uses step equilibration to prevent nonphysical mesh drift. The resulting framework is presented as provably high-order accurate, sensitivity-consistent, and applicable without pre-guessing or enumeration of switching sequences (Nurkanović et al., 2022, Nurkanović et al., 2023).

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Direct-Switch.