A Discrete Variational Derivation of Accelerated Methods in Optimization