Semidifferentiable functions and necessary optimality conditions