Variational sets and necessary optimality conditions