Optimal discrete-valued control computation