Consumer#

class bamengine.roles.consumer.Consumer(income, savings, income_to_spend, propensity, largest_prod_prev, shop_visits_head, shop_visits_targets)[source]#

Bases: Role

Consumer role for households.

Represents the consumption and savings state for households. Each array index corresponds to a household ID (0 to n_households-1).

Parameters:
  • income (Float1D) – Total income received this period from wages.

  • savings (Float1D) – Accumulated savings from previous periods.

  • income_to_spend (Float1D) – Portion of income allocated for consumption this period.

  • propensity (Float1D) – Propensity to consume (calculated from income and savings).

  • largest_prod_prev (Idx1D) – ID of firm with highest production in previous period (search hint).

  • shop_visits_head (Idx1D) – Queue head pointer for shop visits.

  • shop_visits_targets (Idx2D) – Queue of firm IDs to visit, shape (n_households, max_Z).

Examples

Access from simulation:

>>> import bamengine as bam
>>> sim = bam.Simulation.init(n_households=500, seed=42)
>>> con = sim.con
>>> con.income.shape
(500,)
>>> con.savings.shape
(500,)

Calculate aggregate consumption spending:

>>> import numpy as np
>>> total_spending = con.income_to_spend.sum()
>>> total_spending
525.5

Find households with high savings:

>>> high_savers = con.savings > 100
>>> high_savers.sum()
45

Check propensity to consume distribution:

>>> mean_propensity = con.propensity.mean()
>>> mean_propensity
0.75

Find households targeting specific firm:

>>> target_firm = 5
>>> targeting = con.largest_prod_prev == target_firm
>>> targeting.sum()
12

Notes

The Consumer role is one of two roles assigned to households:

  • Worker: employment and labor supply (see Worker)

  • Consumer: consumption and savings

The propensity to consume is calculated using the formula: propensity = income^beta / (income^beta + savings^beta) where beta is a configuration parameter (typically beta=2.5).

See also

Worker

Employment role for households

Producer

Production role for firms

goods_market

Goods market logic

income#

Total income received this period from wages.

savings#

Accumulated savings from previous periods.

income_to_spend#

Portion of income allocated for consumption this period.

propensity#

Propensity to consume (0 to 1).

__init__(income, savings, income_to_spend, propensity, largest_prod_prev, shop_visits_head, shop_visits_targets)#
name = 'Consumer'#
largest_prod_prev#

Firm with highest production in previous period (loyalty target).

shop_visits_head#

Queue head pointer for shop visits.

shop_visits_targets#

Queue of firm IDs to visit, shape (n_households, max_Z).