  Let (N,g) be a nilpotent Lie group endowed with an invariant geometric
structure (cf. symplectic, complex, hypercomplex or any of their `almost'
versions). We define a left invariant Riemannian metric on N compatible with g
to be minimal, if it minimizes the norm of the invariant part of the Ricci
tensor among all compatible metrics with the same scalar curvature. We prove
that minimal metrics (if any) are unique up to isometry and scaling, they
develop soliton solutions for the `invariant Ricci' flow and are characterized
as the critical points of a natural variational problem. The uniqueness allows
us to distinguish two geometric structures with Riemannian data, giving rise to
a great deal of invariants.
  Our approach proposes to vary Lie brackets rather than inner products; our
tool is the moment map for the action of a reductive Lie group on the algebraic
variety of all Lie algebras, which we show to coincide in this setting with the
Ricci operator. This gives us the possibility to use strong results from
geometric invariant theory.
