A diagonal Hamiltonian is diagonal in a specified product basis, usually the computational basis. Every basis state is therefore an energy eigenstate, and optimization of its diagonal entries becomes minimization of the corresponding classical cost function.
New to topics? Read the docs here!