Learning, heterogeneity, and complexity in the New Keynesian model