FirmsFireExcessWorkers#

class bamengine.events.planning.FirmsFireExcessWorkers[source]#

Bases: Event

Fire workers when current labor exceeds desired labor.

Firms with more workers than needed (due to reduced production targets) lay off the excess workers. By default, firms fire workers randomly, but can be configured to fire the most expensive workers first.

Algorithm

For each firm i with \(L_i > L^d_i\) (current labor exceeds desired):

  1. Calculate excess: \(E_i = L_i - L^d_i\)

  2. Select \(E_i\) workers to fire (by method: random or expensive first)

  3. Fire selected workers: - Set worker’s employer = -1 (unemployed) - Set worker’s wage = 0 - Set worker’s fired flag = True - Decrement firm’s current_labor

Mathematical Notation

For firm i with \(L_i > L^d_i\):

\[E_i = L_i - L^d_i\]

Fire \(E_i\) workers so that:

\[L_i \leftarrow L^d_i\]

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_fire_excess_workers")
>>> event.execute(sim)

Check that firms now have current_labor <= desired_labor:

>>> (sim.emp.current_labor <= sim.emp.desired_labor).all()
True

Notes

This event executes in the Planning phase after vacancies are calculated. Workers fired here have their fired flag set to True, which affects their job search behavior (loyalty rule does not apply).

See also

FirmsDecideVacancies

Calculate job openings

FirmsFireWorkers

Fire workers due to financing gaps (credit market)

bamengine.events._internal.planning.firms_fire_excess_workers

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