and later initialize the policy of a new run of SLQ with the most similar switching time’s policy (refer to Algorithm \[alg:ocs2\]). The similarity between two switching time sequences is measured as a sum of squared differences between corresponding times in two sequences.

Case Studies {#sec:numerical_example}
============

In this section, we evaluate the performance of the proposed method on three numerical examples. The first two examples are provided as illustrative cases to compare the performance of the proposed algorithm to the baseline algorithm introduced by [@xu04] and the third one is about the application of our method in motion control of legged robots. We here refer to the baseline algorithm as the BVP method since it is based on the solution of two-point BVPs.

#### Example 1: {#example-1 .unnumbered}

The first example is a nonlinear switched system with three mode switches which are defined as followings $$\begin{aligned}
& 1: \left\{ \begin{array}{ll}
        \dot{x}_1 = x_1 + u_1\sin{x_1}\\
        \dot{x}_2 = -x_2 + u_1\cos{x_2}
        \end{array} 
\right.,   \quad
2: \left\{ \begin{array}{ll}
        \dot{x}_1 = x_2 + u_1\sin{x_2}\\
        \dot{x}_2 = -x_1 - u_1\cos{x_1}
        \end{array} 
\right.   \notag \\
& 3: \left\{ \begin{array}{ll}
        \dot{x}_1 = -x_1 - u_1\sin{x_1}\\
        \dot{x}_2 = x_2 + u_1\cos{x_2}
        \end{array} 
\right.\end{aligned}$$ with the initial 