generalized lattice to mf, optimization compatible