Optimal Line Switching Maneuvers