An algorithm for approximating subactions