Implementation of IDP^G algorithm.