Variational principle and periodic solution of the Kundu–Mukherjee–Naskar equation