Updated Discrete Optimization Script