A human subject experiment was conducted to investigate caffeine's effect on appraisal and performance of a mental serial subtraction task. Serial subtraction performance data was collected from three treatment groups: placebo, 200, and 400 mg caffeine. The data were analyzed by caffeine treatment group and how subjects appraised the task (as challenging or threatening). A cognitive model of the serial subtraction task was developed. The model was fit to the human performance data using a parallel genetic algorithm. How the model's parameters change to fit the data suggest how cognition changes due to caffeine and appraisal. Overall, the cognitive modeling and optimization results suggest that the speed of vocalization varies the most along with changes to declarative memory. This approach provides a way to compute how cognitive mechanisms change due to moderators.