Enhanced global gradient algorithm: A general formulation