Numerical solution of Hamiltonian problems by G-symplectic integrators