| Algorithm 2: Proposed method: Monte Carlo AMM with preprocessing |
| Require: and , and |
| Ensure: , such that is small |
| 1: |
| 2: , , |
| 3: for all and |
| 4: Set such that |
| 5: for do |
| 6: Pick with |
| 7: |
| 8: end for |
| Algorithm 2: Proposed method: Monte Carlo AMM with preprocessing |
| Require: and , and |
| Ensure: , such that is small |
| 1: |
| 2: , , |
| 3: for all and |
| 4: Set such that |
| 5: for do |
| 6: Pick with |
| 7: |
| 8: end for |