The abce.Agent class is the basic class for creating your agents. It automatically handles the possession of goods of an agent. In order to produce/transforme goods you also need to subclass the abce.Firm or to create a consumer the abce.Household.

For detailed documentation on:

Trading, see Trade

Logging and data creation, see Observing agents.

Messaging between agents, see Messaging.

class abce.Agent(id, group, trade_logging, database, logger, random_seed, start_round, num_managers)[source]

Bases: abce.database.Database, abce.networklogger.NetworkLogger, trade.Trade, abce.messaging.Messaging

Every agent has to inherit this class. It connects the agent to the simulation and to other agent. The abce.Trade, abce.Database and abce.Messaging classes are included. You can enhance an agent, by also inheriting from abce.Firm. abce.FirmMultiTechnologies or abce.Household.

For example:

class Household(abce.Agent, abce.Household):
    def init(self, simulation_parameters, agent_parameters):
        self.num_firms = simulation_parameters['num_firms']
        self.type = agent_parameters['type']

    def selling(self):
        for i in range(self.num_firms):
            self.sell('firm', i, 'good', quantity=1, price=1)


use in action list to create data

create(good, quantity)[source]

creates quantity of the good out of nothing

Use create with care, as long as you use it only for labor and natural resources your model is macro-economically complete.

‘good’: is the name of the good quantity: number
create_agent(AgentClass, group_name, parameters=None, agent_parameters=None)[source]

create a new agent.


the class of agent to create. (can be the same class as the creating agent)
the name of the group the agent should belong to
a dictionary of parameters
a dictionary of parameters


self.create_agent(BeerFirm, 'beerfirm',
                  agent_parameters={'creation': self.round + 1})
create_timestructured(good, quantity)[source]

creates quantity of the time structured good out of nothing. For example:

self.creat_timestructured('capital', [10,20,30])

Creates capital. 10 units are 2 years old 20 units are 1 year old and 30 units are new.

It can alse be used with a quantity instead of an array. In this case the amount is equally split on the years.:

self.creat_timestructured('capital', 60)

In this case 20 units are 2 years old 20 units are 1 year old and 20 units are new.

is the name of the good
an arry or number

If ABCE is run in calendar mode (via abce.Simulation.declare_calendar()), date shows the current date.: # the weekday as a number Monday being 0 #

The date works like python’s date object

delete_agent(group_name, id, quite=True)[source]

This deletes an agent, an agent can delete itself. There are two ways of deleting an agent. By default, quite is set to True, all future messages to this agent are deleted. If quite is set to False agents are completely deleted. This makes the simulation faster, but if messages are send to this agents the simulation stops.


group name of the agent
the id of the agent to be deleted
whether the agent deletes incomming messages.
destroy(good, quantity=None)[source]

destroys quantity of the good. If quantity is omitted destroys all


    is the name of the good
quantity (optional):


NotEnoughGoods: when goods are insufficient
group = None returns the agents group or type READ ONLY!

id = None returns the agents id READ ONLY

init(parameters, agent_parameters)[source]

This method is called when the agents are build. It can be overwritten by the user, to initialize the agents. parameters and agent_parameters are the parameters given in abce.Simulation.build_agents()

name = None returns the agents name, which is the group name and the id seperated by ‘_’ e.G. “household_12” READ ONLY!


use in action list to create panel data


returns how much of good an agent possesses.

A number.

possession does not return a dictionary for self.log(...), you can use self.possessions([...]) (plural) with self.log.


if self.possession(‘money’) < 1:
self.financial_crisis = True
if not(is_positive(self.possession(‘money’)):
self.bancrupcy = True

returns all possessions

round = None

self.round returns the current round in the simulation READ ONLY!