Optimality conditions for a class of variational inequalities with cone constraints