robot while it minimizes a cost function. To fulfill this task, the robot can manipulate the ground reaction forces at the stance feet and adjust the switching times between different stance leg configurations. For instance, assume the problem of controlling the walking gait for a quadruped robot. In this task, the gait is fixed, thus the sequence of mode switches are known. The control task is to modulate the contact forces of the stance legs and to determine the switching times between each mode.

The optimal control problem for the switched systems involves synthesizing the optimal controller for the continuous inputs and finding a mode sequence and the switching times between the modes. In general, the procedure of synthesizing an optimal control law for a switched system can be divided into three subtasks [@giua01; @xu04]: (1) finding the optimal sequence of the modes, (2) finding the optimal switching times between consecutive modes, (3) finding the optimal continuous control inputs. Given the switching sequence and times, the third subtask is a regular optimal control problem with a finite number of discontinuities in the system vector field. The necessary condition of optimality in the context of hybrid systems has been derived from 