Agents¶
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 and logging.
Messaging between agents, see Messaging.
-
class
abce.Agent(id, agent_parameters, simulation_parameters, group, trade_logging, database, check_unchecked_msgs, expiring, perishable, resource_endowment, start_round=None)[source]¶ Bases:
abce.database.Database,abce.trade.Trade,abce.messaging.Messaging,abce.goods.GoodsEvery agent has to inherit this class. It connects the agent to the simulation and to other agent. The
abce.Trade,abce.Databaseandabce.Messagingclasses are included. An agent can also inheriting fromabce.Firm,abce.FirmMultiTechnologiesorabce.Householdclasses.Every method can return parameters to the simulation.
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) ... def return_quantity_of_good(self): return['good'] ... simulation = Simulation() households = Simulation.build_agents(household, 'household', parameters={...}, agent_parameters=[{'type': 'a'}, {'type': 'b'}]) for r in range(10): simulation.advance_round(r) households.selling() print(households.return_quantity_of_good())
-
group= None¶ self.group returns the agents group or type READ ONLY!
-
id= None¶ self.name returns the agents name, which is the group name and the id
-
init()[source]¶ This method is called when the agents are build. It can be overwritten by the user, to initialize the agents. Parameters are the parameters given to
abce.Simulation.build_agents().Example:
class Student(abce.Agent): def init(self, rounds, age, lazy, school_size): self.rounds = rounds self.age = age self.lazy = lazy self.school_size = school_size def say(self): print('I am', self.age ' years old and go to a school that is ', self.school_size') def main(): sim = Simulation() students = sim.build_agents(Student, 'student', agent_parameters=[{'age': 12, lazy: True}, {'age': 12, lazy: True}, {'age': 13, lazy: False}, {'age': 14, lazy: True}], rounds=50, school_size=990)
-
round= None¶ self.round is depreciated
-
time= None¶ self.time, contains the time set with simulation.advance_round(time) you can set time to anything you want an integer or (12, 30, 21, 09, 1979) or ‘monday’
-