  This paper concerns the numerical procedure for solving hybrid optimal
control problems with sliding modes. A sliding mode is coped with
differential-algebraic equations (DAEs) and that guarantees accurate tracking
of the sliding motion surface. In the second part of the paper we demonstrate
the correspondence between the discrete adjoint equations and the discretized
version of the continuous adjoint equations in the case of system equations
described by DAEs. We show that the discrete adjoint state trajectories
converge to their continuous counterparts. Next, we describe the application of
the proposed procedure to three optimal control problems. The first problem
concerns optimal control of a simple mechanical system with dry friction. The
second problem is related to the planning of a haemodialysis process. The third
problem concerns the optimal steering of a racing car.
