FirmsRunProduction#

class bamengine.events.production.FirmsRunProduction[source]#

Bases: Event

Firms produce goods using labor and add output to inventory.

Production follows a simple linear technology: output equals labor productivity times number of workers. The produced goods are added to inventory for sale in the goods market.

The calculated production is saved to both production (current period’s output) and production_prev (for use as next period’s planning signal).

Algorithm

For each firm i:

  1. Calculate output: \(Y_i = \phi_i \times L_i\)

  2. Store production: \(\text{production}_i = Y_i\)

  3. Store for next period’s planning: \(\text{production\_prev}_i = Y_i\)

  4. Add to inventory: \(S_i \leftarrow Y_i\)

Mathematical Notation

\[ \begin{align}\begin{aligned}Y_i = \phi_i \times L_i\\S_i \leftarrow Y_i\end{aligned}\end{align} \]

where:

  • \(Y_i\): production output for firm i

  • \(\phi_i\): labor productivity (output per worker)

  • \(L_i\): current labor force (number of workers)

  • \(S_i\): inventory (replaces previous inventory with current production)

Examples

>>> import bamengine as be
>>> sim = be.Simulation.init(n_firms=100, seed=42)
>>> event = sim.get_event("firms_run_production")
>>> event.execute(sim)

Check production output:

>>> sim.prod.production.mean()
52.5

Verify production formula:

>>> import numpy as np
>>> expected_output = sim.prod.labor_productivity * sim.emp.current_labor
>>> np.allclose(sim.prod.production, expected_output)
True

Check inventory accumulation:

>>> total_inventory = sim.prod.inventory.sum()
>>> total_production = sim.prod.production.sum()
>>> total_inventory >= total_production  # Inventory includes previous unsold goods
True

Notes

This event must execute after WorkersReceiveWage.

Firms with zero labor (L_i = 0) produce zero output and are marked for bankruptcy in later events.

Inventory accumulates: S_new = S_old + Y. Unsold goods from previous periods remain in inventory.

See also

FirmsDecideDesiredProduction

Plans production targets

Producer

Production state with labor_prod, production, inventory

bamengine.events._internal.production.firms_run_production

Implementation

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:

None

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_run_production'#