Added maxfun parameter to scipy.optimize to reduce the amount of time
spent in optimizing parameters for the Q-function.