An algorithm for semi-infinite polynomial optimization