Towards convergent approximate message passing by alternating constrained minimization of Bethe free energy