Optimal switching for ordinary differential equations.