Optimization and stability theory for economic analysis