Household and consumption¶
The Household class extends the agent by giving him utility functions and the ability to consume goods.
-
class
abce.agents.
Household
[source]¶ Bases:
object
-
consume
(input_goods)[source]¶ consumes input_goods returns utility according to the agent’s consumption function
A utility_function, has to be set before see py:meth:~abceagent.Household.set_ utility_function, py:meth:~abceagent.Household.set_cobb_douglas_utility_function or
- Args:
- {‘input_good1’: amount1, ‘input_good2’: amount2 …}:
- dictionary containing the amount of input good consumed.
- Raises:
- NotEnoughGoods: This is raised when the goods are insufficient.
- Returns:
- The utility as a number. To log it see example.
Example:
self.consumption_set = {'car': 1, 'ball': 2000, 'bike': 2} self.consumption_set = {'car': 0, 'ball': 2500, 'bike': 20} try: utility = self.consume(self.consumption_set) except NotEnoughGoods: utility = self.consume(self.smaller_consumption_set) self.log('utility': {'u': utility})
-
consume_everything
()[source]¶ consumes everything that is in the utility function returns utility according consumption
A utility_function, has to be set before see py:meth:~abceagent.Household.set_ utility_function, py:meth:~abceagent.Household.set_cobb_douglas_utility_function
- Returns:
- A the utility a number. To log it see example.
Example:
utility = self.consume_everything() self.log('utility': {'u': utility})
-
get_utility_function
()[source]¶ the utility function should be created with: set_cobb_douglas_utility_function, set_utility_function or set_utility_function_fast
-
predict_utility
(input_goods)[source]¶ Predicts the utility of a vecor of input goods
Predicts the utility of consume_with_utility(utility_function, input_goods)Args:
{'input_good1': amount1, 'input_good2': amount2 ...}: dictionary containing the amount of input good used for the production.
Returns:
utility: Number
Example:
print(A.predict_utility(self._utility_function, {'ball': 2, 'paint': 1}))
-
set_cobb_douglas_utility_function
(exponents)[source]¶ creates a Cobb-Douglas utility function
Utility_functions are than used as an argument in consume_with_utility, predict_utility and predict_utility_and_consumption.
- Args:
- {‘input1’: exponent1, ‘input2’: exponent2 …}: dictionary containing good names ‘input’ and correstponding exponents
- Returns:
- A utility_function that can be used in consume_with_utility etc.
Example: self._utility_function = self.create_cobb_douglas({‘bread’ : 10, ‘milk’ : 1}) self.produce(self.plastic_utility_function, {‘bread’ : 20, ‘milk’ : 1})
-
set_utility_function
(formula, use)[source]¶ creates a utility function from a formula
The formula is a function that takes a dictionary of goods as an argument and returns a floating point number, the utility. use is a dictionary containing the percentage use of the goods used in the consumption. Goods can be fully used (=1) for example food, partially used e.G. a car. And not used at all (=0) for example a house.
Args:
- formula:
- a function that takes a dictionary of goods and computes the utility as a floating number.
- use:
- a dictionary that specifies for every good, how much it depreciates in percent.
Example:
self init(self): ... def utility_function(goods): return goods['house'] ** 0.2 * good['food'] ** 0.6 + good['car'] ** 0.2 {'house': 0, 'food': 1, 'car': 0.05} self.set_utility_function(utility_function, use)
-