flexops.costing.add_operating_cost¶
- flexops.costing.add_operating_cost(*, block: Block, time_index: DatetimeIndex, dt_hours: float, tariff: DataFrame, electrical_power=None, fuel_power=None, dr_config: DRConfig | None = None, prorate: bool = True, consumption_estimate: dict[str, float] | None = None) OperatingCostHandles¶
Build the facility’s whole in-objective operating cost — electric and fuel.
The umbrella over
add_electricity_cost()andadd_fuel_cost(): it builds each present utility’s convex-relaxed cost on the same opexblock(EECO namespaces its components by utility, so the two never collide) and returns oneOperatingCostHandleswhose fields are the per-utility sums — the singletotal_operating_costthe scheduler minimizes. Still a RELAXED proxy, not the reported bill (useevaluate_cost()/evaluate_fuel_cost()post-solve).The facility-level consumption defaults to the standard series registered on
block—block.power_electrical(the canonicalPOWER_ELECTRICALname) andblock.fuel_usage— so a caller need not re-declare them each use; passelectrical_power/fuel_powerto override (e.g. a toy model or a pre-aggregated series). A utility whose series is neither passed nor present on the block is simply omitted; at least one must resolve. The fuel leg bills through EECO’s"gas"utility (add_fuel_cost()’s only supportedfuel_typetoday).- Parameters:
block – The Pyomo opex block to build both utilities’ cost on.
time_index – Naive
pd.DatetimeIndexaligning to the power series.dt_hours – Timestep length in hours; passed to EECO once for kW→kWh.
tariff – An EECO rate_data DataFrame (its electric and/or gas rows).
electrical_power – Time-indexed series of bare kW magnitudes (no units); defaults to
block.power_electricalif present, or whatever pyo object is provided, else the electric leg is skipped.fuel_power – Time-indexed fuel-usage series of bare m³/hr magnitudes (no units); defaults to
block.fuel_usageif present, else the fuel leg is skipped.dr_config – Optional DR container (v0: no constraints built).
consumption_estimate – Estimated total consumption over the horizon, keyed by EECO utility (
"electric"/"gas"; kWh / m³). EECO needs it to price any tier other than a flat top tier.
- Returns:
energy_cost,demand_chargeandtotal_operating_costare the sums across the built utilities, andeeco_blockmaps each built utility name ("electric"/"gas") to its raw EECO itemized structure.- Return type:
A combined
OperatingCostHandles- Raises:
FlexConfigError – If neither an electric nor a fuel consumption series is passed or found on
block.FlexDataError – If
time_indexis timezone-aware.