PlantAgentsModel Orchestration¶
Overview¶
PlantAgentsModel is the main orchestrator that coordinates all PAM decision-making within a simulation year. It processes plants and plant groups in sequence, issuing commands for technology switches, renovations, closures, and capacity expansions.
The model executes the following workflow each year:
Calculate market conditions (current and future prices of steel and iron)
Evaluate each plant’s furnace groups for potential actions
Evaluate plant groups for plant expansion opportunities
Track and enforce capacity limits (for steel and iron buildout separately)
Role in Simulation¶
PAM is called once per simulation year from simulation.py:
Simulation(bus=bus, economic_model=PlantAgentsModel()).run_simulation()
Before PAM runs:
Trade Module allocates production:
Sets
furnace_group.allocated_volumesSets
furnace_group.utilization_rate
TM-PAM Connector disaggregates cluster flows and updates costs:
Splits LP cluster-level flows to individual FG level via
disaggregate_allocations()Sets
furnace_group.bill_of_materialsSets
furnace_group.emissions
BOM validation and utilisation correction (
handlers.py):TMPAMConnector.validate_bom_consistency()checks every active FG for: mass balance (metallic input / production ∈ [0.99, 1.21]), per-feedstock minimum shares (e.g. BOF hot_metal ≥ 70% − 1pp, hot and cold forms counted together), aggregated metallic-charge constraints checked against their minimum and maximum independently (e.g. BOF DRI ≤ 15% + 1pp and HBI ≤ 15% + 1pp, each pattern counted on its own), and zero metallic charge where metallics are required. Violations are logged as[BOM-CHECK]warnings; the run continues.correct_utilization_for_supply_constraints()scales down production and utilisation for any BOF FG that received insufficient hot metal to meet its minimum share. This is a safety net for edge cases (e.g. technology-cluster mismatch) that survive the structural disaggregation checks.
After PAM runs:
Handlers execute commands:
Update furnace group attributes
Create new furnace groups
Record domain events
Refresh hot-metal access (
simulation.py):Calls
update_hot_metal_access(plants, config.hot_metal_radius, config.active_statuses, clustering_scope)once over every plant in the world.clustering_scopeisconfig.geographical_clustering_scope, or"plant"when clustering is offOnly hot-metal producers (any technology whose Bill of Materials outputs hot metal) in an
active_statusesstatus count; a retired, mothballed or announced BF grants no accessA producer reaches a plant under the shared reach rule that clustering and the trade LP also apply: within
hot_metal_radius, any owner and country under plant scope, the same plant group under plant-group scope, the same country under iso3 scopeSets
has_hot_metal_accesson everyPlantand on all itsFurnaceGroups, not only BOFs: access belongs to the site, so a BF-only or EAF-only plant can be offered a BOF expansion or switchConsumed downstream by the PAM’s BOF-transition check and by
PlantGroup.evaluate_expansion()to skip BOF expansion options at plants without access.cluster_furnace_groups()recomputes the same rule itself rather than reading the flag
Checkpoint saves state:
Serializes all plants, furnace groups, plant groups
Records issued commands for replay
Orchestration Workflow¶
PAM executes the following steps each simulation year:
Step 1: Calculate Market Conditions¶
Establishes the economic environment for all decisions:
Carbon costs: Updates carbon costs for all furnace groups based on current carbon price
Current prices: Extracts market prices from cost curves (frozen for consistent evaluation)
Future price series: Builds time series of expected prices for NPV and COSA calculations (covering construction time + plant lifetime)
Step 2: Evaluate Furnace Group Strategies¶
For each plant (in random order):
Update balances: Aggregates furnace group balances to plant level and resets furnace group balances to zero
Evaluate each furnace group (in random order) using
plant.evaluate_furnace_group_strategy():Renovate: Current technology remains optimal at end-of-life
Switch: Different technology offers superior NPV (accounting for COSA)
Close: Historic losses exceed acceptable threshold
Continue: No action needed
Issue commands: Approved decisions are sent via message bus
Step 3: Evaluate Plant Group Expansions¶
For each plant group (in random order):
Collect total balance: Sums all plant balances to calculate available capital for investment
Evaluate expansion using
plant_group.evaluate_expansion():Assesses all plants and available technologies
Selects the option with highest NPV (using future price forecasts based on demand)
Verifies affordability against accumulated balance
Checks compliance with capacity limits (separate for steel and iron)
Issue commands: Approved expansions are sent via message bus
Step 4: Track and Enforce Capacity Limits¶
Throughout the evaluation process:
Monitors cumulative capacity additions by product type (steel/iron)
Rejects expansion and switch commands that would exceed annual limits
Capacity limits exclude new plants (handled separately by GeospatialModel)
Data Flow and Key Parameters¶
Inputs¶
From Unit of Work (bus.uow)¶
bus.uow.plants.list()→ List of allPlantobjectsEach plant contains
furnace_groupslist
bus.uow.plant_groups.list()→ List of allPlantGroupobjectsAggregated by ownership (parent company)
From Environment (bus.env)¶
Demand Signals:
current_demand→ Current year steel/iron demand (dict by product)iron_demand→ Iron-specific demandfuture_demand(year)→ Demand forecast for future years
Market Data:
extract_price_from_costcurve()→ Derives market prices from cost curvecarbon_costs_for_emissions→ Carbon price time series
Cost Data:
name_to_capex→ CAPEX by technology and regioncapex_renovation_share→ Brownfield cost multiplierscost_of_debt_by_tech→ Interest rates by country and technologycost_of_equity_by_tech→ Required returns by country and technology
Technology Configuration:
allowed_furnace_transitions→ Valid technology switchesdynamic_feedstocks→ Feedstock options by technologyallowed_techs→ Technologies allowed by year
Constraints:
capacity_limit_steel→ Max steel capacity additions per yearcapacity_limit_iron→ Max iron capacity additions per yearnew_capacity_share_from_new_plants→ Reserved capacity share for new plants
Subsidies (optional):
tech_capex_subsidies→ Capital subsidies by country/technologytech_opex_subsidies→ Operating subsidiestech_debt_subsidies→ Interest rate subsidies
Intermediate Values¶
Price Snapshots:
freeze_market_price→ Market price at start of PAM run (dict by product)Used for balance sheet updates of furnace groups
current_price→ Refreshed price for each evaluationfuture_price→ Future prices based on future demand and current cost curves for all furnace evaluations
Tracking Variables:
counter→ Number of commands issued this yearadded_capacity→ Total capacity added by PAM this year (tracked inbus.env)
Regional Mapping:
region_capex→ CAPEX data indexed by plant’s region, changes as new capacity is added following the learning curve logicrenovation_share→ Renovation cost ratios by technology
Outputs¶
Commands Dispatched¶
All commands sent via bus.handle(cmd):
ChangeFurnaceGroupStatusToSwitchingTechnology→ Scheduling technology switchAllows to produce with the old technology, unitl new technology is installed
ChangeFurnaceGroupTechnology→ Technology switchRenovateFurnaceGroup→ Renovate at end-of-lifeCloseFurnaceGroup→ Shut down unprofitable furnaceAddFurnaceGroup→ Expand capacity at existing plant
Logged Metrics¶
counter→ Total commands issuedbus.env.added_capacity→ Total capacity added
Key Design Patterns¶
1. Snapshot Market Prices¶
Freeze prices at start of PAM run and use frozen prices for all furnace evaluations to prevent mid-run price changes from affecting decisions and ensure all furnace groups evaluate under consistent market conditions.
2. Command-Based Updates¶
All changes issued as commands via message bus to:
Decouple decision-making from state mutation
Enable event sourcing and undo/replay
Handler can enforce validation and logging
Debugging Tips¶
Tracing Decisions¶
Enable furnace group breakdown in logging_config.yaml:
features:
furnace_group_breakdown: true # Set to false to disable
To keep the failing trade LP for offline reproduction, enable the (large) MPS dump the same way:
features:
dump_failed_lp: true # Writes TM/trade_lp_failed_<year>.mps on a non-optimal solve
Key Metrics to Monitor¶
Command counts: How many switches, renovations, closures, expansions?
Price stability: Are prices fluctuating year-to-year?
Balance sheet health: What % of plant groups have positive balance?
Capacity utilization: Are new plants being utilized?
Subsidy uptake: How many commands benefited from subsidies?
Common Issues¶
Issue: No technology switches happening
Check: allowed transitions Excel tab allows switches between expected technologies
Check: NPV calculations include correct CAPEX and OPEX
Check: COSA isn’t too high: a profitable incumbent with many years left forgoes a large operating margin by switching (see the
[OPTIMAL TECH] COSAdebug line). Remaining debt does not enter COSA.
Issue: Expansions not happening
Check: Plant group balances (need positive balance)
Check: New capacity limits reached (increase limits, decrease expansion capacity, or decrease the share of new capacity reserved for new plants)
Check: Future demand forecasts (need growth)