FirmsUpdateNetWorth#
- class bamengine.events.bankruptcy.FirmsUpdateNetWorth[source]#
Bases:
EventUpdate firm net worth with retained profits/losses.
Net worth accumulates retained earnings from each period. Negative net worth (insolvency) leads to bankruptcy in the next event.
Algorithm
For each firm i:
\[ \begin{align}\begin{aligned}A_i \leftarrow A_i + RP_i\\\text{total\_funds}_i = \max(0, A_i)\end{aligned}\end{align} \]where \(A_i\) = net_worth, \(RP_i\) = retained_profit.
Examples
>>> import bamengine as be >>> sim = be.Simulation.init(n_firms=100, seed=42) >>> event = sim.get_event("firms_update_net_worth") >>> event.execute(sim)
See also
FirmsPayDividendsCalculates retained_profit
bamengine.events._internal.bankruptcy.firms_update_net_worthImplementation
- 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_update_net_worth'#