FirmsCalcWageBill#
- class bamengine.events.labor_market.FirmsCalcWageBill[source]#
Bases:
EventFirms calculate total wage bill based on currently employed workers.
The wage bill is the sum of wages for all workers employed by the firm. This is used by FirmsCalcBreakevenPrice to determine production costs.
Algorithm
For each firm i:
Find all workers employed by firm i: \(E_i = \{j : \text{employer}_j = i\}\)
Sum wages: \(W_i = \sum_{j \in E_i} w_j\)
Store in firm’s wage_bill field
Uses vectorized aggregation via np.bincount for efficiency.
Mathematical Notation
\[W_i = \sum_{j \in E_i} w_j\]where:
\(W_i\): total wage bill for firm i
\(E_i\): set of workers employed by firm i
\(w_j\): wage of worker j
Examples
Execute this event:
>>> import bamengine as be >>> sim = be.Simulation.init(n_firms=100, n_households=500, seed=42) >>> event = sim.get_event("firms_calc_wage_bill") >>> event.execute(sim)
Check total wage bill:
>>> sim.emp.wage_bill.sum() 552.5
Verify wage bill matches sum of worker wages:
>>> import numpy as np >>> employed_mask = sim.wrk.employed >>> total_wages = sim.wrk.wage[employed_mask].sum() >>> total_wage_bill = sim.emp.wage_bill.sum() >>> abs(total_wages - total_wage_bill) < 1e-10 # Allow floating point tolerance True
Check firms with no employees have zero wage bill:
>>> no_labor_mask = sim.emp.current_labor == 0 >>> (sim.emp.wage_bill[no_labor_mask] == 0).all() True
Notes
This event must execute after all LaborMarketRound rounds complete.
The wage bill represents the total labor cost that will be paid in the production phase (FirmsPayWages event).
The wage bill is shared with Borrower role (same underlying array) for memory efficiency and consistency with credit demand calculations.
See also
LaborMarketRoundBatch labor market matching that hires workers
FirmsCalcBreakevenPriceUses wage bill to calculate production costs
FirmsPayWagesPays wages based on wage_bill
EmployerLabor hiring state with wage_bill field
bamengine.events._internal.labor_market.firms_calc_wage_billImplementation
- execute(sim)[source]#
Execute the event’s logic.
Mutates simulation state in-place. This method must be implemented by all Event subclasses.
- Parameters:
sim (
Simulation) – The simulation instance containing all state and configuration.- Returns:
All mutations are in-place.
- Return type:
Examples
Implement execute in a custom event:
>>> from bamengine import event, ops >>> >>> @event ... class CustomPricingEvent: ... def execute(self, sim): ... prod = sim.get_role("Producer") ... # Apply 10% markup to all prices ... new_prices = ops.multiply(prod.price, 1.1) ... ops.assign(prod.price, new_prices)
Access configuration and RNG:
>>> @event ... class StochasticEvent: ... def execute(self, sim): ... shock = sim.config.h_rho ... random_values = sim.rng.uniform(0, shock, size=sim.n_firms) ... # Use random_values in calculations
Notes
The execute method receives full Simulation access, including: - All roles: sim.get_role(“RoleName”) or sim.prod, sim.wrk, etc. - Configuration: sim.config - RNG: sim.rng - Economy state: sim.ec
- __init__()#
- name = 'firms_calc_wage_bill'#