Computing Economic Equilibria through Nonsmooth Optimization