An explicit algorithm for solving the optimize hierarchical problems