A Rational Analysis of Cognitive Control in a Speeded Discrimination Task