Agent-based Models of the Economy: From Theories to Applications